-
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.
Rollup merge of #122195 - jieyouxu:impl-return-note, r=fmease
Note that the caller chooses a type for type param ``` error[E0308]: mismatched types --> $DIR/return-impl-trait.rs:23:5 | LL | fn other_bounds<T>() -> T | - - | | | | | expected `T` because of return type | | help: consider using an impl return type: `impl Trait` | expected this type parameter ... LL | () | ^^ expected type parameter `T`, found `()` | = note: expected type parameter `T` found unit type `()` = note: the caller chooses the type of T which can be different from () ``` Tried to see if "expected this type parameter" can be replaced, but that goes all the way to `rustc_infer` so seems not worth the effort and can affect other diagnostics. Revives #112088 and #104755.
- Loading branch information
Showing
13 changed files
with
98 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
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,36 @@ | ||
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}` | ||
|
||
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}` | ||
|
||
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` | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
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
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