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

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

Closed
jendrikw opened this issue Aug 4, 2022 · 4 comments · Fixed by #100205
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Milestone

Comments

@jendrikw
Copy link
Contributor

jendrikw commented Aug 4, 2022

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 1b57946 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 jendrikw added 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. labels Aug 4, 2022
@fmease

This comment was marked as resolved.

@rustbot rustbot added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Aug 4, 2022
@5225225
Copy link
Contributor

5225225 commented Aug 4, 2022

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.

@jendrikw
Copy link
Contributor Author

jendrikw commented Aug 4, 2022

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!()
    }
}

@5225225
Copy link
Contributor

5225225 commented Aug 4, 2022

searched nightlies: from nightly-2022-01-01 to nightly-2022-08-02
regressed nightly: nightly-2022-06-23
searched commit range: dc80ca7...10f4ce3
regressed commit: 10f4ce3

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 #98279

@rustbot rustbot removed the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Aug 5, 2022
@Alexendoo Alexendoo added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 6, 2022
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Aug 6, 2022
@camelid camelid added the regression-from-stable-to-beta Performance or correctness regression from stable to beta. label Aug 8, 2022
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Aug 8, 2022
@Mark-Simulacrum Mark-Simulacrum added this to the 1.63.0 milestone Aug 8, 2022
@bors bors closed this as completed in 8d1fa71 Aug 9, 2022
@apiraino apiraino removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Aug 9, 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. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-beta Performance or correctness regression from stable to beta. 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.

9 participants