X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_passes%2Fsrc%2Fcheck_attr.rs;h=b3f15ba7cbf25609bf5f0d84bf927336fb955c02;hb=672831a5c890f51d3222511ab2575ca7a86c8e20;hp=d0b46aa2c4530a97893b48e77f15c17603ee0990;hpb=6d2033512b37a7e6f1b659404e471c2352b2f83f;p=rust.git diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index d0b46aa2c45..b3f15ba7cbf 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -131,6 +131,7 @@ fn check_attributes( | sym::rustc_if_this_changed | sym::rustc_then_this_would_need => self.check_rustc_dirty_clean(&attr), sym::cmse_nonsecure_entry => self.check_cmse_nonsecure_entry(attr, span, target), + sym::collapse_debuginfo => self.check_collapse_debuginfo(attr, span, target), sym::const_trait => self.check_const_trait(attr, span, target), sym::must_not_suspend => self.check_must_not_suspend(&attr, span, target), sym::must_use => self.check_must_use(hir_id, &attr, span, target), @@ -431,6 +432,19 @@ fn check_object_lifetime_default(&self, hir_id: HirId) { } } + /// Checks if `#[collapse_debuginfo]` is applied to a macro. + fn check_collapse_debuginfo(&self, attr: &Attribute, span: Span, target: Target) -> bool { + match target { + Target::MacroDef => true, + _ => { + self.tcx + .sess + .emit_err(errors::CollapseDebuginfo { attr_span: attr.span, defn_span: span }); + false + } + } + } + /// Checks if a `#[track_caller]` is applied to a non-naked function. Returns `true` if valid. fn check_track_caller( &self, @@ -661,6 +675,7 @@ fn check_doc_alias_value( | Target::GlobalAsm | Target::TyAlias | Target::OpaqueTy + | Target::ImplTraitPlaceholder | Target::Enum | Target::Variant | Target::Struct @@ -1651,7 +1666,8 @@ fn check_repr( E0552, "unrecognized representation hint" ) - .help("valid reprs are `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize`") + .help("valid reprs are `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, \ + `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize`") .emit(); continue;