Move Spanned.

It's defined in `rustc_span::source_map` which doesn't make any sense
because it has nothing to do with source maps. This commit moves it to
the crate root, a more sensible spot for something this basic.
This commit is contained in:
Nicholas Nethercote
2026-03-10 16:12:05 +11:00
parent b41f22de2a
commit c12ab08c14
99 changed files with 128 additions and 183 deletions
+3 -2
View File
@@ -30,8 +30,9 @@
use rustc_data_structures::tagged_ptr::Tag;
use rustc_macros::{Decodable, Encodable, HashStable_Generic, Walkable};
pub use rustc_span::AttrId;
use rustc_span::source_map::{Spanned, respan};
use rustc_span::{ByteSymbol, DUMMY_SP, ErrorGuaranteed, Ident, Span, Symbol, kw, sym};
use rustc_span::{
ByteSymbol, DUMMY_SP, ErrorGuaranteed, Ident, Span, Spanned, Symbol, kw, respan, sym,
};
use thin_vec::{ThinVec, thin_vec};
use crate::attr::data_structures::CfgEntry;
+1 -2
View File
@@ -11,8 +11,7 @@
use std::panic;
use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
use rustc_span::source_map::Spanned;
use rustc_span::{Ident, Span, Symbol};
use rustc_span::{Ident, Span, Spanned, Symbol};
use smallvec::{SmallVec, smallvec};
use thin_vec::ThinVec;
+1 -2
View File
@@ -15,8 +15,7 @@
pub use rustc_ast_ir::visit::VisitorResult;
pub use rustc_ast_ir::{try_visit, visit_opt, walk_list, walk_visitable_list};
use rustc_span::source_map::Spanned;
use rustc_span::{Ident, Span, Symbol};
use rustc_span::{Ident, Span, Spanned, Symbol};
use thin_vec::ThinVec;
use crate::ast::*;
+1 -2
View File
@@ -13,8 +13,7 @@
use rustc_middle::span_bug;
use rustc_middle::ty::TyCtxt;
use rustc_session::errors::report_lit_error;
use rustc_span::source_map::{Spanned, respan};
use rustc_span::{ByteSymbol, DUMMY_SP, DesugaringKind, Ident, Span, Symbol, sym};
use rustc_span::{ByteSymbol, DUMMY_SP, DesugaringKind, Ident, Span, Spanned, Symbol, respan, sym};
use thin_vec::{ThinVec, thin_vec};
use visit::{Visitor, walk_expr};
+1 -2
View File
@@ -6,8 +6,7 @@
use rustc_hir::definitions::DefPathData;
use rustc_hir::{self as hir, LangItem, Target};
use rustc_middle::span_bug;
use rustc_span::source_map::{Spanned, respan};
use rustc_span::{DesugaringKind, Ident, Span};
use rustc_span::{DesugaringKind, Ident, Span, Spanned, respan};
use super::errors::{
ArbitraryExpressionInPattern, ExtraDoubleDot, MisplacedDoubleDot, SubTupleBinding,
@@ -7,8 +7,7 @@
use rustc_hir::attrs::AttributeKind;
use rustc_session::Session;
use rustc_session::parse::{feature_err, feature_warn};
use rustc_span::source_map::Spanned;
use rustc_span::{DUMMY_SP, Span, Symbol, sym};
use rustc_span::{DUMMY_SP, Span, Spanned, Symbol, sym};
use thin_vec::ThinVec;
use crate::errors;
@@ -20,9 +20,11 @@
RangeEnd, RangeSyntax, Safety, SelfKind, Term, attr,
};
use rustc_span::edition::Edition;
use rustc_span::source_map::{SourceMap, Spanned};
use rustc_span::source_map::SourceMap;
use rustc_span::symbol::IdentPrinter;
use rustc_span::{BytePos, CharPos, DUMMY_SP, FileName, Ident, Pos, Span, Symbol, kw, sym};
use rustc_span::{
BytePos, CharPos, DUMMY_SP, FileName, Ident, Pos, Span, Spanned, Symbol, kw, sym,
};
use crate::pp::Breaks::{Consistent, Inconsistent};
use crate::pp::{self, BoxMarker, Breaks};
@@ -23,8 +23,7 @@
use rustc_middle::{bug, span_bug};
use rustc_mir_dataflow::move_paths::{InitLocation, LookupResult, MoveOutIndex};
use rustc_span::def_id::LocalDefId;
use rustc_span::source_map::Spanned;
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span, Symbol, sym};
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span, Spanned, Symbol, sym};
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::error_reporting::traits::call_kind::{CallDesugaringKind, call_kind};
use rustc_trait_selection::infer::InferCtxtExt;
@@ -32,8 +32,7 @@
use rustc_mir_dataflow::move_paths::MoveData;
use rustc_mir_dataflow::points::DenseLocationMap;
use rustc_span::def_id::CRATE_DEF_ID;
use rustc_span::source_map::Spanned;
use rustc_span::{Span, sym};
use rustc_span::{Span, Spanned, sym};
use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits::query::type_op::custom::scrape_region_constraints;
use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput};
@@ -4,8 +4,7 @@
pub(crate) use Ty::*;
use rustc_ast::{self as ast, Expr, GenericArg, GenericParamKind, Generics, SelfKind, TyKind};
use rustc_expand::base::ExtCtxt;
use rustc_span::source_map::respan;
use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw};
use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw, respan};
use thin_vec::ThinVec;
/// A path, e.g., `::std::option::Option::<i32>` (global). Has support
@@ -20,7 +20,7 @@
use rustc_middle::ty::layout::FnAbiOf;
use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_session::Session;
use rustc_span::source_map::Spanned;
use rustc_span::Spanned;
use rustc_target::callconv::{FnAbi, PassMode};
use rustc_target::spec::Arch;
use smallvec::{SmallVec, smallvec};
@@ -6,8 +6,7 @@
use rustc_middle::ty::layout::{
self, FnAbiError, FnAbiOfHelpers, FnAbiRequest, LayoutError, LayoutOfHelpers,
};
use rustc_span::Symbol;
use rustc_span::source_map::Spanned;
use rustc_span::{Spanned, Symbol};
use rustc_target::callconv::FnAbi;
use rustc_target::spec::{Arch, HasTargetSpec, Target};
@@ -24,8 +24,7 @@ macro_rules! intrinsic_args {
use rustc_middle::ty::GenericArgsRef;
use rustc_middle::ty::layout::ValidityRequirement;
use rustc_middle::ty::print::{with_no_trimmed_paths, with_no_visible_paths};
use rustc_span::source_map::Spanned;
use rustc_span::{Symbol, sym};
use rustc_span::{Spanned, Symbol, sym};
use rustc_target::spec::PanicStrategy;
pub(crate) use self::llvm::codegen_llvm_intrinsic_call;
+1 -2
View File
@@ -21,8 +21,7 @@
use rustc_session::Session;
#[cfg(feature = "master")]
use rustc_session::config::DebugInfo;
use rustc_span::source_map::respan;
use rustc_span::{DUMMY_SP, Span};
use rustc_span::{DUMMY_SP, Span, respan};
use rustc_target::spec::{HasTargetSpec, HasX86AbiOpt, Target, TlsModel, X86Abi};
#[cfg(feature = "master")]
+1 -2
View File
@@ -25,8 +25,7 @@
use rustc_session::config::{
BranchProtection, CFGuard, CFProtection, CrateType, DebugInfo, FunctionReturn, PAuthKey, PacRet,
};
use rustc_span::source_map::Spanned;
use rustc_span::{DUMMY_SP, Span, Symbol};
use rustc_span::{DUMMY_SP, Span, Spanned, Symbol};
use rustc_symbol_mangling::mangle_internal_symbol;
use rustc_target::spec::{
Abi, Arch, Env, HasTargetSpec, Os, RelocModel, SmallDataThresholdSupport, Target, TlsModel,
+1 -2
View File
@@ -12,8 +12,7 @@
use rustc_middle::ty::{self, Instance, Ty, TypeVisitableExt};
use rustc_middle::{bug, span_bug};
use rustc_session::config::OptLevel;
use rustc_span::Span;
use rustc_span::source_map::Spanned;
use rustc_span::{Span, Spanned};
use rustc_target::callconv::{ArgAbi, ArgAttributes, CastTarget, FnAbi, PassMode};
use tracing::{debug, info};
@@ -10,7 +10,7 @@
use rustc_index::IndexSlice;
use rustc_middle::ty::{self, Instance, Ty};
use rustc_middle::{bug, mir, span_bug};
use rustc_span::source_map::Spanned;
use rustc_span::Spanned;
use rustc_target::callconv::FnAbi;
use tracing::field::Empty;
use tracing::{info, instrument, trace};
+1 -2
View File
@@ -11,8 +11,7 @@
use rustc_error_messages::{DiagArgMap, DiagArgName, DiagArgValue, IntoDiagArg};
use rustc_lint_defs::{Applicability, LintExpectationId};
use rustc_macros::{Decodable, Encodable};
use rustc_span::source_map::Spanned;
use rustc_span::{DUMMY_SP, Span, Symbol};
use rustc_span::{DUMMY_SP, Span, Spanned, Symbol};
use tracing::debug;
use crate::{
+1 -2
View File
@@ -5,8 +5,7 @@
self as ast, AnonConst, AttrItem, AttrVec, BlockCheckMode, Expr, LocalKind, MatchKind,
MgcaDisambiguation, PatKind, UnOp, attr, token, tokenstream,
};
use rustc_span::source_map::Spanned;
use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw, sym};
use rustc_span::{DUMMY_SP, Ident, Span, Spanned, Symbol, kw, sym};
use thin_vec::{ThinVec, thin_vec};
use crate::base::ExtCtxt;
+1 -2
View File
@@ -23,9 +23,8 @@
use rustc_index::IndexVec;
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use rustc_span::def_id::LocalDefId;
use rustc_span::source_map::Spanned;
use rustc_span::{
BytePos, DUMMY_SP, DesugaringKind, ErrorGuaranteed, Ident, Span, Symbol, kw, sym,
BytePos, DUMMY_SP, DesugaringKind, ErrorGuaranteed, Ident, Span, Spanned, Symbol, kw, sym,
};
use rustc_target::asm::InlineAsmRegOrRegClass;
use smallvec::SmallVec;
@@ -24,7 +24,7 @@
TypeVisitable, TypeVisitableExt, fold_regions,
};
use rustc_session::lint::builtin::UNINHABITED_STATIC;
use rustc_span::source_map::Spanned;
use rustc_span::Spanned;
use rustc_target::spec::{AbiMap, AbiMapping};
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::traits;
@@ -18,7 +18,7 @@
use rustc_middle::middle::region::*;
use rustc_middle::ty::TyCtxt;
use rustc_session::lint;
use rustc_span::source_map;
use rustc_span::Spanned;
use tracing::debug;
#[derive(Debug, Copy, Clone)]
@@ -181,7 +181,7 @@ fn resolve_cond<'tcx>(visitor: &mut ScopeResolutionVisitor<'tcx>, cond: &'tcx hi
// operands will be terminated). Any temporaries that would need to be dropped will be
// dropped before we leave this operator's scope; terminating them here would be redundant.
hir::ExprKind::Binary(
source_map::Spanned { node: hir::BinOpKind::And | hir::BinOpKind::Or, .. },
Spanned { node: hir::BinOpKind::And | hir::BinOpKind::Or, .. },
_,
_,
) => false,
@@ -264,7 +264,7 @@ fn resolve_expr<'tcx>(
// scopes, meaning that temporaries cannot outlive them.
// This ensures fixed size stacks.
hir::ExprKind::Binary(
source_map::Spanned { node: hir::BinOpKind::And | hir::BinOpKind::Or, .. },
Spanned { node: hir::BinOpKind::And | hir::BinOpKind::Or, .. },
left,
right,
) => {
@@ -293,7 +293,7 @@ fn resolve_expr<'tcx>(
// This is purely an optimization to reduce the number of
// terminating scopes.
hir::ExprKind::Binary(
source_map::Spanned { node: hir::BinOpKind::And | hir::BinOpKind::Or, .. },
Spanned { node: hir::BinOpKind::And | hir::BinOpKind::Or, .. },
..,
) => false,
// otherwise: mark it as terminating
+2 -2
View File
@@ -23,8 +23,8 @@
GenericParam, GenericParamKind, HirId, ImplicitSelfKind, LifetimeParamKind, Node, PatKind,
PreciseCapturingArg, RangeEnd, Term, TyFieldPath, TyPatKind,
};
use rustc_span::source_map::{SourceMap, Spanned};
use rustc_span::{DUMMY_SP, FileName, Ident, Span, Symbol, kw, sym};
use rustc_span::source_map::SourceMap;
use rustc_span::{DUMMY_SP, FileName, Ident, Span, Spanned, Symbol, kw, sym};
pub fn id_to_string(cx: &dyn rustc_hir::intravisit::HirTyCtxt<'_>, hir_id: HirId) -> String {
to_string(&cx, |s| s.print_node(cx.hir_node(hir_id)))
+1 -2
View File
@@ -14,8 +14,7 @@
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_middle::ty::{self, Ty};
use rustc_span::edition::{Edition, LATEST_STABLE_EDITION};
use rustc_span::source_map::Spanned;
use rustc_span::{Ident, Span, Symbol};
use rustc_span::{Ident, Span, Spanned, Symbol};
use crate::FnCtxt;
+1 -2
View File
@@ -34,8 +34,7 @@
use rustc_session::parse::feature_err;
use rustc_span::edit_distance::find_best_match_for_name;
use rustc_span::hygiene::DesugaringKind;
use rustc_span::source_map::Spanned;
use rustc_span::{Ident, Span, Symbol, kw, sym};
use rustc_span::{Ident, Span, Spanned, Symbol, kw, sym};
use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits::{self, ObligationCauseCode, ObligationCtxt};
use tracing::{debug, instrument, trace};
@@ -23,8 +23,7 @@
suggest_constraining_type_params,
};
use rustc_session::errors::ExprParenthesesNeeded;
use rustc_span::source_map::Spanned;
use rustc_span::{ExpnKind, Ident, MacroKind, Span, Symbol, sym};
use rustc_span::{ExpnKind, Ident, MacroKind, Span, Spanned, Symbol, sym};
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::error_reporting::traits::DefIdOrName;
use rustc_trait_selection::infer::InferCtxtExt;
+1 -2
View File
@@ -13,8 +13,7 @@
use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_middle::ty::{self, IsSuggestable, Ty, TyCtxt, TypeVisitableExt};
use rustc_session::errors::ExprParenthesesNeeded;
use rustc_span::source_map::Spanned;
use rustc_span::{Span, Symbol, sym};
use rustc_span::{Span, Spanned, Symbol, sym};
use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits::{FulfillmentError, Obligation, ObligationCtxt};
use tracing::debug;
+1 -2
View File
@@ -39,8 +39,7 @@
use rustc_session::lint::fcw;
use rustc_session::{declare_lint, declare_lint_pass, impl_lint_pass};
use rustc_span::edition::Edition;
use rustc_span::source_map::Spanned;
use rustc_span::{DUMMY_SP, Ident, InnerSpan, Span, Symbol, kw, sym};
use rustc_span::{DUMMY_SP, Ident, InnerSpan, Span, Spanned, Symbol, kw, sym};
use rustc_target::asm::InlineAsmArch;
use rustc_trait_selection::infer::{InferCtxtExt, TyCtxtInferExt};
use rustc_trait_selection::traits;
+1 -2
View File
@@ -3,8 +3,7 @@
use rustc_ast::LitKind;
use rustc_hir::{Expr, ExprKind};
use rustc_session::{declare_lint, declare_lint_pass};
use rustc_span::source_map::Spanned;
use rustc_span::sym;
use rustc_span::{Spanned, sym};
use crate::lints::InvalidFromUtf8Diag;
use crate::{LateContext, LateLintPass, LintContext};
+1 -1
View File
@@ -600,7 +600,7 @@ fn check_unused_delims_expr(
&& !value.span.from_expansion()
&& (ctx != UnusedDelimsCtx::LetScrutineeExpr
|| !matches!(inner.kind, ast::ExprKind::Binary(
rustc_span::source_map::Spanned { node, .. },
rustc_span::Spanned { node, .. },
_,
_,
) if node.is_lazy()))
+1 -2
View File
@@ -24,8 +24,7 @@
use rustc_index::{Idx, IndexSlice, IndexVec};
use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable};
use rustc_serialize::{Decodable, Encodable};
use rustc_span::source_map::Spanned;
use rustc_span::{DUMMY_SP, Span, Symbol};
use rustc_span::{DUMMY_SP, Span, Spanned, Symbol};
use tracing::{debug, trace};
pub use self::query::*;
+1 -2
View File
@@ -11,8 +11,7 @@
use rustc_index::IndexVec;
use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable};
use rustc_span::def_id::LocalDefId;
use rustc_span::source_map::Spanned;
use rustc_span::{Span, Symbol};
use rustc_span::{Span, Spanned, Symbol};
use rustc_target::asm::InlineAsmRegOrRegClass;
use smallvec::SmallVec;
+1 -2
View File
@@ -96,8 +96,7 @@
};
use rustc_session::lint::LintExpectationId;
use rustc_span::def_id::LOCAL_CRATE;
use rustc_span::source_map::Spanned;
use rustc_span::{DUMMY_SP, LocalExpnId, Span, Symbol};
use rustc_span::{DUMMY_SP, LocalExpnId, Span, Spanned, Symbol};
use rustc_target::spec::PanicStrategy;
use crate::infer::canonical::{self, Canonical};
+1 -2
View File
@@ -10,8 +10,7 @@
use std::mem::MaybeUninit;
use rustc_ast::tokenstream::TokenStream;
use rustc_span::ErrorGuaranteed;
use rustc_span::source_map::Spanned;
use rustc_span::{ErrorGuaranteed, Spanned};
use crate::mir::interpret::EvalToValTreeResult;
use crate::mir::mono::{MonoItem, NormalizationErrorInMono};
@@ -17,10 +17,9 @@
use rustc_span::hygiene::{
ExpnId, HygieneDecodeContext, HygieneEncodeContext, SyntaxContext, SyntaxContextKey,
};
use rustc_span::source_map::Spanned;
use rustc_span::{
BlobDecoder, BytePos, ByteSymbol, CachingSourceMapView, ExpnData, ExpnHash, RelativeBytePos,
SourceFile, Span, SpanDecoder, SpanEncoder, StableSourceFileId, Symbol,
SourceFile, Span, SpanDecoder, SpanEncoder, Spanned, StableSourceFileId, Symbol,
};
use crate::dep_graph::{DepNodeIndex, QuerySideEffect, SerializedDepNodeIndex};
+1 -2
View File
@@ -15,8 +15,7 @@
use rustc_hir::def_id::LocalDefId;
use rustc_middle::ty::Const;
use rustc_serialize::{Decodable, Encodable};
use rustc_span::source_map::Spanned;
use rustc_span::{Span, SpanDecoder, SpanEncoder};
use rustc_span::{Span, SpanDecoder, SpanEncoder, Spanned};
use crate::arena::ArenaAllocatable;
use crate::infer::canonical::{CanonicalVarKind, CanonicalVarKinds};
@@ -8,7 +8,7 @@
use rustc_abi::TyAndLayout;
use rustc_hir::def::Namespace;
use rustc_hir::def_id::LocalDefId;
use rustc_span::source_map::Spanned;
use rustc_span::Spanned;
use rustc_type_ir::{ConstKind, TypeFolder, VisitorResult, try_visit};
use super::{GenericArg, GenericArgKind, Pattern, Region};
@@ -4,8 +4,7 @@
use rustc_middle::thir::*;
use rustc_middle::ty;
use rustc_middle::ty::cast::mir_cast_kind;
use rustc_span::Span;
use rustc_span::source_map::Spanned;
use rustc_span::{Span, Spanned};
use super::{PResult, ParseCtxt, parse_by_kind};
use crate::builder::custom::ParseError;
@@ -11,8 +11,7 @@
use rustc_middle::ty::cast::{CastTy, mir_cast_kind};
use rustc_middle::ty::util::IntTypeExt;
use rustc_middle::ty::{self, Ty, UpvarArgs};
use rustc_span::source_map::Spanned;
use rustc_span::{DUMMY_SP, Span};
use rustc_span::{DUMMY_SP, Span, Spanned};
use tracing::debug;
use crate::builder::expr::as_place::PlaceBase;
@@ -10,8 +10,7 @@
use rustc_middle::span_bug;
use rustc_middle::thir::*;
use rustc_middle::ty::{self, CanonicalUserTypeAnnotation, Ty};
use rustc_span::source_map::Spanned;
use rustc_span::{DUMMY_SP, sym};
use rustc_span::{DUMMY_SP, Spanned, sym};
use rustc_trait_selection::infer::InferCtxtExt;
use tracing::{debug, instrument};
@@ -2,7 +2,7 @@
use rustc_middle::mir::*;
use rustc_middle::span_bug;
use rustc_middle::thir::*;
use rustc_span::source_map::Spanned;
use rustc_span::Spanned;
use tracing::debug;
use crate::builder::scope::{BreakableTarget, LintLevel};
@@ -14,8 +14,7 @@
use rustc_middle::ty::util::IntTypeExt;
use rustc_middle::ty::{self, GenericArg, Ty, TyCtxt};
use rustc_span::def_id::DefId;
use rustc_span::source_map::Spanned;
use rustc_span::{DUMMY_SP, Span, Symbol, sym};
use rustc_span::{DUMMY_SP, Span, Spanned, Symbol, sym};
use tracing::{debug, instrument};
use crate::builder::Builder;
@@ -94,8 +94,7 @@
use rustc_middle::{bug, span_bug};
use rustc_pattern_analysis::rustc::RustcPatCtxt;
use rustc_session::lint::Level;
use rustc_span::source_map::Spanned;
use rustc_span::{DUMMY_SP, Span};
use rustc_span::{DUMMY_SP, Span, Spanned};
use tracing::{debug, instrument};
use super::matches::BuiltMatchTree;
@@ -83,8 +83,7 @@
Analysis, Results, ResultsCursor, ResultsVisitor, visit_reachable_results,
};
use rustc_span::def_id::{DefId, LocalDefId};
use rustc_span::source_map::dummy_spanned;
use rustc_span::{DUMMY_SP, Span};
use rustc_span::{DUMMY_SP, Span, dummy_spanned};
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::infer::TyCtxtInferExt as _;
use rustc_trait_selection::traits::{ObligationCause, ObligationCauseCode, ObligationCtxt};
@@ -9,8 +9,7 @@
use rustc_middle::ty::util::IntTypeExt;
use rustc_middle::ty::{self, GenericArg, GenericArgsRef, Ty, TyCtxt};
use rustc_middle::{bug, span_bug, traits};
use rustc_span::DUMMY_SP;
use rustc_span::source_map::{Spanned, dummy_spanned};
use rustc_span::{DUMMY_SP, Spanned, dummy_spanned};
use tracing::{debug, instrument};
use crate::patch::MirPatch;
@@ -5,8 +5,7 @@
use rustc_middle::mir::*;
use rustc_middle::ty::{self, EarlyBinder, GenericArgsRef, Ty, TyCtxt};
use rustc_session::lint::builtin::FUNCTION_ITEM_REFERENCES;
use rustc_span::source_map::Spanned;
use rustc_span::{Span, sym};
use rustc_span::{Span, Spanned, sym};
use crate::errors;
+1 -1
View File
@@ -15,7 +15,7 @@
use rustc_middle::mir::*;
use rustc_middle::ty::{self, Instance, InstanceKind, Ty, TyCtxt, TypeFlags, TypeVisitableExt};
use rustc_session::config::{DebugInfo, OptLevel};
use rustc_span::source_map::Spanned;
use rustc_span::Spanned;
use tracing::{debug, instrument, trace, trace_span};
use crate::cost_checker::{CostChecker, is_call_like};
+1 -2
View File
@@ -27,8 +27,7 @@
use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt};
use rustc_middle::util::Providers;
use rustc_middle::{bug, query, span_bug};
use rustc_span::source_map::Spanned;
use rustc_span::{DUMMY_SP, sym};
use rustc_span::{DUMMY_SP, Spanned, sym};
use tracing::debug;
#[macro_use]
@@ -3,7 +3,7 @@
use rustc_middle::ty::adjustment::PointerCoercion;
use rustc_middle::ty::{self, TyCtxt};
use rustc_session::Session;
use rustc_span::source_map::Spanned;
use rustc_span::Spanned;
pub(super) struct MentionedItems;
@@ -23,8 +23,7 @@
use rustc_middle::mir::*;
use rustc_middle::ty::{self, GenericArgs, List, Ty, TyCtxt, TypeVisitableExt};
use rustc_middle::{bug, mir, span_bug};
use rustc_span::Span;
use rustc_span::source_map::Spanned;
use rustc_span::{Span, Spanned};
use tracing::{debug, instrument};
/// A `MirPass` for promotion.
+1 -2
View File
@@ -12,8 +12,7 @@
self, CoroutineArgs, CoroutineArgsExt, EarlyBinder, GenericArgs, Ty, TyCtxt,
};
use rustc_middle::{bug, span_bug};
use rustc_span::source_map::{Spanned, dummy_spanned};
use rustc_span::{DUMMY_SP, Span};
use rustc_span::{DUMMY_SP, Span, Spanned, dummy_spanned};
use tracing::{debug, instrument};
use crate::deref_separator::deref_finder;
+1 -2
View File
@@ -236,8 +236,7 @@
use rustc_middle::util::Providers;
use rustc_middle::{bug, span_bug};
use rustc_session::config::{DebugInfo, EntryFnType};
use rustc_span::source_map::{Spanned, dummy_spanned, respan};
use rustc_span::{DUMMY_SP, Span};
use rustc_span::{DUMMY_SP, Span, Spanned, dummy_spanned, respan};
use tracing::{debug, instrument, trace};
use crate::collector::autodiff::collect_autodiff_fn;
@@ -6,8 +6,7 @@
use rustc_middle::mir::{self, Location, traversal};
use rustc_middle::ty::{self, AssocTag, Instance, Ty, TyCtxt, TypeFoldable};
use rustc_session::lint::builtin::LARGE_ASSIGNMENTS;
use rustc_span::source_map::Spanned;
use rustc_span::{Ident, Span, sym};
use rustc_span::{Ident, Span, Spanned, sym};
use tracing::{debug, trace};
use crate::errors::LargeAssignmentsLint;
@@ -16,9 +16,8 @@
pluralize,
};
use rustc_session::errors::ExprParenthesesNeeded;
use rustc_span::source_map::Spanned;
use rustc_span::symbol::used_keywords;
use rustc_span::{BytePos, DUMMY_SP, Ident, Span, SpanSnippetError, Symbol, kw, sym};
use rustc_span::{BytePos, DUMMY_SP, Ident, Span, SpanSnippetError, Spanned, Symbol, kw, sym};
use thin_vec::{ThinVec, thin_vec};
use tracing::{debug, trace};
+4 -5
View File
@@ -25,8 +25,7 @@
use rustc_session::lint::BuiltinLintDiag;
use rustc_session::lint::builtin::BREAK_WITH_LABEL_AND_LOOP;
use rustc_span::edition::Edition;
use rustc_span::source_map::{self, Spanned};
use rustc_span::{BytePos, ErrorGuaranteed, Ident, Pos, Span, Symbol, kw, sym};
use rustc_span::{BytePos, ErrorGuaranteed, Ident, Pos, Span, Spanned, Symbol, kw, respan, sym};
use thin_vec::{ThinVec, thin_vec};
use tracing::instrument;
@@ -296,12 +295,12 @@ pub(super) fn parse_expr_assoc_rest_with(
let span = self.mk_expr_sp(&lhs, lhs_span, op_span, rhs.span);
lhs = match op {
AssocOp::Binary(ast_op) => {
let binary = self.mk_binary(source_map::respan(cur_op_span, ast_op), lhs, rhs);
let binary = self.mk_binary(respan(cur_op_span, ast_op), lhs, rhs);
self.mk_expr(span, binary)
}
AssocOp::Assign => self.mk_expr(span, ExprKind::Assign(lhs, rhs, cur_op_span)),
AssocOp::AssignOp(aop) => {
let aopexpr = self.mk_assign_op(source_map::respan(cur_op_span, aop), lhs, rhs);
let aopexpr = self.mk_assign_op(respan(cur_op_span, aop), lhs, rhs);
self.mk_expr(span, aopexpr)
}
AssocOp::Cast | AssocOp::Range(_) => {
@@ -409,7 +408,7 @@ pub(super) fn check_assoc_op(&self) -> Option<Spanned<AssocOp>> {
}
_ => return None,
};
Some(source_map::respan(span, op))
Some(respan(span, op))
}
/// Checks if this expression is a successfully parsed statement.
+2 -2
View File
@@ -13,7 +13,7 @@
use rustc_session::lint::builtin::VARARGS_WITHOUT_PATTERN;
use rustc_span::edit_distance::edit_distance;
use rustc_span::edition::Edition;
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Ident, Span, Symbol, kw, source_map, sym};
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Ident, Span, Symbol, kw, respan, sym};
use thin_vec::{ThinVec, thin_vec};
use tracing::debug;
@@ -3557,7 +3557,7 @@ fn parse_self_param(&mut self) -> PResult<'a, Option<Param>> {
_ => return Ok(None),
};
let eself = source_map::respan(eself_lo.to(eself_hi), eself);
let eself = respan(eself_lo.to(eself_hi), eself);
Ok(Some(Param::from_self(AttrVec::default(), eself, eself_ident)))
}
+1 -2
View File
@@ -12,8 +12,7 @@
use rustc_ast_pretty::pprust;
use rustc_errors::{Applicability, Diag, DiagArgValue, PResult, StashKey};
use rustc_session::errors::ExprParenthesesNeeded;
use rustc_span::source_map::{Spanned, respan};
use rustc_span::{BytePos, ErrorGuaranteed, Ident, Span, kw, sym};
use rustc_span::{BytePos, ErrorGuaranteed, Ident, Span, Spanned, kw, respan, sym};
use thin_vec::{ThinVec, thin_vec};
use super::{ForceCollect, Parser, PathStyle, Restrictions, Trailing, UsePreAttrPos};
+1 -2
View File
@@ -5,8 +5,7 @@
use rustc_middle::span_bug;
use rustc_middle::ty::layout::{FnAbiError, LayoutError};
use rustc_middle::ty::{self, GenericArgs, Instance, Ty, TyCtxt};
use rustc_span::Span;
use rustc_span::source_map::Spanned;
use rustc_span::{Span, Spanned};
use rustc_target::callconv::FnAbi;
use super::layout_test::ensure_wf;
+1 -2
View File
@@ -6,8 +6,7 @@
use rustc_middle::span_bug;
use rustc_middle::ty::layout::{HasTyCtxt, HasTypingEnv, LayoutError, LayoutOfHelpers};
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_span::Span;
use rustc_span::source_map::Spanned;
use rustc_span::{Span, Spanned};
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::infer::TyCtxtInferExt;
use rustc_trait_selection::traits;
+4 -2
View File
@@ -32,8 +32,10 @@
use rustc_span::edit_distance::find_best_match_for_name;
use rustc_span::edition::Edition;
use rustc_span::hygiene::MacroKind;
use rustc_span::source_map::{SourceMap, Spanned};
use rustc_span::{BytePos, Ident, RemapPathScopeComponents, Span, Symbol, SyntaxContext, kw, sym};
use rustc_span::source_map::SourceMap;
use rustc_span::{
BytePos, Ident, RemapPathScopeComponents, Span, Spanned, Symbol, SyntaxContext, kw, sym,
};
use thin_vec::{ThinVec, thin_vec};
use tracing::{debug, instrument};
+1 -2
View File
@@ -5,8 +5,7 @@
EmissionGuarantee, IntoDiagArg, Level, MultiSpan, Subdiagnostic, msg,
};
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_span::source_map::Spanned;
use rustc_span::{Ident, Span, Symbol};
use rustc_span::{Ident, Span, Spanned, Symbol};
use crate::Res;
use crate::late::PatternSource;
+1 -2
View File
@@ -37,8 +37,7 @@
use rustc_session::config::{CrateType, ResolveDocLinks};
use rustc_session::lint;
use rustc_session::parse::feature_err;
use rustc_span::source_map::{Spanned, respan};
use rustc_span::{BytePos, DUMMY_SP, Ident, Span, Symbol, kw, sym};
use rustc_span::{BytePos, DUMMY_SP, Ident, Span, Spanned, Symbol, kw, respan, sym};
use smallvec::{SmallVec, smallvec};
use thin_vec::ThinVec;
use tracing::{debug, instrument, trace};
+14
View File
@@ -90,6 +90,20 @@
#[cfg(test)]
mod tests;
#[derive(Clone, Encodable, Decodable, Debug, Copy, PartialEq, Hash, HashStable_Generic)]
pub struct Spanned<T> {
pub node: T,
pub span: Span,
}
pub fn respan<T>(sp: Span, t: T) -> Spanned<T> {
Spanned { node: t, span: sp }
}
pub fn dummy_spanned<T>(t: T) -> Spanned<T> {
respan(DUMMY_SP, t)
}
/// Per-session global variables: this struct is stored in thread-local storage
/// in such a way that it is accessible without any kind of handle to all
/// threads within the compilation session, but is not accessible outside the
-15
View File
@@ -15,7 +15,6 @@
use rustc_data_structures::sync::{IntoDynSyncSend, MappedReadGuard, ReadGuard, RwLock};
use rustc_data_structures::unhash::UnhashMap;
use rustc_macros::{Decodable, Encodable};
use tracing::{debug, instrument, trace};
use crate::*;
@@ -74,20 +73,6 @@ fn deref(&self) -> &Self::Target {
impl<T> !DerefMut for MonotonicVec<T> {}
}
#[derive(Clone, Encodable, Decodable, Debug, Copy, PartialEq, Hash, HashStable_Generic)]
pub struct Spanned<T> {
pub node: T,
pub span: Span,
}
pub fn respan<T>(sp: Span, t: T) -> Spanned<T> {
Spanned { node: t, span: sp }
}
pub fn dummy_spanned<T>(t: T) -> Spanned<T> {
respan(DUMMY_SP, t)
}
// _____________________________________________________________________________
// SourceFile, MultiByteChar, FileName, FileLines
//
@@ -6,8 +6,7 @@
use rustc_hir::{BinOpKind, Expr, ExprKind};
use rustc_lint::{LateContext, LateLintPass};
use rustc_session::declare_lint_pass;
use rustc_span::Span;
use rustc_span::source_map::Spanned;
use rustc_span::{Span, Spanned};
declare_clippy_lint! {
/// ### What it does
@@ -6,7 +6,7 @@
use rustc_errors::Applicability;
use rustc_hir::{Expr, ExprKind, GenericArg, Mutability, QPath, Ty, TyKind};
use rustc_lint::LateContext;
use rustc_span::source_map::Spanned;
use rustc_span::Spanned;
use super::MANUAL_DANGLING_PTR;
@@ -7,7 +7,7 @@
use rustc_hir::{BinOpKind, Expr, ExprKind, UnOp};
use rustc_lint::LateContext;
use rustc_span::SyntaxContext;
use rustc_span::source_map::Spanned;
use rustc_span::Spanned;
use super::SUBOPTIMAL_FLOPS;
@@ -6,7 +6,7 @@
use rustc_errors::Applicability;
use rustc_hir::{BinOpKind, Expr, ExprKind};
use rustc_lint::LateContext;
use rustc_span::source_map::Spanned;
use rustc_span::Spanned;
use super::IMPRECISE_FLOPS;
@@ -6,7 +6,7 @@
use rustc_errors::Applicability;
use rustc_hir::{BinOpKind, Expr, ExprKind, PathSegment};
use rustc_lint::LateContext;
use rustc_span::source_map::Spanned;
use rustc_span::Spanned;
use super::IMPRECISE_FLOPS;
@@ -4,7 +4,7 @@
use rustc_errors::Applicability;
use rustc_hir::{BinOpKind, Expr, ExprKind};
use rustc_lint::LateContext;
use rustc_span::source_map::Spanned;
use rustc_span::Spanned;
use super::IMPRECISE_FLOPS;
@@ -4,7 +4,7 @@
use rustc_errors::Applicability;
use rustc_hir::{BinOpKind, Expr, ExprKind, PathSegment};
use rustc_lint::LateContext;
use rustc_span::source_map::Spanned;
use rustc_span::Spanned;
use super::SUBOPTIMAL_FLOPS;
@@ -5,7 +5,7 @@
use rustc_errors::Applicability;
use rustc_hir::{BinOpKind, Expr, ExprKind, PathSegment};
use rustc_lint::LateContext;
use rustc_span::source_map::Spanned;
use rustc_span::Spanned;
use super::SUBOPTIMAL_FLOPS;
@@ -6,7 +6,7 @@
use rustc_errors::Applicability;
use rustc_hir::{BinOpKind, Expr, ExprKind, PathSegment};
use rustc_lint::LateContext;
use rustc_span::source_map::Spanned;
use rustc_span::Spanned;
use super::SUBOPTIMAL_FLOPS;
@@ -6,7 +6,7 @@
use rustc_errors::Applicability;
use rustc_hir::{BinOpKind, Expr, ExprKind};
use rustc_lint::LateContext;
use rustc_span::source_map::Spanned;
use rustc_span::Spanned;
use std::f32::consts as f32_consts;
use std::f64::consts as f64_consts;
@@ -13,8 +13,7 @@
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty::{self, Ty};
use rustc_session::impl_lint_pass;
use rustc_span::source_map::Spanned;
use rustc_span::{Span, Symbol};
use rustc_span::{Span, Spanned, Symbol};
declare_clippy_lint! {
/// ### What it does
@@ -13,8 +13,7 @@
use rustc_hir::def::Res;
use rustc_hir::{Expr, ExprKind, Pat};
use rustc_lint::LateContext;
use rustc_span::source_map::Spanned;
use rustc_span::sym;
use rustc_span::{Spanned, sym};
use super::MANUAL_SLICE_FILL;
@@ -8,7 +8,7 @@
use rustc_lint::LateContext;
use rustc_middle::hir::nested_filter;
use rustc_middle::ty::{self, Ty};
use rustc_span::source_map::Spanned;
use rustc_span::Spanned;
use rustc_span::symbol::{Symbol, sym};
#[derive(Debug, PartialEq, Eq)]
@@ -15,8 +15,7 @@
use rustc_lint::{LateContext, LateLintPass, LintContext as _};
use rustc_middle::ty;
use rustc_session::impl_lint_pass;
use rustc_span::source_map::Spanned;
use rustc_span::{Symbol, SyntaxContext};
use rustc_span::{Spanned, Symbol, SyntaxContext};
use std::iter;
declare_clippy_lint! {
@@ -10,7 +10,7 @@
use rustc_hir::{Arm, BorrowKind, Expr, ExprKind, Pat, PatKind, QPath};
use rustc_lint::{LateContext, LintContext};
use rustc_middle::ty;
use rustc_span::source_map::Spanned;
use rustc_span::Spanned;
use super::MATCH_LIKE_MATCHES_MACRO;
@@ -8,7 +8,7 @@
use rustc_hir::{Expr, ExprKind, LangItem};
use rustc_lint::LateContext;
use rustc_span::Span;
use rustc_span::source_map::Spanned;
use rustc_span::Spanned;
use super::CASE_SENSITIVE_FILE_EXTENSION_COMPARISONS;
@@ -7,7 +7,7 @@
use rustc_errors::Applicability;
use rustc_hir as hir;
use rustc_lint::LateContext;
use rustc_span::source_map::Spanned;
use rustc_span::Spanned;
use super::GET_FIRST;
@@ -5,7 +5,7 @@
use rustc_hir::{BinOpKind, Expr, ExprKind};
use rustc_lint::LateContext;
use rustc_middle::ty;
use rustc_span::source_map::Spanned;
use rustc_span::Spanned;
use super::GET_LAST_WITH_LEN;
@@ -9,7 +9,7 @@
use rustc_hir::{BinOpKind, Body, Expr, ExprKind, HirId, QPath};
use rustc_lint::LateContext;
use rustc_middle::ty;
use rustc_span::source_map::Spanned;
use rustc_span::Spanned;
use super::MANUAL_CONTAINS;
@@ -8,7 +8,7 @@
use rustc_lint::LateContext;
use rustc_middle::ty::Ty;
use rustc_span::Span;
use rustc_span::source_map::Spanned;
use rustc_span::Spanned;
use super::{NONSENSICAL_OPEN_OPTIONS, SUSPICIOUS_OPEN_OPTIONS};
@@ -3,7 +3,7 @@
use rustc_hir::{Expr, ExprKind};
use rustc_lint::LateContext;
use rustc_span::Symbol;
use rustc_span::source_map::Spanned;
use rustc_span::Spanned;
use super::SUSPICIOUS_SPLITN;
@@ -5,8 +5,7 @@
use rustc_errors::Applicability;
use rustc_hir::{Expr, ExprKind};
use rustc_lint::LateContext;
use rustc_span::source_map::Spanned;
use rustc_span::{Span, sym};
use rustc_span::{Span, Spanned, sym};
use super::VEC_RESIZE_TO_ZERO;
@@ -15,8 +15,7 @@
use rustc_hir::{Block, Body, Expr, ExprKind, UnOp};
use rustc_lint::{LateContext, LateLintPass};
use rustc_session::declare_lint_pass;
use rustc_span::source_map::Spanned;
use rustc_span::{Span, Symbol, sym};
use rustc_span::{Span, Spanned, Symbol, sym};
declare_clippy_lint! {
/// ### What it does
@@ -7,8 +7,7 @@
use rustc_lint::LateContext;
use rustc_middle::ty::layout::HasTyCtxt;
use rustc_middle::ty::{Ty, TypeckResults};
use rustc_span::Span;
use rustc_span::source_map::Spanned;
use rustc_span::{Span, Spanned};
use clippy_utils::SpanlessEq;
use clippy_utils::diagnostics::span_lint_and_note;
@@ -6,7 +6,7 @@
use rustc_hir::{BinOpKind, Expr, ExprKind};
use rustc_lint::LateContext;
use rustc_middle::ty;
use rustc_span::source_map::Spanned;
use rustc_span::Spanned;
use super::FLOAT_EQUALITY_WITHOUT_ABS;
@@ -9,7 +9,7 @@
use rustc_hir::{Expr, ExprKind};
use rustc_lint::LateContext;
use rustc_middle::ty::{self, Ty};
use rustc_span::source_map::Spanned;
use rustc_span::Spanned;
use super::MANUAL_DIV_CEIL;
@@ -5,7 +5,7 @@
use rustc_errors::Applicability;
use rustc_lint::{EarlyContext, EarlyLintPass, Lint};
use rustc_session::declare_lint_pass;
use rustc_span::source_map::Spanned;
use rustc_span::Spanned;
declare_clippy_lint! {
/// ### What it does
+1 -2
View File
@@ -14,8 +14,7 @@
use rustc_lint::{LateContext, LateLintPass, Lint};
use rustc_middle::ty::{self, ClauseKind, GenericArgKind, PredicatePolarity, Ty};
use rustc_session::impl_lint_pass;
use rustc_span::source_map::Spanned;
use rustc_span::{DesugaringKind, Span};
use rustc_span::{DesugaringKind, Span, Spanned};
use std::cmp::Ordering;
declare_clippy_lint! {
+1 -1
View File
@@ -11,7 +11,7 @@
use rustc_lint::{LateContext, LateLintPass, LintContext};
use rustc_middle::ty;
use rustc_session::declare_lint_pass;
use rustc_span::source_map::Spanned;
use rustc_span::Spanned;
declare_clippy_lint! {
/// ### What it does
@@ -8,7 +8,7 @@
use rustc_lint::{EarlyContext, EarlyLintPass};
use rustc_session::declare_lint_pass;
use rustc_span::Span;
use rustc_span::source_map::Spanned;
use rustc_span::Spanned;
use rustc_span::symbol::Ident;
declare_clippy_lint! {
+1 -2
View File
@@ -14,9 +14,8 @@
use rustc_lint::{LateContext, LateLintPass, LintContext};
use rustc_middle::ty;
use rustc_session::declare_lint_pass;
use rustc_span::source_map::Spanned;
use rustc_span::symbol::Ident;
use rustc_span::{Span, SyntaxContext};
use rustc_span::{Span, Spanned, SyntaxContext};
declare_clippy_lint! {
/// ### What it does
@@ -12,9 +12,8 @@
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::hir::nested_filter;
use rustc_session::{declare_tool_lint, impl_lint_pass};
use rustc_span::Span;
use rustc_span::source_map::Spanned;
use rustc_span::symbol::Symbol;
use rustc_span::{Span, Spanned};
declare_tool_lint! {
/// ### What it does
+1 -1
View File
@@ -361,7 +361,7 @@ pub(crate) fn rewrite_range_pat<T: Rewrite>(
shape: Shape,
lhs: &Option<Box<T>>,
rhs: &Option<Box<T>>,
end_kind: &rustc_span::source_map::Spanned<RangeEnd>,
end_kind: &rustc_span::Spanned<RangeEnd>,
span: Span,
) -> RewriteResult {
let infix = match end_kind.node {
+2 -2
View File
@@ -1,7 +1,7 @@
use std::cmp::max;
use rustc_ast::ast;
use rustc_span::{Span, source_map};
use rustc_span::Span;
use crate::macros::MacroArg;
use crate::patterns::RangeOperand;
@@ -18,7 +18,7 @@ fn span(&self) -> Span {
}
}
impl<T> Spanned for source_map::Spanned<T> {
impl<T> Spanned for rustc_span::Spanned<T> {
fn span(&self) -> Span {
self.span
}
+1 -2
View File
@@ -38,9 +38,8 @@
use rustc_ast::*;
use rustc_ast_pretty::pprust;
use rustc_session::parse::ParseSess;
use rustc_span::source_map::Spanned;
use rustc_span::symbol::Ident;
use rustc_span::DUMMY_SP;
use rustc_span::{DUMMY_SP, Spanned};
use thin_vec::{thin_vec, ThinVec};
// Helper functions for building exprs