Skip to content

Commit 7249512

Browse files
committed
Make ty::util take SpanId.
1 parent 433686d commit 7249512

File tree

22 files changed

+41
-43
lines changed

22 files changed

+41
-43
lines changed

src/librustc_codegen_ssa/traits/type_.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::common::TypeKind;
55
use crate::mir::place::PlaceRef;
66
use rustc_middle::ty::layout::TyAndLayout;
77
use rustc_middle::ty::{self, Ty};
8-
use rustc_span::DUMMY_SP;
8+
use rustc_span::DUMMY_SPID;
99
use rustc_target::abi::call::{ArgAbi, CastTarget, FnAbi, Reg};
1010
use rustc_target::abi::Integer;
1111

@@ -70,16 +70,16 @@ pub trait DerivedTypeMethods<'tcx>: BaseTypeMethods<'tcx> + MiscMethods<'tcx> {
7070
}
7171

7272
fn type_is_sized(&self, ty: Ty<'tcx>) -> bool {
73-
ty.is_sized(self.tcx().at(DUMMY_SP), ty::ParamEnv::reveal_all())
73+
ty.is_sized(self.tcx().at(DUMMY_SPID), ty::ParamEnv::reveal_all())
7474
}
7575

7676
fn type_is_freeze(&self, ty: Ty<'tcx>) -> bool {
77-
ty.is_freeze(self.tcx(), ty::ParamEnv::reveal_all(), DUMMY_SP)
77+
ty.is_freeze(self.tcx(), ty::ParamEnv::reveal_all(), DUMMY_SPID)
7878
}
7979

8080
fn type_has_metadata(&self, ty: Ty<'tcx>) -> bool {
8181
let param_env = ty::ParamEnv::reveal_all();
82-
if ty.is_sized(self.tcx().at(DUMMY_SP), param_env) {
82+
if ty.is_sized(self.tcx().at(DUMMY_SPID), param_env) {
8383
return false;
8484
}
8585

src/librustc_lint/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingCopyImplementations {
562562
return;
563563
}
564564
let param_env = ty::ParamEnv::empty();
565-
if ty.is_copy_modulo_regions(cx.tcx, param_env, item.span) {
565+
if ty.is_copy_modulo_regions(cx.tcx, param_env, item.span.into()) {
566566
return;
567567
}
568568
if can_type_implement_copy(cx.tcx, param_env, ty).is_ok() {

src/librustc_middle/ty/layout.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_index::bit_set::BitSet;
1212
use rustc_index::vec::{Idx, IndexVec};
1313
use rustc_session::{DataTypeKind, FieldInfo, SizeKind, VariantInfo};
1414
use rustc_span::symbol::{Ident, Symbol};
15-
use rustc_span::DUMMY_SP;
15+
use rustc_span::DUMMY_SPID;
1616
use rustc_target::abi::call::{
1717
ArgAbi, ArgAttribute, ArgAttributes, Conv, FnAbi, PassMode, Reg, RegKind,
1818
};
@@ -535,7 +535,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
535535
}
536536

537537
let pointee = tcx.normalize_erasing_regions(param_env, pointee);
538-
if pointee.is_sized(tcx.at(DUMMY_SP), param_env) {
538+
if pointee.is_sized(tcx.at(DUMMY_SPID), param_env) {
539539
return Ok(tcx.intern_layout(Layout::scalar(self, data_ptr)));
540540
}
541541

@@ -798,7 +798,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
798798
let param_env = tcx.param_env(def.did);
799799
let last_field = def.variants[v].fields.last().unwrap();
800800
let always_sized =
801-
tcx.type_of(last_field.did).is_sized(tcx.at(DUMMY_SP), param_env);
801+
tcx.type_of(last_field.did).is_sized(tcx.at(DUMMY_SPID), param_env);
802802
if !always_sized {
803803
StructKind::MaybeUnsized
804804
} else {
@@ -2160,7 +2160,7 @@ where
21602160

21612161
ty::Ref(_, ty, mt) if offset.bytes() == 0 => {
21622162
let tcx = cx.tcx();
2163-
let is_freeze = ty.is_freeze(tcx, cx.param_env(), DUMMY_SP);
2163+
let is_freeze = ty.is_freeze(tcx, cx.param_env(), DUMMY_SPID);
21642164
let kind = match mt {
21652165
hir::Mutability::Not => {
21662166
if is_freeze {

src/librustc_middle/ty/util.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use rustc_hir as hir;
1818
use rustc_hir::def::DefKind;
1919
use rustc_hir::def_id::DefId;
2020
use rustc_macros::HashStable;
21-
use rustc_span::Span;
21+
use rustc_span::{Span, SpanId};
2222
use rustc_target::abi::{Integer, Size, TargetDataLayout};
2323
use smallvec::SmallVec;
2424
use std::{cmp, fmt};
@@ -683,7 +683,7 @@ impl<'tcx> ty::TyS<'tcx> {
683683
&'tcx self,
684684
tcx: TyCtxt<'tcx>,
685685
param_env: ty::ParamEnv<'tcx>,
686-
span: Span,
686+
span: SpanId,
687687
) -> bool {
688688
tcx.at(span).is_copy_raw(param_env.and(self))
689689
}
@@ -709,7 +709,7 @@ impl<'tcx> ty::TyS<'tcx> {
709709
&'tcx self,
710710
tcx: TyCtxt<'tcx>,
711711
param_env: ty::ParamEnv<'tcx>,
712-
span: Span,
712+
span: SpanId,
713713
) -> bool {
714714
self.is_trivially_freeze() || tcx.at(span).is_freeze_raw(param_env.and(self))
715715
}

src/librustc_mir/dataflow/impls/borrowed_locals.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::dataflow::{AnalysisDomain, GenKill, GenKillAnalysis};
44
use rustc_middle::mir::visit::Visitor;
55
use rustc_middle::mir::*;
66
use rustc_middle::ty::{ParamEnv, TyCtxt};
7-
use rustc_span::DUMMY_SP;
7+
use rustc_span::DUMMY_SPID;
88

99
pub type MaybeMutBorrowedLocals<'mir, 'tcx> = MaybeBorrowedLocals<MutBorrow<'mir, 'tcx>>;
1010

@@ -231,7 +231,7 @@ impl MutBorrow<'mir, 'tcx> {
231231
///
232232
/// [rust-lang/unsafe-code-guidelines#134]: https://github.com/rust-lang/unsafe-code-guidelines/issues/134
233233
fn shared_borrow_allows_mutation(&self, place: Place<'tcx>) -> bool {
234-
!place.ty(self.body, self.tcx).ty.is_freeze(self.tcx, self.param_env, DUMMY_SP)
234+
!place.ty(self.body, self.tcx).ty.is_freeze(self.tcx, self.param_env, DUMMY_SPID)
235235
}
236236
}
237237

src/librustc_mir/interpret/eval_context.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_middle::ty::layout::{self, TyAndLayout};
1717
use rustc_middle::ty::{
1818
self, fold::BottomUpFolder, query::TyCtxtAt, subst::SubstsRef, Ty, TyCtxt, TypeFoldable,
1919
};
20-
use rustc_span::{source_map::DUMMY_SP, SpanId};
20+
use rustc_span::{SpanId, DUMMY_SP, DUMMY_SPID};
2121
use rustc_target::abi::{Align, HasDataLayout, LayoutOf, Size, TargetDataLayout};
2222

2323
use super::{
@@ -392,7 +392,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
392392

393393
#[inline]
394394
pub fn type_is_freeze(&self, ty: Ty<'tcx>) -> bool {
395-
ty.is_freeze(*self.tcx, self.param_env, DUMMY_SP)
395+
ty.is_freeze(*self.tcx, self.param_env, DUMMY_SPID)
396396
}
397397

398398
pub fn load_mir(
@@ -948,7 +948,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
948948
mir::ClearCrossCrate::Clear => None,
949949
}
950950
});
951-
let span = source_info.map_or(DUMMY_SP, |source_info| source_info.span);
951+
let span = source_info.map_or(DUMMY_SP, |source_info| source_info.span).into();
952952

953953
frames.push(FrameInfo { span, instance: frame.instance, lint_root });
954954
}

src/librustc_mir/interpret/intern.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,7 @@ fn intern_shallow<'rt, 'mir, 'tcx, M: CompileTimeMachine<'mir, 'tcx>>(
109109
// access this one.
110110
if mode == InternMode::Static {
111111
// When `ty` is `None`, we assume no interior mutability.
112-
let frozen = ty.map_or(true, |ty| {
113-
ty.is_freeze(ecx.tcx.tcx, ecx.param_env, ecx.tcx.reify_span(ecx.tcx.span))
114-
});
112+
let frozen = ty.map_or(true, |ty| ty.is_freeze(ecx.tcx.tcx, ecx.param_env, ecx.tcx.span));
115113
// For statics, allocation mutability is the combination of the place mutability and
116114
// the type mutability.
117115
// The entire allocation needs to be mutable if it contains an `UnsafeCell` anywhere.

src/librustc_mir/shim.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ fn build_clone_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, self_ty: Ty<'tcx>) -
306306
let param_env = tcx.param_env(def_id);
307307

308308
let mut builder = CloneShimBuilder::new(tcx, def_id, self_ty);
309-
let is_copy = self_ty.is_copy_modulo_regions(tcx, param_env, builder.span);
309+
let is_copy = self_ty.is_copy_modulo_regions(tcx, param_env, builder.span.into());
310310

311311
let dest = Place::return_place();
312312
let src = tcx.mk_place_deref(Place::from(Local::new(1 + 0)));

src/librustc_mir/transform/check_consts/qualifs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use rustc_infer::infer::TyCtxtInferExt;
66
use rustc_middle::mir::*;
77
use rustc_middle::ty::{self, subst::SubstsRef, AdtDef, Ty};
8-
use rustc_span::DUMMY_SP;
8+
use rustc_span::DUMMY_SPID;
99
use rustc_trait_selection::traits;
1010

1111
use super::ConstCx;
@@ -78,7 +78,7 @@ impl Qualif for HasMutInterior {
7878
}
7979

8080
fn in_any_value_of_ty(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> bool {
81-
!ty.is_freeze(cx.tcx, cx.param_env, DUMMY_SP)
81+
!ty.is_freeze(cx.tcx, cx.param_env, DUMMY_SPID)
8282
}
8383

8484
fn in_adt_inherently(cx: &ConstCx<'_, 'tcx>, adt: &'tcx AdtDef, _: SubstsRef<'tcx>) -> bool {

src/librustc_mir/transform/check_unsafety.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
271271
if !elem_ty.is_copy_modulo_regions(
272272
self.tcx,
273273
self.param_env,
274-
self.source_info.span,
274+
self.source_info.span.into(),
275275
) {
276276
self.require_unsafe(
277277
"assignment to non-`Copy` union field",
@@ -419,7 +419,7 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> {
419419
} else if !place.ty(self.body, self.tcx).ty.is_freeze(
420420
self.tcx,
421421
self.param_env,
422-
self.source_info.span,
422+
self.source_info.span.into(),
423423
) {
424424
(
425425
"borrow of layout constrained field with interior \

src/librustc_mir/transform/promote_consts.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use rustc_middle::ty::cast::CastTy;
2222
use rustc_middle::ty::subst::InternalSubsts;
2323
use rustc_middle::ty::{self, List, TyCtxt, TypeFoldable};
2424
use rustc_span::symbol::sym;
25-
use rustc_span::{Span, DUMMY_SP};
25+
use rustc_span::{Span, DUMMY_SPID};
2626

2727
use rustc_index::vec::{Idx, IndexVec};
2828
use rustc_target::spec::abi::Abi;
@@ -330,7 +330,7 @@ impl<'tcx> Validator<'_, 'tcx> {
330330
Place::ty_from(place.local, proj_base, self.body, self.tcx)
331331
.projection_ty(self.tcx, elem)
332332
.ty;
333-
if ty.is_freeze(self.tcx, self.param_env, DUMMY_SP) {
333+
if ty.is_freeze(self.tcx, self.param_env, DUMMY_SPID) {
334334
has_mut_interior = false;
335335
break;
336336
}
@@ -653,7 +653,7 @@ impl<'tcx> Validator<'_, 'tcx> {
653653
let ty = Place::ty_from(place.local, proj_base, self.body, self.tcx)
654654
.projection_ty(self.tcx, elem)
655655
.ty;
656-
if ty.is_freeze(self.tcx, self.param_env, DUMMY_SP) {
656+
if ty.is_freeze(self.tcx, self.param_env, DUMMY_SPID) {
657657
has_mut_interior = false;
658658
break;
659659
}

src/librustc_mir_build/build/expr/as_operand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
172172

173173
if !ty.is_sized(tcx.at(span), param_env) {
174174
// !sized means !copy, so this is an unsized move
175-
assert!(!ty.is_copy_modulo_regions(tcx, param_env, span));
175+
assert!(!ty.is_copy_modulo_regions(tcx, param_env, span.into()));
176176

177177
// As described above, detect the case where we are passing a value of unsized
178178
// type, and that value is coming from the deref of a box.

src/librustc_mir_build/hair/pattern/check_match.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ fn maybe_point_at_variant(ty: Ty<'_>, patterns: &[super::Pat<'_>]) -> Vec<Span>
579579

580580
/// Check if a by-value binding is by-value. That is, check if the binding's type is not `Copy`.
581581
fn is_binding_by_move(cx: &MatchVisitor<'_, '_>, hir_id: HirId, span: Span) -> bool {
582-
!cx.tables.node_type(hir_id).is_copy_modulo_regions(cx.tcx, cx.param_env, span)
582+
!cx.tables.node_type(hir_id).is_copy_modulo_regions(cx.tcx, cx.param_env, span.into())
583583
}
584584

585585
/// Check the legality of legality of by-move bindings.

src/librustc_trait_selection/infer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'tcx> {
4444
let ty = self.resolve_vars_if_possible(&ty);
4545

4646
if !(param_env, ty).needs_infer() {
47-
return ty.is_copy_modulo_regions(self.tcx, param_env, span);
47+
return ty.is_copy_modulo_regions(self.tcx, param_env, span.into());
4848
}
4949

5050
let copy_def_id = self.tcx.require_lang_item(lang_items::CopyTraitLangItem, None);

src/librustc_trait_selection/traits/misc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub fn can_type_implement_copy(
5252
let ctx = traits::FulfillmentContext::new();
5353
match traits::fully_normalize(&infcx, ctx, cause, param_env, &ty) {
5454
Ok(ty) => {
55-
if !infcx.type_is_copy_modulo_regions(param_env, ty, span) {
55+
if !infcx.type_is_copy_modulo_regions(param_env, ty, span.into()) {
5656
infringing.push(field);
5757
}
5858
}

src/librustc_ty/needs_drop.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_hir::def_id::DefId;
55
use rustc_middle::ty::subst::Subst;
66
use rustc_middle::ty::util::{needs_drop_components, AlwaysRequiresDrop};
77
use rustc_middle::ty::{self, Ty, TyCtxt};
8-
use rustc_span::DUMMY_SP;
8+
use rustc_span::DUMMY_SPID;
99

1010
type NeedsDropResult<T> = Result<T, AlwaysRequiresDrop>;
1111

@@ -71,7 +71,7 @@ where
7171
// Not having a `Span` isn't great. But there's hopefully some other
7272
// recursion limit error as well.
7373
tcx.sess.span_err(
74-
DUMMY_SP,
74+
DUMMY_SPID,
7575
&format!("overflow while checking whether `{}` requires drop", self.query_ty),
7676
);
7777
return Some(Err(AlwaysRequiresDrop));
@@ -91,7 +91,7 @@ where
9191

9292
for component in components {
9393
match component.kind {
94-
_ if component.is_copy_modulo_regions(tcx, self.param_env, DUMMY_SP) => (),
94+
_ if component.is_copy_modulo_regions(tcx, self.param_env, DUMMY_SPID) => (),
9595

9696
ty::Closure(_, substs) => {
9797
for upvar_ty in substs.as_closure().upvar_tys() {

src/tools/clippy/clippy_lints/src/functions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ fn is_mutable_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty<'tcx>, span: Span,
507507
// primitive types are never mutable
508508
ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Str => false,
509509
ty::Adt(ref adt, ref substs) => {
510-
tys.insert(adt.did) && !ty.is_freeze(cx.tcx, cx.param_env, span)
510+
tys.insert(adt.did) && !ty.is_freeze(cx.tcx, cx.param_env, span.into())
511511
|| KNOWN_WRAPPER_TYS.iter().any(|path| match_def_path(cx, adt.did, path))
512512
&& substs.types().any(|ty| is_mutable_ty(cx, ty, span, tys))
513513
},

src/tools/clippy/clippy_lints/src/let_if_seq.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetIfSeq {
7676
let has_interior_mutability = !cx.tables.node_type(canonical_id).is_freeze(
7777
cx.tcx,
7878
cx.param_env,
79-
span
79+
span.into()
8080
);
8181
if has_interior_mutability { return; }
8282

src/tools/clippy/clippy_lints/src/mut_key.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ fn is_mutable_type<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty<'tcx>, span: Spa
118118
size.try_eval_usize(cx.tcx, cx.param_env).map_or(true, |u| u != 0) && is_mutable_type(cx, inner_ty, span)
119119
},
120120
Tuple(..) => ty.tuple_fields().any(|ty| is_mutable_type(cx, ty, span)),
121-
Adt(..) => cx.tcx.layout_of(cx.param_env.and(ty)).is_ok() && !ty.is_freeze(cx.tcx, cx.param_env, span),
121+
Adt(..) => cx.tcx.layout_of(cx.param_env.and(ty)).is_ok() && !ty.is_freeze(cx.tcx, cx.param_env, span.into()),
122122
_ => false,
123123
}
124124
}

src/tools/clippy/clippy_lints/src/non_copy_const.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_lint::{LateContext, LateLintPass, Lint};
1010
use rustc_middle::ty::adjustment::Adjust;
1111
use rustc_middle::ty::{Ty, TypeFlags};
1212
use rustc_session::{declare_lint_pass, declare_tool_lint};
13-
use rustc_span::{InnerSpan, Span, DUMMY_SP};
13+
use rustc_span::{InnerSpan, Span, DUMMY_SPID};
1414
use rustc_typeck::hir_ty_to_ty;
1515

1616
use crate::utils::{in_constant, is_copy, qpath_res, span_lint_and_then};
@@ -110,7 +110,7 @@ impl Source {
110110
}
111111

112112
fn verify_ty_bound<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty<'tcx>, source: Source) {
113-
if ty.is_freeze(cx.tcx, cx.param_env, DUMMY_SP) || is_copy(cx, ty) {
113+
if ty.is_freeze(cx.tcx, cx.param_env, DUMMY_SPID) || is_copy(cx, ty) {
114114
// An `UnsafeCell` is `!Copy`, and an `UnsafeCell` is also the only type which
115115
// is `!Freeze`, thus if our type is `Copy` we can be sure it must be `Freeze`
116116
// as well.

src/tools/clippy/clippy_lints/src/question_mark.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl QuestionMark {
137137
fn moves_by_default(cx: &LateContext<'_, '_>, expression: &Expr<'_>) -> bool {
138138
let expr_ty = cx.tables.expr_ty(expression);
139139

140-
!expr_ty.is_copy_modulo_regions(cx.tcx, cx.param_env, expression.span)
140+
!expr_ty.is_copy_modulo_regions(cx.tcx, cx.param_env, expression.span.into())
141141
}
142142

143143
fn is_option(cx: &LateContext<'_, '_>, expression: &Expr<'_>) -> bool {

src/tools/clippy/clippy_lints/src/utils/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ use rustc_middle::ty::{self, layout::IntegerExt, subst::GenericArg, Binder, Ty,
4545
use rustc_span::hygiene::{ExpnKind, MacroKind};
4646
use rustc_span::source_map::original_sp;
4747
use rustc_span::symbol::{self, kw, Symbol};
48-
use rustc_span::{BytePos, Pos, Span, DUMMY_SP};
48+
use rustc_span::{BytePos, Pos, Span, DUMMY_SP, DUMMY_SPID};
4949
use rustc_target::abi::Integer;
5050
use rustc_trait_selection::traits::predicate_for_trait_def;
5151
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt;
@@ -914,7 +914,7 @@ pub fn type_is_unsafe_function<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty<'tcx
914914
}
915915

916916
pub fn is_copy<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty<'tcx>) -> bool {
917-
ty.is_copy_modulo_regions(cx.tcx, cx.param_env, DUMMY_SP)
917+
ty.is_copy_modulo_regions(cx.tcx, cx.param_env, DUMMY_SPID)
918918
}
919919

920920
/// Checks if an expression is constructing a tuple-like enum variant or struct

0 commit comments

Comments
 (0)