Skip to content

Adding functions through crate level syntax extensions crashes compiler #45458

Closed
@Rantanen

Description

@Rantanen

Having a MultiDecorator push function items on an attribute defined on the crate level (#![...) will result in the compiler crashing if these functions are called from the code.

#![decorator]  // Changing this to #[decorator] prevents the crash.

fn main() {
    decorated_method();  // Commenting out this line prevents the crash.
}

Full reproduction case is at https://github.com/Rantanen/com-export-rs/tree/issue
intercom-issue.zip

Use cargo run --example example

Meta

rustc --version --verbose:
rustc 1.22.0-nightly (f6d7514 2017-10-17)
binary: rustc
commit-hash: f6d7514
commit-date: 2017-10-17
host: x86_64-pc-windows-msvc
release: 1.22.0-nightly
LLVM version: 4.0

Backtrace:

thread 'rustc' panicked at 'Box<Any>', src\librustc_errors\lib.rs:492:8
stack backtrace:
   0: _rdl_shrink_in_place
   1: std::panicking::Location::column
   2: std::panicking::Location::column
   3: std::panicking::rust_panic_with_hook
   4: <unknown>
   5: rustc_errors::Handler::bug
   6: rustc::session::bug_fmt
   7: rustc::session::bug_fmt
   8: rustc::session::bug_fmt
   9: rustc::hir::map::Map::read
  10: rustc::hir::map::Map::span
  11: rustc::ty::maps::<impl rustc::ty::maps::queries::def_span<'tcx>>::ensure
  12: rustc::ty::maps::<impl rustc::ty::maps::queries::def_span<'tcx>>::try_get
  13: rustc::ty::maps::TyCtxtAt::def_span
  14: rustc::ty::maps::<impl rustc::ty::maps::queries::lookup_deprecation_entry<'tcx>>::try_get
  15: rustc::ty::maps::TyCtxtAt::lookup_deprecation_entry
  16: rustc::middle::stability::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::check_stability
  17: <rustc::middle::stability::Checker<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_path

Edit: I removed the branch repro branch from the repository. It was causing problems with Codecov, which figured it was the default branch. Zip file of the repro case attached instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions