Rollup merge of #67382 - nnethercote:rm-unnecessary-ATTR-constants, r=michaelwoerister
Remove some unnecessary `ATTR_*` constants. r? @michaelwoerister
This commit is contained in:
commit
126c8adb33
|
@ -12,21 +12,13 @@ mod impls_hir;
|
||||||
mod impls_ty;
|
mod impls_ty;
|
||||||
mod impls_syntax;
|
mod impls_syntax;
|
||||||
|
|
||||||
pub const ATTR_DIRTY: Symbol = sym::rustc_dirty;
|
|
||||||
pub const ATTR_CLEAN: Symbol = sym::rustc_clean;
|
|
||||||
pub const ATTR_IF_THIS_CHANGED: Symbol = sym::rustc_if_this_changed;
|
|
||||||
pub const ATTR_THEN_THIS_WOULD_NEED: Symbol = sym::rustc_then_this_would_need;
|
|
||||||
pub const ATTR_PARTITION_REUSED: Symbol = sym::rustc_partition_reused;
|
|
||||||
pub const ATTR_PARTITION_CODEGENED: Symbol = sym::rustc_partition_codegened;
|
|
||||||
pub const ATTR_EXPECTED_CGU_REUSE: Symbol = sym::rustc_expected_cgu_reuse;
|
|
||||||
|
|
||||||
pub const IGNORED_ATTRIBUTES: &[Symbol] = &[
|
pub const IGNORED_ATTRIBUTES: &[Symbol] = &[
|
||||||
sym::cfg,
|
sym::cfg,
|
||||||
ATTR_IF_THIS_CHANGED,
|
sym::rustc_if_this_changed,
|
||||||
ATTR_THEN_THIS_WOULD_NEED,
|
sym::rustc_then_this_would_need,
|
||||||
ATTR_DIRTY,
|
sym::rustc_dirty,
|
||||||
ATTR_CLEAN,
|
sym::rustc_clean,
|
||||||
ATTR_PARTITION_REUSED,
|
sym::rustc_partition_reused,
|
||||||
ATTR_PARTITION_CODEGENED,
|
sym::rustc_partition_codegened,
|
||||||
ATTR_EXPECTED_CGU_REUSE,
|
sym::rustc_expected_cgu_reuse,
|
||||||
];
|
];
|
||||||
|
|
|
@ -44,11 +44,10 @@ use rustc_data_structures::graph::implementation::{
|
||||||
};
|
};
|
||||||
use rustc::hir;
|
use rustc::hir;
|
||||||
use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor};
|
use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor};
|
||||||
use rustc::ich::{ATTR_IF_THIS_CHANGED, ATTR_THEN_THIS_WOULD_NEED};
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs::{self, File};
|
use std::fs::{self, File};
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use syntax::ast;
|
use syntax::{ast, symbol::sym};
|
||||||
use syntax_pos::Span;
|
use syntax_pos::Span;
|
||||||
|
|
||||||
pub fn assert_dep_graph(tcx: TyCtxt<'_>) {
|
pub fn assert_dep_graph(tcx: TyCtxt<'_>) {
|
||||||
|
@ -78,7 +77,7 @@ pub fn assert_dep_graph(tcx: TyCtxt<'_>) {
|
||||||
assert!(tcx.sess.opts.debugging_opts.query_dep_graph,
|
assert!(tcx.sess.opts.debugging_opts.query_dep_graph,
|
||||||
"cannot use the `#[{}]` or `#[{}]` annotations \
|
"cannot use the `#[{}]` or `#[{}]` annotations \
|
||||||
without supplying `-Z query-dep-graph`",
|
without supplying `-Z query-dep-graph`",
|
||||||
ATTR_IF_THIS_CHANGED, ATTR_THEN_THIS_WOULD_NEED);
|
sym::rustc_if_this_changed, sym::rustc_then_this_would_need);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check paths.
|
// Check paths.
|
||||||
|
@ -114,7 +113,7 @@ impl IfThisChanged<'tcx> {
|
||||||
let def_id = self.tcx.hir().local_def_id(hir_id);
|
let def_id = self.tcx.hir().local_def_id(hir_id);
|
||||||
let def_path_hash = self.tcx.def_path_hash(def_id);
|
let def_path_hash = self.tcx.def_path_hash(def_id);
|
||||||
for attr in attrs {
|
for attr in attrs {
|
||||||
if attr.check_name(ATTR_IF_THIS_CHANGED) {
|
if attr.check_name(sym::rustc_if_this_changed) {
|
||||||
let dep_node_interned = self.argument(attr);
|
let dep_node_interned = self.argument(attr);
|
||||||
let dep_node = match dep_node_interned {
|
let dep_node = match dep_node_interned {
|
||||||
None => def_path_hash.to_dep_node(DepKind::Hir),
|
None => def_path_hash.to_dep_node(DepKind::Hir),
|
||||||
|
@ -130,7 +129,7 @@ impl IfThisChanged<'tcx> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
self.if_this_changed.push((attr.span, def_id, dep_node));
|
self.if_this_changed.push((attr.span, def_id, dep_node));
|
||||||
} else if attr.check_name(ATTR_THEN_THIS_WOULD_NEED) {
|
} else if attr.check_name(sym::rustc_then_this_would_need) {
|
||||||
let dep_node_interned = self.argument(attr);
|
let dep_node_interned = self.argument(attr);
|
||||||
let dep_node = match dep_node_interned {
|
let dep_node = match dep_node_interned {
|
||||||
Some(n) => {
|
Some(n) => {
|
||||||
|
|
|
@ -28,8 +28,6 @@ use rustc::ty::TyCtxt;
|
||||||
use std::collections::BTreeSet;
|
use std::collections::BTreeSet;
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::symbol::{Symbol, sym};
|
use syntax::symbol::{Symbol, sym};
|
||||||
use rustc::ich::{ATTR_PARTITION_REUSED, ATTR_PARTITION_CODEGENED,
|
|
||||||
ATTR_EXPECTED_CGU_REUSE};
|
|
||||||
|
|
||||||
pub fn assert_module_sources(tcx: TyCtxt<'_>) {
|
pub fn assert_module_sources(tcx: TyCtxt<'_>) {
|
||||||
tcx.dep_graph.with_ignore(|| {
|
tcx.dep_graph.with_ignore(|| {
|
||||||
|
@ -62,11 +60,11 @@ struct AssertModuleSource<'tcx> {
|
||||||
|
|
||||||
impl AssertModuleSource<'tcx> {
|
impl AssertModuleSource<'tcx> {
|
||||||
fn check_attr(&self, attr: &ast::Attribute) {
|
fn check_attr(&self, attr: &ast::Attribute) {
|
||||||
let (expected_reuse, comp_kind) = if attr.check_name(ATTR_PARTITION_REUSED) {
|
let (expected_reuse, comp_kind) = if attr.check_name(sym::rustc_partition_reused) {
|
||||||
(CguReuse::PreLto, ComparisonKind::AtLeast)
|
(CguReuse::PreLto, ComparisonKind::AtLeast)
|
||||||
} else if attr.check_name(ATTR_PARTITION_CODEGENED) {
|
} else if attr.check_name(sym::rustc_partition_codegened) {
|
||||||
(CguReuse::No, ComparisonKind::Exact)
|
(CguReuse::No, ComparisonKind::Exact)
|
||||||
} else if attr.check_name(ATTR_EXPECTED_CGU_REUSE) {
|
} else if attr.check_name(sym::rustc_expected_cgu_reuse) {
|
||||||
match &*self.field(attr, sym::kind).as_str() {
|
match &*self.field(attr, sym::kind).as_str() {
|
||||||
"no" => (CguReuse::No, ComparisonKind::Exact),
|
"no" => (CguReuse::No, ComparisonKind::Exact),
|
||||||
"pre-lto" => (CguReuse::PreLto, ComparisonKind::Exact),
|
"pre-lto" => (CguReuse::PreLto, ComparisonKind::Exact),
|
||||||
|
|
|
@ -22,7 +22,6 @@ use rustc::hir::Node as HirNode;
|
||||||
use rustc::hir::def_id::DefId;
|
use rustc::hir::def_id::DefId;
|
||||||
use rustc::hir::itemlikevisit::ItemLikeVisitor;
|
use rustc::hir::itemlikevisit::ItemLikeVisitor;
|
||||||
use rustc::hir::intravisit;
|
use rustc::hir::intravisit;
|
||||||
use rustc::ich::{ATTR_DIRTY, ATTR_CLEAN};
|
|
||||||
use rustc::ty::TyCtxt;
|
use rustc::ty::TyCtxt;
|
||||||
use rustc_data_structures::fingerprint::Fingerprint;
|
use rustc_data_structures::fingerprint::Fingerprint;
|
||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
|
@ -224,7 +223,7 @@ pub fn check_dirty_clean_annotations(tcx: TyCtxt<'_>) {
|
||||||
|
|
||||||
let mut all_attrs = FindAllAttrs {
|
let mut all_attrs = FindAllAttrs {
|
||||||
tcx,
|
tcx,
|
||||||
attr_names: vec![ATTR_DIRTY, ATTR_CLEAN],
|
attr_names: vec![sym::rustc_dirty, sym::rustc_clean],
|
||||||
found_attrs: vec![],
|
found_attrs: vec![],
|
||||||
};
|
};
|
||||||
intravisit::walk_crate(&mut all_attrs, krate);
|
intravisit::walk_crate(&mut all_attrs, krate);
|
||||||
|
@ -246,9 +245,9 @@ impl DirtyCleanVisitor<'tcx> {
|
||||||
fn assertion_maybe(&mut self, item_id: hir::HirId, attr: &Attribute)
|
fn assertion_maybe(&mut self, item_id: hir::HirId, attr: &Attribute)
|
||||||
-> Option<Assertion>
|
-> Option<Assertion>
|
||||||
{
|
{
|
||||||
let is_clean = if attr.check_name(ATTR_DIRTY) {
|
let is_clean = if attr.check_name(sym::rustc_dirty) {
|
||||||
false
|
false
|
||||||
} else if attr.check_name(ATTR_CLEAN) {
|
} else if attr.check_name(sym::rustc_clean) {
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
// skip: not rustc_clean/dirty
|
// skip: not rustc_clean/dirty
|
||||||
|
|
Loading…
Reference in New Issue