rust icon indicating copy to clipboard operation
rust copied to clipboard

ICE in rustdoc: 'called `Option::unwrap()` on a `None` value', src/librustdoc/clean/auto_trait.rs:356:26

Open jendrikw opened this issue 1 year ago • 4 comments

Code

// struct Peekable<I: Iterator>
use std::iter::Peekable;

pub struct Span<F: Fn(&i32)> {
    inner: Peekable<ConditionalIterator<F>>,
}

struct ConditionalIterator<F> {
    f: F,
}

impl<F: Fn(&i32)> Iterator for ConditionalIterator<F> {
    type Item = ();

    fn next(&mut self) -> Option<Self::Item> {
        todo!()
    }
}

Meta

No crash in stable 1.62.1, crashes with nightly 85b500cca 2022-07-24 and 1b57946a4 2022-08-03

rustc --version --verbose:

rustc 1.64.0-nightly (1b57946a4 2022-08-03)
binary: rustc
commit-hash: 1b57946a405d5b2a87e612335db033edb2c3427f
commit-date: 2022-08-03
host: x86_64-unknown-linux-gnu
release: 1.64.0-nightly
LLVM version: 14.0.6

Error output

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', src/librustdoc/clean/auto_trait.rs:356:26
Backtrace

stack backtrace:
   0:     0x7f297e13f170 - std::backtrace_rs::backtrace::libunwind::trace::h9b4d82cd870228fb
                               at /rustc/4493a0f4724c0bae1436242d76cccc9c0a287b80/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7f297e13f170 - std::backtrace_rs::backtrace::trace_unsynchronized::ha2689bd64a4b7cd3
                               at /rustc/4493a0f4724c0bae1436242d76cccc9c0a287b80/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f297e13f170 - std::sys_common::backtrace::_print_fmt::h7171e7cdb3618754
                               at /rustc/4493a0f4724c0bae1436242d76cccc9c0a287b80/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f297e13f170 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h5f34e59b34d66393
                               at /rustc/4493a0f4724c0bae1436242d76cccc9c0a287b80/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f297e19ab3c - core::fmt::write::hb1777ff310a82958
                               at /rustc/4493a0f4724c0bae1436242d76cccc9c0a287b80/library/core/src/fmt/mod.rs:1198:17
   5:     0x7f297e1303b5 - std::io::Write::write_fmt::hff7e45f7d5a6e56b
                               at /rustc/4493a0f4724c0bae1436242d76cccc9c0a287b80/library/std/src/io/mod.rs:1672:15
   6:     0x7f297e141e51 - std::sys_common::backtrace::_print::h2edb89997dbdc6d9
                               at /rustc/4493a0f4724c0bae1436242d76cccc9c0a287b80/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f297e141e51 - std::sys_common::backtrace::print::h3411f7b71d800108
                               at /rustc/4493a0f4724c0bae1436242d76cccc9c0a287b80/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f297e141e51 - std::panicking::default_hook::{{closure}}::h12beb11c6ee6bec5
                               at /rustc/4493a0f4724c0bae1436242d76cccc9c0a287b80/library/std/src/panicking.rs:295:22
   9:     0x7f297e141b1e - std::panicking::default_hook::h2eef8408d4ca9ede
                               at /rustc/4493a0f4724c0bae1436242d76cccc9c0a287b80/library/std/src/panicking.rs:314:9
  10:     0x7f29809c5c84 - <rustc_driver[7b8e841f406e2b35]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[eaa8289d5e160b7d]::ops::function::FnOnce<(&core[eaa8289d5e160b7d]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f297e142686 - std::panicking::rust_panic_with_hook::h7727c630f4806f59
                               at /rustc/4493a0f4724c0bae1436242d76cccc9c0a287b80/library/std/src/panicking.rs:702:17
  12:     0x7f297e142499 - std::panicking::begin_panic_handler::{{closure}}::hd9895565319b4be3
                               at /rustc/4493a0f4724c0bae1436242d76cccc9c0a287b80/library/std/src/panicking.rs:586:13
  13:     0x7f297e13f694 - std::sys_common::backtrace::__rust_end_short_backtrace::hf6328224d676a394
                               at /rustc/4493a0f4724c0bae1436242d76cccc9c0a287b80/library/std/src/sys_common/backtrace.rs:138:18
  14:     0x7f297e142202 - rust_begin_unwind
                               at /rustc/4493a0f4724c0bae1436242d76cccc9c0a287b80/library/std/src/panicking.rs:584:5
  15:     0x7f297e197613 - core::panicking::panic_fmt::h45ce647c24a8fcf8
                               at /rustc/4493a0f4724c0bae1436242d76cccc9c0a287b80/library/core/src/panicking.rs:142:14
  16:     0x7f297e19745d - core::panicking::panic::h980226bb475510cc
                               at /rustc/4493a0f4724c0bae1436242d76cccc9c0a287b80/library/core/src/panicking.rs:48:5
  17:     0x55d92e35b5ea - <&mut <rustdoc[21d2dc8e35a7e5df]::clean::auto_trait::AutoTraitFinder>::make_final_bounds::{closure#0} as core[eaa8289d5e160b7d]::ops::function::FnOnce<((rustdoc[21d2dc8e35a7e5df]::clean::types::Type, std[ca9781f34924416f]::collections::hash::set::HashSet<rustdoc[21d2dc8e35a7e5df]::clean::types::GenericBound, core[eaa8289d5e160b7d]::hash::BuildHasherDefault<rustc_hash[4e9d7c2b3da32cab]::FxHasher>>),)>>::call_once
  18:     0x55d92e3b8890 - <core[eaa8289d5e160b7d]::iter::adapters::chain::Chain<core[eaa8289d5e160b7d]::iter::adapters::flatten::FlatMap<std[ca9781f34924416f]::collections::hash::map::IntoIter<rustdoc[21d2dc8e35a7e5df]::clean::types::Type, std[ca9781f34924416f]::collections::hash::set::HashSet<rustdoc[21d2dc8e35a7e5df]::clean::types::GenericBound, core[eaa8289d5e160b7d]::hash::BuildHasherDefault<rustc_hash[4e9d7c2b3da32cab]::FxHasher>>>, core[eaa8289d5e160b7d]::option::Option<rustdoc[21d2dc8e35a7e5df]::clean::types::WherePredicate>, <rustdoc[21d2dc8e35a7e5df]::clean::auto_trait::AutoTraitFinder>::make_final_bounds::{closure#0}>, core[eaa8289d5e160b7d]::iter::adapters::map::Map<core[eaa8289d5e160b7d]::iter::adapters::filter::Filter<std[ca9781f34924416f]::collections::hash::map::IntoIter<rustdoc[21d2dc8e35a7e5df]::clean::types::Lifetime, std[ca9781f34924416f]::collections::hash::set::HashSet<rustdoc[21d2dc8e35a7e5df]::clean::types::GenericBound, core[eaa8289d5e160b7d]::hash::BuildHasherDefault<rustc_hash[4e9d7c2b3da32cab]::FxHasher>>>, <rustdoc[21d2dc8e35a7e5df]::clean::auto_trait::AutoTraitFinder>::make_final_bounds::{closure#1}>, <rustdoc[21d2dc8e35a7e5df]::clean::auto_trait::AutoTraitFinder>::make_final_bounds::{closure#2}>> as core[eaa8289d5e160b7d]::iter::traits::iterator::Iterator>::next
  19:     0x55d92e3a23de - <alloc[425a8c2a7e6c88d4]::vec::Vec<rustdoc[21d2dc8e35a7e5df]::clean::types::WherePredicate> as alloc[425a8c2a7e6c88d4]::vec::spec_from_iter::SpecFromIter<rustdoc[21d2dc8e35a7e5df]::clean::types::WherePredicate, core[eaa8289d5e160b7d]::iter::adapters::chain::Chain<core[eaa8289d5e160b7d]::iter::adapters::flatten::FlatMap<std[ca9781f34924416f]::collections::hash::map::IntoIter<rustdoc[21d2dc8e35a7e5df]::clean::types::Type, std[ca9781f34924416f]::collections::hash::set::HashSet<rustdoc[21d2dc8e35a7e5df]::clean::types::GenericBound, core[eaa8289d5e160b7d]::hash::BuildHasherDefault<rustc_hash[4e9d7c2b3da32cab]::FxHasher>>>, core[eaa8289d5e160b7d]::option::Option<rustdoc[21d2dc8e35a7e5df]::clean::types::WherePredicate>, <rustdoc[21d2dc8e35a7e5df]::clean::auto_trait::AutoTraitFinder>::make_final_bounds::{closure#0}>, core[eaa8289d5e160b7d]::iter::adapters::map::Map<core[eaa8289d5e160b7d]::iter::adapters::filter::Filter<std[ca9781f34924416f]::collections::hash::map::IntoIter<rustdoc[21d2dc8e35a7e5df]::clean::types::Lifetime, std[ca9781f34924416f]::collections::hash::set::HashSet<rustdoc[21d2dc8e35a7e5df]::clean::types::GenericBound, core[eaa8289d5e160b7d]::hash::BuildHasherDefault<rustc_hash[4e9d7c2b3da32cab]::FxHasher>>>, <rustdoc[21d2dc8e35a7e5df]::clean::auto_trait::AutoTraitFinder>::make_final_bounds::{closure#1}>, <rustdoc[21d2dc8e35a7e5df]::clean::auto_trait::AutoTraitFinder>::make_final_bounds::{closure#2}>>>>::from_iter
  20:     0x55d92e361300 - <rustdoc[21d2dc8e35a7e5df]::clean::auto_trait::AutoTraitFinder>::param_env_to_generics
  21:     0x55d92e334d55 - <rustc_infer[9079d72f7c0e37ff]::infer::InferCtxtBuilder>::enter::<rustc_trait_selection[34dd72e2874013f0]::traits::auto_trait::AutoTraitResult<rustdoc[21d2dc8e35a7e5df]::clean::types::Generics>, <rustc_trait_selection[34dd72e2874013f0]::traits::auto_trait::AutoTraitFinder>::find_auto_trait_generics<rustdoc[21d2dc8e35a7e5df]::clean::types::Generics, <rustdoc[21d2dc8e35a7e5df]::clean::auto_trait::AutoTraitFinder>::generate_for_trait::{closure#0}>::{closure#1}>
  22:     0x55d92e2fe8b4 - <rustc_trait_selection[34dd72e2874013f0]::traits::auto_trait::AutoTraitFinder>::find_auto_trait_generics::<rustdoc[21d2dc8e35a7e5df]::clean::types::Generics, <rustdoc[21d2dc8e35a7e5df]::clean::auto_trait::AutoTraitFinder>::generate_for_trait::{closure#0}>
  23:     0x55d92e35c46c - <rustdoc[21d2dc8e35a7e5df]::clean::auto_trait::AutoTraitFinder>::generate_for_trait
  24:     0x55d92e3b7f40 - <alloc[425a8c2a7e6c88d4]::vec::Vec<rustdoc[21d2dc8e35a7e5df]::clean::types::Item> as alloc[425a8c2a7e6c88d4]::vec::spec_from_iter::SpecFromIter<rustdoc[21d2dc8e35a7e5df]::clean::types::Item, core[eaa8289d5e160b7d]::iter::adapters::filter_map::FilterMap<alloc[425a8c2a7e6c88d4]::vec::into_iter::IntoIter<rustc_span[2e8002963ade6a2d]::def_id::DefId>, <rustdoc[21d2dc8e35a7e5df]::clean::auto_trait::AutoTraitFinder>::get_auto_trait_impls::{closure#0}>>>::from_iter
  25:     0x55d92e35d203 - <rustdoc[21d2dc8e35a7e5df]::clean::auto_trait::AutoTraitFinder>::get_auto_trait_impls
  26:     0x55d92e312be1 - rustdoc[21d2dc8e35a7e5df]::clean::utils::get_auto_trait_and_blanket_impls
  27:     0x55d92e3ed9b3 - <rustdoc[21d2dc8e35a7e5df]::passes::collect_trait_impls::SyntheticImplCollector as rustdoc[21d2dc8e35a7e5df]::visit::DocVisitor>::visit_item
  28:     0x55d92e3edafa - <rustdoc[21d2dc8e35a7e5df]::passes::collect_trait_impls::SyntheticImplCollector as rustdoc[21d2dc8e35a7e5df]::visit::DocVisitor>::visit_item
  29:     0x55d92e3edafa - <rustdoc[21d2dc8e35a7e5df]::passes::collect_trait_impls::SyntheticImplCollector as rustdoc[21d2dc8e35a7e5df]::visit::DocVisitor>::visit_item
  30:     0x55d92e3edafa - <rustdoc[21d2dc8e35a7e5df]::passes::collect_trait_impls::SyntheticImplCollector as rustdoc[21d2dc8e35a7e5df]::visit::DocVisitor>::visit_item
  31:     0x55d92e3eec2d - <rustdoc[21d2dc8e35a7e5df]::passes::collect_trait_impls::SyntheticImplCollector as rustdoc[21d2dc8e35a7e5df]::visit::DocVisitor>::visit_crate
  32:     0x55d92e5a7e22 - <rustc_session[c468c539a2679830]::session::Session>::time::<alloc[425a8c2a7e6c88d4]::vec::Vec<rustdoc[21d2dc8e35a7e5df]::clean::types::Item>, rustdoc[21d2dc8e35a7e5df]::passes::collect_trait_impls::collect_trait_impls::{closure#0}>
  33:     0x55d92e3ebdf3 - rustdoc[21d2dc8e35a7e5df]::passes::collect_trait_impls::collect_trait_impls
  34:     0x55d92e5a83ed - <rustc_session[c468c539a2679830]::session::Session>::time::<rustdoc[21d2dc8e35a7e5df]::clean::types::Crate, rustdoc[21d2dc8e35a7e5df]::core::run_global_ctxt::{closure#8}>
  35:     0x55d92e2b9885 - rustdoc[21d2dc8e35a7e5df]::core::run_global_ctxt
  36:     0x55d92e5a86cf - <rustc_session[c468c539a2679830]::session::Session>::time::<(rustdoc[21d2dc8e35a7e5df]::clean::types::Crate, rustdoc[21d2dc8e35a7e5df]::config::RenderOptions, rustdoc[21d2dc8e35a7e5df]::formats::cache::Cache), rustdoc[21d2dc8e35a7e5df]::main_options::{closure#0}::{closure#0}::{closure#1}::{closure#0}>
  37:     0x55d92e47eb4c - <rustc_interface[676c19a11e42c774]::passes::QueryContext>::enter::<rustdoc[21d2dc8e35a7e5df]::main_options::{closure#0}::{closure#0}::{closure#1}, core[eaa8289d5e160b7d]::result::Result<(), rustc_errors[1e64fe3ba67d1f19]::ErrorGuaranteed>>
  38:     0x55d92e3f6cfc - <rustc_interface[676c19a11e42c774]::interface::Compiler>::enter::<rustdoc[21d2dc8e35a7e5df]::main_options::{closure#0}::{closure#0}, core[eaa8289d5e160b7d]::result::Result<(), rustc_errors[1e64fe3ba67d1f19]::ErrorGuaranteed>>
  39:     0x55d92e5e1e4c - rustc_span[2e8002963ade6a2d]::with_source_map::<core[eaa8289d5e160b7d]::result::Result<(), rustc_errors[1e64fe3ba67d1f19]::ErrorGuaranteed>, rustc_interface[676c19a11e42c774]::interface::create_compiler_and_run<core[eaa8289d5e160b7d]::result::Result<(), rustc_errors[1e64fe3ba67d1f19]::ErrorGuaranteed>, rustdoc[21d2dc8e35a7e5df]::main_options::{closure#0}>::{closure#1}>
  40:     0x55d92e3f91fb - rustc_interface[676c19a11e42c774]::interface::create_compiler_and_run::<core[eaa8289d5e160b7d]::result::Result<(), rustc_errors[1e64fe3ba67d1f19]::ErrorGuaranteed>, rustdoc[21d2dc8e35a7e5df]::main_options::{closure#0}>
  41:     0x55d92e2ccc82 - rustdoc[21d2dc8e35a7e5df]::main_options
  42:     0x55d92e47c79c - <scoped_tls[11e482a8578ae990]::ScopedKey<rustc_span[2e8002963ade6a2d]::SessionGlobals>>::set::<rustdoc[21d2dc8e35a7e5df]::main_args::{closure#0}, core[eaa8289d5e160b7d]::result::Result<(), rustc_errors[1e64fe3ba67d1f19]::ErrorGuaranteed>>
  43:     0x55d92e55610f - std[ca9781f34924416f]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[676c19a11e42c774]::util::run_in_thread_pool_with_globals<rustdoc[21d2dc8e35a7e5df]::main_args::{closure#0}, core[eaa8289d5e160b7d]::result::Result<(), rustc_errors[1e64fe3ba67d1f19]::ErrorGuaranteed>>::{closure#0}, core[eaa8289d5e160b7d]::result::Result<(), rustc_errors[1e64fe3ba67d1f19]::ErrorGuaranteed>>
  44:     0x55d92e49a2f9 - <<std[ca9781f34924416f]::thread::Builder>::spawn_unchecked_<rustc_interface[676c19a11e42c774]::util::run_in_thread_pool_with_globals<rustdoc[21d2dc8e35a7e5df]::main_args::{closure#0}, core[eaa8289d5e160b7d]::result::Result<(), rustc_errors[1e64fe3ba67d1f19]::ErrorGuaranteed>>::{closure#0}, core[eaa8289d5e160b7d]::result::Result<(), rustc_errors[1e64fe3ba67d1f19]::ErrorGuaranteed>>::{closure#1} as core[eaa8289d5e160b7d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  45:     0x7f297e14c653 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h3dc11c0be18dca7f
                               at /rustc/4493a0f4724c0bae1436242d76cccc9c0a287b80/library/alloc/src/boxed.rs:1935:9
  46:     0x7f297e14c653 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h4d10783815c25313
                               at /rustc/4493a0f4724c0bae1436242d76cccc9c0a287b80/library/alloc/src/boxed.rs:1935:9
  47:     0x7f297e14c653 - std::sys::unix::thread::Thread::new::thread_start::h80c041693146deb9
                               at /rustc/4493a0f4724c0bae1436242d76cccc9c0a287b80/library/std/src/sys/unix/thread.rs:108:17
  48:     0x7f297de5754d - <unknown>
  49:     0x7f297dedc874 - clone
  50:                0x0 - <unknown>

jendrikw avatar Aug 04 '22 14:08 jendrikw

@rustbot label -E-needs-mcve

fmease avatar Aug 04 '22 15:08 fmease

Was this at least on a project you can share the source to, or was it closed source?

If it's a big project that you can't minimise, then it would be good to share/link to that, so someone else can do the minimisation. an example is better than no example, even if it's not minimal.

5225225 avatar Aug 04 '22 15:08 5225225

Managed to find something. The Fn bound seems crucially important.

// struct Peekable<I: Iterator>
use std::iter::Peekable;

pub struct Span<F: Fn(&i32)> {
    inner: Peekable<ConditionalIterator<F>>,
}

struct ConditionalIterator<F> {
    f: F,
}

impl<F: Fn(&i32)> Iterator for ConditionalIterator<F> {
    type Item = ();

    fn next(&mut self) -> Option<Self::Item> {
        todo!()
    }
}

jendrikw avatar Aug 04 '22 16:08 jendrikw

searched nightlies: from nightly-2022-01-01 to nightly-2022-08-02 regressed nightly: nightly-2022-06-23 searched commit range: https://github.com/rust-lang/rust/compare/dc80ca78b6ec2b6bba02560470347433bcd0bb3c...10f4ce324baf7cfb7ce2b2096662b82b79204944 regressed commit: https://github.com/rust-lang/rust/commit/10f4ce324baf7cfb7ce2b2096662b82b79204944

bisected with cargo-bisect-rustc v0.6.4

Host triple: x86_64-unknown-linux-gnu Reproduce with:

cargo bisect-rustc 2022-01-01 --preserve --prompt -- doc 

Looks like https://github.com/rust-lang/rust/pull/98279

5225225 avatar Aug 04 '22 21:08 5225225