forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
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 rust-lang#100389 - compiler-errors:return-type-sugges…
…tion-cycle, r=cjgillot Do not report cycle error when inferring return type for suggestion The UI test is a good example of a case where this happens. The cycle is due to needing the value of the return type `-> _` to compute the variances of items in the crate, but then needing the variances of the items in the crate to do typechecking to infer what `-> _`'s real type is. Since we're already gonna emit an error in astconv, just delay the cycle bug as an error.
- Loading branch information
Showing
8 changed files
with
75 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4359,6 +4359,7 @@ dependencies = [ | |
"rustc_serialize", | ||
"rustc_session", | ||
"rustc_span", | ||
"rustc_target", | ||
"tracing", | ||
] | ||
|
||
|
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,14 @@ | ||
use std::marker::PhantomData; | ||
|
||
struct Token<T>(PhantomData<T>); | ||
|
||
impl<T> Token<T> { | ||
fn as_ref(_: i32, _: i32) -> _ { | ||
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types | ||
//~| NOTE not allowed in type signatures | ||
//~| HELP replace with the correct return type | ||
Token(PhantomData::<&T>) | ||
} | ||
} | ||
|
||
fn main() {} |
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,12 @@ | ||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types | ||
--> $DIR/return-cycle-2.rs:6:34 | ||
| | ||
LL | fn as_ref(_: i32, _: i32) -> _ { | ||
| ^ | ||
| | | ||
| not allowed in type signatures | ||
| help: replace with the correct return type: `Token<&'static T>` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0121`. |
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,14 @@ | ||
use std::marker::PhantomData; | ||
|
||
struct Token<T>(PhantomData<T>); | ||
|
||
impl<T> Token<T> { | ||
fn new() -> _ { | ||
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types | ||
//~| NOTE not allowed in type signatures | ||
//~| HELP replace with the correct return type | ||
Token(PhantomData::<()>) | ||
} | ||
} | ||
|
||
fn main() {} |
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,12 @@ | ||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types | ||
--> $DIR/return-cycle.rs:6:17 | ||
| | ||
LL | fn new() -> _ { | ||
| ^ | ||
| | | ||
| not allowed in type signatures | ||
| help: replace with the correct return type: `Token<()>` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0121`. |