Skip to content

Commit

Permalink
Remove extern crate rustc_macros from numerous crates.
Browse files Browse the repository at this point in the history
  • Loading branch information
nnethercote committed Apr 29, 2024
1 parent 10505a1 commit 4814fd0
Show file tree
Hide file tree
Showing 110 changed files with 99 additions and 94 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use rustc_data_structures::packed::Pu128;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_data_structures::sync::Lrc;
use rustc_macros::HashStable_Generic;
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use rustc_span::source_map::{respan, Spanned};
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP};
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_ast/src/expand/allocator.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use rustc_macros::HashStable_Generic;
use rustc_span::symbol::{sym, Symbol};

#[derive(Clone, Debug, Copy, Eq, PartialEq, HashStable_Generic)]
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_ast/src/expand/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Definitions shared by macros / syntax extensions and e.g. `rustc_middle`.

use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use rustc_span::{def_id::DefId, symbol::Ident};

use crate::MetaItem;
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_ast/src/format.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::ptr::P;
use crate::Expr;
use rustc_data_structures::fx::FxHashMap;
use rustc_macros::{Decodable, Encodable};
use rustc_span::symbol::{Ident, Symbol};
use rustc_span::Span;

Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_ast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
#![feature(negative_impls)]
#![feature(stmt_expr_attributes)]

#[macro_use]
extern crate rustc_macros;

#[macro_use]
extern crate tracing;

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::util::case::Case;

use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::Lrc;
use rustc_macros::HashStable_Generic;
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use rustc_span::symbol::{kw, sym};
#[allow(clippy::useless_attribute)] // FIXME: following use of `hidden_glob_reexports` incorrectly triggers `useless_attribute` lint.
#[allow(hidden_glob_reexports)]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast/src/tokenstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::AttrVec;

use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::{self, Lrc};
use rustc_macros::HashStable_Generic;
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use rustc_serialize::{Decodable, Encodable};
use rustc_span::{sym, Span, SpanDecoder, SpanEncoder, Symbol, DUMMY_SP};
use smallvec::{smallvec, SmallVec};
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_ast_ir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
#![cfg_attr(feature = "nightly", allow(internal_features))]

#[cfg(feature = "nightly")]
#[macro_use]
extern crate rustc_macros;
use rustc_macros::{Decodable, Encodable, HashStable_NoContext};

pub mod visit;

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use rustc_ast::{Attribute, LitKind, MetaItem, MetaItemKind, MetaItemLit, NestedM
use rustc_ast_pretty::pprust;
use rustc_errors::ErrorGuaranteed;
use rustc_feature::{find_gated_cfg, is_builtin_attr_name, Features, GatedCfg};
use rustc_macros::HashStable_Generic;
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use rustc_session::config::ExpectedValues;
use rustc_session::lint::builtin::UNEXPECTED_CFGS;
use rustc_session::lint::BuiltinLintDiag;
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_attr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
#![doc(rust_logo)]
#![feature(let_chains)]

#[macro_use]
extern crate rustc_macros;

mod builtin;
mod session_diagnostics;

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr/src/session_diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::num::IntErrorKind;

use rustc_ast as ast;
use rustc_errors::{codes::*, Applicability, Diag, DiagCtxt, Diagnostic, EmissionGuarantee, Level};
use rustc_macros::Diagnostic;
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_span::{Span, Symbol};

use crate::fluent_generated as fluent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use rustc_data_structures::{
fx::FxHashMap,
stable_hasher::{HashStable, StableHasher},
};
use rustc_macros::HashStable;
use rustc_middle::{
bug,
ty::{ParamEnv, PolyExistentialTraitRef, Ty, TyCtxt},
Expand All @@ -23,6 +24,8 @@ use crate::{
use super::{unknown_file_metadata, SmallVec, UNKNOWN_LINE_NUMBER};

mod private {
use rustc_macros::HashStable;

// This type cannot be constructed outside of this module because
// it has a private field. We make use of this in order to prevent
// `UniqueTypeId` from being constructed directly, without asserting
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_codegen_llvm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
#![feature(let_chains)]
#![feature(impl_trait_in_assoc_type)]

#[macro_use]
extern crate rustc_macros;
#[macro_use]
extern crate tracing;

Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_codegen_ssa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
//! The backend-agnostic functions of this crate use functions defined in various traits that
//! have to be implemented by each backend.

#[macro_use]
extern crate rustc_macros;
#[macro_use]
extern crate tracing;
#[macro_use]
Expand All @@ -29,6 +27,7 @@ use rustc_data_structures::fx::FxIndexMap;
use rustc_data_structures::sync::Lrc;
use rustc_data_structures::unord::UnordMap;
use rustc_hir::def_id::CrateNum;
use rustc_macros::{Decodable, Encodable, HashStable};
use rustc_middle::dep_graph::WorkProduct;
use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile;
use rustc_middle::middle::dependency_format::Dependencies;
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_data_structures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@

#[macro_use]
extern crate tracing;
#[macro_use]
extern crate rustc_macros;

use std::fmt;

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_data_structures/src/sorted_map.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::stable_hasher::{HashStable, StableHasher, StableOrd};
use rustc_macros::{Decodable_Generic, Encodable_Generic};
use std::borrow::Borrow;
use std::fmt::Debug;
use std::mem;
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_data_structures/src/svh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
//! compiled from distinct sources.

use crate::fingerprint::Fingerprint;
use std::fmt;

use crate::stable_hasher;
use rustc_macros::{Decodable_Generic, Encodable_Generic};
use std::fmt;

#[derive(Copy, Clone, PartialEq, Eq, Debug, Encodable_Generic, Decodable_Generic, Hash)]
pub struct Svh {
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_data_structures/src/unord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//! as required by the query system.

use rustc_hash::{FxHashMap, FxHashSet};
use rustc_macros::{Decodable_Generic, Encodable_Generic};
use std::{
borrow::{Borrow, BorrowMut},
collections::hash_map::Entry,
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_errors/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use rustc_data_structures::fx::FxIndexMap;
use rustc_error_messages::fluent_value_from_str_list_sep_by_and;
use rustc_error_messages::FluentValue;
use rustc_lint_defs::{Applicability, LintExpectationId};
use rustc_macros::{Decodable, Encodable};
use rustc_span::source_map::Spanned;
use rustc_span::symbol::Symbol;
use rustc_span::{Span, DUMMY_SP};
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_errors/src/diagnostic_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::{
use rustc_ast as ast;
use rustc_ast_pretty::pprust;
use rustc_hir as hir;
use rustc_macros::Subdiagnostic;
use rustc_span::edition::Edition;
use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent, Symbol};
use rustc_span::Span;
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
#![feature(yeet_expr)]
// tidy-alphabetical-end

#[macro_use]
extern crate rustc_macros;

#[macro_use]
extern crate tracing;

Expand Down Expand Up @@ -64,6 +61,7 @@ use rustc_data_structures::stable_hasher::{Hash128, StableHasher};
use rustc_data_structures::sync::{Lock, Lrc};
use rustc_data_structures::AtomicRef;
use rustc_lint_defs::LintExpectationId;
use rustc_macros::{Decodable, Encodable};
use rustc_span::source_map::SourceMap;
use rustc_span::{Loc, Span, DUMMY_SP};
use std::backtrace::{Backtrace, BacktraceStatus};
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_errors/src/snippet.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Code for annotating snippets.

use crate::{Level, Loc};
use rustc_macros::{Decodable, Encodable};

#[derive(Clone, Debug, PartialOrd, Ord, PartialEq, Eq)]
pub struct Line {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_expand/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use rustc_ast::ast;
use rustc_errors::codes::*;
use rustc_macros::Diagnostic;
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_session::Limit;
use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent};
use rustc_span::{Span, Symbol};
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_expand/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(internal_features)]

#[macro_use]
extern crate rustc_macros;

#[macro_use]
extern crate tracing;

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_expand/src/mbe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub(crate) mod transcribe;
use metavar_expr::MetaVarExpr;
use rustc_ast::token::{Delimiter, NonterminalKind, Token, TokenKind};
use rustc_ast::tokenstream::{DelimSpacing, DelimSpan};
use rustc_macros::{Decodable, Encodable};
use rustc_span::symbol::Ident;
use rustc_span::Span;

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_expand/src/mbe/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use rustc_ast::token::{self, Token, TokenKind};
use rustc_ast::tokenstream::TokenStream;
use rustc_ast_pretty::pprust;
use rustc_errors::{Applicability, Diag, DiagCtxt, DiagMessage};
use rustc_macros::Subdiagnostic;
use rustc_parse::parser::{Parser, Recovery};
use rustc_span::source_map::SourceMap;
use rustc_span::symbol::Ident;
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_expand/src/mbe/metavar_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use rustc_ast::tokenstream::{RefTokenTreeCursor, TokenStream, TokenTree};
use rustc_ast::{LitIntType, LitKind};
use rustc_ast_pretty::pprust;
use rustc_errors::{Applicability, PResult};
use rustc_macros::{Decodable, Encodable};
use rustc_session::parse::ParseSess;
use rustc_span::symbol::Ident;
use rustc_span::Span;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir/src/def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use rustc_ast as ast;
use rustc_ast::NodeId;
use rustc_data_structures::stable_hasher::ToStableHashKey;
use rustc_data_structures::unord::UnordMap;
use rustc_macros::HashStable_Generic;
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use rustc_span::def_id::{DefId, LocalDefId};
use rustc_span::hygiene::MacroKind;
use rustc_span::symbol::kw;
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir/src/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::def_path_hash_map::DefPathHashMap;
use rustc_data_structures::stable_hasher::{Hash64, StableHasher};
use rustc_data_structures::unord::UnordMap;
use rustc_index::IndexVec;
use rustc_macros::{Decodable, Encodable};
use rustc_span::symbol::{kw, sym, Symbol};

use std::fmt::{self, Write};
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::sorted_map::SortedMap;
use rustc_index::IndexVec;
use rustc_macros::HashStable_Generic;
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use rustc_span::hygiene::MacroKind;
use rustc_span::source_map::Spanned;
use rustc_span::symbol::{kw, sym, Ident, Symbol};
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir/src/hir_id.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::def_id::{DefId, DefIndex, LocalDefId, CRATE_DEF_ID};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableOrd, ToStableHashKey};
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use rustc_span::{def_id::DefPathHash, HashStableContext};
use std::fmt::{self, Debug};

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir/src/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{MethodKind, Target};

use rustc_ast as ast;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_macros::HashStable_Generic;
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use rustc_span::symbol::{kw, sym, Symbol};
use rustc_span::Span;

Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_hir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
#![feature(variant_count)]
#![allow(internal_features)]

#[macro_use]
extern crate rustc_macros;

#[macro_use]
extern crate tracing;

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_infer/src/infer/canonical/instantiate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//! [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html

use crate::infer::canonical::{Canonical, CanonicalVarValues};
use rustc_macros::extension;
use rustc_middle::ty::fold::{FnMutDelegate, TypeFoldable};
use rustc_middle::ty::GenericArgKind;
use rustc_middle::ty::{self, TyCtxt};
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_infer/src/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ use rustc_hir::def::DefKind;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::intravisit::Visitor;
use rustc_hir::lang_items::LangItem;
use rustc_macros::extension;
use rustc_middle::dep_graph::DepContext;
use rustc_middle::ty::print::{with_forced_trimmed_paths, PrintError};
use rustc_middle::ty::relate::{self, RelateResult, TypeRelation};
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_infer/src/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pub use lexical_region_resolve::RegionResolutionError;
pub use relate::combine::CombineFields;
pub use relate::combine::ObligationEmittingRelation;
pub use relate::StructurallyRelateAliases;
pub use rustc_macros::{TypeFoldable, TypeVisitable};
pub use rustc_middle::ty::IntVarValue;
pub use BoundRegionConversionTime::*;
pub use RegionVariableOrigin::*;
Expand All @@ -20,13 +21,13 @@ use opaque_types::OpaqueTypeStorage;
use region_constraints::{GenericKind, VarInfos, VerifyBound};
use region_constraints::{RegionConstraintCollector, RegionConstraintStorage};
use rustc_data_structures::captures::Captures;
use rustc_data_structures::fx::FxIndexMap;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
use rustc_data_structures::sync::Lrc;
use rustc_data_structures::undo_log::Rollback;
use rustc_data_structures::unify as ut;
use rustc_errors::{Diag, DiagCtxt, ErrorGuaranteed};
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_macros::extension;
use rustc_middle::infer::canonical::{Canonical, CanonicalVarValues};
use rustc_middle::infer::unify_key::ConstVariableValue;
use rustc_middle::infer::unify_key::EffectVarValue;
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_infer/src/infer/region_constraints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use rustc_data_structures::sync::Lrc;
use rustc_data_structures::undo_log::UndoLogs;
use rustc_data_structures::unify as ut;
use rustc_index::IndexVec;
use rustc_macros::{TypeFoldable, TypeVisitable};
use rustc_middle::infer::unify_key::{RegionVariableValue, RegionVidKey};
use rustc_middle::ty::ReStatic;
use rustc_middle::ty::{self, Ty, TyCtxt};
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_infer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
#![feature(yeet_expr)]
#![recursion_limit = "512"] // For rustdoc

#[macro_use]
extern crate rustc_macros;
#[cfg(target_pointer_width = "64")]
#[macro_use]
extern crate rustc_data_structures;
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_infer/src/traits/engine.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::infer::InferCtxt;
use crate::traits::Obligation;
use rustc_hir::def_id::DefId;
use rustc_macros::extension;
use rustc_middle::ty::{self, ToPredicate, Ty};

use super::FulfillmentError;
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_lint_defs/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#[macro_use]
extern crate rustc_macros;

pub use self::Level::*;
use rustc_ast::node_id::NodeId;
use rustc_ast::{AttrId, Attribute};
Expand All @@ -11,6 +8,7 @@ use rustc_data_structures::stable_hasher::{
use rustc_error_messages::{DiagMessage, MultiSpan};
use rustc_hir::HashStableContext;
use rustc_hir::HirId;
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use rustc_span::edition::Edition;
use rustc_span::{sym, symbol::Ident, Span, Symbol};
use rustc_target::spec::abi::Abi;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_metadata/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{
};

use rustc_errors::{codes::*, Diag, DiagCtxt, Diagnostic, EmissionGuarantee, Level};
use rustc_macros::Diagnostic;
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_session::config;
use rustc_span::{sym, Span, Symbol};
use rustc_target::spec::{PanicStrategy, TargetTriple};
Expand Down
Loading

0 comments on commit 4814fd0

Please sign in to comment.