Rollup merge of #83313 - cjgillot:assert, r=michaelwoerister

Only enable assert_dep_graph when query-dep-graph is enabled.

This is a debugging option. The only effect should be on rustc tests.

r? ``@michaelwoerister``
This commit is contained in:
Dylan DPC 2021-03-24 01:52:28 +01:00 committed by GitHub
commit 2f611da1d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 77 additions and 1 deletions

View file

@ -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,20 @@ impl CheckAttrVisitor<'tcx> {
}
}
/// Checks that the dep-graph debugging attributes are only present when the query-dep-graph
/// option is passed to the compiler.
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 {