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

Do not ICE on unmet trait alias bounds #108093

Closed
wants to merge 1 commit into from

Conversation

eggyal
Copy link
Contributor

@eggyal eggyal commented Feb 15, 2023

Obligations derived from trait alias predicates are not from any impl and therefore should be DerivedObligation rather than ImplDerivedObligation.

Fixes #108072

r? compiler

@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 Feb 15, 2023
@eggyal
Copy link
Contributor Author

eggyal commented Feb 15, 2023

I'll open another PR to add that the missing diagnostic note for DerivedObligations, then rebase this off that.

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 15, 2023
@eggyal eggyal marked this pull request as draft February 15, 2023 20:29
@compiler-errors
Copy link
Member

Hmmm.. thinking whether or not I'd prefer if you just fixed the ICE at the spot that the ICE occurs. Conceptually, the trait alias is its own "synthetic" impl, and most other users of ImplDerivedObligation are designed to correctly handle trait alias def ids (like method probe error reporting code).

If you're going to stick with this appproach, be careful not to introduce a bunch of other diagnostic fallout that comes from trying to "un-regress" the diagnostic regression here from using DerivedObligation...

@eggyal
Copy link
Contributor Author

eggyal commented Feb 15, 2023

Conceptually, the trait alias is its own "synthetic" impl

Ah, okay, if that's the case then I agree we should handle this differently. Will rework in a different PR.

@eggyal eggyal closed this Feb 15, 2023
@eggyal eggyal deleted the unmet_trait_alias_bound branch February 15, 2023 20:47
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-14 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
Prepare all required actions
Getting action download info
Download action repository 'actions/checkout@v3' (SHA:ac593985615ec2ede58e132d2e21d2b1cbd6127c)
Download action repository 'rust-lang/simpleinfra@master' (SHA:7ea263296c702710d7fac3c6d5bccdb2895b4e79)
Complete job name: PR (x86_64-gnu-llvm-14, false, ubuntu-20.04-xl)
git config --global core.autocrlf false
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  CI_JOB_NAME: x86_64-gnu-llvm-14
---

---- [ui] tests/ui/traits/alias/cross-crate.rs stdout ----
diff of stderr:

5    |                 ^^^^^^^ `Rc<u32>` cannot be sent between threads safely
6    |
7    = help: the trait `Send` is not implemented for `Rc<u32>`
-    = note: required for `Rc<u32>` to implement `SendSync`
9 note: required by a bound in `use_alias`
11    |


19    |                 ^^^^^^^ `Rc<u32>` cannot be shared between threads safely
20    |
21    = help: the trait `Sync` is not implemented for `Rc<u32>`
-    = note: required for `Rc<u32>` to implement `SendSync`
23 note: required by a bound in `use_alias`
25    |


The actual stderr differed from the expected stderr.
The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/traits/alias/cross-crate/cross-crate.stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args traits/alias/cross-crate.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/traits/alias/cross-crate.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Zdeduplicate-diagnostics=no" "-Cstrip=debuginfo" "--remap-path-prefix=/checkout/tests/ui=fake-test-src-base" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/traits/alias/cross-crate" "-A" "unused" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/traits/alias/cross-crate/auxiliary"
stdout: none
--- stderr -------------------------------
error[E0277]: `Rc<u32>` cannot be sent between threads safely
  --> fake-test-src-base/traits/alias/cross-crate.rs:14:17
   |
LL |     use_alias::<Rc<u32>>();
   |                 ^^^^^^^ `Rc<u32>` cannot be sent between threads safely
   |
   = help: the trait `Send` is not implemented for `Rc<u32>`
note: required by a bound in `use_alias`
  --> fake-test-src-base/traits/alias/cross-crate.rs:10:17
   |
LL | fn use_alias<T: SendSync>() {}
   |                 ^^^^^^^^ required by this bound in `use_alias`

error[E0277]: `Rc<u32>` cannot be shared between threads safely
  --> fake-test-src-base/traits/alias/cross-crate.rs:14:17
   |
LL |     use_alias::<Rc<u32>>();
   |                 ^^^^^^^ `Rc<u32>` cannot be shared between threads safely
   |
   = help: the trait `Sync` is not implemented for `Rc<u32>`
note: required by a bound in `use_alias`
  --> fake-test-src-base/traits/alias/cross-crate.rs:10:17
Some tests failed in compiletest suite=ui mode=ui host=x86_64-unknown-linux-gnu target=x86_64-unknown-linux-gnu
   |
LL | fn use_alias<T: SendSync>() {}
   |                 ^^^^^^^^ required by this bound in `use_alias`
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0277`.
------------------------------------------

@eggyal
Copy link
Contributor Author

eggyal commented Feb 16, 2023

Speedy bot! 😂

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 16, 2023
…compiler-errors

Do not ICE on unmet trait alias bounds

Rework of rust-lang#108093 following feedback on that PR.

Fixes rust-lang#108072

r? `@compiler-errors`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

ICE when generic constraint involving trait alias is not met
5 participants