Skip to content

Commit 68c836a

Browse files
committed
Auto merge of rust-lang#103727 - GuillaumeGomez:rollup-hfyxccr, r=GuillaumeGomez
Rollup of 8 pull requests Successful merges: - rust-lang#102634 (compiletest: Refactor test rustcflags) - rust-lang#102721 (Prevent foreign Rust exceptions from being caught) - rust-lang#103415 (filter candidates in pick probe for diagnostics) - rust-lang#103618 (Rename some `OwnerId` fields.) - rust-lang#103625 (Accept `TyCtxt` instead of `TyCtxtAt` in `Ty::is_*` functions) - rust-lang#103653 (Add missing impl blocks for item reexported from private mod in JSON output) - rust-lang#103699 (Emit proper error when casting to `dyn*`) - rust-lang#103719 (fix typo in `try_reserve` method from `HashMap` and `HashSet`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 33b530e + 6425764 commit 68c836a

File tree

165 files changed

+1084
-864
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+1084
-864
lines changed

compiler/rustc_ast_lowering/src/index.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -112,19 +112,19 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
112112
113113
fn visit_nested_item(&mut self, item: ItemId) {
114114
debug!("visit_nested_item: {:?}", item);
115-
self.insert_nested(item.def_id.def_id);
115+
self.insert_nested(item.owner_id.def_id);
116116
}
117117

118118
fn visit_nested_trait_item(&mut self, item_id: TraitItemId) {
119-
self.insert_nested(item_id.def_id.def_id);
119+
self.insert_nested(item_id.owner_id.def_id);
120120
}
121121

122122
fn visit_nested_impl_item(&mut self, item_id: ImplItemId) {
123-
self.insert_nested(item_id.def_id.def_id);
123+
self.insert_nested(item_id.owner_id.def_id);
124124
}
125125

126126
fn visit_nested_foreign_item(&mut self, foreign_id: ForeignItemId) {
127-
self.insert_nested(foreign_id.def_id.def_id);
127+
self.insert_nested(foreign_id.owner_id.def_id);
128128
}
129129

130130
fn visit_nested_body(&mut self, id: BodyId) {
@@ -143,7 +143,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
143143

144144
#[instrument(level = "debug", skip(self))]
145145
fn visit_item(&mut self, i: &'hir Item<'hir>) {
146-
debug_assert_eq!(i.def_id, self.owner);
146+
debug_assert_eq!(i.owner_id, self.owner);
147147
self.with_parent(i.hir_id(), |this| {
148148
if let ItemKind::Struct(ref struct_def, _) = i.kind {
149149
// If this is a tuple or unit-like struct, register the constructor.
@@ -157,7 +157,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
157157

158158
#[instrument(level = "debug", skip(self))]
159159
fn visit_foreign_item(&mut self, fi: &'hir ForeignItem<'hir>) {
160-
debug_assert_eq!(fi.def_id, self.owner);
160+
debug_assert_eq!(fi.owner_id, self.owner);
161161
self.with_parent(fi.hir_id(), |this| {
162162
intravisit::walk_foreign_item(this, fi);
163163
});
@@ -176,15 +176,15 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
176176

177177
#[instrument(level = "debug", skip(self))]
178178
fn visit_trait_item(&mut self, ti: &'hir TraitItem<'hir>) {
179-
debug_assert_eq!(ti.def_id, self.owner);
179+
debug_assert_eq!(ti.owner_id, self.owner);
180180
self.with_parent(ti.hir_id(), |this| {
181181
intravisit::walk_trait_item(this, ti);
182182
});
183183
}
184184

185185
#[instrument(level = "debug", skip(self))]
186186
fn visit_impl_item(&mut self, ii: &'hir ImplItem<'hir>) {
187-
debug_assert_eq!(ii.def_id, self.owner);
187+
debug_assert_eq!(ii.owner_id, self.owner);
188188
self.with_parent(ii.hir_id(), |this| {
189189
intravisit::walk_impl_item(this, ii);
190190
});

compiler/rustc_ast_lowering/src/item.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
178178

179179
pub(super) fn lower_item_ref(&mut self, i: &Item) -> SmallVec<[hir::ItemId; 1]> {
180180
let mut node_ids =
181-
smallvec![hir::ItemId { def_id: hir::OwnerId { def_id: self.local_def_id(i.id) } }];
181+
smallvec![hir::ItemId { owner_id: hir::OwnerId { def_id: self.local_def_id(i.id) } }];
182182
if let ItemKind::Use(ref use_tree) = &i.kind {
183183
self.lower_item_id_use_tree(use_tree, i.id, &mut node_ids);
184184
}
@@ -195,7 +195,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
195195
UseTreeKind::Nested(ref nested_vec) => {
196196
for &(ref nested, id) in nested_vec {
197197
vec.push(hir::ItemId {
198-
def_id: hir::OwnerId { def_id: self.local_def_id(id) },
198+
owner_id: hir::OwnerId { def_id: self.local_def_id(id) },
199199
});
200200
self.lower_item_id_use_tree(nested, id, vec);
201201
}
@@ -206,7 +206,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
206206
iter::zip(self.expect_full_res_from_use(base_id).skip(1), &[id1, id2])
207207
{
208208
vec.push(hir::ItemId {
209-
def_id: hir::OwnerId { def_id: self.local_def_id(id) },
209+
owner_id: hir::OwnerId { def_id: self.local_def_id(id) },
210210
});
211211
}
212212
}
@@ -220,7 +220,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
220220
let attrs = self.lower_attrs(hir_id, &i.attrs);
221221
let kind = self.lower_item_kind(i.span, i.id, hir_id, &mut ident, attrs, vis_span, &i.kind);
222222
let item = hir::Item {
223-
def_id: hir_id.expect_owner(),
223+
owner_id: hir_id.expect_owner(),
224224
ident: self.lower_ident(ident),
225225
kind,
226226
vis_span,
@@ -562,7 +562,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
562562
}
563563

564564
let item = hir::Item {
565-
def_id: hir::OwnerId { def_id: new_id },
565+
owner_id: hir::OwnerId { def_id: new_id },
566566
ident: this.lower_ident(ident),
567567
kind,
568568
vis_span,
@@ -640,7 +640,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
640640
}
641641

642642
let item = hir::Item {
643-
def_id: hir::OwnerId { def_id: new_hir_id },
643+
owner_id: hir::OwnerId { def_id: new_hir_id },
644644
ident: this.lower_ident(ident),
645645
kind,
646646
vis_span,
@@ -660,10 +660,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
660660

661661
fn lower_foreign_item(&mut self, i: &ForeignItem) -> &'hir hir::ForeignItem<'hir> {
662662
let hir_id = self.lower_node_id(i.id);
663-
let def_id = hir_id.expect_owner();
663+
let owner_id = hir_id.expect_owner();
664664
self.lower_attrs(hir_id, &i.attrs);
665665
let item = hir::ForeignItem {
666-
def_id,
666+
owner_id,
667667
ident: self.lower_ident(i.ident),
668668
kind: match i.kind {
669669
ForeignItemKind::Fn(box Fn { ref sig, ref generics, .. }) => {
@@ -702,7 +702,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
702702

703703
fn lower_foreign_item_ref(&mut self, i: &ForeignItem) -> hir::ForeignItemRef {
704704
hir::ForeignItemRef {
705-
id: hir::ForeignItemId { def_id: hir::OwnerId { def_id: self.local_def_id(i.id) } },
705+
id: hir::ForeignItemId { owner_id: hir::OwnerId { def_id: self.local_def_id(i.id) } },
706706
ident: self.lower_ident(i.ident),
707707
span: self.lower_span(i.span),
708708
}
@@ -845,7 +845,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
845845

846846
self.lower_attrs(hir_id, &i.attrs);
847847
let item = hir::TraitItem {
848-
def_id: trait_item_def_id,
848+
owner_id: trait_item_def_id,
849849
ident: self.lower_ident(i.ident),
850850
generics,
851851
kind,
@@ -864,7 +864,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
864864
}
865865
AssocItemKind::MacCall(..) => unimplemented!(),
866866
};
867-
let id = hir::TraitItemId { def_id: hir::OwnerId { def_id: self.local_def_id(i.id) } };
867+
let id = hir::TraitItemId { owner_id: hir::OwnerId { def_id: self.local_def_id(i.id) } };
868868
hir::TraitItemRef {
869869
id,
870870
ident: self.lower_ident(i.ident),
@@ -931,7 +931,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
931931
let hir_id = self.lower_node_id(i.id);
932932
self.lower_attrs(hir_id, &i.attrs);
933933
let item = hir::ImplItem {
934-
def_id: hir_id.expect_owner(),
934+
owner_id: hir_id.expect_owner(),
935935
ident: self.lower_ident(i.ident),
936936
generics,
937937
kind,
@@ -944,7 +944,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
944944

945945
fn lower_impl_item_ref(&mut self, i: &AssocItem) -> hir::ImplItemRef {
946946
hir::ImplItemRef {
947-
id: hir::ImplItemId { def_id: hir::OwnerId { def_id: self.local_def_id(i.id) } },
947+
id: hir::ImplItemId { owner_id: hir::OwnerId { def_id: self.local_def_id(i.id) } },
948948
ident: self.lower_ident(i.ident),
949949
span: self.lower_span(i.span),
950950
kind: match &i.kind {

compiler/rustc_ast_lowering/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1574,7 +1574,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
15741574

15751575
// `impl Trait` now just becomes `Foo<'a, 'b, ..>`.
15761576
hir::TyKind::OpaqueDef(
1577-
hir::ItemId { def_id: hir::OwnerId { def_id: opaque_ty_def_id } },
1577+
hir::ItemId { owner_id: hir::OwnerId { def_id: opaque_ty_def_id } },
15781578
lifetimes,
15791579
in_trait,
15801580
)
@@ -1593,7 +1593,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
15931593
// Generate an `type Foo = impl Trait;` declaration.
15941594
trace!("registering opaque type with id {:#?}", opaque_ty_id);
15951595
let opaque_ty_item = hir::Item {
1596-
def_id: hir::OwnerId { def_id: opaque_ty_id },
1596+
owner_id: hir::OwnerId { def_id: opaque_ty_id },
15971597
ident: Ident::empty(),
15981598
kind: opaque_ty_item_kind,
15991599
vis_span: self.lower_span(span.shrink_to_lo()),
@@ -2044,7 +2044,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20442044
// async fn, so the *type parameters* are inherited. It's
20452045
// only the lifetime parameters that we must supply.
20462046
let opaque_ty_ref = hir::TyKind::OpaqueDef(
2047-
hir::ItemId { def_id: hir::OwnerId { def_id: opaque_ty_def_id } },
2047+
hir::ItemId { owner_id: hir::OwnerId { def_id: opaque_ty_def_id } },
20482048
generic_args,
20492049
in_trait,
20502050
);

compiler/rustc_borrowck/src/type_check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1783,7 +1783,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
17831783
// `Sized` bound in no way depends on precise regions, so this
17841784
// shouldn't affect `is_sized`.
17851785
let erased_ty = tcx.erase_regions(ty);
1786-
if !erased_ty.is_sized(tcx.at(span), self.param_env) {
1786+
if !erased_ty.is_sized(tcx, self.param_env) {
17871787
// in current MIR construction, all non-control-flow rvalue
17881788
// expressions evaluate through `as_temp` or `into` a return
17891789
// slot or local, so to find all unsized rvalues it is enough

compiler/rustc_codegen_cranelift/src/base.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -770,11 +770,7 @@ fn codegen_stmt<'tcx>(
770770
lval.write_cvalue(fx, CValue::by_val(operand, box_layout));
771771
}
772772
Rvalue::NullaryOp(null_op, ty) => {
773-
assert!(
774-
lval.layout()
775-
.ty
776-
.is_sized(fx.tcx.at(stmt.source_info.span), ParamEnv::reveal_all())
777-
);
773+
assert!(lval.layout().ty.is_sized(fx.tcx, ParamEnv::reveal_all()));
778774
let layout = fx.layout_of(fx.monomorphize(ty));
779775
let val = match null_op {
780776
NullOp::SizeOf => layout.size.bytes(),

compiler/rustc_codegen_cranelift/src/constant.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
55
use rustc_middle::mir::interpret::{
66
read_target_uint, AllocId, ConstAllocation, ConstValue, ErrorHandled, GlobalAlloc, Scalar,
77
};
8-
use rustc_span::DUMMY_SP;
98

109
use cranelift_module::*;
1110

@@ -291,7 +290,7 @@ fn data_id_for_static(
291290
let is_mutable = if tcx.is_mutable_static(def_id) {
292291
true
293292
} else {
294-
!ty.is_freeze(tcx.at(DUMMY_SP), ParamEnv::reveal_all())
293+
!ty.is_freeze(tcx, ParamEnv::reveal_all())
295294
};
296295
let align = tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap().align.pref.bytes();
297296

compiler/rustc_codegen_ssa/src/traits/type_.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ 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;
98
use rustc_target::abi::call::{ArgAbi, CastTarget, FnAbi, Reg};
109
use rustc_target::abi::{AddressSpace, Integer};
1110

@@ -75,16 +74,16 @@ pub trait DerivedTypeMethods<'tcx>: BaseTypeMethods<'tcx> + MiscMethods<'tcx> {
7574
}
7675

7776
fn type_is_sized(&self, ty: Ty<'tcx>) -> bool {
78-
ty.is_sized(self.tcx().at(DUMMY_SP), ty::ParamEnv::reveal_all())
77+
ty.is_sized(self.tcx(), ty::ParamEnv::reveal_all())
7978
}
8079

8180
fn type_is_freeze(&self, ty: Ty<'tcx>) -> bool {
82-
ty.is_freeze(self.tcx().at(DUMMY_SP), ty::ParamEnv::reveal_all())
81+
ty.is_freeze(self.tcx(), ty::ParamEnv::reveal_all())
8382
}
8483

8584
fn type_has_metadata(&self, ty: Ty<'tcx>) -> bool {
8685
let param_env = ty::ParamEnv::reveal_all();
87-
if ty.is_sized(self.tcx().at(DUMMY_SP), param_env) {
86+
if ty.is_sized(self.tcx(), param_env) {
8887
return false;
8988
}
9089

compiler/rustc_const_eval/src/const_eval/valtrees.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ fn create_pointee_place<'tcx>(
212212
) -> MPlaceTy<'tcx> {
213213
let tcx = ecx.tcx.tcx;
214214

215-
if !ty.is_sized(ecx.tcx, ty::ParamEnv::empty()) {
215+
if !ty.is_sized(*ecx.tcx, ty::ParamEnv::empty()) {
216216
// We need to create `Allocation`s for custom DSTs
217217

218218
let (unsized_inner_ty, num_elems) = get_info_on_unsized_field(ty, valtree, tcx);
@@ -398,7 +398,7 @@ fn valtree_into_mplace<'tcx>(
398398

399399
let mut place_inner = match ty.kind() {
400400
ty::Str | ty::Slice(_) => ecx.mplace_index(&place, i as u64).unwrap(),
401-
_ if !ty.is_sized(ecx.tcx, ty::ParamEnv::empty())
401+
_ if !ty.is_sized(*ecx.tcx, ty::ParamEnv::empty())
402402
&& i == branches.len() - 1 =>
403403
{
404404
// Note: For custom DSTs we need to manually process the last unsized field.

compiler/rustc_const_eval/src/interpret/eval_context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
468468

469469
#[inline]
470470
pub fn type_is_freeze(&self, ty: Ty<'tcx>) -> bool {
471-
ty.is_freeze(self.tcx, self.param_env)
471+
ty.is_freeze(*self.tcx, self.param_env)
472472
}
473473

474474
pub fn load_mir(

compiler/rustc_const_eval/src/interpret/intern.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ fn intern_shallow<'rt, 'mir, 'tcx, M: CompileTimeMachine<'mir, 'tcx, const_eval:
114114
if let InternMode::Static(mutability) = mode {
115115
// For this, we need to take into account `UnsafeCell`. When `ty` is `None`, we assume
116116
// no interior mutability.
117-
let frozen = ty.map_or(true, |ty| ty.is_freeze(ecx.tcx, ecx.param_env));
117+
let frozen = ty.map_or(true, |ty| ty.is_freeze(*ecx.tcx, ecx.param_env));
118118
// For statics, allocation mutability is the combination of place mutability and
119119
// type mutability.
120120
// The entire allocation needs to be mutable if it contains an `UnsafeCell` anywhere.

compiler/rustc_const_eval/src/interpret/validity.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use rustc_middle::mir::interpret::InterpError;
1515
use rustc_middle::ty;
1616
use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
1717
use rustc_span::symbol::{sym, Symbol};
18-
use rustc_span::DUMMY_SP;
1918
use rustc_target::abi::{Abi, Scalar as ScalarAbi, Size, VariantIdx, Variants, WrappingRange};
2019

2120
use std::hash::Hash;
@@ -726,7 +725,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M>
726725
) -> InterpResult<'tcx> {
727726
// Special check preventing `UnsafeCell` inside unions in the inner part of constants.
728727
if matches!(self.ctfe_mode, Some(CtfeValidationMode::Const { inner: true, .. })) {
729-
if !op.layout.ty.is_freeze(self.ecx.tcx.at(DUMMY_SP), self.ecx.param_env) {
728+
if !op.layout.ty.is_freeze(*self.ecx.tcx, self.ecx.param_env) {
730729
throw_validation_failure!(self.path, { "`UnsafeCell` in a `const`" });
731730
}
732731
}

compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use rustc_infer::infer::TyCtxtInferExt;
88
use rustc_middle::mir;
99
use rustc_middle::mir::*;
1010
use rustc_middle::ty::{self, subst::SubstsRef, AdtDef, Ty};
11-
use rustc_span::DUMMY_SP;
1211
use rustc_trait_selection::traits::{
1312
self, ImplSource, Obligation, ObligationCause, SelectionContext,
1413
};
@@ -92,7 +91,7 @@ impl Qualif for HasMutInterior {
9291
}
9392

9493
fn in_any_value_of_ty<'tcx>(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> bool {
95-
!ty.is_freeze(cx.tcx.at(DUMMY_SP), cx.param_env)
94+
!ty.is_freeze(cx.tcx, cx.param_env)
9695
}
9796

9897
fn in_adt_inherently<'tcx>(

compiler/rustc_const_eval/src/transform/check_consts/resolver.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use rustc_middle::mir::{self, BasicBlock, Local, Location, Statement, StatementK
88
use rustc_mir_dataflow::fmt::DebugWithContext;
99
use rustc_mir_dataflow::JoinSemiLattice;
1010
use rustc_mir_dataflow::{Analysis, AnalysisDomain, CallReturnPlaces};
11-
use rustc_span::DUMMY_SP;
1211

1312
use std::fmt;
1413
use std::marker::PhantomData;
@@ -120,10 +119,7 @@ where
120119
///
121120
/// [rust-lang/unsafe-code-guidelines#134]: https://github.com/rust-lang/unsafe-code-guidelines/issues/134
122121
fn shared_borrow_allows_mutation(&self, place: mir::Place<'tcx>) -> bool {
123-
!place
124-
.ty(self.ccx.body, self.ccx.tcx)
125-
.ty
126-
.is_freeze(self.ccx.tcx.at(DUMMY_SP), self.ccx.param_env)
122+
!place.ty(self.ccx.body, self.ccx.tcx).ty.is_freeze(self.ccx.tcx, self.ccx.param_env)
127123
}
128124
}
129125

compiler/rustc_const_eval/src/transform/validate.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,8 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
235235
// `Operand::Copy` is only supposed to be used with `Copy` types.
236236
if let Operand::Copy(place) = operand {
237237
let ty = place.ty(&self.body.local_decls, self.tcx).ty;
238-
let span = self.body.source_info(location).span;
239238

240-
if !ty.is_copy_modulo_regions(self.tcx.at(span), self.param_env) {
239+
if !ty.is_copy_modulo_regions(self.tcx, self.param_env) {
241240
self.fail(location, format!("`Operand::Copy` with non-`Copy` type {}", ty));
242241
}
243242
}

0 commit comments

Comments
 (0)