-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cleanup: Move an impl-Trait check from AST validation to AST lowering #132214
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,35 @@ | ||
error[E0667]: `impl Trait` is not allowed in path parameters | ||
error[E0562]: `impl Trait` is not allowed in paths | ||
--> $DIR/impl_trait_projections.rs:12:51 | ||
| | ||
LL | fn projection_is_disallowed(x: impl Iterator) -> <impl Iterator>::Item { | ||
| ^^^^^^^^^^^^^ | ||
| | ||
= note: `impl Trait` is only allowed in arguments and return types of functions and methods | ||
|
||
error[E0667]: `impl Trait` is not allowed in path parameters | ||
--> $DIR/impl_trait_projections.rs:19:9 | ||
error[E0562]: `impl Trait` is not allowed in paths | ||
--> $DIR/impl_trait_projections.rs:18:9 | ||
| | ||
LL | -> <impl Iterator as Iterator>::Item | ||
| ^^^^^^^^^^^^^ | ||
| | ||
= note: `impl Trait` is only allowed in arguments and return types of functions and methods | ||
|
||
error[E0667]: `impl Trait` is not allowed in path parameters | ||
--> $DIR/impl_trait_projections.rs:26:27 | ||
error[E0562]: `impl Trait` is not allowed in paths | ||
--> $DIR/impl_trait_projections.rs:25:27 | ||
| | ||
LL | -> <::std::ops::Range<impl Debug> as Iterator>::Item | ||
| ^^^^^^^^^^ | ||
| | ||
= note: `impl Trait` is only allowed in arguments and return types of functions and methods | ||
|
||
error[E0667]: `impl Trait` is not allowed in path parameters | ||
--> $DIR/impl_trait_projections.rs:35:29 | ||
error[E0562]: `impl Trait` is not allowed in paths | ||
--> $DIR/impl_trait_projections.rs:32:29 | ||
| | ||
LL | -> <dyn Iterator<Item = impl Debug> as Iterator>::Item | ||
| ^^^^^^^^^^ | ||
|
||
error[E0667]: `impl Trait` is not allowed in path parameters | ||
--> $DIR/impl_trait_projections.rs:12:51 | ||
| | ||
LL | fn projection_is_disallowed(x: impl Iterator) -> <impl Iterator>::Item { | ||
| ^^^^^^^^^^^^^ | ||
|
||
error[E0277]: the trait bound `impl Debug: Step` is not satisfied | ||
--> $DIR/impl_trait_projections.rs:26:8 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both " |
||
| | ||
LL | -> <::std::ops::Range<impl Debug> as Iterator>::Item | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Step` is not implemented for `impl Debug`, which is required by `std::ops::Range<impl Debug>: Iterator` | ||
| | ||
= help: the following other types implement trait `Step`: | ||
Char | ||
Ipv4Addr | ||
Ipv6Addr | ||
char | ||
i128 | ||
i16 | ||
i32 | ||
i64 | ||
and 8 others | ||
= note: required for `std::ops::Range<impl Debug>` to implement `Iterator` | ||
|
||
error[E0277]: the trait bound `impl Debug: Step` is not satisfied | ||
--> $DIR/impl_trait_projections.rs:29:1 | ||
| | ||
LL | / { | ||
LL | | | ||
LL | | (1i32..100).next().unwrap() | ||
LL | | } | ||
| |_^ the trait `Step` is not implemented for `impl Debug`, which is required by `std::ops::Range<impl Debug>: Iterator` | ||
| | ||
= help: the following other types implement trait `Step`: | ||
Char | ||
Ipv4Addr | ||
Ipv6Addr | ||
char | ||
i128 | ||
i16 | ||
i32 | ||
i64 | ||
and 8 others | ||
= note: required for `std::ops::Range<impl Debug>` to implement `Iterator` | ||
= note: `impl Trait` is only allowed in arguments and return types of functions and methods | ||
|
||
error: aborting due to 7 previous errors | ||
error: aborting due to 4 previous errors | ||
|
||
Some errors have detailed explanations: E0277, E0667. | ||
For more information about an error, try `rustc --explain E0277`. | ||
For more information about this error, try `rustc --explain E0562`. |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cc @compiler-errors since you assigned yourself to #126725. However, my PR just masks the bug by lowering the "bad" opaque to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, I was able to find a new reproducer for the underlying bug: #126725 (comment). I guess I will reopen #126725 once it gets closed. And I should maybe add a new crash test in this PR. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// issue: rust-lang/rust#126725 | ||
|
||
trait Foo { | ||
fn foo<'a>() -> <&'a impl Sized as Bar>::Output; | ||
//~^ ERROR `impl Trait` is not allowed in paths | ||
} | ||
|
||
trait Bar { | ||
type Output; | ||
} | ||
|
||
impl<'a> Bar for &'a () { | ||
type Output = &'a i32; | ||
} | ||
|
||
impl Foo for () { | ||
fn foo<'a>() -> <&'a Self as Bar>::Output { | ||
&0 | ||
} | ||
} | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
error[E0562]: `impl Trait` is not allowed in paths | ||
--> $DIR/bad-projection-from-opaque.rs:4:26 | ||
| | ||
LL | fn foo<'a>() -> <&'a impl Sized as Bar>::Output; | ||
| ^^^^^^^^^^ | ||
| | ||
= note: `impl Trait` is only allowed in arguments and return types of functions and methods | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0562`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
error[E0667]: `impl Trait` is not allowed in path parameters | ||
error[E0562]: `impl Trait` is not allowed in paths | ||
--> $DIR/issue-57979-impl-trait-in-path.rs:8:48 | ||
| | ||
LL | pub fn demo(_: impl Quux<(), Assoc=<() as Quux<impl Bar>>::Assoc>) { } | ||
| ^^^^^^^^ | ||
| | ||
= note: `impl Trait` is only allowed in arguments and return types of functions and methods | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0667`. | ||
For more information about this error, try `rustc --explain E0562`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should've been a
span_delayed_bug
in the first place (before this PR). This double emission (once during AST validation, once here during HIR ty lowering) actually lead to two identical diagnostics getting emitted (indeed, even without-Zdeduplicate-diagnostics=no
).