Skip to content

rustdoc: ICE: synthetic auto trait impls: unexpected result when selecting […] obligation involving projection #105199

Open
@matthiaskrgr

Description

@matthiaskrgr

Code

pub trait Stream {
    type Item;
    type Error;
}

pub trait ParseError<I> {
    type Output;
}

impl ParseError<char> for u32 {
    type Output = ();
}

impl Stream for () {
    type Item = char;
    type Error = char;
}

pub struct Lex<'a, I>
    where I: Stream,
          I::Error: ParseError<char>,
          <<char as Stream>::Error as ParseError<I::Item>>::Output: 'a
{
    x: &'a <I::Error as ParseError<char>>::Output
}

pub struct Reserved<'a, I> where
    I: ParseError<char> + 'a,
    I: ParseError<char> + 'a,
    <<I as Stream>::Error as ParseError<char>>::Output: 'a

{
    x: Lex<'a, I>
}

fn main() {
    let r: Reserved<()> = Reserved {
        x: Reserved {
            x: Reserved {
             x: &()
        }
        }
    };

    let _v = r.x.x;
}

Meta

rustc --version --verbose:

32e613bbaafee1bcabba48a2257b838f8d1c03d3

Error output

error[E0277]: the trait bound `char: Stream` is not satisfied
  --> ./a3ed373bd420d9a6f1371fa61c7a6a549d1377d2.rs:21:1
   |
21 | pub struct Lex<'a, I>
   | ^^^^^^^^^^^^^^^^^^^^^ the trait `Stream` is not implemented for `char`
   |
   = help: the trait `Stream` is implemented for `()`

error[E0277]: the trait bound `char: Stream` is not satisfied
  --> ./a3ed373bd420d9a6f1371fa61c7a6a549d1377d2.rs:29:1
   |
29 | pub struct Reserved<'a, I> where
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Stream` is not implemented for `char`
   |
   = help: the trait `Stream` is implemented for `()`

error[E0277]: the trait bound `I: Stream` is not satisfied
  --> ./a3ed373bd420d9a6f1371fa61c7a6a549d1377d2.rs:29:1
   |
29 | pub struct Reserved<'a, I> where
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Stream` is not implemented for `I`
   |
help: consider further restricting this bound
   |
30 |     I: ParseError<char> + 'a + Stream,
   |                              ++++++++
Backtrace

thread 'rustc' panicked at 'Unexpected result when selecting Reserved<'a, I> Obligation(predicate=Binder(ProjectionPredicate(ProjectionTy { substs: [_, char], item_def_id: DefId(0:8 ~ a3ed373bd420d9a6f1371fa61c7a6a549d1377d2[a5ec]::ParseError::Output) }, Term::Ty(_)), []), depth=2)', compiler/rustc_trait_selection/src/traits/auto_trait.rs:762:33
stack backtrace:
   0:     0x7f7e0996661a - std::backtrace_rs::backtrace::libunwind::trace::hec1c9a33ec35a782
                               at /rustc/c090c6880c0183ba248bde4a16e29ba29ac4fbba/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f7e0996661a - std::backtrace_rs::backtrace::trace_unsynchronized::hef44794102f9589c
                               at /rustc/c090c6880c0183ba248bde4a16e29ba29ac4fbba/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f7e0996661a - std::sys_common::backtrace::_print_fmt::h3d085ebafa3ff4d4
                               at /rustc/c090c6880c0183ba248bde4a16e29ba29ac4fbba/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f7e0996661a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1dc483ce0b0acc38
                               at /rustc/c090c6880c0183ba248bde4a16e29ba29ac4fbba/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f7e099c920e - core::fmt::write::hdde74b1f9f025400
                               at /rustc/c090c6880c0183ba248bde4a16e29ba29ac4fbba/library/core/src/fmt/mod.rs:1208:17
   5:     0x7f7e09956b35 - std::io::Write::write_fmt::h93bb2bce537087eb
                               at /rustc/c090c6880c0183ba248bde4a16e29ba29ac4fbba/library/std/src/io/mod.rs:1682:15
   6:     0x7f7e099663e5 - std::sys_common::backtrace::_print::hffbee7406e6f5871
                               at /rustc/c090c6880c0183ba248bde4a16e29ba29ac4fbba/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f7e099663e5 - std::sys_common::backtrace::print::ha3e39199dd4aff7e
                               at /rustc/c090c6880c0183ba248bde4a16e29ba29ac4fbba/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f7e0996912f - std::panicking::default_hook::{{closure}}::h9d3052b99dbdb269
                               at /rustc/c090c6880c0183ba248bde4a16e29ba29ac4fbba/library/std/src/panicking.rs:267:22
   9:     0x7f7e09968e6b - std::panicking::default_hook::hf85cde60e828679e
                               at /rustc/c090c6880c0183ba248bde4a16e29ba29ac4fbba/library/std/src/panicking.rs:286:9
  10:     0x7f7e0996994c - std::panicking::rust_panic_with_hook::h7bb6b938bd4ce622
                               at /rustc/c090c6880c0183ba248bde4a16e29ba29ac4fbba/library/std/src/panicking.rs:688:13
  11:     0x7f7e099696e9 - std::panicking::begin_panic_handler::{{closure}}::h894513d3c9ea77f1
                               at /rustc/c090c6880c0183ba248bde4a16e29ba29ac4fbba/library/std/src/panicking.rs:579:13
  12:     0x7f7e09966acc - std::sys_common::backtrace::__rust_end_short_backtrace::h478da9df1dc8d9c3
                               at /rustc/c090c6880c0183ba248bde4a16e29ba29ac4fbba/library/std/src/sys_common/backtrace.rs:137:18
  13:     0x7f7e099693f2 - rust_begin_unwind
                               at /rustc/c090c6880c0183ba248bde4a16e29ba29ac4fbba/library/std/src/panicking.rs:575:5
  14:     0x7f7e099c5c23 - core::panicking::panic_fmt::h0f7f0682c1639601
                               at /rustc/c090c6880c0183ba248bde4a16e29ba29ac4fbba/library/core/src/panicking.rs:65:14
  15:     0x7f7e0d8d3ed6 - <rustc_trait_selection[397ae88777b610b2]::traits::auto_trait::AutoTraitFinder>::evaluate_predicates
  16:     0x55847d63af96 - <rustc_trait_selection[397ae88777b610b2]::traits::auto_trait::AutoTraitFinder>::find_auto_trait_generics::<rustdoc[5777193071682c2]::clean::types::Generics, <rustdoc[5777193071682c2]::clean::auto_trait::AutoTraitFinder>::generate_for_trait::{closure#0}>
  17:     0x55847d3ea883 - <rustdoc[5777193071682c2]::clean::auto_trait::AutoTraitFinder>::generate_for_trait
  18:     0x55847d4663e7 - <alloc[22a8e43ef760e53a]::vec::Vec<rustdoc[5777193071682c2]::clean::types::Item> as alloc[22a8e43ef760e53a]::vec::spec_from_iter::SpecFromIter<rustdoc[5777193071682c2]::clean::types::Item, core[e5d1a7e8c6989fb6]::iter::adapters::filter_map::FilterMap<alloc[22a8e43ef760e53a]::vec::into_iter::IntoIter<rustc_span[e9db05e073d6ae0e]::def_id::DefId>, <rustdoc[5777193071682c2]::clean::auto_trait::AutoTraitFinder>::get_auto_trait_impls::{closure#0}>>>::from_iter
  19:     0x55847d3eb55e - <rustdoc[5777193071682c2]::clean::auto_trait::AutoTraitFinder>::get_auto_trait_impls
  20:     0x55847d4dd815 - rustdoc[5777193071682c2]::clean::utils::get_auto_trait_and_blanket_impls
  21:     0x55847d5fd9b2 - <rustdoc[5777193071682c2]::passes::collect_trait_impls::SyntheticImplCollector as rustdoc[5777193071682c2]::visit::DocVisitor>::visit_item
  22:     0x55847d5fdafa - <rustdoc[5777193071682c2]::passes::collect_trait_impls::SyntheticImplCollector as rustdoc[5777193071682c2]::visit::DocVisitor>::visit_item
  23:     0x55847d5fabb7 - rustdoc[5777193071682c2]::passes::collect_trait_impls::collect_trait_impls
  24:     0x55847d5d4f4e - <rustc_session[72ee2d53e3941d51]::session::Session>::time::<rustdoc[5777193071682c2]::clean::types::Crate, rustdoc[5777193071682c2]::core::run_global_ctxt::{closure#7}>
  25:     0x55847d5bbc0a - rustdoc[5777193071682c2]::core::run_global_ctxt
  26:     0x55847d5d73c4 - <rustc_interface[163ae487477d9c3c]::passes::QueryContext>::enter::<rustdoc[5777193071682c2]::main_args::{closure#1}::{closure#0}::{closure#1}, core[e5d1a7e8c6989fb6]::result::Result<(), rustc_errors[7f7a26e842223f7b]::ErrorGuaranteed>>
  27:     0x55847d3b085a - <rustc_interface[163ae487477d9c3c]::interface::Compiler>::enter::<rustdoc[5777193071682c2]::main_args::{closure#1}::{closure#0}, core[e5d1a7e8c6989fb6]::result::Result<(), rustc_errors[7f7a26e842223f7b]::ErrorGuaranteed>>
  28:     0x55847d52cc1e - <scoped_tls[e75e6c3262949904]::ScopedKey<rustc_span[e9db05e073d6ae0e]::SessionGlobals>>::set::<rustc_interface[163ae487477d9c3c]::interface::run_compiler<core[e5d1a7e8c6989fb6]::result::Result<(), rustc_errors[7f7a26e842223f7b]::ErrorGuaranteed>, rustdoc[5777193071682c2]::main_args::{closure#1}>::{closure#0}, core[e5d1a7e8c6989fb6]::result::Result<(), rustc_errors[7f7a26e842223f7b]::ErrorGuaranteed>>
  29:     0x55847d5e47a0 - std[819d5ca3b5620c33]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[163ae487477d9c3c]::util::run_in_thread_pool_with_globals<rustc_interface[163ae487477d9c3c]::interface::run_compiler<core[e5d1a7e8c6989fb6]::result::Result<(), rustc_errors[7f7a26e842223f7b]::ErrorGuaranteed>, rustdoc[5777193071682c2]::main_args::{closure#1}>::{closure#0}, core[e5d1a7e8c6989fb6]::result::Result<(), rustc_errors[7f7a26e842223f7b]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e5d1a7e8c6989fb6]::result::Result<(), rustc_errors[7f7a26e842223f7b]::ErrorGuaranteed>>
  30:     0x55847d6cecdd - <<std[819d5ca3b5620c33]::thread::Builder>::spawn_unchecked_<rustc_interface[163ae487477d9c3c]::util::run_in_thread_pool_with_globals<rustc_interface[163ae487477d9c3c]::interface::run_compiler<core[e5d1a7e8c6989fb6]::result::Result<(), rustc_errors[7f7a26e842223f7b]::ErrorGuaranteed>, rustdoc[5777193071682c2]::main_args::{closure#1}>::{closure#0}, core[e5d1a7e8c6989fb6]::result::Result<(), rustc_errors[7f7a26e842223f7b]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e5d1a7e8c6989fb6]::result::Result<(), rustc_errors[7f7a26e842223f7b]::ErrorGuaranteed>>::{closure#1} as core[e5d1a7e8c6989fb6]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  31:     0x7f7e09973663 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hd0b2a5e0dbe3c403
                               at /rustc/c090c6880c0183ba248bde4a16e29ba29ac4fbba/library/alloc/src/boxed.rs:2000:9
  32:     0x7f7e09973663 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h082e01feb1661ff6
                               at /rustc/c090c6880c0183ba248bde4a16e29ba29ac4fbba/library/alloc/src/boxed.rs:2000:9
  33:     0x7f7e09973663 - std::sys::unix::thread::Thread::new::thread_start::hf94610e63e426d69
                               at /rustc/c090c6880c0183ba248bde4a16e29ba29ac4fbba/library/std/src/sys/unix/thread.rs:108:17
  34:     0x7f7e097068fd - <unknown>
  35:     0x7f7e09788a60 - <unknown>
  36:                0x0 - <unknown>
error: aborting due to 3 previous errors

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

Metadata

Metadata

Assignees

Labels

A-auto-traitsArea: auto traits (e.g., `auto trait Send {}`)A-synthetic-implsArea: Synthetic impls, used by rustdoc to document auto traits and traits with blanket implsC-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.T-rustdocRelevant to the rustdoc 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