Skip to content

[ICE]: doc_cfg: None in sub_item.ident() (invalid_doc_attribute lint) #158744

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

#[doc(auto_cfg(hide(a, values(::b))))]
fn f() {}

original:

#![feature(doc_cfg)]
#[doc(auto_cfg(hide(a, values(::b))))]
fn f() {}

Version information

rustc 1.98.0-nightly (c397dae80 2026-07-02)
binary: rustc
commit-hash: c397dae808f70caebab1fc4e11b3edf7e59f58c7
commit-date: 2026-07-02
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.8

Possibly related line of code:

cfg_values.push_none(sub_item.span());
}
} else {
cx.emit_lint(
rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES,
DocAutoCfgHideShowUnexpectedItem {
attr_name: sub_item.ident().unwrap().name,
},
sub_item.span(),
);
}
}
}

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error[E0658]: `#[doc(auto_cfg)]` is experimental
 --> /tmp/icemaker_global_tempdir.5f7lmr32T6MV/rustc_testrunner_tmpdir_reporting.VIohsEI3Ys9u/mvce.rs:1:1
  |
1 | #[doc(auto_cfg(hide(a, values(::b))))]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #43781 <https://github.com/rust-lang/rust/issues/43781> for more information
  = help: add `#![feature(doc_cfg)]` to the crate attributes to enable
  = note: this compiler was built on 2026-07-02; consider upgrading it if it is out of date


thread 'rustc' (2477313) panicked at /rustc-dev/c397dae808f70caebab1fc4e11b3edf7e59f58c7/compiler/rustc_attr_parsing/src/attributes/doc.rs:375:61:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7f45d78f0836 - <<std[9825f2e6b8e19478]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[98665f3f32c5c4a4]::fmt::Display>::fmt
   1:     0x7f45d800ec9e - core[98665f3f32c5c4a4]::fmt::write
   2:     0x7f45d7905c1c - <std[9825f2e6b8e19478]::sys::stdio::unix::Stderr as std[9825f2e6b8e19478]::io::Write>::write_fmt
   3:     0x7f45d78c4c9a - std[9825f2e6b8e19478]::panicking::default_hook::{closure#0}
   4:     0x7f45d78e2f83 - std[9825f2e6b8e19478]::panicking::default_hook
   5:     0x7f45d68cf4d8 - std[9825f2e6b8e19478]::panicking::update_hook::<alloc[c330bc42d7fbe3f9]::boxed::Box<rustc_driver_impl[86b904b42ab60ec6]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f45d78e3422 - std[9825f2e6b8e19478]::panicking::panic_with_hook
   7:     0x7f45d78c4d84 - std[9825f2e6b8e19478]::panicking::panic_handler::{closure#0}
   8:     0x7f45d78bba19 - std[9825f2e6b8e19478]::sys::backtrace::__rust_end_short_backtrace::<std[9825f2e6b8e19478]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f45d78c66bd - __rustc[41205345b0684f81]::rust_begin_unwind
  10:     0x7f45d496ac1c - core[98665f3f32c5c4a4]::panicking::panic_fmt
  11:     0x7f45d4ea15a2 - core[98665f3f32c5c4a4]::panicking::panic
  12:     0x7f45d49a1669 - core[98665f3f32c5c4a4]::option::unwrap_failed
  13:     0x7f45d92f2129 - <rustc_attr_parsing[503c0de8ee6c8b17]::attributes::doc::DocParser>::accept_single_doc_attr
  14:     0x7f45d8a047a7 - <rustc_ast_lowering[db02e65ef0f609ec]::LoweringContext>::lower_attrs_vec
  15:     0x7f45d85ebde6 - rustc_ast_lowering[db02e65ef0f609ec]::lower_to_hir
  16:     0x7f45d85e8a51 - rustc_query_impl[f65037dd5affda9e]::query_impl::lower_to_hir::invoke_provider_fn::__rust_begin_short_backtrace
  17:     0x7f45d85e488a - rustc_query_impl[f65037dd5affda9e]::execution::try_execute_query::<rustc_data_structures[a2c8f28b31afc7d6]::vec_cache::VecCache<rustc_span[92f9b61efdf79936]::def_id::LocalDefId, rustc_middle[88f8ef47a2d07faa]::query::erase::ErasedData<[u8; 16usize]>, rustc_middle[88f8ef47a2d07faa]::dep_graph::graph::DepNodeIndex>, false>
  18:     0x7f45d85e45c5 - rustc_query_impl[f65037dd5affda9e]::query_impl::lower_to_hir::execute_query_non_incr::__rust_end_short_backtrace
  19:     0x7f45d85e40ae - rustc_query_impl[f65037dd5affda9e]::query_impl::hir_owner::invoke_provider_fn::__rust_begin_short_backtrace
  20:     0x7f45d85e350c - rustc_query_impl[f65037dd5affda9e]::execution::try_execute_query::<rustc_data_structures[a2c8f28b31afc7d6]::vec_cache::VecCache<rustc_span[92f9b61efdf79936]::def_id::LocalDefId, rustc_middle[88f8ef47a2d07faa]::query::erase::ErasedData<[u8; 32usize]>, rustc_middle[88f8ef47a2d07faa]::dep_graph::graph::DepNodeIndex>, false>
  21:     0x7f45d85e3226 - rustc_query_impl[f65037dd5affda9e]::query_impl::hir_owner::execute_query_non_incr::__rust_end_short_backtrace
  22:     0x7f45d8f512ec - <rustc_middle[88f8ef47a2d07faa]::hir::map::ItemCollector as rustc_hir[21a02c6169a039be]::intravisit::Visitor>::visit_nested_item
  23:     0x7f45d8f4ef25 - rustc_middle[88f8ef47a2d07faa]::hir::map::hir_crate_items
  24:     0x7f45d9141d21 - rustc_query_impl[f65037dd5affda9e]::query_impl::hir_crate_items::invoke_provider_fn::__rust_begin_short_backtrace
  25:     0x7f45d913ce1a - rustc_query_impl[f65037dd5affda9e]::execution::try_execute_query::<rustc_middle[88f8ef47a2d07faa]::query::caches::SingleCache<rustc_middle[88f8ef47a2d07faa]::query::erase::ErasedData<[u8; 8usize]>>, false>
  26:     0x7f45d913d8b9 - rustc_query_impl[f65037dd5affda9e]::query_impl::hir_crate_items::execute_query_non_incr::__rust_end_short_backtrace
  27:     0x7f45d83ed85e - rustc_interface[3af1732d5ed36fcb]::passes::analysis
  28:     0x7f45d913c4c7 - rustc_query_impl[f65037dd5affda9e]::execution::try_execute_query::<rustc_middle[88f8ef47a2d07faa]::query::caches::SingleCache<rustc_middle[88f8ef47a2d07faa]::query::erase::ErasedData<[u8; 0usize]>>, false>
  29:     0x7f45d913c129 - rustc_query_impl[f65037dd5affda9e]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  30:     0x7f45d9193380 - rustc_interface[3af1732d5ed36fcb]::interface::run_compiler::<(), rustc_driver_impl[86b904b42ab60ec6]::run_compiler::{closure#0}>::{closure#1}
  31:     0x7f45d91505ba - std[9825f2e6b8e19478]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[3af1732d5ed36fcb]::util::run_in_thread_with_globals<rustc_interface[3af1732d5ed36fcb]::util::run_in_thread_pool_with_globals<rustc_interface[3af1732d5ed36fcb]::interface::run_compiler<(), rustc_driver_impl[86b904b42ab60ec6]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  32:     0x7f45d915036d - <std[9825f2e6b8e19478]::thread::lifecycle::spawn_unchecked<rustc_interface[3af1732d5ed36fcb]::util::run_in_thread_with_globals<rustc_interface[3af1732d5ed36fcb]::util::run_in_thread_pool_with_globals<rustc_interface[3af1732d5ed36fcb]::interface::run_compiler<(), rustc_driver_impl[86b904b42ab60ec6]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[98665f3f32c5c4a4]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  33:     0x7f45d91467fa - <std[9825f2e6b8e19478]::sys::thread::unix::Thread>::new::thread_start
  34:     0x7f45d2a981b9 - <unknown>
  35:     0x7f45d2b1d21c - <unknown>
  36:                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: please make sure that you have updated to the latest nightly

note: rustc 1.98.0-nightly (c397dae80 2026-07-02) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [lower_to_hir] lowering HIR for `f`
#1 [hir_owner] getting owner for `f`
#2 [hir_crate_items] getting HIR crate items
#3 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 1 previous error

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

@rustbot label +F-doc_cfg

Metadata

Metadata

Assignees

Labels

A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.F-doc_cfg`#![feature(doc_cfg)]`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.

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions