1
Fork 0

Reformat use declarations.

The previous commit updated `rustfmt.toml` appropriately. This commit is
the outcome of running `x fmt --all` with the new formatting options.
This commit is contained in:
Nicholas Nethercote 2024-07-29 08:13:50 +10:00
parent 118f9350c5
commit 84ac80f192
1865 changed files with 8367 additions and 9199 deletions

View file

@ -1,14 +1,15 @@
use crate::errors;
use crate::util::check_builtin_macro_attribute;
use rustc_ast::ptr::P;
use rustc_ast::{self as ast, FnHeader, FnSig, Generics, StmtKind};
use rustc_ast::{Fn, ItemKind, Safety, Stmt, TyKind};
use rustc_ast::{
self as ast, Fn, FnHeader, FnSig, Generics, ItemKind, Safety, Stmt, StmtKind, TyKind,
};
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::Span;
use thin_vec::{thin_vec, ThinVec};
use crate::errors;
use crate::util::check_builtin_macro_attribute;
pub(crate) fn expand(
ecx: &mut ExtCtxt<'_>,
_span: Span,

View file

@ -1,8 +1,5 @@
use crate::errors;
use crate::util::expr_to_spanned_string;
use ast::token::IdentIsRaw;
use lint::BuiltinLintDiag;
use rustc_ast as ast;
use rustc_ast::ptr::P;
use rustc_ast::token::{self, Delimiter};
use rustc_ast::tokenstream::TokenStream;
@ -11,13 +8,15 @@ use rustc_errors::PResult;
use rustc_expand::base::*;
use rustc_index::bit_set::GrowableBitSet;
use rustc_parse::parser::Parser;
use rustc_parse_format as parse;
use rustc_session::lint;
use rustc_span::symbol::Ident;
use rustc_span::symbol::{kw, sym, Symbol};
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::{ErrorGuaranteed, InnerSpan, Span};
use rustc_target::asm::InlineAsmArch;
use smallvec::smallvec;
use {rustc_ast as ast, rustc_parse_format as parse};
use crate::errors;
use crate::util::expr_to_spanned_string;
pub struct AsmArgs {
pub templates: Vec<P<ast::Expr>>,

View file

@ -1,12 +1,9 @@
mod context;
use crate::edition_panic::use_panic_2021;
use crate::errors;
use rustc_ast::ptr::P;
use rustc_ast::token;
use rustc_ast::token::Delimiter;
use rustc_ast::tokenstream::{DelimSpan, TokenStream};
use rustc_ast::{DelimArgs, Expr, ExprKind, MacCall, Path, PathSegment, UnOp};
use rustc_ast::{token, DelimArgs, Expr, ExprKind, MacCall, Path, PathSegment, UnOp};
use rustc_ast_pretty::pprust;
use rustc_errors::PResult;
use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult};
@ -15,6 +12,9 @@ use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_span::{Span, DUMMY_SP};
use thin_vec::thin_vec;
use crate::edition_panic::use_panic_2021;
use crate::errors;
pub(crate) fn expand_assert<'cx>(
cx: &'cx mut ExtCtxt<'_>,
span: Span,

View file

@ -1,17 +1,15 @@
use rustc_ast::ptr::P;
use rustc_ast::token::{self, Delimiter, IdentIsRaw};
use rustc_ast::tokenstream::{DelimSpan, TokenStream, TokenTree};
use rustc_ast::{
ptr::P,
token::{self, Delimiter, IdentIsRaw},
tokenstream::{DelimSpan, TokenStream, TokenTree},
BinOpKind, BorrowKind, DelimArgs, Expr, ExprKind, ItemKind, MacCall, MethodCall, Mutability,
Path, PathSegment, Stmt, StructRest, UnOp, UseTree, UseTreeKind, DUMMY_NODE_ID,
};
use rustc_ast_pretty::pprust;
use rustc_data_structures::fx::FxHashSet;
use rustc_expand::base::ExtCtxt;
use rustc_span::{
symbol::{sym, Ident, Symbol},
Span,
};
use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_span::Span;
use thin_vec::{thin_vec, ThinVec};
pub(super) struct Context<'cx, 'a> {

View file

@ -2,14 +2,14 @@
//! a literal `true` or `false` based on whether the given cfg matches the
//! current compilation environment.
use crate::errors;
use rustc_ast as ast;
use rustc_ast::token;
use rustc_ast::tokenstream::TokenStream;
use rustc_attr as attr;
use rustc_errors::PResult;
use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult};
use rustc_span::Span;
use {rustc_ast as ast, rustc_attr as attr};
use crate::errors;
pub(crate) fn expand_cfg(
cx: &mut ExtCtxt<'_>,

View file

@ -1,6 +1,5 @@
//! Implementation of the `#[cfg_accessible(path)]` attribute macro.
use crate::errors;
use rustc_ast as ast;
use rustc_expand::base::{Annotatable, ExpandResult, ExtCtxt, Indeterminate, MultiItemModifier};
use rustc_feature::AttributeTemplate;
@ -8,6 +7,8 @@ use rustc_parse::validate_attr;
use rustc_span::symbol::sym;
use rustc_span::Span;
use crate::errors;
pub(crate) struct Expander;
fn validate_input<'a>(ecx: &ExtCtxt<'_>, mi: &'a ast::MetaItem) -> Option<&'a ast::Path> {

View file

@ -1,13 +1,10 @@
use crate::util::{check_builtin_macro_attribute, warn_on_duplicate_attribute};
use core::ops::ControlFlow;
use rustc_ast as ast;
use rustc_ast::mut_visit::MutVisitor;
use rustc_ast::ptr::P;
use rustc_ast::visit::{AssocCtxt, Visitor};
use rustc_ast::NodeId;
use rustc_ast::{mut_visit, visit};
use rustc_ast::{Attribute, HasAttrs, HasTokens};
use rustc_ast::{mut_visit, visit, Attribute, HasAttrs, HasTokens, NodeId};
use rustc_errors::PResult;
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_expand::config::StripUnconfigured;
@ -20,6 +17,8 @@ use rustc_span::Span;
use smallvec::SmallVec;
use tracing::instrument;
use crate::util::{check_builtin_macro_attribute, warn_on_duplicate_attribute};
pub(crate) fn expand(
ecx: &mut ExtCtxt<'_>,
_span: Span,

View file

@ -1,14 +1,14 @@
//! Attributes injected into the crate root from command line using `-Z crate-attr`.
use crate::errors;
use rustc_ast::attr::mk_attr;
use rustc_ast::token;
use rustc_ast::{self as ast, AttrItem, AttrStyle};
use rustc_ast::{self as ast, token, AttrItem, AttrStyle};
use rustc_parse::parser::ForceCollect;
use rustc_parse::{new_parser_from_source_str, unwrap_or_emit_fatal};
use rustc_session::parse::ParseSess;
use rustc_span::FileName;
use crate::errors;
pub fn inject(krate: &mut ast::Crate, psess: &ParseSess, attrs: &[String]) {
for raw_attr in attrs {
let mut parser = unwrap_or_emit_fatal(new_parser_from_source_str(

View file

@ -1,10 +1,11 @@
// The compiler code necessary to support the compile_error! extension.
use crate::util::get_single_str_from_tts;
use rustc_ast::tokenstream::TokenStream;
use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacroExpanderResult};
use rustc_span::Span;
use crate::util::get_single_str_from_tts;
pub(crate) fn expand_compile_error<'cx>(
cx: &'cx mut ExtCtxt<'_>,
sp: Span,

View file

@ -1,11 +1,12 @@
use crate::errors;
use crate::util::get_exprs_from_tts;
use rustc_ast::tokenstream::TokenStream;
use rustc_ast::{ExprKind, LitKind, UnOp};
use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult};
use rustc_session::errors::report_lit_error;
use rustc_span::symbol::Symbol;
use crate::errors;
use crate::util::get_exprs_from_tts;
pub(crate) fn expand_concat(
cx: &mut ExtCtxt<'_>,
sp: rustc_span::Span,

View file

@ -1,10 +1,13 @@
use crate::errors;
use crate::util::get_exprs_from_tts;
use rustc_ast::{ptr::P, token, tokenstream::TokenStream, ExprKind, LitIntType, LitKind, UintTy};
use rustc_ast::ptr::P;
use rustc_ast::tokenstream::TokenStream;
use rustc_ast::{token, ExprKind, LitIntType, LitKind, UintTy};
use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult};
use rustc_session::errors::report_lit_error;
use rustc_span::{ErrorGuaranteed, Span};
use crate::errors;
use crate::util::get_exprs_from_tts;
/// Emits errors for literal expressions that are invalid inside and outside of an array.
fn invalid_type_err(
cx: &ExtCtxt<'_>,

View file

@ -1,6 +1,3 @@
use crate::cfg_eval::cfg_eval;
use crate::errors;
use rustc_ast as ast;
use rustc_ast::{GenericParamKind, ItemKind, MetaItemKind, NestedMetaItem, Safety, StmtKind};
use rustc_expand::base::{
@ -12,6 +9,9 @@ use rustc_session::Session;
use rustc_span::symbol::{sym, Ident};
use rustc_span::{ErrorGuaranteed, Span};
use crate::cfg_eval::cfg_eval;
use crate::errors;
pub(crate) struct Expander {
pub is_const: bool,
}

View file

@ -1,10 +1,10 @@
use crate::deriving::generic::*;
use crate::deriving::path_std;
use rustc_ast::MetaItem;
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::Span;
use crate::deriving::generic::*;
use crate::deriving::path_std;
pub(crate) fn expand_deriving_copy(
cx: &ExtCtxt<'_>,
span: Span,

View file

@ -1,6 +1,3 @@
use crate::deriving::generic::ty::*;
use crate::deriving::generic::*;
use crate::deriving::path_std;
use rustc_ast::{self as ast, Generics, ItemKind, MetaItem, VariantData};
use rustc_data_structures::fx::FxHashSet;
use rustc_expand::base::{Annotatable, ExtCtxt};
@ -8,6 +5,10 @@ use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::Span;
use thin_vec::{thin_vec, ThinVec};
use crate::deriving::generic::ty::*;
use crate::deriving::generic::*;
use crate::deriving::path_std;
pub(crate) fn expand_deriving_clone(
cx: &ExtCtxt<'_>,
span: Span,

View file

@ -1,7 +1,3 @@
use crate::deriving::generic::ty::*;
use crate::deriving::generic::*;
use crate::deriving::path_std;
use rustc_ast::{self as ast, MetaItem};
use rustc_data_structures::fx::FxHashSet;
use rustc_expand::base::{Annotatable, ExtCtxt};
@ -9,6 +5,10 @@ use rustc_span::symbol::sym;
use rustc_span::Span;
use thin_vec::{thin_vec, ThinVec};
use crate::deriving::generic::ty::*;
use crate::deriving::generic::*;
use crate::deriving::path_std;
pub(crate) fn expand_deriving_eq(
cx: &ExtCtxt<'_>,
span: Span,

View file

@ -1,12 +1,13 @@
use crate::deriving::generic::ty::*;
use crate::deriving::generic::*;
use crate::deriving::path_std;
use rustc_ast::MetaItem;
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{sym, Ident};
use rustc_span::Span;
use thin_vec::thin_vec;
use crate::deriving::generic::ty::*;
use crate::deriving::generic::*;
use crate::deriving::path_std;
pub(crate) fn expand_deriving_ord(
cx: &ExtCtxt<'_>,
span: Span,

View file

@ -1,6 +1,3 @@
use crate::deriving::generic::ty::*;
use crate::deriving::generic::*;
use crate::deriving::{path_local, path_std};
use rustc_ast::ptr::P;
use rustc_ast::{BinOpKind, BorrowKind, Expr, ExprKind, MetaItem, Mutability};
use rustc_expand::base::{Annotatable, ExtCtxt};
@ -8,6 +5,10 @@ use rustc_span::symbol::sym;
use rustc_span::Span;
use thin_vec::thin_vec;
use crate::deriving::generic::ty::*;
use crate::deriving::generic::*;
use crate::deriving::{path_local, path_std};
pub(crate) fn expand_deriving_partial_eq(
cx: &ExtCtxt<'_>,
span: Span,

View file

@ -1,12 +1,13 @@
use crate::deriving::generic::ty::*;
use crate::deriving::generic::*;
use crate::deriving::{path_std, pathvec_std};
use rustc_ast::{ExprKind, ItemKind, MetaItem, PatKind};
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{sym, Ident};
use rustc_span::Span;
use thin_vec::thin_vec;
use crate::deriving::generic::ty::*;
use crate::deriving::generic::*;
use crate::deriving::{path_std, pathvec_std};
pub(crate) fn expand_deriving_partial_ord(
cx: &ExtCtxt<'_>,
span: Span,

View file

@ -1,13 +1,13 @@
use crate::deriving::generic::ty::*;
use crate::deriving::generic::*;
use crate::deriving::path_std;
use rustc_ast::{self as ast, EnumDef, MetaItem};
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_span::Span;
use thin_vec::{thin_vec, ThinVec};
use crate::deriving::generic::ty::*;
use crate::deriving::generic::*;
use crate::deriving::path_std;
pub(crate) fn expand_deriving_debug(
cx: &ExtCtxt<'_>,
span: Span,

View file

@ -1,8 +1,5 @@
//! The compiler code necessary for `#[derive(RustcDecodable)]`. See encodable.rs for more.
use crate::deriving::generic::ty::*;
use crate::deriving::generic::*;
use crate::deriving::pathvec_std;
use rustc_ast::ptr::P;
use rustc_ast::{self as ast, Expr, MetaItem, Mutability};
use rustc_expand::base::{Annotatable, ExtCtxt};
@ -10,6 +7,10 @@ use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_span::Span;
use thin_vec::{thin_vec, ThinVec};
use crate::deriving::generic::ty::*;
use crate::deriving::generic::*;
use crate::deriving::pathvec_std;
pub(crate) fn expand_deriving_rustc_decodable(
cx: &ExtCtxt<'_>,
span: Span,

View file

@ -1,17 +1,18 @@
use crate::deriving::generic::ty::*;
use crate::deriving::generic::*;
use crate::errors;
use core::ops::ControlFlow;
use rustc_ast as ast;
use rustc_ast::visit::visit_opt;
use rustc_ast::{attr, EnumDef, VariantData};
use rustc_expand::base::{Annotatable, DummyResult, ExtCtxt};
use rustc_span::symbol::Ident;
use rustc_span::symbol::{kw, sym};
use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::{ErrorGuaranteed, Span};
use smallvec::SmallVec;
use thin_vec::{thin_vec, ThinVec};
use crate::deriving::generic::ty::*;
use crate::deriving::generic::*;
use crate::errors;
pub(crate) fn expand_deriving_default(
cx: &ExtCtxt<'_>,
span: Span,

View file

@ -85,15 +85,16 @@
//! }
//! ```
use crate::deriving::generic::ty::*;
use crate::deriving::generic::*;
use crate::deriving::pathvec_std;
use rustc_ast::{AttrVec, ExprKind, MetaItem, Mutability};
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_span::Span;
use thin_vec::{thin_vec, ThinVec};
use crate::deriving::generic::ty::*;
use crate::deriving::generic::*;
use crate::deriving::pathvec_std;
pub(crate) fn expand_deriving_rustc_encodable(
cx: &ExtCtxt<'_>,
span: Span,

View file

@ -174,10 +174,10 @@
//! )
//! ```
pub(crate) use StaticFields::*;
pub(crate) use SubstructureFields::*;
use std::cell::RefCell;
use std::ops::Not;
use std::{iter, vec};
use crate::{deriving, errors};
use rustc_ast::ptr::P;
use rustc_ast::{
self as ast, BindingMode, ByRef, EnumDef, Expr, GenericArg, GenericParamKind, Generics,
@ -188,12 +188,12 @@ use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_session::lint::builtin::BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE;
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::{Span, DUMMY_SP};
use std::cell::RefCell;
use std::iter;
use std::ops::Not;
use std::vec;
use thin_vec::{thin_vec, ThinVec};
use ty::{Bounds, Path, Ref, Self_, Ty};
pub(crate) use StaticFields::*;
pub(crate) use SubstructureFields::*;
use crate::{deriving, errors};
pub(crate) mod ty;

View file

@ -1,8 +1,6 @@
//! A mini version of ast::Ty, which is easier to use, and features an explicit `Self` type to use
//! when specifying impls to be derived.
pub(crate) use Ty::*;
use rustc_ast::ptr::P;
use rustc_ast::{self as ast, Expr, GenericArg, GenericParamKind, Generics, SelfKind};
use rustc_expand::base::ExtCtxt;
@ -10,6 +8,7 @@ use rustc_span::source_map::respan;
use rustc_span::symbol::{kw, Ident, Symbol};
use rustc_span::{Span, DUMMY_SP};
use thin_vec::ThinVec;
pub(crate) use Ty::*;
/// A path, e.g., `::std::option::Option::<i32>` (global). Has support
/// for type parameters.

View file

@ -1,12 +1,13 @@
use crate::deriving::generic::ty::*;
use crate::deriving::generic::*;
use crate::deriving::{path_std, pathvec_std};
use rustc_ast::{MetaItem, Mutability};
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::sym;
use rustc_span::Span;
use thin_vec::thin_vec;
use crate::deriving::generic::ty::*;
use crate::deriving::generic::*;
use crate::deriving::{path_std, pathvec_std};
pub(crate) fn expand_deriving_hash(
cx: &ExtCtxt<'_>,
span: Span,

View file

@ -3,18 +3,20 @@
// interface.
//
use crate::errors;
use crate::util::{expr_to_string, get_exprs_from_tts, get_single_str_from_tts};
use std::env;
use std::env::VarError;
use rustc_ast::token::{self, LitKind};
use rustc_ast::tokenstream::TokenStream;
use rustc_ast::{AstDeref, ExprKind, GenericArg, Mutability};
use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult};
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::Span;
use std::env;
use std::env::VarError;
use thin_vec::thin_vec;
use crate::errors;
use crate::util::{expr_to_string, get_exprs_from_tts, get_single_str_from_tts};
fn lookup_env<'cx>(cx: &'cx ExtCtxt<'_>, var: Symbol) -> Result<Symbol, VarError> {
let var = var.as_str();
if let Some(value) = cx.sess.opts.logical_env.get(var) {

View file

@ -1,9 +1,11 @@
use rustc_errors::codes::*;
use rustc_errors::{
codes::*, Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, MultiSpan,
SingleLabelManySpans, SubdiagMessageOp, Subdiagnostic,
Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, MultiSpan, SingleLabelManySpans,
SubdiagMessageOp, Subdiagnostic,
};
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_span::{symbol::Ident, Span, Symbol};
use rustc_span::symbol::Ident;
use rustc_span::{Span, Symbol};
#[derive(Diagnostic)]
#[diag(builtin_macros_requires_cfg_pattern)]

View file

@ -1,13 +1,10 @@
use crate::errors;
use crate::util::expr_to_spanned_string;
use parse::Position::ArgumentNamed;
use rustc_ast::ptr::P;
use rustc_ast::tokenstream::TokenStream;
use rustc_ast::{token, StmtKind};
use rustc_ast::{
Expr, ExprKind, FormatAlignment, FormatArgPosition, FormatArgPositionKind, FormatArgs,
token, Expr, ExprKind, FormatAlignment, FormatArgPosition, FormatArgPositionKind, FormatArgs,
FormatArgsPiece, FormatArgument, FormatArgumentKind, FormatArguments, FormatCount,
FormatDebugHex, FormatOptions, FormatPlaceholder, FormatSign, FormatTrait, Recovered,
FormatDebugHex, FormatOptions, FormatPlaceholder, FormatSign, FormatTrait, Recovered, StmtKind,
};
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{Applicability, Diag, MultiSpan, PResult, SingleLabelManySpans};
@ -18,6 +15,9 @@ use rustc_parse_format as parse;
use rustc_span::symbol::{Ident, Symbol};
use rustc_span::{BytePos, ErrorGuaranteed, InnerSpan, Span};
use crate::errors;
use crate::util::expr_to_spanned_string;
// The format_args!() macro is expanded in three steps:
// 1. First, `parse_args` will parse the `(literal, arg, arg, name=arg, name=arg)` syntax,
// but doesn't parse the template (the literal) itself.

View file

@ -1,7 +1,8 @@
pub(crate) mod printf {
use super::strcursor::StrCursor as Cur;
use rustc_span::InnerSpan;
use super::strcursor::StrCursor as Cur;
/// Represents a single `printf`-style substitution.
#[derive(Clone, PartialEq, Debug)]
pub enum Substitution<'a> {
@ -615,9 +616,10 @@ pub(crate) mod printf {
}
pub mod shell {
use super::strcursor::StrCursor as Cur;
use rustc_span::InnerSpan;
use super::strcursor::StrCursor as Cur;
#[derive(Clone, PartialEq, Debug)]
pub enum Substitution<'a> {
Ordinal(u8, (usize, usize)),

View file

@ -1,17 +1,19 @@
use crate::util::check_builtin_macro_attribute;
use crate::errors;
use rustc_ast::expand::allocator::{
global_fn_name, AllocatorMethod, AllocatorMethodInput, AllocatorTy, ALLOCATOR_METHODS,
};
use rustc_ast::ptr::P;
use rustc_ast::{self as ast, AttrVec, Expr, FnHeader, FnSig, Generics, Param, StmtKind};
use rustc_ast::{Fn, ItemKind, Mutability, Safety, Stmt, Ty, TyKind};
use rustc_ast::{
self as ast, AttrVec, Expr, Fn, FnHeader, FnSig, Generics, ItemKind, Mutability, Param, Safety,
Stmt, StmtKind, Ty, TyKind,
};
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::Span;
use thin_vec::{thin_vec, ThinVec};
use crate::errors;
use crate::util::check_builtin_macro_attribute;
pub(crate) fn expand(
ecx: &mut ExtCtxt<'_>,
_span: Span,

View file

@ -21,11 +21,12 @@
extern crate proc_macro;
use crate::deriving::*;
use rustc_expand::base::{MacroExpanderFn, ResolverExpand, SyntaxExtensionKind};
use rustc_expand::proc_macro::BangProcMacro;
use rustc_span::symbol::sym;
use crate::deriving::*;
mod alloc_error_handler;
mod assert;
mod cfg;

View file

@ -1,4 +1,6 @@
use rustc_ast::{ast, ptr::P, tokenstream::TokenStream, Pat, Ty};
use rustc_ast::ptr::P;
use rustc_ast::tokenstream::TokenStream;
use rustc_ast::{ast, Pat, Ty};
use rustc_errors::PResult;
use rustc_expand::base::{self, DummyResult, ExpandResult, ExtCtxt, MacroExpanderResult};
use rustc_span::{sym, Span};

View file

@ -1,4 +1,5 @@
use crate::errors;
use std::mem;
use rustc_ast::ptr::P;
use rustc_ast::visit::{self, Visitor};
use rustc_ast::{self as ast, attr, NodeId};
@ -13,9 +14,10 @@ use rustc_span::source_map::SourceMap;
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::{Span, DUMMY_SP};
use smallvec::smallvec;
use std::mem;
use thin_vec::{thin_vec, ThinVec};
use crate::errors;
struct ProcMacroDerive {
id: NodeId,
trait_name: Symbol,

View file

@ -1,7 +1,6 @@
use crate::errors;
use crate::util::{
check_zero_tts, get_single_str_from_tts, get_single_str_spanned_from_tts, parse_expr,
};
use std::path::{Path, PathBuf};
use std::rc::Rc;
use rustc_ast as ast;
use rustc_ast::ptr::P;
use rustc_ast::token;
@ -20,8 +19,11 @@ use rustc_span::source_map::SourceMap;
use rustc_span::symbol::Symbol;
use rustc_span::{Pos, Span};
use smallvec::SmallVec;
use std::path::{Path, PathBuf};
use std::rc::Rc;
use crate::errors;
use crate::util::{
check_zero_tts, get_single_str_from_tts, get_single_str_spanned_from_tts, parse_expr,
};
// These macros all relate to the file system; they either return
// the column/row/filename of the expression, or they include
@ -71,7 +73,8 @@ pub(crate) fn expand_file(
let topmost = cx.expansion_cause().unwrap_or(sp);
let loc = cx.source_map().lookup_char_pos(topmost.lo());
use rustc_session::{config::RemapPathScopeComponents, RemapFileNameExt};
use rustc_session::config::RemapPathScopeComponents;
use rustc_session::RemapFileNameExt;
ExpandResult::Ready(MacEager::expr(cx.expr_str(
topmost,
Symbol::intern(

View file

@ -1,8 +1,9 @@
//! The expansion from a test function to the appropriate test struct for libtest
//! Ideally, this code would be in libtest but for efficiency and error messages it lives here.
use crate::errors;
use crate::util::{check_builtin_macro_attribute, warn_on_duplicate_attribute};
use std::assert_matches::assert_matches;
use std::iter;
use rustc_ast::ptr::P;
use rustc_ast::{self as ast, attr, GenericParamKind};
use rustc_ast_pretty::pprust;
@ -10,11 +11,12 @@ use rustc_errors::{Applicability, Diag, Level};
use rustc_expand::base::*;
use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_span::{ErrorGuaranteed, FileNameDisplayPreference, Span};
use std::assert_matches::assert_matches;
use std::iter;
use thin_vec::{thin_vec, ThinVec};
use tracing::debug;
use crate::errors;
use crate::util::{check_builtin_macro_attribute, warn_on_duplicate_attribute};
/// #[test_case] is used by custom test authors to mark tests
/// When building for test, it needs to make the item public and gensym the name
/// Otherwise, we'll omit the item. This behavior means that any item annotated

View file

@ -1,5 +1,7 @@
// Code that generates a test runner to run all the tests in a crate
use std::{iter, mem};
use rustc_ast as ast;
use rustc_ast::entry::EntryPointType;
use rustc_ast::mut_visit::*;
@ -21,8 +23,6 @@ use smallvec::{smallvec, SmallVec};
use thin_vec::{thin_vec, ThinVec};
use tracing::debug;
use std::{iter, mem};
use crate::errors;
#[derive(Clone)]

View file

@ -1,9 +1,10 @@
use crate::errors;
use rustc_ast::tokenstream::{TokenStream, TokenTree};
use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacroExpanderResult};
use rustc_span::symbol::kw;
use rustc_span::Span;
use crate::errors;
pub(crate) fn expand_trace_macros(
cx: &mut ExtCtxt<'_>,
sp: Span,

View file

@ -1,15 +1,18 @@
use crate::errors;
use rustc_ast::ptr::P;
use rustc_ast::tokenstream::TokenStream;
use rustc_ast::{self as ast, attr, ptr::P, token, AttrStyle, Attribute, MetaItem};
use rustc_ast::{self as ast, attr, token, AttrStyle, Attribute, MetaItem};
use rustc_errors::{Applicability, Diag, ErrorGuaranteed};
use rustc_expand::base::{Annotatable, ExpandResult, ExtCtxt};
use rustc_expand::expand::AstFragment;
use rustc_feature::AttributeTemplate;
use rustc_lint_defs::{builtin::DUPLICATE_MACRO_ATTRIBUTES, BuiltinLintDiag};
use rustc_lint_defs::builtin::DUPLICATE_MACRO_ATTRIBUTES;
use rustc_lint_defs::BuiltinLintDiag;
use rustc_parse::{parser, validate_attr};
use rustc_session::errors::report_lit_error;
use rustc_span::{BytePos, Span, Symbol};
use crate::errors;
pub(crate) fn check_builtin_macro_attribute(ecx: &ExtCtxt<'_>, meta_item: &MetaItem, name: Symbol) {
// All the built-in macro attributes are "words" at the moment.
let template = AttributeTemplate { word: true, ..Default::default() };