Skip to content

ice: auto-traits: Region parameter out of range when substituting in region #117628

Closed
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

auto trait Trait1<'outer> {}

fn f<'a>(x: &dyn Trait1<'a>) {}

fn main() {
    f(42, "forty-two");
}

original:

#![feature(auto_traits)]

auto trait Trait1<'outer> {}
//~^ ERROR auto traits cannot have generic parameters

fn f<'a>(x: &dyn Trait1<'a>)
{}

fn main() {
    f(42, "forty-two");
}

Version information

rustc 1.75.0-nightly (c1ccc29cd 2023-11-05)
binary: rustc
commit-hash: c1ccc29cd6eeb79f24511d75e9db553385a5d73f
commit-date: 2023-11-05
host: x86_64-unknown-linux-gnu
release: 1.75.0-nightly
LLVM version: 17.0.4

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error[E0567]: auto traits cannot have generic parameters
 --> /tmp/icemaker_global_tempdir.dXXKiNrJeoxQ/rustc_testrunner_tmpdir_reporting.giHvAqdtCGu2/mvce.rs:1:18
  |
1 | auto trait Trait1<'outer> {}
  |            ------^^^^^^^^ help: remove the parameters
  |            |
  |            auto trait cannot have generic parameters

error[E0658]: auto traits are experimental and possibly buggy
 --> /tmp/icemaker_global_tempdir.dXXKiNrJeoxQ/rustc_testrunner_tmpdir_reporting.giHvAqdtCGu2/mvce.rs:1:1
  |
1 | auto trait Trait1<'outer> {}
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #13231 <https://github.com/rust-lang/rust/issues/13231> for more information
  = help: add `#![feature(auto_traits)]` to the crate attributes to enable

error: internal compiler error: compiler/rustc_middle/src/ty/generic_args.rs:813:13: Region parameter out of range when substituting in region 'outer (index=1, args = [[u8]])

thread 'rustc' panicked at /rustc/c1ccc29cd6eeb79f24511d75e9db553385a5d73f/compiler/rustc_errors/src/lib.rs:1661:9:
Box<dyn Any>
stack backtrace:
   0:     0x7f00cff69cfc - std::backtrace_rs::backtrace::libunwind::trace::h0673664ac4c09afc
                               at /rustc/c1ccc29cd6eeb79f24511d75e9db553385a5d73f/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f00cff69cfc - std::backtrace_rs::backtrace::trace_unsynchronized::h10965f5e9fe660cd
                               at /rustc/c1ccc29cd6eeb79f24511d75e9db553385a5d73f/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f00cff69cfc - std::sys_common::backtrace::_print_fmt::hafc97fd8408da37f
                               at /rustc/c1ccc29cd6eeb79f24511d75e9db553385a5d73f/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f00cff69cfc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::he48271a38e932a65
                               at /rustc/c1ccc29cd6eeb79f24511d75e9db553385a5d73f/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f00cffcbf20 - core::fmt::rt::Argument::fmt::hcbab977793b0f156
                               at /rustc/c1ccc29cd6eeb79f24511d75e9db553385a5d73f/library/core/src/fmt/rt.rs:142:9
   5:     0x7f00cffcbf20 - core::fmt::write::he4bd5356d9f17884
                               at /rustc/c1ccc29cd6eeb79f24511d75e9db553385a5d73f/library/core/src/fmt/mod.rs:1117:17
   6:     0x7f00cff5dc1f - std::io::Write::write_fmt::h82adc48b3ee28659
                               at /rustc/c1ccc29cd6eeb79f24511d75e9db553385a5d73f/library/std/src/io/mod.rs:1763:15
   7:     0x7f00cff69ae4 - std::sys_common::backtrace::_print::hbd621057f3ffa9bc
                               at /rustc/c1ccc29cd6eeb79f24511d75e9db553385a5d73f/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f00cff69ae4 - std::sys_common::backtrace::print::h81ad22e342d549fc
                               at /rustc/c1ccc29cd6eeb79f24511d75e9db553385a5d73f/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f00cff6c777 - std::panicking::default_hook::{{closure}}::h5d97101a34edaa94
  10:     0x7f00cff6c4df - std::panicking::default_hook::h56fdc01062773acb
                               at /rustc/c1ccc29cd6eeb79f24511d75e9db553385a5d73f/library/std/src/panicking.rs:292:9
  11:     0x7f00d2ae7500 - std[e90f7a7fa7044fea]::panicking::update_hook::<alloc[fc864e814057f6af]::boxed::Box<rustc_driver_impl[68bf50888c03d6]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f00cff6ceb8 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h754c416c3eca40da
                               at /rustc/c1ccc29cd6eeb79f24511d75e9db553385a5d73f/library/alloc/src/boxed.rs:2021:9
  13:     0x7f00cff6ceb8 - std::panicking::rust_panic_with_hook::hf0bbf40131c92c5b
                               at /rustc/c1ccc29cd6eeb79f24511d75e9db553385a5d73f/library/std/src/panicking.rs:783:13
  14:     0x7f00d2ead974 - std[e90f7a7fa7044fea]::panicking::begin_panic::<rustc_errors[8b097aa55369fe9f]::ExplicitBug>::{closure#0}
  15:     0x7f00d2ea5166 - std[e90f7a7fa7044fea]::sys_common::backtrace::__rust_end_short_backtrace::<std[e90f7a7fa7044fea]::panicking::begin_panic<rustc_errors[8b097aa55369fe9f]::ExplicitBug>::{closure#0}, !>
  16:     0x7f00d2e9f856 - std[e90f7a7fa7044fea]::panicking::begin_panic::<rustc_errors[8b097aa55369fe9f]::ExplicitBug>
  17:     0x7f00d2e86da4 - <rustc_errors[8b097aa55369fe9f]::HandlerInner>::bug::<alloc[fc864e814057f6af]::string::String>
  18:     0x7f00d2e86b64 - <rustc_errors[8b097aa55369fe9f]::Handler>::bug::<alloc[fc864e814057f6af]::string::String>
  19:     0x7f00d2f27c6d - rustc_middle[d9d5d5dafa4ee93d]::util::bug::opt_span_bug_fmt::<rustc_span[f4f73156f59d64eb]::span_encoding::Span>::{closure#0}
  20:     0x7f00d2f0fb9a - rustc_middle[d9d5d5dafa4ee93d]::ty::context::tls::with_opt::<rustc_middle[d9d5d5dafa4ee93d]::util::bug::opt_span_bug_fmt<rustc_span[f4f73156f59d64eb]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f00d2f0fa38 - rustc_middle[d9d5d5dafa4ee93d]::ty::context::tls::with_context_opt::<rustc_middle[d9d5d5dafa4ee93d]::ty::context::tls::with_opt<rustc_middle[d9d5d5dafa4ee93d]::util::bug::opt_span_bug_fmt<rustc_span[f4f73156f59d64eb]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f00d0fcccf0 - rustc_middle[d9d5d5dafa4ee93d]::util::bug::bug_fmt
  23:     0x7f00d2f1dd51 - <rustc_middle[d9d5d5dafa4ee93d]::ty::generic_args::ArgFolder as rustc_type_ir[2c2405cd158b7271]::fold::TypeFolder<rustc_middle[d9d5d5dafa4ee93d]::ty::context::TyCtxt>>::fold_region::region_param_out_of_range
  24:     0x7f00d4eaf77e - <rustc_middle[d9d5d5dafa4ee93d]::ty::generic_args::ArgFolder as rustc_type_ir[2c2405cd158b7271]::fold::TypeFolder<rustc_middle[d9d5d5dafa4ee93d]::ty::context::TyCtxt>>::fold_region.cold.0
  25:     0x7f00d3e4a879 - <rustc_middle[d9d5d5dafa4ee93d]::ty::Clause as rustc_type_ir[2c2405cd158b7271]::fold::TypeFoldable<rustc_middle[d9d5d5dafa4ee93d]::ty::context::TyCtxt>>::try_fold_with::<rustc_middle[d9d5d5dafa4ee93d]::ty::generic_args::ArgFolder>
  26:     0x7f00d3e4b4b4 - <rustc_trait_selection[db8dce1dc207c74c]::traits::select::SelectionContext>::vtable_auto_impl::{closure#0}
  27:     0x7f00d434fd6b - <rustc_trait_selection[db8dce1dc207c74c]::traits::select::SelectionContext>::confirm_candidate
  28:     0x7f00d4613b56 - <rustc_trait_selection[db8dce1dc207c74c]::traits::select::SelectionContext>::evaluate_candidate
  29:     0x7f00d4576ecd - <rustc_trait_selection[db8dce1dc207c74c]::traits::select::SelectionContext>::evaluate_trait_predicate_recursively
  30:     0x7f00d4613ea0 - <rustc_trait_selection[db8dce1dc207c74c]::traits::select::SelectionContext>::evaluate_candidate
  31:     0x7f00d4576ecd - <rustc_trait_selection[db8dce1dc207c74c]::traits::select::SelectionContext>::evaluate_trait_predicate_recursively
  32:     0x7f00d40193d8 - <rustc_trait_selection[db8dce1dc207c74c]::traits::select::SelectionContext>::evaluation_probe::<<rustc_trait_selection[db8dce1dc207c74c]::traits::select::SelectionContext>::evaluate_root_obligation::{closure#0}>
  33:     0x7f00d3de6d46 - rustc_traits[edf149fbc1966192]::evaluate_obligation::evaluate_obligation
  34:     0x7f00d3de67a0 - rustc_query_impl[b05542e5b9354c35]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[b05542e5b9354c35]::query_impl::evaluate_obligation::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d9d5d5dafa4ee93d]::query::erase::Erased<[u8; 2usize]>>
  35:     0x7f00d3de6175 - rustc_query_system[941bc27e835c2025]::query::plumbing::try_execute_query::<rustc_query_impl[b05542e5b9354c35]::DynamicConfig<rustc_query_system[941bc27e835c2025]::query::caches::DefaultCache<rustc_type_ir[2c2405cd158b7271]::canonical::Canonical<rustc_middle[d9d5d5dafa4ee93d]::ty::context::TyCtxt, rustc_middle[d9d5d5dafa4ee93d]::ty::ParamEnvAnd<rustc_middle[d9d5d5dafa4ee93d]::ty::Predicate>>, rustc_middle[d9d5d5dafa4ee93d]::query::erase::Erased<[u8; 2usize]>>, false, false, false>, rustc_query_impl[b05542e5b9354c35]::plumbing::QueryCtxt, false>
  36:     0x7f00d3de5e61 - rustc_query_impl[b05542e5b9354c35]::query_impl::evaluate_obligation::get_query_non_incr::__rust_end_short_backtrace
  37:     0x7f00d0f9539e - <rustc_trait_selection[db8dce1dc207c74c]::traits::fulfill::FulfillProcessor as rustc_data_structures[456b2b95d99f99bb]::obligation_forest::ObligationProcessor>::process_obligation
  38:     0x7f00d3c11455 - <rustc_data_structures[456b2b95d99f99bb]::obligation_forest::ObligationForest<rustc_trait_selection[db8dce1dc207c74c]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[db8dce1dc207c74c]::traits::fulfill::FulfillProcessor>
  39:     0x7f00d43c0ec0 - <rustc_trait_selection[db8dce1dc207c74c]::traits::engine::ObligationCtxt>::select_where_possible
  40:     0x7f00d2c6eba8 - <rustc_hir_typeck[da2baecc2f74febd]::fn_ctxt::FnCtxt>::can_coerce
  41:     0x7f00d2c84c47 - <rustc_hir_typeck[da2baecc2f74febd]::fn_ctxt::FnCtxt>::report_arg_errors
  42:     0x7f00d4717a89 - <rustc_hir_typeck[da2baecc2f74febd]::fn_ctxt::FnCtxt>::check_argument_types
  43:     0x7f00d44d4798 - <rustc_hir_typeck[da2baecc2f74febd]::fn_ctxt::FnCtxt>::check_call
  44:     0x7f00d46a0283 - <rustc_hir_typeck[da2baecc2f74febd]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  45:     0x7f00d40ca62a - <rustc_hir_typeck[da2baecc2f74febd]::fn_ctxt::FnCtxt>::check_block_with_expected
  46:     0x7f00d46a0706 - <rustc_hir_typeck[da2baecc2f74febd]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  47:     0x7f00d40dced9 - rustc_hir_typeck[da2baecc2f74febd]::check::check_fn
  48:     0x7f00d3ee3e96 - rustc_hir_typeck[da2baecc2f74febd]::typeck
  49:     0x7f00d3ee3309 - rustc_query_impl[b05542e5b9354c35]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[b05542e5b9354c35]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d9d5d5dafa4ee93d]::query::erase::Erased<[u8; 8usize]>>
  50:     0x7f00d3d1ba6c - rustc_query_system[941bc27e835c2025]::query::plumbing::try_execute_query::<rustc_query_impl[b05542e5b9354c35]::DynamicConfig<rustc_query_system[941bc27e835c2025]::query::caches::VecCache<rustc_span[f4f73156f59d64eb]::def_id::LocalDefId, rustc_middle[d9d5d5dafa4ee93d]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[b05542e5b9354c35]::plumbing::QueryCtxt, false>
  51:     0x7f00d3d1b750 - rustc_query_impl[b05542e5b9354c35]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  52:     0x7f00d40b8859 - rustc_hir_analysis[bdf8a1accce8e596]::check_crate
  53:     0x7f00d419d9d6 - rustc_interface[91c995b27a546283]::passes::analysis
  54:     0x7f00d419d3f5 - rustc_query_impl[b05542e5b9354c35]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[b05542e5b9354c35]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d9d5d5dafa4ee93d]::query::erase::Erased<[u8; 1usize]>>
  55:     0x7f00d46da066 - rustc_query_system[941bc27e835c2025]::query::plumbing::try_execute_query::<rustc_query_impl[b05542e5b9354c35]::DynamicConfig<rustc_query_system[941bc27e835c2025]::query::caches::SingleCache<rustc_middle[d9d5d5dafa4ee93d]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[b05542e5b9354c35]::plumbing::QueryCtxt, false>
  56:     0x7f00d46d9e95 - rustc_query_impl[b05542e5b9354c35]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  57:     0x7f00d4768906 - rustc_interface[91c995b27a546283]::interface::run_compiler::<core[36988a101ff2abff]::result::Result<(), rustc_span[f4f73156f59d64eb]::ErrorGuaranteed>, rustc_driver_impl[68bf50888c03d6]::run_compiler::{closure#1}>::{closure#0}
  58:     0x7f00d4b5065b - std[e90f7a7fa7044fea]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[91c995b27a546283]::util::run_in_thread_with_globals<rustc_interface[91c995b27a546283]::interface::run_compiler<core[36988a101ff2abff]::result::Result<(), rustc_span[f4f73156f59d64eb]::ErrorGuaranteed>, rustc_driver_impl[68bf50888c03d6]::run_compiler::{closure#1}>::{closure#0}, core[36988a101ff2abff]::result::Result<(), rustc_span[f4f73156f59d64eb]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[36988a101ff2abff]::result::Result<(), rustc_span[f4f73156f59d64eb]::ErrorGuaranteed>>
  59:     0x7f00d4b504b3 - <<std[e90f7a7fa7044fea]::thread::Builder>::spawn_unchecked_<rustc_interface[91c995b27a546283]::util::run_in_thread_with_globals<rustc_interface[91c995b27a546283]::interface::run_compiler<core[36988a101ff2abff]::result::Result<(), rustc_span[f4f73156f59d64eb]::ErrorGuaranteed>, rustc_driver_impl[68bf50888c03d6]::run_compiler::{closure#1}>::{closure#0}, core[36988a101ff2abff]::result::Result<(), rustc_span[f4f73156f59d64eb]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[36988a101ff2abff]::result::Result<(), rustc_span[f4f73156f59d64eb]::ErrorGuaranteed>>::{closure#1} as core[36988a101ff2abff]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  60:     0x7f00cff77c25 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h6b5b3d4ca98509ce
                               at /rustc/c1ccc29cd6eeb79f24511d75e9db553385a5d73f/library/alloc/src/boxed.rs:2007:9
  61:     0x7f00cff77c25 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hce947dc8abad5bcc
                               at /rustc/c1ccc29cd6eeb79f24511d75e9db553385a5d73f/library/alloc/src/boxed.rs:2007:9
  62:     0x7f00cff77c25 - std::sys::unix::thread::Thread::new::thread_start::h08f590d7bae0d0b7
                               at /rustc/c1ccc29cd6eeb79f24511d75e9db553385a5d73f/library/std/src/sys/unix/thread.rs:108:17
  63:     0x7f00cfd0c9eb - <unknown>
  64:     0x7f00cfd907cc - <unknown>
  65:                0x0 - <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.75.0-nightly (c1ccc29cd 2023-11-05) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `str: Trait1<'a>`
#1 [typeck] type-checking `main`
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors

Some errors have detailed explanations: E0567, E0658.
For more information about an error, try `rustc --explain E0567`.

Metadata

Metadata

Labels

A-auto-traitsArea: auto traits (e.g., `auto trait Send {}`)C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions