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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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 \

0 commit comments

Comments
 (0)