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

ICE with type_alias_impl_trait #99348

Closed
JoJoJet opened this issue Jul 16, 2022 · 6 comments
Closed

ICE with type_alias_impl_trait #99348

JoJoJet opened this issue Jul 16, 2022 · 6 comments
Assignees
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@JoJoJet
Copy link
Contributor

JoJoJet commented Jul 16, 2022

Code

Minimum reproducible example:
https://github.com/JoJoJet/bevy_param_example/blob/4ee1ab4d2ad7858df2a84a5ab2d88fc83c0d882b/src/main.rs

Meta

rustc --version --verbose:

rustc 1.64.0-nightly (7425fb293 2022-06-30)
binary: rustc
commit-hash: 7425fb293f510a6f138e82a963a3bc599a5b9e1c
commit-date: 2022-06-30
host: x86_64-pc-windows-msvc
release: 1.64.0-nightly
LLVM version: 14.0.6

Error output

    Checking bevy_param_example v0.1.0 (C:\Users\joe10\rust\projects\bevy_param_example)
warning: private type `Private` in public interface (error E0446)
  --> src\main.rs:76:9
   |
76 | /         unsafe fn get_param(
77 | |             state: &'s mut Self,
78 | |             system_meta: &bevy::ecs::system::SystemMeta,
79 | |             world: &'w bevy::ecs::world::World,
80 | |             change_tick: u32,
81 | |         ) -> Self::Item {
   | |_______________________^
   |
   = note: `#[warn(private_in_public)]` on by default
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>

warning: Error finalizing incremental compilation session directory `\\?\C:\Users\joe10\rust\projects\target\debug\incremental\bevy_param_example-3654vmmjs670z\s-gbpsey1uol-fv4sp2-working`: The system cannot find the file specified. (os error 2)

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: VecMap([(OpaqueTypeKey { def_id: DefId(0:14 ~ bevy_param_example[d07e]::inner::OpaqueFetch::{opaque#0}), substs: [] }, OpaqueTypeDecl { hidden_type: OpaqueHiddenType { span: src\main.rs:75:21: 75:41 (#0), ty: inner::OpaqueParamsState<(bevy::prelude::QueryState<&'static inner::Private>,)> }, origin: TyAlias })])
  |
  = note: delayed at compiler\rustc_infer\src\infer\opaque_types\table.rs:50:26

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.64.0-nightly (7425fb293 2022-06-30) running on x86_64-pc-windows-msvc

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
warning: `bevy_param_example` (bin "bevy_param_example") generated 2 warnings
error: could not compile `bevy_param_example`; 2 warnings emitted
Backtrace

thread 'rustc' panicked at 'Box<dyn Any>', compiler\rustc_errors\src\lib.rs:1425:13
stack backtrace:
   0:     0x7ffbc9c19fff - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3c410eac6bf1896a
   1:     0x7ffbc9c5426a - core::fmt::write::hb34cfbd7fc8b3c9a
   2:     0x7ffbc9c0c4f9 - <std::io::IoSliceMut as core::fmt::Debug>::fmt::h507d5d0f0254c738
   3:     0x7ffbc9c1d8eb - std::panicking::default_hook::hf68d7718f0acf962
   4:     0x7ffbc9c1d56b - std::panicking::default_hook::hf68d7718f0acf962
   5:     0x7ffb95947106 - rustc_driver[4b277adb16bde54b]::pretty::print_after_hir_lowering
   6:     0x7ffbc9c1e092 - std::panicking::rust_panic_with_hook::h395aeb81db8d4939
   7:     0x7ffb9a141715 - <rustc_errors[38d2af6b2210a203]::snippet::Style as core[cdaa59ed781cf1aa]::fmt::Debug>::fmt
   8:     0x7ffb9a13d699 - <rustc_errors[38d2af6b2210a203]::snippet::Style as core[cdaa59ed781cf1aa]::fmt::Debug>::fmt
   9:     0x7ffb9a485529 - rustc_query_system[88c026d040f23148]::query::job::report_cycle
  10:     0x7ffb9a0ec5f9 - <rustc_feature[6828f12c25d06830]::builtin_attrs::AttributeType as core[cdaa59ed781cf1aa]::fmt::Debug>::fmt
  11:     0x7ffb9a0f09bc - <rustc_errors[38d2af6b2210a203]::HandlerInner as core[cdaa59ed781cf1aa]::ops::drop::Drop>::drop
  12:     0x7ffb958c3fa4 - <chalk_engine[27d0f598a74b3c5c]::table::AnswerIndex>::increment
  13:     0x7ffb958ce72a - <chalk_engine[27d0f598a74b3c5c]::table::AnswerIndex>::increment
  14:     0x7ffb95958a6d - <rustc_driver[4b277adb16bde54b]::Compilation as core[cdaa59ed781cf1aa]::fmt::Debug>::fmt
  15:     0x7ffb95955999 - <rustc_driver[4b277adb16bde54b]::Compilation as core[cdaa59ed781cf1aa]::fmt::Debug>::fmt
  16:     0x7ffb958d648d - <chalk_engine[27d0f598a74b3c5c]::table::AnswerIndex>::increment
  17:     0x7ffb959000d6 - <rustc_driver[4b277adb16bde54b]::args::Error as core[cdaa59ed781cf1aa]::fmt::Debug>::fmt
  18:     0x7ffb95900958 - <rustc_driver[4b277adb16bde54b]::args::Error as core[cdaa59ed781cf1aa]::fmt::Debug>::fmt
  19:     0x7ffbc9c2e61c - std::sys::windows::thread::Thread::new::h7f265c57c73b4ff5
  20:     0x7ffc2e2c7034 - BaseThreadInitThunk
  21:     0x7ffc30182651 - RtlUserThreadStart

@JoJoJet JoJoJet added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 16, 2022
@compiler-errors
Copy link
Member

Thank you for reporting this issue. I have minimized this into two different issues:

(1.) Checking trait and impl assoc type compatibility might constrain opaques in ways we don't observe during find_opaque_ty_constraints:

#![feature(type_alias_impl_trait)]

struct Concrete;

type Tait = impl Sized;

impl Foo for Concrete {
    type Item = Concrete;
}

impl Bar for Concrete {
    type Other = Tait;
}

trait Foo {
    type Item: Bar<Other = Self>;
}

trait Bar {
    type Other;
}

fn tait() -> Tait {}

(2.) Borrowck's opaque type constraints differ from typeck's constraints. Probably due to reachability during mir build.

#![feature(type_alias_impl_trait)]

type Tait = impl Sized;

struct One;
fn one() -> Tait { One }

struct Two<T>(T);
fn two() -> Tait { Two::<()>(todo!()) }

@compiler-errors
Copy link
Member

This might be another, unrelated bug.

You were correct about this 😜

@JoJoJet
Copy link
Contributor Author

JoJoJet commented Jul 17, 2022

Wow that example is much more minimal than mine 😀

@compiler-errors
Copy link
Member

No worries, the fact that you provided sample code is very well appreciated.

@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Jul 17, 2022
JohnTitor added a commit to JohnTitor/rust that referenced this issue Jul 17, 2022
…pertraits, r=oli-obk

Do not constraint TAITs when checking impl/trait item compatibility

Check out the UI test for the example.

Open to other approaches to fix this issue -- ideally we _would_ be able to collect this opaque type constraint in a way to use it in `find_opaque_ty_constraints`, so we can report a better mismatch error in the incompatible case, and just allow it in the compatible case. But that seems like a bigger refactor, so I wouldn't want to start it unless someone else thought it was a good idea.

cc rust-lang#99348
r? `@oli-obk`
JohnTitor added a commit to JohnTitor/rust that referenced this issue Jul 17, 2022
…pertraits, r=oli-obk

Do not constraint TAITs when checking impl/trait item compatibility

Check out the UI test for the example.

Open to other approaches to fix this issue -- ideally we _would_ be able to collect this opaque type constraint in a way to use it in `find_opaque_ty_constraints`, so we can report a better mismatch error in the incompatible case, and just allow it in the compatible case. But that seems like a bigger refactor, so I wouldn't want to start it unless someone else thought it was a good idea.

cc rust-lang#99348
r? ``@oli-obk``
@JohnTitor
Copy link
Member

Triage: The ICE itself has been fixed by #99356 but I'm not sure why it didn't close this issue, @compiler-errors Is there a remaining task?

@compiler-errors
Copy link
Member

There's another issue I pointed out in (2.) that remains, I'll file another task for just that and then close this out..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants