Skip to content
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

Make sure to insert Sized bound first into clauses list #123302

Merged
merged 1 commit into from Apr 2, 2024

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Mar 31, 2024

#120323 made it so that we don't insert an implicit Sized bound whenever we see an explicit Sized bound. However, since the code that inserts implicit sized bounds puts the bound as the first in the list, that means that it had the side-effect of possibly meaning we check Sized after checking other trait bounds.

If those trait bounds result in ambiguity or overflow or something, it may change how we winnow candidates. (edit: SEE #123303) This is likely the cause for the regression in #123279 (comment), since the impl...

impl<T: Job + Sized> AsJob for T { // <----- changing this to `Sized + Job` or just `Job` (which turns into `Sized + Job`) will FIX the issue.
}

...looks incredibly suspicious.

Fixes [after beta-backport] #123279.

Alternative is to revert #120323. I don't have a strong opinion about this, but think it may be nice to keep the diagnostic changes around.

@rustbot
Copy link
Collaborator

rustbot commented Mar 31, 2024

r? @fmease

rustbot has assigned @fmease.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 31, 2024
@rust-log-analyzer

This comment has been minimized.

@compiler-errors
Copy link
Member Author

So the Sized thing is actually a red herring and this is actually due to #123303. Still think we should fix this on beta, first, and this seems relatively harmless.

@fmease
Copy link
Member

fmease commented Mar 31, 2024

The job x86_64-gnu-llvm-17 failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)

You probably need to do sth. similar to #120323 (comment) / https://github.com/rust-lang/rust/pull/120323/files#diff-bdb9592e6609d61bb876c9d8a8da8b0acf3d1516ee7f35eaca144d74b96afdf0 to fix the incremental issue.

@compiler-errors
Copy link
Member Author

compiler-errors commented Mar 31, 2024

ya i'll fix the test later -- too interested in the root cause rn lol

@fmease fmease added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Mar 31, 2024
@estebank
Copy link
Contributor

estebank commented Apr 1, 2024

I'm ok with reverting the change that triggered this at least in beta to get some additional time for the fix for the underlying issue. Am I right to understand that even though my PR caused a user visible change, conceptually it shouldn't have? If I'm wrong on that, then my mental model of the language of how trait bounds are meant to work is incorrect and needs a refresher.

Copy link
Contributor

@estebank estebank left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The failing test is one that changed on the original PR but isn't now. The reason for it is that by removing an explicit Sized bound the implicit one is added, and in the incr compilation mode where we ignore spans, that means adding or removing an explicit Sized bound is a no-op. With this change instead just reordering the bounds list, it goes back to triggering recompilation of that item. You can look at the original PR for what the test change needs to be.

r=me.

@estebank
Copy link
Contributor

estebank commented Apr 1, 2024

Idle thought: I wonder what happens if we always sorted trait bound predicates in a stable way, independent of source placement 🤔

@lcnr
Copy link
Contributor

lcnr commented Apr 2, 2024

Am I right to understand that even though my PR caused a user visible change, conceptually it shouldn't have?

yes, caching in the old trait solver is broken.

Idle thought: I wonder what happens if we always sorted trait bound predicates in a stable way, independent of source placement

Breakage :3 this affects both incomplete inference guides from ParamEnv candidates and causes crates to now hit overflow for T: Impossible + Overflow bounds (which then results in fatal errors in the old solver)

@estebank
Copy link
Contributor

estebank commented Apr 2, 2024

r? @estebank
@bors r+

@bors
Copy link
Contributor

bors commented Apr 2, 2024

📌 Commit f2fd2d8 has been approved by estebank

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 2, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Apr 2, 2024
… r=estebank

Make sure to insert `Sized` bound first into clauses list

rust-lang#120323 made it so that we don't insert an implicit `Sized` bound whenever we see an *explicit* `Sized` bound. However, since the code that inserts implicit sized bounds puts the bound as the *first* in the list, that means that it had the **side-effect** of possibly meaning we check `Sized` *after* checking other trait bounds.

If those trait bounds result in ambiguity or overflow or something, it may change how we winnow candidates. (**edit: SEE** rust-lang#123303) This is likely the cause for the regression in rust-lang#123279 (comment), since the impl...

```rust
impl<T: Job + Sized> AsJob for T { // <----- changing this to `Sized + Job` or just `Job` (which turns into `Sized + Job`) will FIX the issue.
}
```

...looks incredibly suspicious.

Fixes [after beta-backport] rust-lang#123279.

Alternative is to revert rust-lang#120323. I don't have a strong opinion about this, but think it may be nice to keep the diagnostic changes around.
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 2, 2024
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#123198 (Add fn const BuildHasherDefault::new)
 - rust-lang#123226 (De-LLVM the unchecked shifts [MCP#693])
 - rust-lang#123302 (Make sure to insert `Sized` bound first into clauses list)
 - rust-lang#123348 (rustdoc: add a couple of regression tests)
 - rust-lang#123362 (Check that nested statics in thread locals are duplicated per thread.)
 - rust-lang#123368 (CFI: Support non-general coroutines)
 - rust-lang#123375 (rustdoc: synthetic auto trait impls: accept unresolved region vars for now)
 - rust-lang#123378 (Update sysinfo to 0.30.8)

Failed merges:

 - rust-lang#123349 (Fix capture analysis for by-move closure bodies)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit a38dde9 into rust-lang:master Apr 2, 2024
11 checks passed
@rustbot rustbot added this to the 1.79.0 milestone Apr 2, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Apr 2, 2024
Rollup merge of rust-lang#123302 - compiler-errors:sized-bound-first, r=estebank

Make sure to insert `Sized` bound first into clauses list

rust-lang#120323 made it so that we don't insert an implicit `Sized` bound whenever we see an *explicit* `Sized` bound. However, since the code that inserts implicit sized bounds puts the bound as the *first* in the list, that means that it had the **side-effect** of possibly meaning we check `Sized` *after* checking other trait bounds.

If those trait bounds result in ambiguity or overflow or something, it may change how we winnow candidates. (**edit: SEE** rust-lang#123303) This is likely the cause for the regression in rust-lang#123279 (comment), since the impl...

```rust
impl<T: Job + Sized> AsJob for T { // <----- changing this to `Sized + Job` or just `Job` (which turns into `Sized + Job`) will FIX the issue.
}
```

...looks incredibly suspicious.

Fixes [after beta-backport] rust-lang#123279.

Alternative is to revert rust-lang#120323. I don't have a strong opinion about this, but think it may be nice to keep the diagnostic changes around.
@apiraino
Copy link
Contributor

apiraino commented Apr 4, 2024

Beta backport accepted as per compiler team on Zulip. A backport PR will be authored by the release team at the end of the current development cycle.

@rustbot label +beta-accepted

@rustbot rustbot added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Apr 4, 2024
@cuviper cuviper mentioned this pull request Apr 4, 2024
@cuviper cuviper modified the milestones: 1.79.0, 1.78.0 Apr 4, 2024
@cuviper cuviper removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Apr 4, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 5, 2024
[beta] backports

- Fix f16 and f128 feature gates in editions other than 2015 rust-lang#123307 / rust-lang#123445
- Update to LLVM 18.1.2 rust-lang#122772
- unix fs: Make hurd using explicit new rather than From rust-lang#123057
- Don't inherit codegen attrs from parent static rust-lang#123310
- Make sure to insert Sized bound first into clauses list rust-lang#123302

r? cuviper
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 6, 2024
[beta] backports

- Fix f16 and f128 feature gates in editions other than 2015 rust-lang#123307 / rust-lang#123445
- Update to LLVM 18.1.2 rust-lang#122772
- unix fs: Make hurd using explicit new rather than From rust-lang#123057
- Don't inherit codegen attrs from parent static rust-lang#123310
- Make sure to insert Sized bound first into clauses list rust-lang#123302

r? cuviper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants