Skip to content

can't get the span of an arbitrary parsed attribute: Parsed(Repr { reprs: #143787

@sososopy

Description

@sososopy

The code is generated by a fuzzer and reduced manually
Possibly a duplicate of #138510

Code

#![feature(stmt_expr_attributes)]
fn main() {
    let _: fn(isize) -> usize = #[repr()] std::string::String::new();
}

Meta

rustc --version --verbose:

rustc 1.90.0-nightly (2a023bf80 2025-07-10)
binary: rustc
commit-hash: 2a023bf80a6fbd6a06d5460a34eb247b986286ed
commit-date: 2025-07-10
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.7

Error output

<None>
Backtrace

thread 'rustc' panicked at /rustc-dev/2a023bf80a6fbd6a06d5460a34eb247b986286ed/compiler/rustc_hir/src/hir.rs:1307:18:
can't get the span of an arbitrary parsed attribute: Parsed(Repr { reprs: [], first_span: ./test.rs:3:33: 3:42 (#0) })
stack backtrace:
   0:     0x7fde4f7b36b3 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hde9130f8bb8f05be
   1:     0x7fde50002637 - core::fmt::write::hf0a4fa274f906048
   2:     0x7fde4f7a91e3 - std::io::Write::write_fmt::h5529dcbcd2adc016
   3:     0x7fde4f7b3512 - std::sys::backtrace::BacktraceLock::print::h6d08de9067bcf327
   4:     0x7fde4f7b6fb7 - std::panicking::default_hook::{{closure}}::h47fd54be39e8f976
   5:     0x7fde4f7b6b1b - std::panicking::default_hook::h3e18904fa30c45d8
   6:     0x7fde4e855a03 - std[3d755e9610f7e251]::panicking::update_hook::<alloc[7f4c2d72f38b8d7e]::boxed::Box<rustc_driver_impl[63982ee25ad4258]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7fde4f7b77fe - std::panicking::rust_panic_with_hook::h95fdb0db127e3393
   8:     0x7fde4f7b74fa - std::panicking::begin_panic_handler::{{closure}}::h60a8d1dd28fdf2f9
   9:     0x7fde4f7b3b79 - std::sys::backtrace::__rust_end_short_backtrace::h257feb614e80fbd3
  10:     0x7fde4f7b71dd - __rustc[c00c44d2e7a9f37a]::rust_begin_unwind
  11:     0x7fde4bee32c0 - core::panicking::panic_fmt::h34a2576cfcb88dba
  12:     0x7fde51be725e - <rustc_hir_typeck[e05746f8d1463b85]::fn_ctxt::FnCtxt>::precedence::{closure#0}.llvm.12623543789783378793.cold
  13:     0x7fde50f035ed - <rustc_hir[ac0ad48649a9a1c6]::hir::Expr>::precedence
  14:     0x7fde4eb731e8 - <rustc_hir_typeck[e05746f8d1463b85]::fn_ctxt::FnCtxt>::suggest_deref_ref_or_into
  15:     0x7fde4eb2e8b3 - <rustc_hir_typeck[e05746f8d1463b85]::fn_ctxt::FnCtxt>::emit_type_mismatch_suggestions
  16:     0x7fde4eb33e31 - <rustc_hir_typeck[e05746f8d1463b85]::fn_ctxt::FnCtxt>::emit_coerce_suggestions
  17:     0x7fde50263b0d - <rustc_hir_typeck[e05746f8d1463b85]::fn_ctxt::FnCtxt>::check_decl
  18:     0x7fde50d2f92f - <rustc_hir_typeck[e05746f8d1463b85]::fn_ctxt::FnCtxt>::check_expr_block
  19:     0x7fde50d495e1 - <rustc_hir_typeck[e05746f8d1463b85]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  20:     0x7fde50d39985 - rustc_hir_typeck[e05746f8d1463b85]::check::check_fn
  21:     0x7fde512132bd - rustc_hir_typeck[e05746f8d1463b85]::typeck_with_inspect::{closure#0}
  22:     0x7fde511ffcb0 - rustc_query_impl[73f7b85c6196fc58]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[73f7b85c6196fc58]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[bfb8074addc0df29]::query::erase::Erased<[u8; 8usize]>>
  23:     0x7fde501c7b2e - rustc_query_system[9ad56969e99527f5]::query::plumbing::try_execute_query::<rustc_query_impl[73f7b85c6196fc58]::DynamicConfig<rustc_data_structures[3e414e5f4aa76e06]::vec_cache::VecCache<rustc_span[34d8fcb52d2fde04]::def_id::LocalDefId, rustc_middle[bfb8074addc0df29]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[9ad56969e99527f5]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[73f7b85c6196fc58]::plumbing::QueryCtxt, false>
  24:     0x7fde501c74c9 - rustc_query_impl[73f7b85c6196fc58]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  25:     0x7fde50804584 - rustc_hir_analysis[3ed7bc842342b5c1]::check_crate
  26:     0x7fde501c3671 - rustc_interface[ca8d5c69dfd7f14d]::passes::analysis
  27:     0x7fde501c328b - rustc_query_impl[73f7b85c6196fc58]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[73f7b85c6196fc58]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[bfb8074addc0df29]::query::erase::Erased<[u8; 0usize]>>
  28:     0x7fde5109f93c - rustc_query_system[9ad56969e99527f5]::query::plumbing::try_execute_query::<rustc_query_impl[73f7b85c6196fc58]::DynamicConfig<rustc_query_system[9ad56969e99527f5]::query::caches::SingleCache<rustc_middle[bfb8074addc0df29]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[73f7b85c6196fc58]::plumbing::QueryCtxt, false>
  29:     0x7fde5109f506 - rustc_query_impl[73f7b85c6196fc58]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7fde51319296 - rustc_interface[ca8d5c69dfd7f14d]::passes::create_and_enter_global_ctxt::<core[557129ac99d5593e]::option::Option<rustc_interface[ca8d5c69dfd7f14d]::queries::Linker>, rustc_driver_impl[63982ee25ad4258]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  31:     0x7fde51228f17 - rustc_interface[ca8d5c69dfd7f14d]::interface::run_compiler::<(), rustc_driver_impl[63982ee25ad4258]::run_compiler::{closure#0}>::{closure#1}
  32:     0x7fde511e52f8 - std[3d755e9610f7e251]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[ca8d5c69dfd7f14d]::util::run_in_thread_with_globals<rustc_interface[ca8d5c69dfd7f14d]::util::run_in_thread_pool_with_globals<rustc_interface[ca8d5c69dfd7f14d]::interface::run_compiler<(), rustc_driver_impl[63982ee25ad4258]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  33:     0x7fde511e4fd6 - <<std[3d755e9610f7e251]::thread::Builder>::spawn_unchecked_<rustc_interface[ca8d5c69dfd7f14d]::util::run_in_thread_with_globals<rustc_interface[ca8d5c69dfd7f14d]::util::run_in_thread_pool_with_globals<rustc_interface[ca8d5c69dfd7f14d]::interface::run_compiler<(), rustc_driver_impl[63982ee25ad4258]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[557129ac99d5593e]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  34:     0x7fde511eaebd - std::sys::pal::unix::thread::Thread::new::thread_start::h94d994b2c0a286ed
  35:     0x7fde4aa6bac3 - <unknown>
  36:     0x7fde4aafca04 - clone
  37:                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: please attach the file at `/root/autodl-tmp/rustc-ice-2025-07-11T13_24_59-467604.txt` to your bug report

query stack during panic:
#0 [typeck] type-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack
warning: 1 warning emitted

note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error: `TypeError` when attempting coercion but no error emitted
 --> ./test.rs:3:43
  |
3 |     let _: fn(isize) -> usize = #[repr()] std::string::String::new();
  |                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
note: delayed at compiler/rustc_hir_typeck/src/demand.rs:276:47 - disabled backtrace
 --> ./test.rs:3:43
  |
3 |     let _: fn(isize) -> usize = #[repr()] std::string::String::new();
  |                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^

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: please attach the file at `/root/autodl-tmp/rustc-ice-2025-07-11T13_24_59-467604.txt` to your bug report

query stack during panic:
end of query stack

Metadata

Metadata

Labels

C-bugCategory: This is a bug.F-stmt_expr_attributes`#![feature(stmt_expr_attributes)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-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