Skip to content

Attribute "[deprecated()]": thread 'rustc' panicked at 'called Option::unwrap() on a None value' #66340

Closed

Description

Steps to Reproduce

$ cargo new deprecate_crash
     Created binary (application) `deprecate_crash` package
Friendly_Name /cygdrive/c/Users/eric/Documents/projects/cevi-versand (master)
$ vim deprecate_crash/src/main.rs
fn main() {
    println!("main.");
    foo(); // remove this line for compiler output A
}

#[deprecated(note=test)]
fn foo(){
    println!("Hello, world");
}

Compiler Output A

This happens when you run above code without calling foo();.

$ cargo run
   Compiling deprecate_crash v0.1.0 (C:\Users\eric\Documents\projects\cevi-versand\deprecate_crash)
error: expected unsuffixed literal or identifier, found `test`
 --> src\main.rs:5:19
  |
5 | #[deprecated(note=test)]
  |                   ^^^^

error: aborting due to previous error

error: Could not compile `deprecate_crash`.

To learn more, run the command again with --verbose.

Compiler Output B

This happens when you run above code verbatim.

$ cargo run
   Compiling deprecate_crash v0.1.0 (C:\Users\eric\Documents\projects\cevi-versand\deprecate_crash)
error: expected unsuffixed literal or identifier, found `test`
 --> src\main.rs:6:19
  |
6 | #[deprecated(note=test)]
  |                   ^^^^

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', src\libcore\option.rs:347:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
error: aborting due to previous error


error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.37.0 (eae3437df 2019-08-13) running on x86_64-pc-windows-msvc

note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

error: Could not compile `deprecate_crash`.

To learn more, run the command again with --verbose.

Expected Behaviour

I would expect Compiler Output A in both cases.

Backtrace

$ cargo run
   Compiling deprecate_crash v0.1.0 (C:\Users\eric\Documents\projects\cevi-versand\deprecate_crash)
error: expected unsuffixed literal or identifier, found `test`
 --> src\main.rs:6:19
  |
6 | #[deprecated(note=test)]
  |                   ^^^^

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', src\libcore\option.rs:347:21
stack backtrace:
   0: std::sys_common::alloc::realloc_fallback
   1: std::panicking::take_hook
   2: std::panicking::take_hook
   3: <(rustc::hir::def_id::DefId, rustc::hir::def_id::DefId) as rustc::ty::query::keys::Key>::default_span
   4: std::panicking::rust_panic_with_hook
   5: std::panicking::begin_panic_fmt
   6: rust_begin_unwind
   7: core::panicking::panic_fmt
   8: core::panicking::panic
   9: syntax::attr::builtin::find_deprecation
  10: <rustc::middle::stability::Annotator as rustc::hir::intravisit::Visitor>::visit_item
  11: rustc::middle::stability::Index::new
  12: rustc::ty::structural_impls::<impl rustc::ty::context::Lift for syntax_pos::span_encoding::Span>::lift_to_tcx
  13: rustc::middle::weak_lang_items::<impl rustc::ty::context::TyCtxt>::is_weak_lang_item
  14: rustc::dep_graph::graph::DepGraph::assert_ignored
  15: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::try_print_query_stack
  16: rustc::ty::structural_impls::<impl rustc::ty::context::Lift for syntax_pos::span_encoding::Span>::lift_to_tcx
  17: rustc::ty::print::pretty::<impl core::fmt::Display for rustc::ty::subst::Kind>::fmt
  18: rustc::middle::weak_lang_items::<impl rustc::ty::context::TyCtxt>::is_weak_lang_item
  19: rustc::dep_graph::graph::DepGraph::assert_ignored
  20: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::try_print_query_stack
  21: rustc::middle::stability::<impl rustc::ty::context::TyCtxt>::eval_stability
  22: rustc::middle::stability::<impl rustc::ty::context::TyCtxt>::check_stability
  23: rustc::hir::intravisit::NestedVisitorMap::inter
  24: rustc::hir::intravisit::NestedVisitorMap::inter
  25: rustc::hir::intravisit::NestedVisitorMap::inter
  26: rustc::hir::intravisit::NestedVisitorMap::inter
  27: rustc::dep_graph::cgu_reuse_tracker::CguReuseTracker::check_expected_reuse
  28: rustc::hir::intravisit::NestedVisitorMap::inter
  29: <rustc::middle::stability::Checker as rustc::hir::intravisit::Visitor>::visit_item
  30: rustc::hir::map::Map::get_module
  31: rustc::middle::stability::Index::local_deprecation_entry
  32: <rustc_interface::util::ReplaceBodyWithLoop as syntax::mut_visit::MutVisitor>::visit_mac
  33: <rustc_interface::proc_macro_decls::Finder as rustc::hir::itemlikevisit::ItemLikeVisitor>::visit_item
  34: <rustc_interface::proc_macro_decls::Finder as rustc::hir::itemlikevisit::ItemLikeVisitor>::visit_item
  35: <rustc_interface::proc_macro_decls::Finder as rustc::hir::itemlikevisit::ItemLikeVisitor>::visit_item
  36: <rustc_interface::proc_macro_decls::Finder as rustc::hir::itemlikevisit::ItemLikeVisitor>::visit_trait_item
  37: _rust_maybe_catch_panic
  38: <rustc_interface::profile::trace::Query as core::fmt::Debug>::fmt
  39: <rustc_interface::profile::trace::Query as core::fmt::Debug>::fmt
  40: rustc_interface::passes::BoxedResolver::to_expansion_result
  41: rustc_driver::set_sigpipe_handler
  42: rustc_driver::set_sigpipe_handler
  43: <rustc_driver::pretty::UserIdentifiedItem as core::fmt::Debug>::fmt
  44: rustc_driver::set_sigpipe_handler
  45: rustc_driver::set_sigpipe_handler
  46: rustc_driver::set_sigpipe_handler
  47: <rustc_interface::util::ReplaceBodyWithLoop as syntax::mut_visit::MutVisitor>::visit_mac
  48: rustc_driver::set_sigpipe_handler
  49: <env_logger::filter::inner::Filter as core::fmt::Display>::fmt
  50: <env_logger::filter::inner::Filter as core::fmt::Display>::fmt
  51: <rustc_driver::Compilation as core::fmt::Debug>::fmt
  52: <rustc_driver::pretty::UserIdentifiedItem as core::fmt::Debug>::fmt
  53: _rust_maybe_catch_panic
  54: rustc_driver::set_sigpipe_handler
  55: ZN244_$LT$std..error..$LT$impl$u20$core..convert..From$LT$alloc..string..String$GT$$u20$for$u20$alloc..boxed..Box$LT$dyn$u20$std..error..Error$u2b$core..marker..Send$u2b$core..marker..Sync$GT$$GT$..from..StringError$u20$as$u20$core..fmt..Display$GT$3fmt17
  56: std::sys::windows::thread::Thread::new
  57: BaseThreadInitThunk
  58: RtlUserThreadStart
query stack during panic:
#0 [stability_index] calculating the stability index for the local crate
#1 [lookup_deprecation_entry] processing `foo`
#2 [check_mod_unstable_api_usage] checking for unstable API usage in top-level module
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error


error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.37.0 (eae3437df 2019-08-13) running on x86_64-pc-windows-msvc

note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

error: Could not compile `deprecate_crash`.

To learn more, run the command again with --verbose.

Environment

Win10, cygwin

$ cargo --version
cargo 1.37.0 (9edd08916 2019-08-02)
$ rustc --version --verbose
rustc 1.37.0 (eae3437df 2019-08-13)
binary: rustc
commit-hash: eae3437dfe991621e8afdc82734f4a172d7ddf9b
commit-date: 2019-08-13
host: x86_64-pc-windows-msvc
release: 1.37.0
LLVM version: 8.0

Why Would You Even Do This?

I had no internet connection at the time and was trying to achieve #[deprecated(note="test")]

I don't find that crash annoying, but since the message asked me to report it, here I am. Enjoy :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

A-attributesArea: Attributes (`#[…]`, `#![…]`)C-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.glacierICE tracked in rust-lang/glacier.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions