Skip to content

rustdoc: assertion failed: !ty.needs_infer() on unconstrained lifetime  #109204

Closed
@matthiaskrgr

Description

@matthiaskrgr

Code

tests/ui/impl-unused-rps-in-assoc-type.rs

Rustdoc would previously eat that without error.

// Test that lifetime parameters must be constrained if they appear in
// an associated type def'n. Issue #22077.

trait Fun {
    type Output;
    fn call<'x>(&'x self) -> Self::Output;
}

struct Holder { x: String }

impl<'a> Fun for Holder { //~ ERROR E0207
    type Output = &'a str;
    fn call<'b>(&'b self) -> &'b str {
        &self.x[..]
    }
}

fn main() { }

reduced to

trait Fun {
    type Output;
    fn call(&self) -> Self::Output;
}

impl<'a> Fun for () {
    type Output = &'a str;
    fn call(&self) -> &str {}
}

Meta

rustc --version --verbose:
searched toolchains 1716932 through ab65486


Regression in e84e5ff


cc @aliemjay

Error output

<output>
Backtrace

thread 'rustc' panicked at 'assertion failed: !ty.needs_infer()', compiler/rustc_trait_selection/src/traits/outlives_bounds.rs:58:9
stack backtrace:
   0:     0x7f0f1656750a - std::backtrace_rs::backtrace::libunwind::trace::hca5b94e57c77ccf5
                               at /rustc/ab654863c3d50482f260cf862647f1fe0ff5e010/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f0f1656750a - std::backtrace_rs::backtrace::trace_unsynchronized::h5b5fce74d82f8778
                               at /rustc/ab654863c3d50482f260cf862647f1fe0ff5e010/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f0f1656750a - std::sys_common::backtrace::_print_fmt::ha47e7aaa1d2225ec
                               at /rustc/ab654863c3d50482f260cf862647f1fe0ff5e010/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f0f1656750a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::ha1aaba92be89501b
                               at /rustc/ab654863c3d50482f260cf862647f1fe0ff5e010/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f0f165cab3e - core::fmt::write::h750a8e721825859f
                               at /rustc/ab654863c3d50482f260cf862647f1fe0ff5e010/library/core/src/fmt/mod.rs:1232:17
   5:     0x7f0f1655a375 - std::io::Write::write_fmt::hbf6015e32697f7ba
                               at /rustc/ab654863c3d50482f260cf862647f1fe0ff5e010/library/std/src/io/mod.rs:1684:15
   6:     0x7f0f165672d5 - std::sys_common::backtrace::_print::h301c6b6cac7c0a3a
                               at /rustc/ab654863c3d50482f260cf862647f1fe0ff5e010/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f0f165672d5 - std::sys_common::backtrace::print::h7f921f37b0542aab
                               at /rustc/ab654863c3d50482f260cf862647f1fe0ff5e010/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f0f1656a04f - std::panicking::default_hook::{{closure}}::ha1e8e5c596b5be71
                               at /rustc/ab654863c3d50482f260cf862647f1fe0ff5e010/library/std/src/panicking.rs:271:22
   9:     0x7f0f16569d8b - std::panicking::default_hook::hb0497d64ba7aeb9b
                               at /rustc/ab654863c3d50482f260cf862647f1fe0ff5e010/library/std/src/panicking.rs:290:9
  10:     0x7f0f19865475 - rustc_driver_impl[190cb2184ae08abb]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f0f1656a88d - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h5fe0c368b54c8ed7
                               at /rustc/ab654863c3d50482f260cf862647f1fe0ff5e010/library/alloc/src/boxed.rs:2002:9
  12:     0x7f0f1656a88d - std::panicking::rust_panic_with_hook::hde905c542c1ea61a
                               at /rustc/ab654863c3d50482f260cf862647f1fe0ff5e010/library/std/src/panicking.rs:696:13
  13:     0x7f0f1656a5c2 - std::panicking::begin_panic_handler::{{closure}}::hb8e5dc8ca1bc0593
                               at /rustc/ab654863c3d50482f260cf862647f1fe0ff5e010/library/std/src/panicking.rs:581:13
  14:     0x7f0f16567976 - std::sys_common::backtrace::__rust_end_short_backtrace::h5b7e4b9492630e37
                               at /rustc/ab654863c3d50482f260cf862647f1fe0ff5e010/library/std/src/sys_common/backtrace.rs:150:18
  15:     0x7f0f1656a312 - rust_begin_unwind
                               at /rustc/ab654863c3d50482f260cf862647f1fe0ff5e010/library/std/src/panicking.rs:579:5
  16:     0x7f0f165c6e93 - core::panicking::panic_fmt::hb9f9af2a2de3db20
                               at /rustc/ab654863c3d50482f260cf862647f1fe0ff5e010/library/core/src/panicking.rs:64:14
  17:     0x7f0f165c6f2d - core::panicking::panic::h52f24dac4e3af747
                               at /rustc/ab654863c3d50482f260cf862647f1fe0ff5e010/library/core/src/panicking.rs:114:5
  18:     0x7f0f18080dfc - <rustc_infer[4cb97a789990ae8c]::infer::outlives::env::OutlivesEnvironment>::with_bounds::<core[86d79cd3dd753e85]::iter::adapters::flatten::Flatten<core[86d79cd3dd753e85]::iter::adapters::map::Map<indexmap[6bbb46ee84024ff5]::set::IntoIter<rustc_middle[d8dcb3e1f9b6a1d3]::ty::Ty>, <rustc_infer[4cb97a789990ae8c]::infer::InferCtxt as rustc_trait_selection[834a42ea12cf8990]::traits::outlives_bounds::InferCtxtExt>::implied_bounds_tys::{closure#0}>>>
  19:     0x7f0f1837d580 - rustc_hir_analysis[60e36e2803dc18bc]::check::compare_impl_item::compare_method_predicate_entailment
  20:     0x7f0f183776bb - rustc_hir_analysis[60e36e2803dc18bc]::check::compare_impl_item::compare_impl_method
  21:     0x7f0f1836ff1c - rustc_hir_analysis[60e36e2803dc18bc]::check::check::check_impl_items_against_trait
  22:     0x7f0f183672b8 - rustc_hir_analysis[60e36e2803dc18bc]::check::check::check_mod_item_types
  23:     0x7f0f18e982be - rustc_query_system[1a66d6a5882ef44d]::query::plumbing::try_execute_query::<rustc_query_impl[9c3c364151da071f]::queries::check_mod_item_types, rustc_query_impl[9c3c364151da071f]::plumbing::QueryCtxt>
  24:     0x7f0f18e97e43 - <rustc_query_impl[9c3c364151da071f]::Queries as rustc_middle[d8dcb3e1f9b6a1d3]::ty::query::QueryEngine>::check_mod_item_types
  25:     0x56347077a097 - <rustc_middle[d8dcb3e1f9b6a1d3]::hir::map::Map>::for_each_module::<rustdoc[45dc7c546e81bc9c]::core::run_global_ctxt::{closure#0}::{closure#0}>
  26:     0x563470837cc2 - <rustc_session[de52af1e8e7b6fd9]::session::Session>::time::<(), rustdoc[45dc7c546e81bc9c]::core::run_global_ctxt::{closure#0}>
  27:     0x56347092b944 - rustdoc[45dc7c546e81bc9c]::core::run_global_ctxt
  28:     0x5634708377a9 - <rustc_session[de52af1e8e7b6fd9]::session::Session>::time::<(rustdoc[45dc7c546e81bc9c]::clean::types::Crate, rustdoc[45dc7c546e81bc9c]::config::RenderOptions, rustdoc[45dc7c546e81bc9c]::formats::cache::Cache), rustdoc[45dc7c546e81bc9c]::main_args::{closure#1}::{closure#0}::{closure#0}::{closure#0}>
  29:     0x563470686897 - <rustc_middle[d8dcb3e1f9b6a1d3]::ty::context::GlobalCtxt>::enter::<rustdoc[45dc7c546e81bc9c]::main_args::{closure#1}::{closure#0}::{closure#0}, core[86d79cd3dd753e85]::result::Result<(), rustc_span[e39f9d1da20fb520]::ErrorGuaranteed>>
  30:     0x56347071f66e - rustc_span[e39f9d1da20fb520]::with_source_map::<core[86d79cd3dd753e85]::result::Result<(), rustc_span[e39f9d1da20fb520]::ErrorGuaranteed>, rustc_interface[c60781b202b529bb]::interface::run_compiler<core[86d79cd3dd753e85]::result::Result<(), rustc_span[e39f9d1da20fb520]::ErrorGuaranteed>, rustdoc[45dc7c546e81bc9c]::main_args::{closure#1}>::{closure#0}::{closure#0}>
  31:     0x56347077ddc4 - <scoped_tls[3baa4ec3dd04ff72]::ScopedKey<rustc_span[e39f9d1da20fb520]::SessionGlobals>>::set::<rustc_interface[c60781b202b529bb]::interface::run_compiler<core[86d79cd3dd753e85]::result::Result<(), rustc_span[e39f9d1da20fb520]::ErrorGuaranteed>, rustdoc[45dc7c546e81bc9c]::main_args::{closure#1}>::{closure#0}, core[86d79cd3dd753e85]::result::Result<(), rustc_span[e39f9d1da20fb520]::ErrorGuaranteed>>
  32:     0x56347088fc60 - std[75e4c6f671155ce4]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[c60781b202b529bb]::util::run_in_thread_pool_with_globals<rustc_interface[c60781b202b529bb]::interface::run_compiler<core[86d79cd3dd753e85]::result::Result<(), rustc_span[e39f9d1da20fb520]::ErrorGuaranteed>, rustdoc[45dc7c546e81bc9c]::main_args::{closure#1}>::{closure#0}, core[86d79cd3dd753e85]::result::Result<(), rustc_span[e39f9d1da20fb520]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[86d79cd3dd753e85]::result::Result<(), rustc_span[e39f9d1da20fb520]::ErrorGuaranteed>>
  33:     0x563470919d2d - <<std[75e4c6f671155ce4]::thread::Builder>::spawn_unchecked_<rustc_interface[c60781b202b529bb]::util::run_in_thread_pool_with_globals<rustc_interface[c60781b202b529bb]::interface::run_compiler<core[86d79cd3dd753e85]::result::Result<(), rustc_span[e39f9d1da20fb520]::ErrorGuaranteed>, rustdoc[45dc7c546e81bc9c]::main_args::{closure#1}>::{closure#0}, core[86d79cd3dd753e85]::result::Result<(), rustc_span[e39f9d1da20fb520]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[86d79cd3dd753e85]::result::Result<(), rustc_span[e39f9d1da20fb520]::ErrorGuaranteed>>::{closure#1} as core[86d79cd3dd753e85]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  34:     0x7f0f16574783 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h3341c80cf784afb0
                               at /rustc/ab654863c3d50482f260cf862647f1fe0ff5e010/library/alloc/src/boxed.rs:1988:9
  35:     0x7f0f16574783 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h6a4397435c8c4587
                               at /rustc/ab654863c3d50482f260cf862647f1fe0ff5e010/library/alloc/src/boxed.rs:1988:9
  36:     0x7f0f16574783 - std::sys::unix::thread::Thread::new::thread_start::h4d87276efd9893f6
                               at /rustc/ab654863c3d50482f260cf862647f1fe0ff5e010/library/std/src/sys/unix/thread.rs:108:17
  37:     0x7f0f16306bb5 - <unknown>
  38:     0x7f0f16388d90 - <unknown>
  39:                0x0 - <unknown>

error: 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.70.0-nightly (ab654863c 2023-03-15) 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

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-lowLow priorityS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-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