-
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
Conversation
rustbot has assigned @petrochenkov. Use |
// `<impl Trait as OtherTrait>::Assoc` makes no sense. | ||
struct_span_code_err!( | ||
self.dcx(), | ||
tcx.def_span(alias_ty.def_id), | ||
E0667, | ||
"`impl Trait` is not allowed in path parameters" | ||
) | ||
.emit() // Already reported in an earlier stage. |
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
).
9f7cad3
to
c5af024
Compare
LL | fn projection_is_disallowed(x: impl Iterator) -> <impl Iterator>::Item { | ||
| ^^^^^^^^^^^^^ | ||
|
||
error[E0277]: the trait bound `impl Debug: Step` is not satisfied |
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.
Both "impl Debug: Step
diagnostics" were just useless. They obscured the more important issues (impl-Trait in a forbidden context) and plastered the terminal.
This comment has been minimized.
This comment has been minimized.
c5af024
to
442f395
Compare
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.
cc @compiler-errors since you assigned yourself to #126725. However, my PR just masks the bug by lowering the "bad" opaque to {type error}
. I should come up with a different reproducer as the underlying bug still hasn't been fixed.
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.
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.
…compiler-errors Cleanup: Move an impl-Trait check from AST validation to AST lowering Namely the one that rejects `impl Trait` in qself types and non-final path segments. There's no good reason to perform this during AST validation. We have better infrastructure in place in the AST lowerer (`ImplTraitContext`). This shaves off a lot of code. We now lower `impl Trait` in bad positions to `{type error}` which allows us to remove a special case from HIR ty lowering. Coincidentally fixes rust-lang#126725. Well, it only *masks* it by passing `{type error}` to HIR analysis instead of a "bad" opaque. I was able to find a new reproducer for it. See the issue.
…iaskrgr Rollup of 5 pull requests Successful merges: - rust-lang#132043 (Simplify param handling in `resolve_bound_vars`) - rust-lang#132214 (Cleanup: Move an impl-Trait check from AST validation to AST lowering) - rust-lang#132221 (Clean up some comments on lint implementation) - rust-lang#132228 (Revert "ci update freebsd version proposal, freebsd 12 being eol.") - rust-lang#132234 (Miri subtree update) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#132214 - fmease:mv-impl-trait-val-paths, r=compiler-errors Cleanup: Move an impl-Trait check from AST validation to AST lowering Namely the one that rejects `impl Trait` in qself types and non-final path segments. There's no good reason to perform this during AST validation. We have better infrastructure in place in the AST lowerer (`ImplTraitContext`). This shaves off a lot of code. We now lower `impl Trait` in bad positions to `{type error}` which allows us to remove a special case from HIR ty lowering. Coincidentally fixes rust-lang#126725. Well, it only *masks* it by passing `{type error}` to HIR analysis instead of a "bad" opaque. I was able to find a new reproducer for it. See the issue.
Namely the one that rejects
impl Trait
in qself types and non-final path segments.There's no good reason to perform this during AST validation.
We have better infrastructure in place in the AST lowerer (
ImplTraitContext
).This shaves off a lot of code.
We now lower
impl Trait
in bad positions to{type error}
which allows us toremove a special case from HIR ty lowering.
Coincidentally fixes #126725. Well, it only masks it by passing
{type error}
to HIR analysis instead of a "bad" opaque. I was able to find a new reproducer for it. See the issue.