-
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
Fix validation when lowering ?
trait bounds
#132209
Conversation
r? @Nadrieril rustbot has assigned @Nadrieril. Use |
HIR ty lowering was modified cc @fmease |
Funny enough, this code passes on nightly:
|
@@ -681,11 +681,20 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { | |||
Some(self_ty), |
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.
^(a handful of lines above) we were probably also allowing ?std::ops::Fn<T>
but i dont care to write a test for that.
?
trait bounds, improve spans for const
trait bounds
Frankly I am of half a mind to say that we don't need to do the annoying and time-consuming dance of cratering the regression for (2.). If this actually ended up being "used" anywhere in the wild, then we will obviously catch this in the next beta crater and deal with it then, or I can crater this after it's landed. |
The span change I can approve; the validation change looks good but I don't know that code, @fmease any objections? |
Actually, I'll just split the span change out and just r=Nadrieril on that one first, since it's really kinda unrelated. My fault for putting this into one PR rbh. |
… r=Nadrieril Pass constness with span into lower_poly_trait_ref Gives us a span to point at for ~const/const on non-const traits. Split from rust-lang#132209. r? Nadrieril
Rollup merge of rust-lang#132227 - compiler-errors:better-const-span, r=Nadrieril Pass constness with span into lower_poly_trait_ref Gives us a span to point at for ~const/const on non-const traits. Split from rust-lang#132209. r? Nadrieril
0cdc673
to
c8f33e5
Compare
?
trait bounds, improve spans for const
trait bounds?
trait bounds
Omg, this is insane! 🙏 Thanks for catching this! |
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.
I have one concern but otherwise looks pretty good to me!
// No-op. | ||
return arg_count; |
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.
Doesn't this early return mean we don't validate associated item constraints which get lowered below this point in lower_assoc_item_constraint
? E.g., isn't it still the case that ?Sized<Undefined = (), Undefined = ()>
gets accepted under this PR?
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.
:'( yeah
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.
OK, so I made it so that we at least validate these associated type bounds, but not outright deny them. We may want to do that later.
c8f33e5
to
06a49b6
Compare
@rustbot ready |
@bors r+ |
Fix validation when lowering `?` trait bounds Pass the unlowered (`rustc_hir`) polarity to `lower_poly_trait_ref`. This allows us to actually *validate* that generic args are actually valid on `?Trait` paths. This actually regressed in rust-lang#113671 because that PR changed the behavior where we were inadvertently re-lowering paths as `BoundPolarity::Positive`, which was also coincidentally the only place we were enforcing the generics on `?Trait` paths were correct.
…iaskrgr Rollup of 5 pull requests Successful merges: - rust-lang#131168 (Fix `target_os` for `mipsel-sony-psx`) - rust-lang#132209 (Fix validation when lowering `?` trait bounds) - rust-lang#132357 (Improve missing_abi lint) - rust-lang#132385 (compiler: Move `rustc_target::spec::abi::Abi` to `rustc_abi::ExternAbi`) - rust-lang#132417 (macOS: Document the difference between Clang's `-darwin` and `-macosx` targets) r? `@ghost` `@rustbot` modify labels: rollup
…kingjubilee Rollup of 9 pull requests Successful merges: - rust-lang#131168 (Fix `target_os` for `mipsel-sony-psx`) - rust-lang#132209 (Fix validation when lowering `?` trait bounds) - rust-lang#132294 (Bump Fuchsia) - rust-lang#132357 (Improve missing_abi lint) - rust-lang#132385 (compiler: Move `rustc_target::spec::abi::Abi` to `rustc_abi::ExternAbi`) - rust-lang#132403 (continue `TypingMode` refactor) - rust-lang#132417 (macOS: Document the difference between Clang's `-darwin` and `-macosx` targets) - rust-lang#132421 (Remove `""` case from RISC-V `llvm_abiname` match statement) - rust-lang#132422 (llvm: Match new LLVM 128-bit integer alignment on sparc) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#132209 - compiler-errors:modifiers, r=fmease Fix validation when lowering `?` trait bounds Pass the unlowered (`rustc_hir`) polarity to `lower_poly_trait_ref`. This allows us to actually *validate* that generic args are actually valid on `?Trait` paths. This actually regressed in rust-lang#113671 because that PR changed the behavior where we were inadvertently re-lowering paths as `BoundPolarity::Positive`, which was also coincidentally the only place we were enforcing the generics on `?Trait` paths were correct.
Pass the unlowered (
rustc_hir
) polarity tolower_poly_trait_ref
.This allows us to actually validate that generic args are actually valid on
?Trait
paths. This actually regressed in #113671 because that PR changed the behavior where we were inadvertently re-lowering paths asBoundPolarity::Positive
, which was also coincidentally the only place we were enforcing the generics on?Trait
paths were correct.