From 1aad7e738e10e3e1315c219cc3d865fb710fa894 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Mon, 22 Mar 2021 19:21:55 +0100 Subject: Err if the debugging options are not passed. --- compiler/rustc_passes/src/check_attr.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'compiler/rustc_passes/src') diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index d91d0e1765b..a86de6fc6f3 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -99,6 +99,12 @@ impl CheckAttrVisitor<'tcx> { self.check_naked(hir_id, attr, span, target) } else if self.tcx.sess.check_name(attr, sym::rustc_legacy_const_generics) { self.check_rustc_legacy_const_generics(&attr, span, target, item) + } else if self.tcx.sess.check_name(attr, sym::rustc_clean) + || self.tcx.sess.check_name(attr, sym::rustc_dirty) + || self.tcx.sess.check_name(attr, sym::rustc_if_this_changed) + || self.tcx.sess.check_name(attr, sym::rustc_then_this_would_need) + { + self.check_rustc_dirty_clean(&attr) } else { // lint-only checks if self.tcx.sess.check_name(attr, sym::cold) { @@ -1012,6 +1018,19 @@ impl CheckAttrVisitor<'tcx> { } } + /// Checks if `#[rustc_legacy_const_generics]` is applied to a function and has a valid argument. + fn check_rustc_dirty_clean(&self, attr: &Attribute) -> bool { + if self.tcx.sess.opts.debugging_opts.query_dep_graph { + true + } else { + self.tcx + .sess + .struct_span_err(attr.span, "attribute requires -Z query-dep-graph to be enabled") + .emit(); + false + } + } + /// Checks if `#[link_section]` is applied to a function or static. fn check_link_section(&self, hir_id: HirId, attr: &Attribute, span: &Span, target: Target) { match target { -- cgit 1.4.1-3-g733a5