-
Notifications
You must be signed in to change notification settings - Fork 13.7k
default auto traits: use default supertraits instead of Self: Trait
bounds on associated items
#145879
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
base: master
Are you sure you want to change the base?
Conversation
HIR ty lowering was modified cc @fmease |
@@ -21,6 +21,20 @@ fn bar<T: ?Sized + ?Trait2 + ?Trait1 + ?Trait4>(_: &T) {} | |||
|
|||
// FIXME: `?Trait1` should be rejected, `Trait1` isn't marked `#[lang = "default_traitN"]`. | |||
fn baz<T>() where T: Iterator<Item: ?Trait1> {} | |||
//~^ ERROR this relaxed bound is not permitted here |
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.
Please remove the above FIXME
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.
Moreover this test is quite a mixed bag, it's unclear what the test intentions are. In #142693 I almost deleted it for that reason but I kept it to track bugs pertaining to more_maybe_bounds
instead (as can be seen by the top-level FIXME).
I don't think we should test "this relaxed bound is not permitted here" in this file, I'd advise you to create a new one whose name is based on tests/ui/unsized/relaxed-bounds-invalid-places.rs
(obv not inside unsized/
; maybe have both test files in trait-bounds/
actually).
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.
From my understanding there are 2 checks for relaxed bounds consistency:
- Syntactic check during AST->HIR lowering (
validate_relaxed_bound
) to ensure that?Trait
bounds are in a right place. - Semantic check during HIR->ty lowering (
check_and_report_invalid_relaxed_bounds
) to ensure that?
modifier is applied to "right" traits. And this check has to be done regardless of the place and results of the first check.
This PR fixes the first check but not the second and therefore FIXME comments in this file are still relevant.
So, your suggestion is to keep these checks in separate files for readability reasons, right? In my opinion it isn't very useful because the invocation of second check implies that the first check has already been invoked. That is, the test that covers the second check also covers the first one.
55e0947
to
b8175b6
Compare
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
First commit: the motivation has been discussed here.
Second commit: the only new places where new implicit
DefaultAutoTrait
bounds are generated are supertraits and trait object so?Trait
syntax should be extended to these places only.r? @lcnr