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

rustdoc: ice: cannot relate region: LUB(ReErased, ReFre... #96381

Closed
matthiaskrgr opened this issue Apr 25, 2022 · 1 comment · Fixed by #96383
Closed

rustdoc: ice: cannot relate region: LUB(ReErased, ReFre... #96381

matthiaskrgr opened this issue Apr 25, 2022 · 1 comment · Fixed by #96383
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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

Code

./src/test/ui/did_you_mean/replace-impl-infer-ty-from-trait.rs

// run-rustfix
#![allow(unused)]

trait Foo<T>: Sized {
    fn bar(i: i32, t: T, s: &Self) -> (T, i32);
}

impl Foo<usize> for () {
    fn bar(i: _, t: _, s: _) -> _ {
        //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
        (1, 2)
    }
}

fn main() {}

Meta

rustc --version --verbose:

This was introduced between 18f314e (no ice) and 1f631e8 (ice)

rustdoc 1.62.0-nightly (1f631e8e9 2022-04-24)
binary: rustdoc
commit-hash: 1f631e8e93681ddc6e62d6ba6065cac7c449534c
commit-date: 2022-04-24
host: x86_64-unknown-linux-gnu
release: 1.62.0-nightly
LLVM version: 14.0.1

Error output

error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
 --> ./src/test/ui/did_you_mean/replace-impl-infer-ty-from-trait.rs:9:15
  |
9 |     fn bar(i: _, t: _, s: _) -> _ {
  |               ^     ^     ^     ^ not allowed in type signatures
  |               |     |     |
  |               |     |     not allowed in type signatures
  |               |     not allowed in type signatures
  |               not allowed in type signatures
  |
help: try replacing `_` with the types in the corresponding trait method signature
  |
9 |     fn bar(i: i32, t: usize, s: &()) -> (usize, i32) {
  |               ~~~     ~~~~~     ~~~     ~~~~~~~~~~~~

error: internal compiler error: compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs:376:17: cannot relate region: LUB(ReErased, ReFree(DefId(0:7 ~ replace_impl_infer_ty_from_trait[c2b9]::{impl#0}::bar), BrAnon(0)))

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/1f631e8e93681ddc6e62d6ba6065cac7c449534c/compiler/rustc_errors/src/lib.rs:1313:9
stack backtrace:
Backtrace


error: internal compiler error: compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs:376:17: cannot relate region: LUB(ReErased, ReFree(DefId(0:7 ~ replace_impl_infer_ty_from_trait[c2b9]::{impl#0}::bar), BrAnon(0)))

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/1f631e8e93681ddc6e62d6ba6065cac7c449534c/compiler/rustc_errors/src/lib.rs:1313:9
stack backtrace:
   0:     0x7f160089df1d - std::backtrace_rs::backtrace::libunwind::trace::h669802d1fc21e3b7
                               at /rustc/1f631e8e93681ddc6e62d6ba6065cac7c449534c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f160089df1d - std::backtrace_rs::backtrace::trace_unsynchronized::hbfc8ba10aa84eebd
                               at /rustc/1f631e8e93681ddc6e62d6ba6065cac7c449534c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f160089df1d - std::sys_common::backtrace::_print_fmt::h0465abb622554b49
                               at /rustc/1f631e8e93681ddc6e62d6ba6065cac7c449534c/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f160089df1d - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2b0f6ddf9f6282fc
                               at /rustc/1f631e8e93681ddc6e62d6ba6065cac7c449534c/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f16008f9c9c - core::fmt::write::hbc2b58553b3e2ecb
                               at /rustc/1f631e8e93681ddc6e62d6ba6065cac7c449534c/library/core/src/fmt/mod.rs:1194:17
   5:     0x7f160088f611 - std::io::Write::write_fmt::hbd36e395ea2daebc
                               at /rustc/1f631e8e93681ddc6e62d6ba6065cac7c449534c/library/std/src/io/mod.rs:1655:15
   6:     0x7f16008a0c35 - std::sys_common::backtrace::_print::heef8c09f9d53d84b
                               at /rustc/1f631e8e93681ddc6e62d6ba6065cac7c449534c/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f16008a0c35 - std::sys_common::backtrace::print::hf522092f01c60a20
                               at /rustc/1f631e8e93681ddc6e62d6ba6065cac7c449534c/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f16008a0c35 - std::panicking::default_hook::{{closure}}::hf82ef2bd0c1160a6
                               at /rustc/1f631e8e93681ddc6e62d6ba6065cac7c449534c/library/std/src/panicking.rs:295:22
   9:     0x7f16008a08a9 - std::panicking::default_hook::he60101573da18119
                               at /rustc/1f631e8e93681ddc6e62d6ba6065cac7c449534c/library/std/src/panicking.rs:314:9
  10:     0x7f16010cca11 - rustc_driver[fb008446bf4841d3]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f16008a1406 - std::panicking::rust_panic_with_hook::hdcee580d4be95cc0
                               at /rustc/1f631e8e93681ddc6e62d6ba6065cac7c449534c/library/std/src/panicking.rs:702:17
  12:     0x7f160212f611 - std[d808d730b7ca2da]::panicking::begin_panic::<rustc_errors[51dbba6dbb03a423]::ExplicitBug>::{closure#0}
  13:     0x7f160212deb6 - std[d808d730b7ca2da]::sys_common::backtrace::__rust_end_short_backtrace::<std[d808d730b7ca2da]::panicking::begin_panic<rustc_errors[51dbba6dbb03a423]::ExplicitBug>::{closure#0}, !>
  14:     0x7f16020c020f - std[d808d730b7ca2da]::panicking::begin_panic::<rustc_errors[51dbba6dbb03a423]::ExplicitBug>
  15:     0x7f1602076106 - std[d808d730b7ca2da]::panic::panic_any::<rustc_errors[51dbba6dbb03a423]::ExplicitBug>
  16:     0x7f16020724e5 - <rustc_errors[51dbba6dbb03a423]::HandlerInner>::bug::<&alloc[fe9647f81e1f43ed]::string::String>
  17:     0x7f1602071ef0 - <rustc_errors[51dbba6dbb03a423]::Handler>::bug::<&alloc[fe9647f81e1f43ed]::string::String>
  18:     0x7f16021393cd - rustc_middle[9e9f71bf98ae7d9e]::ty::context::tls::with_opt::<rustc_middle[9e9f71bf98ae7d9e]::util::bug::opt_span_bug_fmt<rustc_span[e82ed2a195beec45]::span_encoding::Span>::{closure#0}, ()>
  19:     0x7f160213bac6 - rustc_middle[9e9f71bf98ae7d9e]::util::bug::opt_span_bug_fmt::<rustc_span[e82ed2a195beec45]::span_encoding::Span>
  20:     0x7f160213ba33 - rustc_middle[9e9f71bf98ae7d9e]::util::bug::bug_fmt
  21:     0x7f160391a1ad - <rustc_infer[674c3dcebe2d7ee9]::infer::lexical_region_resolve::LexicalResolver>::sub_concrete_regions
  22:     0x7f1602f42baf - rustc_infer[674c3dcebe2d7ee9]::infer::lexical_region_resolve::resolve
  23:     0x7f1602ed96a2 - <rustc_infer[674c3dcebe2d7ee9]::infer::InferCtxt>::resolve_regions_and_report_errors
  24:     0x7f16025a4a8e - <rustc_typeck[1f325101f8669612]::check::fn_ctxt::FnCtxt>::regionck_item
  25:     0x7f160260f6f9 - <rustc_infer[674c3dcebe2d7ee9]::infer::InferCtxtBuilder>::enter::<core[5a98fdb7d7f1a1d6]::result::Result<(), rustc_errors[51dbba6dbb03a423]::ErrorGuaranteed>, rustc_typeck[1f325101f8669612]::check::compare_method::compare_predicate_entailment::{closure#0}>
  26:     0x7f16033eb4f8 - rustc_typeck[1f325101f8669612]::check::compare_method::compare_impl_method
  27:     0x7f16025ae979 - rustc_typeck[1f325101f8669612]::check::check::check_item_type
  28:     0x7f1602694bcb - <rustc_middle[9e9f71bf98ae7d9e]::hir::map::Map>::visit_item_likes_in_module::<rustc_typeck[1f325101f8669612]::check::CheckItemTypesVisitor>
  29:     0x7f160337da3c - rustc_typeck[1f325101f8669612]::check::check::check_mod_item_types
  30:     0x7f1602ae6b90 - rustc_query_system[516d1d2c67f99974]::query::plumbing::try_execute_query::<rustc_query_impl[2a77569c5b9c28bb]::plumbing::QueryCtxt, rustc_query_system[516d1d2c67f99974]::query::caches::DefaultCache<rustc_span[e82ed2a195beec45]::def_id::LocalDefId, ()>>
  31:     0x7f160361d973 - rustc_query_system[516d1d2c67f99974]::query::plumbing::get_query::<rustc_query_impl[2a77569c5b9c28bb]::queries::check_mod_item_types, rustc_query_impl[2a77569c5b9c28bb]::plumbing::QueryCtxt>
  32:     0x561bd65b625f - <rustc_middle[9e9f71bf98ae7d9e]::hir::map::Map>::for_each_module::<rustdoc[8c878a1df70953d1]::core::run_global_ctxt::{closure#0}::{closure#0}>
  33:     0x561bd675fe47 - rustdoc[8c878a1df70953d1]::main_options::{closure#0}::{closure#0}::{closure#1}
  34:     0x561bd66ff939 - <rustc_interface[49e29d39294acf22]::passes::QueryContext>::enter::<rustdoc[8c878a1df70953d1]::main_options::{closure#0}::{closure#0}::{closure#1}, core[5a98fdb7d7f1a1d6]::result::Result<(), rustc_errors[51dbba6dbb03a423]::ErrorGuaranteed>>
  35:     0x561bd664be3f - <rustc_interface[49e29d39294acf22]::interface::Compiler>::enter::<rustdoc[8c878a1df70953d1]::main_options::{closure#0}::{closure#0}, core[5a98fdb7d7f1a1d6]::result::Result<(), rustc_errors[51dbba6dbb03a423]::ErrorGuaranteed>>
  36:     0x561bd64ccb4a - rustc_span[e82ed2a195beec45]::with_source_map::<core[5a98fdb7d7f1a1d6]::result::Result<(), rustc_errors[51dbba6dbb03a423]::ErrorGuaranteed>, rustc_interface[49e29d39294acf22]::interface::create_compiler_and_run<core[5a98fdb7d7f1a1d6]::result::Result<(), rustc_errors[51dbba6dbb03a423]::ErrorGuaranteed>, rustdoc[8c878a1df70953d1]::main_options::{closure#0}>::{closure#1}>
  37:     0x561bd664dd94 - rustc_interface[49e29d39294acf22]::interface::create_compiler_and_run::<core[5a98fdb7d7f1a1d6]::result::Result<(), rustc_errors[51dbba6dbb03a423]::ErrorGuaranteed>, rustdoc[8c878a1df70953d1]::main_options::{closure#0}>
  38:     0x561bd64cf7f7 - <scoped_tls[3f0fbddadd7c600e]::ScopedKey<rustc_span[e82ed2a195beec45]::SessionGlobals>>::set::<rustdoc[8c878a1df70953d1]::main_args::{closure#0}, core[5a98fdb7d7f1a1d6]::result::Result<(), rustc_errors[51dbba6dbb03a423]::ErrorGuaranteed>>
  39:     0x561bd667417f - std[d808d730b7ca2da]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[49e29d39294acf22]::util::run_in_thread_pool_with_globals<rustdoc[8c878a1df70953d1]::main_args::{closure#0}, core[5a98fdb7d7f1a1d6]::result::Result<(), rustc_errors[51dbba6dbb03a423]::ErrorGuaranteed>>::{closure#0}, core[5a98fdb7d7f1a1d6]::result::Result<(), rustc_errors[51dbba6dbb03a423]::ErrorGuaranteed>>
  40:     0x561bd6721e29 - <<std[d808d730b7ca2da]::thread::Builder>::spawn_unchecked_<rustc_interface[49e29d39294acf22]::util::run_in_thread_pool_with_globals<rustdoc[8c878a1df70953d1]::main_args::{closure#0}, core[5a98fdb7d7f1a1d6]::result::Result<(), rustc_errors[51dbba6dbb03a423]::ErrorGuaranteed>>::{closure#0}, core[5a98fdb7d7f1a1d6]::result::Result<(), rustc_errors[51dbba6dbb03a423]::ErrorGuaranteed>>::{closure#1} as core[5a98fdb7d7f1a1d6]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  41:     0x7f16008ab353 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h32eefc773c894000
                               at /rustc/1f631e8e93681ddc6e62d6ba6065cac7c449534c/library/alloc/src/boxed.rs:1866:9
  42:     0x7f16008ab353 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hddf864edd64170ab
                               at /rustc/1f631e8e93681ddc6e62d6ba6065cac7c449534c/library/alloc/src/boxed.rs:1866:9
  43:     0x7f16008ab353 - std::sys::unix::thread::Thread::new::thread_start::he8eb4ffb09bd0666
                               at /rustc/1f631e8e93681ddc6e62d6ba6065cac7c449534c/library/std/src/sys/unix/thread.rs:108:17
  44:     0x7f160059b5c2 - start_thread
  45:     0x7f1600620584 - __clone
  46:                0x0 - <unknown>

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.62.0-nightly (1f631e8e9 2022-04-24) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_mod_item_types] checking item types in top-level module
end of query stack
error: aborting due to 2 previous errors

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

@matthiaskrgr matthiaskrgr added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. 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. C-bug Category: This is a bug. labels Apr 25, 2022
@compiler-errors
Copy link
Member

This is my fault in #95395. I'll try to handle regions better here.

@compiler-errors compiler-errors self-assigned this Apr 25, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Apr 26, 2022
…bank

Fix erased region escaping into wfcheck due to rust-lang#95395

We can just use `liberate_late_bound_regions` instead of `erase_late_bound_regions`... This gives us `ReEarlyBound` instead of `ReErased`, the former being something typeck actually knows how to deal with...

Fixes rust-lang#96381

Side-note: We only actually get far enough in the compiler pipeline to cause this ICE when we're invoking rustdoc. We actually abort rustc right before wfcheck because of the error that we emit (having `_` in the type signature). Why does rustdoc keep going even though we raise an error?
compiler-errors added a commit to compiler-errors/rust that referenced this issue Apr 26, 2022
…bank

Fix erased region escaping into wfcheck due to rust-lang#95395

We can just use `liberate_late_bound_regions` instead of `erase_late_bound_regions`... This gives us `ReEarlyBound` instead of `ReErased`, the former being something typeck actually knows how to deal with...

Fixes rust-lang#96381

Side-note: We only actually get far enough in the compiler pipeline to cause this ICE when we're invoking rustdoc. We actually abort rustc right before wfcheck because of the error that we emit (having `_` in the type signature). Why does rustdoc keep going even though we raise an error?
@bors bors closed this as completed in 5645732 Apr 27, 2022
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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants