-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Reject ?Trait
bounds in various places where we unconditionally warned since 1.0
#135841
Conversation
rustbot has assigned @compiler-errors. Use |
HIR ty lowering was modified cc @fmease |
@bors try |
Reject `impl Trait` within `?Trait` generics or assoc ty bounds fixes rust-lang#135730 Also a breaking change, so let's see what crater says. This has been an unconditional warning since *before* 1.0
This comment has been minimized.
This comment has been minimized.
☀️ Try build successful - checks-actions |
@craterbot check |
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
🚧 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
🎉 Experiment
|
impl Trait
within ?Trait
generics or assoc ty bounds?Trait
bounds in various places where we unconditionally warned since 1.0
757c75f
to
4e7c9e6
Compare
Hi @rust-lang/types, it turns out we've accepted One common source of problems with such bounds is that they can have generics or associated types/consts and all of these just get dropped on the floor and never evaluated, normalized, or otherwise processed in the type system. This leads to fun bugs like not evaluating constants or just ICEing because opaque types never got defined. @rfcbot fcp merge |
Team member @oli-obk has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
cc @rust-lang/lang for info I think this is fine as a pure types team FCP. Allowing these bounds is causing bugs without any benefit. |
@rfcbot reviewed |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. |
… warned since 1.0
4e7c9e6
to
c294da3
Compare
"relaxing a default bound only does something for `?Sized`; \ | ||
all other traits are not bound by default", |
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 don't want to block this PR on surface level things like phrasing, so feel free to ignore this and I'll submit this as a follow-up PR. I've never liked how this specific diagnostic is formulated, it's super verbose.
Now with this being a hard error this sentence doesn't quite make sense anymore. I'd rather see a message that's straight to the point like `?` can only be applied to `Sized`
(similar to `~const` can only be applied to `#[const_trait]` traits
or `async` bound modifier only allowed on `Fn`/`FnMut`/`FnOnce` traits
) and defer any further explanations to diagnostic note/help messages if at all (cc error codes).
If we wanted to feel fancy we could provide a structured suggestion for removing the entire bound.
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.
How about we do this as a follow-up
@bors r+ rollup |
…ler-errors Reject `?Trait` bounds in various places where we unconditionally warned since 1.0 fixes rust-lang#135730 fixes rust-lang#135809 Also a breaking change, so let's see what crater says. This has been an unconditional warning since *before* 1.0
Rollup of 12 pull requests Successful merges: - rust-lang#134090 (Stabilize target_feature_11) - rust-lang#135025 (Cast allocas to default address space) - rust-lang#135841 (Reject `?Trait` bounds in various places where we unconditionally warned since 1.0) - rust-lang#136217 (Mark condition/carry bit as clobbered in C-SKY inline assembly) - rust-lang#136699 (std: replace the `FromInner` implementation for addresses with private conversion functions) - rust-lang#136806 (Fix cycle when debug-printing opaque types from RPITIT) - rust-lang#136807 (compiler: internally merge `PtxKernel` into `GpuKernel`) - rust-lang#136818 (Implement `read*_exact` for `std:io::repeat`) - rust-lang#136927 (Correctly escape hashtags when running `invalid_rust_codeblocks` lint) - rust-lang#136937 (Update books) - rust-lang#136945 (Add diagnostic item for `std::io::BufRead`) - rust-lang#136947 (Reinstate nnethercote in the review rotation.) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#135841 - oli-obk:push-qxlnokwrkkym, r=compiler-errors Reject `?Trait` bounds in various places where we unconditionally warned since 1.0 fixes rust-lang#135730 fixes rust-lang#135809 Also a breaking change, so let's see what crater says. This has been an unconditional warning since *before* 1.0
Rollup of 12 pull requests Successful merges: - rust-lang#134090 (Stabilize target_feature_11) - rust-lang#135025 (Cast allocas to default address space) - rust-lang#135841 (Reject `?Trait` bounds in various places where we unconditionally warned since 1.0) - rust-lang#136217 (Mark condition/carry bit as clobbered in C-SKY inline assembly) - rust-lang#136699 (std: replace the `FromInner` implementation for addresses with private conversion functions) - rust-lang#136806 (Fix cycle when debug-printing opaque types from RPITIT) - rust-lang#136807 (compiler: internally merge `PtxKernel` into `GpuKernel`) - rust-lang#136818 (Implement `read*_exact` for `std:io::repeat`) - rust-lang#136927 (Correctly escape hashtags when running `invalid_rust_codeblocks` lint) - rust-lang#136937 (Update books) - rust-lang#136945 (Add diagnostic item for `std::io::BufRead`) - rust-lang#136947 (Reinstate nnethercote in the review rotation.) r? `@ghost` `@rustbot` modify labels: rollup
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.
Note that this PR doesn't catch all occurrences of ?Trait
, Trait
≠Sized
because performing the validation in add_sized_bound
is super backwards and because we don't reject maybe-bounds in ATB position (#135229).
Meaning the following code still compiles successfully and without warnings:
fn _f(_: impl Iterator<Item: ?Copy>) {}
I'll rewrite the way we validate and handle maybe-bounds because I wanted to do that anyway for the longest time (fixing #136944 in the process).
(Lastly, I'll make it so we don't error at all if the internal feature more_maybe_bounds
(#121676) is enabled; while I'm personally not in favor of that internal feature, this PR did partially regress it)
(Re. ATBs / #135229, the crater run didn't show any regressions but GH search revealed users using them (mistakenly), so I'll either make it a FCW or hard error regardless (in yet another PR))
fixes #135730
fixes #135809
Also a breaking change, so let's see what crater says.
This has been an unconditional warning since before 1.0