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

internal compiler error: opaque type with non-universal region substs #109059

Closed
Mari-W opened this issue Mar 12, 2023 · 5 comments · Fixed by #116891
Closed

internal compiler error: opaque type with non-universal region substs #109059

Mari-W opened this issue Mar 12, 2023 · 5 comments · Fixed by #116891
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) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Mari-W
Copy link

Mari-W commented Mar 12, 2023

Code

Crashes for static references in general.

#![allow(incomplete_features)]
#![feature(adt_const_params)]
#![allow(dead_code)]

#[derive(PartialEq, Eq)]
struct S;

trait T<const C: &'static S> {}

fn foo<const C: &'static S>(t: impl T<C>) -> impl T<C> {
    t
}

Meta

rustc --version --verbose:

rustc 1.70.0-nightly (8a73f50d8 2023-03-11)
binary: rustc
commit-hash: 8a73f50d875840b8077b8ec080fa41881d7ce40d
commit-date: 2023-03-11
host: x86_64-unknown-linux-gnu
release: 1.70.0-nightly
LLVM version: 15.0.7

Error output

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

error: internal compiler error: opaque type with non-universal region substs
  --> unnamed-bin/src/main.rs:11:5
   |
11 |     t
   |     ^
   |

Backtrace

0: <rustc_errors::HandlerInner>::emit_diagnostic
1: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, &str>
2: <rustc_borrowck::region_infer::RegionInferenceContext>::infer_opaque_types::{closure#0}::{closure#2}
3: <rustc_middle::ty::Ty as rustc_type_ir::fold::TypeFoldable<rustc_middle::ty::context::TyCtxt>>::try_fold_with::<rustc_middle::ty::fold::RegionFolder>
4: <rustc_middle::ty::fold::RegionFolder as rustc_type_ir::fold::FallibleTypeFolder<rustc_middle::ty::context::TyCtxt>>::try_fold_const
5: <&rustc_middle::ty::list::List<rustc_middle::ty::subst::GenericArg> as rustc_type_ir::fold::TypeFoldable<rustc_middle::ty::context::TyCtxt>>::fold_with::<rustc_middle::ty::fold::RegionFolder>
6: <rustc_borrowck::region_infer::RegionInferenceContext>::infer_opaque_types
7: rustc_borrowck::nll::compute_regions
8: rustc_borrowck::do_mir_borrowck
9: <rustc_borrowck::provide::{closure#0} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId)>>::call_once
10: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::mir_borrowck, rustc_query_impl::plumbing::QueryCtxt>
11: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_borrowck
12: rustc_hir_analysis::collect::type_of::type_of
13: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::type_of, rustc_query_impl::plumbing::QueryCtxt>
14: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::type_of
15: rustc_hir_analysis::check::check::check_mod_item_types
16: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::check_mod_item_types, rustc_query_impl::plumbing::QueryCtxt>
17: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_mod_item_types
18: <rustc_middle::hir::map::Map>::for_each_module::<rustc_hir_analysis::check_crate::{closure#6}::{closure#0}>
19: rustc_hir_analysis::check_crate
20: rustc_interface::passes::analysis
21: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
22: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
23: <rustc_middle::ty::context::GlobalCtxt>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}::{closure#4}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
24: rustc_span::with_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
25: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
26: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
27: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
           at /rustc/8a73f50d875840b8077b8ec080fa41881d7ce40d/library/alloc/src/boxed.rs:1988:9
28: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
           at /rustc/8a73f50d875840b8077b8ec080fa41881d7ce40d/library/alloc/src/boxed.rs:1988:9
29: std::sys::unix::thread::Thread::new::thread_start
           at /rustc/8a73f50d875840b8077b8ec080fa41881d7ce40d/library/std/src/sys/unix/thread.rs:108:17
30: start_thread
           at ./nptl/./nptl/pthread_create.c:442:8
31: clone3
           at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
 
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.70.0-nightly (8a73f50d8 2023-03-11) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C linker=x86_64-linux-gnu-gcc -C incremental=[REDACTED]

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

query stack during panic:
end of query stack

@Mari-W Mari-W 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 Mar 12, 2023
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Mar 15, 2023
@langston-barrett
Copy link

@rustbot label +S-bug-has-mcve

@rustbot rustbot added the S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue label Mar 17, 2023
@DanielLiu-326
Copy link

Similar error shows when compiling the following code:

#![feature(return_position_impl_trait_in_trait)]
#![feature(adt_const_params)]

pub trait Bar<const BAR:&'static str>{}

impl Bar<"asdf"> for () {}

pub trait Foo<const FOO:&'static str>{
    fn foo()->impl Bar<"asdf">{
        ()
    }
}

Output:

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

error: internal compiler error: opaque type with non-universal region substs
  --> src/main.rs:10:9
   |
10 |         ()
   |         ^^
   |
   = note: delayed at    0: <rustc_errors::HandlerInner>::emit_diagnostic
              1: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, &str>
              2: <rustc_borrowck::region_infer::RegionInferenceContext>::infer_opaque_types::{closure#0}::{closure#2}
              3: <rustc_middle::ty::fold::RegionFolder as rustc_type_ir::fold::FallibleTypeFolder<rustc_middle::ty::context::TyCtxt>>::try_fold_ty
              4: <rustc_middle::ty::fold::RegionFolder as rustc_type_ir::fold::FallibleTypeFolder<rustc_middle::ty::context::TyCtxt>>::try_fold_const
              5: <&rustc_middle::ty::list::List<rustc_middle::ty::subst::GenericArg> as rustc_type_ir::fold::TypeFoldable<rustc_middle::ty::context::TyCtxt>>::fold_with::<rustc_middle::ty::fold::RegionFolder>
              6: <rustc_borrowck::region_infer::RegionInferenceContext>::infer_opaque_types
              7: rustc_borrowck::nll::compute_regions
              8: rustc_borrowck::do_mir_borrowck
              9: rustc_borrowck::mir_borrowck
             10: <rustc_borrowck::provide::{closure#0} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId)>>::call_once
             11: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::mir_borrowck, rustc_query_impl::plumbing::QueryCtxt>
             12: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_borrowck
             13: rustc_hir_analysis::collect::type_of::type_of
             14: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::type_of, rustc_query_impl::plumbing::QueryCtxt>
             15: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::type_of
             16: rustc_hir_analysis::check::check::check_mod_item_types
             17: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::check_mod_item_types, rustc_query_impl::plumbing::QueryCtxt>
             18: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_mod_item_types
             19: <rustc_session::session::Session>::time::<(), rustc_hir_analysis::check_crate::{closure#6}>
             20: rustc_hir_analysis::check_crate
             21: rustc_interface::passes::analysis
             22: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
             23: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
             24: <rustc_middle::ty::context::GlobalCtxt>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}::{closure#4}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
             25: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
             26: rustc_span::with_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
             27: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
             28: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
             29: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                        at /rustc/511364e7874dba9649a264100407e4bffe7b5425/library/alloc/src/boxed.rs:1988:9
             30: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                        at /rustc/511364e7874dba9649a264100407e4bffe7b5425/library/alloc/src/boxed.rs:1988:9
             31: std::sys::unix::thread::Thread::new::thread_start
                        at /rustc/511364e7874dba9649a264100407e4bffe7b5425/library/std/src/sys/unix/thread.rs:108:17
             32: <unknown>
             33: <unknown>
           

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.70.0-nightly (511364e78 2023-03-16) running on x86_64-unknown-linux-gnu
note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
end of query stack
error: aborting due to 2 previous errors; 2 warnings emitted

error: could not compile `lear_rust` (bin "lear_rust") due to previous error; 2 warnings emitted
Process finished with exit code 101

@matthiaskrgr
Copy link
Member

searched toolchains nightly-2022-03-24 through nightly-2023-03-31


Regression in nightly-2022-03-31


@JohnTitor
Copy link
Member

Triage: Fixed on the latest nightly (cc @zirconium-n as they have a PR fixing this issue), @rustbot labels: +E-needs-test

@rustbot rustbot added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jun 4, 2023
@compiler-errors
Copy link
Member

compiler-errors commented Sep 11, 2023

This issue is not totally fixed:

#![feature(adt_const_params)]

trait Bar<const FOO: &'static str> {}
impl Bar<"asdf"> for () {}

fn foo<const FOO: &'static str>() -> impl Bar<"asdf"> {
    ()
}

fn main() {}

It has to do with generalizing the types in consts. The const param FOO: &'static str is getting generalized into FOO: &'_ str, which is not related to any other regions 💥.

bors added a commit to rust-lang-ci/rust that referenced this issue Oct 19, 2023
…2, r=<try>

rework opaque type region inference

fixes rust-lang#113971 Pass -> Error

fixes rust-lang#111906 ICE -> Pass
fixes rust-lang#110623 ==
fixes rust-lang#109059 ==

fixes rust-lang#112841 Pass -> Error

fixes rust-lang#110726 ICE->Error

r? `@ghost`
bors added a commit to rust-lang-ci/rust that referenced this issue Oct 21, 2023
…2, r=<try>

rework opaque type region inference

fixes rust-lang#113971 Pass -> Error

fixes rust-lang#111906 ICE -> Pass
fixes rust-lang#110623 ==
fixes rust-lang#109059 ==

fixes rust-lang#112841 Pass -> Error

fixes rust-lang#110726 ICE->Error

r? `@ghost`
bors added a commit to rust-lang-ci/rust that referenced this issue Oct 23, 2023
…2, r=<try>

rework opaque type region inference

fixes rust-lang#113971 Pass -> Error

fixes rust-lang#111906 ICE -> Pass
fixes rust-lang#110623 ==
fixes rust-lang#109059 ==

fixes rust-lang#112841 Pass -> Error

fixes rust-lang#110726 ICE->Error

fixes rust-lang#111935 Pass -> Error
fixes rust-lang#113916 ==

r? `@ghost`
@matthiaskrgr matthiaskrgr removed the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Mar 23, 2024
@bors bors closed this as completed in 551abd6 Mar 28, 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. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
8 participants