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: encountered errors when checking RPITIT refinement (resolution) in rustc_hir_analysis/src/check/compare_impl_item/refine.rs #126670

Closed
cushionbadak opened this issue Jun 19, 2024 · 2 comments · Fixed by #126968
Assignees
Labels
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.

Comments

@cushionbadak
Copy link

cushionbadak commented Jun 19, 2024

Code

(hand-reduced)

pub trait A {}

pub trait Mirror {
    type Assoc: ?Sized;
}
impl<T: ?Sized> Mirror for dyn A {
    type Assoc = T;
}

pub trait First {
    async fn first() -> <dyn A + 'static as Mirror>::Assoc;
}

impl First for dyn A {
    async fn first() {}
}

fn main() {}
(original)

pub trait A {}
pub trait B: A {}

pub trait Mirror {
    type Assoc: ?Sized;
}
impl<T: ?Sized> Mirror for A {
    type Assoc = T;
}

pub fn foo<'a>(x: &'a <dyn A + 'static as Mirror>::Assoc) -> &'a <dyn B + 'static as Mirror>::Assoc {
    static
}


#![feature(async_fn_in_trait)]

fn main() {
    let _ = async {
        A.first().await.second().await;
    };
}

pub trait First {
    type Second: Second;
    async fn first(self) -> <dyn A + 'static as Mirror>::Assoc;
}

struct A;

impl First for A {
    type Second = A;
    async fn first(self) -> Self::Second {
        A
    }
}

pub trait Second {
    async fn second(self);
}

impl<C> Second for C
where
    C: First,
{
    async fn second(self) {
        self.first().await.second().await;
    }
}

Meta

rustc --version --verbose:

rustc 1.81.0-nightly (8fcd4dd08 2024-06-18)
binary: rustc
commit-hash: 8fcd4dd08e2ba3e922d917d819ba0be066bdb005
commit-date: 2024-06-18
host: x86_64-apple-darwin
release: 1.81.0-nightly
LLVM version: 18.1.7

Error output

Command: rustc --edition=2021

  • I put the option --edition=2021 to remove "async fn" error, but I guess it is not an essential option to trigger ICE.
error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
 --> r_rpitit_0773A37F.rs:6:6
  |
6 | impl<T: ?Sized> Mirror for dyn A {
  |      ^ unconstrained type parameter
Backtrace

error: internal compiler error: encountered errors when checking RPITIT refinement (resolution)

thread 'rustc' panicked at compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs:177:19:
Box<dyn Any>
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
   2: rustc_hir_analysis::check::compare_impl_item::refine::check_refining_return_position_impl_trait_in_trait
   3: rustc_hir_analysis::check::check::check_impl_items_against_trait
   4: rustc_hir_analysis::check::check::check_item_type
   5: rustc_hir_analysis::check::wfcheck::check_well_formed
      [... omitted 1 frame ...]
   6: rustc_middle::query::plumbing::query_ensure_error_guaranteed::<rustc_query_system::query::caches::VecCache<rustc_hir::hir_id::OwnerId, rustc_middle::query::erase::Erased<[u8; 1]>>, ()>
   7: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
      [... omitted 1 frame ...]
   8: rustc_hir_analysis::check_crate
   9: rustc_interface::passes::run_required_analyses
  10: rustc_interface::passes::analysis
      [... omitted 1 frame ...]
  11: <rustc_interface::queries::QueryResult<&rustc_middle::ty::context::GlobalCtxt>>::enter::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}::{closure#1}::{closure#3}>
  12: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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: please make sure that you have updated to the latest nightly

note: please attach the file at `/Volumes/T7/workspace/240615_100chaos_tree_combine_typ/icefiles/rustc-ice-2024-06-19T07_28_40-72547.txt` to your bug report

query stack during panic:
#0 [check_well_formed] checking that `<impl at r_rpitit_0773A37F.rs:14:1: 14:21>` is well-formed
#1 [check_mod_type_wf] checking that types are well-formed in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors

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

Note

  • ICE location: compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs#L177
    let Ok((trait_bounds, impl_bounds)) = infcx.fully_resolve((trait_bounds, impl_bounds)) else {
    // This code path is not reached in any tests, but may be reachable. If
    // this is triggered, it should be converted to `delayed_bug` and the
    // triggering case turned into a test.
    tcx.dcx().bug("encountered errors when checking RPITIT refinement (resolution)");
    };
@cushionbadak cushionbadak 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 Jun 19, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jun 19, 2024
@cushionbadak cushionbadak changed the title ICE: encountered errors when checking RPITIT refinement (resolution) ICE: encountered errors when checking RPITIT refinement (resolution) in rustc_hir_analysis/src/check/compare_impl_item/refine.rs Jun 19, 2024
@lqd
Copy link
Member

lqd commented Jun 19, 2024

@rustbot claim

@GrigorenkoPV
Copy link
Contributor

searched nightlies: from nightly-2022-02-19 to nightly-2024-06-19
regressed nightly: nightly-2024-03-08
searched commit range: 7d3702e...9c3ad80
regressed commit: 8c9a75b (#121154)

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jun 26, 2024
Don't ICE during RPITIT refinement checking for resolution errors after normalization

rust-lang#126670 shows a case where resolution errors after normalization can happen during RPITIT refinement checking. Our tests didn't reach this path before, and we explicitly ICEd until we had a test. We can now delay a bug since we're sure it is reachable and have the test from the isue.

The comment I added likely still needs more expert wordsmithing.

r? `@compiler-errors` who's making me work during vacation (j/k).
Fixes rust-lang#126670
@bors bors closed this as completed in 8c6c6a7 Jun 26, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jun 26, 2024
Rollup merge of rust-lang#126968 - lqd:issue-126670, r=compiler-errors

Don't ICE during RPITIT refinement checking for resolution errors after normalization

rust-lang#126670 shows a case where resolution errors after normalization can happen during RPITIT refinement checking. Our tests didn't reach this path before, and we explicitly ICEd until we had a test. We can now delay a bug since we're sure it is reachable and have the test from the isue.

The comment I added likely still needs more expert wordsmithing.

r? ``@compiler-errors`` who's making me work during vacation (j/k).
Fixes rust-lang#126670
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jun 29, 2024
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. 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

Successfully merging a pull request may close this issue.

5 participants