-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Note that type param is chosen by caller when suggesting return impl …
…Trait
- Loading branch information
Showing
5 changed files
with
77 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Checks existence of a note for "a caller chooses ty for ty param" upon return ty mismatch. | ||
|
||
fn f<T>() -> (T,) { | ||
(0,) //~ ERROR mismatched types | ||
} | ||
|
||
fn g<U, V>() -> (U, V) { | ||
(0, "foo") | ||
//~^ ERROR mismatched types | ||
//~| ERROR mismatched types | ||
} | ||
|
||
fn h() -> u8 { | ||
0u8 | ||
} | ||
|
||
fn main() { | ||
f::<()>(); | ||
g::<(), ()>; | ||
let _ = h(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/return-ty-mismatch-note.rs:4:6 | ||
| | ||
LL | fn f<T>() -> (T,) { | ||
| - expected this type parameter | ||
LL | (0,) | ||
| ^ expected type parameter `T`, found integer | ||
| | ||
= note: expected type parameter `T` | ||
found type `{integer}` | ||
= note: the caller chooses a type for `T` which can be different from `{integer}` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/return-ty-mismatch-note.rs:8:6 | ||
| | ||
LL | fn g<U, V>() -> (U, V) { | ||
| - expected this type parameter | ||
LL | (0, "foo") | ||
| ^ expected type parameter `U`, found integer | ||
| | ||
= note: expected type parameter `U` | ||
found type `{integer}` | ||
= note: the caller chooses a type for `U` which can be different from `{integer}` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/return-ty-mismatch-note.rs:8:9 | ||
| | ||
LL | fn g<U, V>() -> (U, V) { | ||
| - expected this type parameter | ||
LL | (0, "foo") | ||
| ^^^^^ expected type parameter `V`, found `&str` | ||
| | ||
= note: expected type parameter `V` | ||
found reference `&'static str` | ||
= note: the caller chooses a type for `V` which can be different from `&'static str` | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |