Skip to content

Commit 03109b6

Browse files
committed
Auto merge of rust-lang#3365 - rust-lang:rustup-2024-03-08, r=RalfJung
Automatic Rustup
2 parents df58a02 + 26ee689 commit 03109b6

File tree

500 files changed

+6936
-4157
lines changed

Some content is hidden

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

500 files changed

+6936
-4157
lines changed

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ pub fn lower_to_hir(tcx: TyCtxt<'_>, (): ()) -> hir::Crate<'_> {
427427
tcx.ensure_with_value().early_lint_checks(());
428428
tcx.ensure_with_value().debugger_visualizers(LOCAL_CRATE);
429429
tcx.ensure_with_value().get_lang_items(());
430-
let (mut resolver, krate) = tcx.resolver_for_lowering(()).steal();
430+
let (mut resolver, krate) = tcx.resolver_for_lowering().steal();
431431

432432
let ast_index = index_crate(&resolver.node_id_to_def_id, &krate);
433433
let mut owners = IndexVec::from_fn_n(

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -929,35 +929,38 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
929929
only_trait: only_trait.then_some(()),
930930
};
931931

932-
self.visibility_not_permitted(
933-
&item.vis,
934-
errors::VisibilityNotPermittedNote::IndividualImplItems,
935-
);
936-
if let &Unsafe::Yes(span) = unsafety {
937-
self.dcx().emit_err(errors::InherentImplCannotUnsafe {
938-
span: self_ty.span,
939-
annotation_span: span,
940-
annotation: "unsafe",
941-
self_ty: self_ty.span,
942-
});
943-
}
944-
if let &ImplPolarity::Negative(span) = polarity {
945-
self.dcx().emit_err(error(span, "negative", false));
946-
}
947-
if let &Defaultness::Default(def_span) = defaultness {
948-
self.dcx().emit_err(error(def_span, "`default`", true));
949-
}
950-
if let &Const::Yes(span) = constness {
951-
self.dcx().emit_err(error(span, "`const`", true));
952-
}
932+
self.with_in_trait_impl(None, |this| {
933+
this.visibility_not_permitted(
934+
&item.vis,
935+
errors::VisibilityNotPermittedNote::IndividualImplItems,
936+
);
937+
if let &Unsafe::Yes(span) = unsafety {
938+
this.dcx().emit_err(errors::InherentImplCannotUnsafe {
939+
span: self_ty.span,
940+
annotation_span: span,
941+
annotation: "unsafe",
942+
self_ty: self_ty.span,
943+
});
944+
}
945+
if let &ImplPolarity::Negative(span) = polarity {
946+
this.dcx().emit_err(error(span, "negative", false));
947+
}
948+
if let &Defaultness::Default(def_span) = defaultness {
949+
this.dcx().emit_err(error(def_span, "`default`", true));
950+
}
951+
if let &Const::Yes(span) = constness {
952+
this.dcx().emit_err(error(span, "`const`", true));
953+
}
953954

954-
self.visit_vis(&item.vis);
955-
self.visit_ident(item.ident);
956-
self.with_tilde_const(Some(DisallowTildeConstContext::Impl(item.span)), |this| {
957-
this.visit_generics(generics)
955+
this.visit_vis(&item.vis);
956+
this.visit_ident(item.ident);
957+
this.with_tilde_const(
958+
Some(DisallowTildeConstContext::Impl(item.span)),
959+
|this| this.visit_generics(generics),
960+
);
961+
this.visit_ty(self_ty);
962+
walk_list!(this, visit_assoc_item, items, AssocCtxt::Impl);
958963
});
959-
self.visit_ty(self_ty);
960-
walk_list!(self, visit_assoc_item, items, AssocCtxt::Impl);
961964
walk_list!(self, visit_attribute, &item.attrs);
962965
return; // Avoid visiting again.
963966
}

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
206206
);
207207
}
208208
}
209-
if !attr.is_doc_comment()
210-
&& let [seg, _] = attr.get_normal_item().path.segments.as_slice()
211-
&& seg.ident.name == sym::diagnostic
212-
&& !self.features.diagnostic_namespace
213-
{
214-
let msg = "`#[diagnostic]` attribute name space is experimental";
215-
gate!(self, diagnostic_namespace, seg.ident.span, msg);
216-
}
217209

218210
// Emit errors for non-staged-api crates.
219211
if !self.features.staged_api {

compiler/rustc_codegen_ssa/src/mir/place.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,6 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
104104
let mut simple = || {
105105
let llval = if offset.bytes() == 0 {
106106
self.llval
107-
} else if field.is_zst() {
108-
// FIXME(erikdesjardins): it should be fine to use inbounds for ZSTs too;
109-
// keeping this logic for now to preserve previous behavior.
110-
bx.ptradd(self.llval, bx.const_usize(offset.bytes()))
111107
} else {
112108
bx.inbounds_ptradd(self.llval, bx.const_usize(offset.bytes()))
113109
};
@@ -168,8 +164,7 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
168164
debug!("struct_field_ptr: DST field offset: {:?}", offset);
169165

170166
// Adjust pointer.
171-
// FIXME(erikdesjardins): should be able to use inbounds here too.
172-
let ptr = bx.ptradd(self.llval, offset);
167+
let ptr = bx.inbounds_ptradd(self.llval, offset);
173168

174169
PlaceRef { llval: ptr, llextra: self.llextra, layout: field, align: effective_field_align }
175170
}

compiler/rustc_const_eval/src/const_eval/machine.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use crate::errors::{LongRunning, LongRunningWarn};
2424
use crate::fluent_generated as fluent;
2525
use crate::interpret::{
2626
self, compile_time_machine, AllocId, AllocRange, ConstAllocation, CtfeProvenance, FnArg, FnVal,
27-
Frame, ImmTy, InterpCx, InterpResult, OpTy, PlaceTy, Pointer, PointerArithmetic, Scalar,
27+
Frame, ImmTy, InterpCx, InterpResult, MPlaceTy, OpTy, Pointer, PointerArithmetic, Scalar,
2828
};
2929

3030
use super::error::*;
@@ -219,7 +219,7 @@ impl<'mir, 'tcx: 'mir> CompileTimeEvalContext<'mir, 'tcx> {
219219
&mut self,
220220
instance: ty::Instance<'tcx>,
221221
args: &[FnArg<'tcx>],
222-
dest: &PlaceTy<'tcx>,
222+
dest: &MPlaceTy<'tcx>,
223223
ret: Option<mir::BasicBlock>,
224224
) -> InterpResult<'tcx, Option<ty::Instance<'tcx>>> {
225225
let def_id = instance.def_id();
@@ -280,7 +280,7 @@ impl<'mir, 'tcx: 'mir> CompileTimeEvalContext<'mir, 'tcx> {
280280
&mut self,
281281
instance: ty::Instance<'tcx>,
282282
args: &[OpTy<'tcx>],
283-
dest: &PlaceTy<'tcx>,
283+
dest: &MPlaceTy<'tcx>,
284284
ret: Option<mir::BasicBlock>,
285285
) -> InterpResult<'tcx, ControlFlow<()>> {
286286
assert_eq!(args.len(), 2);
@@ -410,7 +410,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
410410
orig_instance: ty::Instance<'tcx>,
411411
_abi: CallAbi,
412412
args: &[FnArg<'tcx>],
413-
dest: &PlaceTy<'tcx>,
413+
dest: &MPlaceTy<'tcx>,
414414
ret: Option<mir::BasicBlock>,
415415
_unwind: mir::UnwindAction, // unwinding is not supported in consts
416416
) -> InterpResult<'tcx, Option<(&'mir mir::Body<'tcx>, ty::Instance<'tcx>)>> {
@@ -455,7 +455,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
455455
ecx: &mut InterpCx<'mir, 'tcx, Self>,
456456
instance: ty::Instance<'tcx>,
457457
args: &[OpTy<'tcx>],
458-
dest: &PlaceTy<'tcx, Self::Provenance>,
458+
dest: &MPlaceTy<'tcx, Self::Provenance>,
459459
target: Option<mir::BasicBlock>,
460460
_unwind: mir::UnwindAction,
461461
) -> InterpResult<'tcx> {

compiler/rustc_const_eval/src/interpret/eval_context.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ pub struct Frame<'mir, 'tcx, Prov: Provenance = CtfeProvenance, Extra = ()> {
108108

109109
/// The location where the result of the current stack frame should be written to,
110110
/// and its layout in the caller.
111-
pub return_place: PlaceTy<'tcx, Prov>,
111+
pub return_place: MPlaceTy<'tcx, Prov>,
112112

113113
/// The list of locals for this stack frame, stored in order as
114114
/// `[return_ptr, arguments..., variables..., temporaries...]`.
@@ -771,7 +771,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
771771
&mut self,
772772
instance: ty::Instance<'tcx>,
773773
body: &'mir mir::Body<'tcx>,
774-
return_place: &PlaceTy<'tcx, M::Provenance>,
774+
return_place: &MPlaceTy<'tcx, M::Provenance>,
775775
return_to_block: StackPopCleanup,
776776
) -> InterpResult<'tcx> {
777777
trace!("body: {:#?}", body);
@@ -912,7 +912,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
912912
} else {
913913
self.copy_op_allow_transmute(&op, &dest)
914914
};
915-
trace!("return value: {:?}", self.dump_place(&dest));
915+
trace!("return value: {:?}", self.dump_place(&dest.into()));
916916
// We delay actually short-circuiting on this error until *after* the stack frame is
917917
// popped, since we want this error to be attributed to the caller, whose type defines
918918
// this transmute.

compiler/rustc_const_eval/src/interpret/intrinsics.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use rustc_span::symbol::{sym, Symbol};
2121
use rustc_target::abi::Size;
2222

2323
use super::{
24-
util::ensure_monomorphic_enough, CheckInAllocMsg, ImmTy, InterpCx, Machine, OpTy, PlaceTy,
24+
util::ensure_monomorphic_enough, CheckInAllocMsg, ImmTy, InterpCx, MPlaceTy, Machine, OpTy,
2525
Pointer,
2626
};
2727

@@ -104,7 +104,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
104104
&mut self,
105105
instance: ty::Instance<'tcx>,
106106
args: &[OpTy<'tcx, M::Provenance>],
107-
dest: &PlaceTy<'tcx, M::Provenance>,
107+
dest: &MPlaceTy<'tcx, M::Provenance>,
108108
ret: Option<mir::BasicBlock>,
109109
) -> InterpResult<'tcx, bool> {
110110
let instance_args = instance.args;
@@ -377,7 +377,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
377377
let index = u64::from(self.read_scalar(&args[1])?.to_u32()?);
378378
let elem = &args[2];
379379
let (input, input_len) = self.operand_to_simd(&args[0])?;
380-
let (dest, dest_len) = self.place_to_simd(dest)?;
380+
let (dest, dest_len) = self.mplace_to_simd(dest)?;
381381
assert_eq!(input_len, dest_len, "Return vector length must match input length");
382382
// Bounds are not checked by typeck so we have to do it ourselves.
383383
if index >= input_len {
@@ -430,7 +430,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
430430
_ => return Ok(false),
431431
}
432432

433-
trace!("{:?}", self.dump_place(dest));
433+
trace!("{:?}", self.dump_place(&dest.clone().into()));
434434
self.go_to_block(ret);
435435
Ok(true)
436436
}
@@ -488,7 +488,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
488488
&mut self,
489489
a: &ImmTy<'tcx, M::Provenance>,
490490
b: &ImmTy<'tcx, M::Provenance>,
491-
dest: &PlaceTy<'tcx, M::Provenance>,
491+
dest: &MPlaceTy<'tcx, M::Provenance>,
492492
) -> InterpResult<'tcx> {
493493
assert_eq!(a.layout.ty, b.layout.ty);
494494
assert!(matches!(a.layout.ty.kind(), ty::Int(..) | ty::Uint(..)));
@@ -506,7 +506,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
506506
)
507507
}
508508
// `Rem` says this is all right, so we can let `Div` do its job.
509-
self.binop_ignore_overflow(BinOp::Div, a, b, dest)
509+
self.binop_ignore_overflow(BinOp::Div, a, b, &dest.clone().into())
510510
}
511511

512512
pub fn saturating_arith(

compiler/rustc_const_eval/src/interpret/machine.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ pub trait Machine<'mir, 'tcx: 'mir>: Sized {
196196
instance: ty::Instance<'tcx>,
197197
abi: CallAbi,
198198
args: &[FnArg<'tcx, Self::Provenance>],
199-
destination: &PlaceTy<'tcx, Self::Provenance>,
199+
destination: &MPlaceTy<'tcx, Self::Provenance>,
200200
target: Option<mir::BasicBlock>,
201201
unwind: mir::UnwindAction,
202202
) -> InterpResult<'tcx, Option<(&'mir mir::Body<'tcx>, ty::Instance<'tcx>)>>;
@@ -208,7 +208,7 @@ pub trait Machine<'mir, 'tcx: 'mir>: Sized {
208208
fn_val: Self::ExtraFnVal,
209209
abi: CallAbi,
210210
args: &[FnArg<'tcx, Self::Provenance>],
211-
destination: &PlaceTy<'tcx, Self::Provenance>,
211+
destination: &MPlaceTy<'tcx, Self::Provenance>,
212212
target: Option<mir::BasicBlock>,
213213
unwind: mir::UnwindAction,
214214
) -> InterpResult<'tcx>;
@@ -219,7 +219,7 @@ pub trait Machine<'mir, 'tcx: 'mir>: Sized {
219219
ecx: &mut InterpCx<'mir, 'tcx, Self>,
220220
instance: ty::Instance<'tcx>,
221221
args: &[OpTy<'tcx, Self::Provenance>],
222-
destination: &PlaceTy<'tcx, Self::Provenance>,
222+
destination: &MPlaceTy<'tcx, Self::Provenance>,
223223
target: Option<mir::BasicBlock>,
224224
unwind: mir::UnwindAction,
225225
) -> InterpResult<'tcx>;
@@ -584,7 +584,7 @@ pub macro compile_time_machine(<$mir: lifetime, $tcx: lifetime>) {
584584
fn_val: !,
585585
_abi: CallAbi,
586586
_args: &[FnArg<$tcx>],
587-
_destination: &PlaceTy<$tcx, Self::Provenance>,
587+
_destination: &MPlaceTy<$tcx, Self::Provenance>,
588588
_target: Option<mir::BasicBlock>,
589589
_unwind: mir::UnwindAction,
590590
) -> InterpResult<$tcx> {

compiler/rustc_const_eval/src/interpret/place.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@ pub(super) enum Place<Prov: Provenance = CtfeProvenance> {
194194
Local { frame: usize, local: mir::Local, offset: Option<Size> },
195195
}
196196

197+
/// An evaluated place, together with its type.
198+
///
199+
/// This may reference a stack frame by its index, so `PlaceTy` should generally not be kept around
200+
/// for longer than a single operation. Popping and then pushing a stack frame can make `PlaceTy`
201+
/// point to the wrong destination. If the interpreter has multiple stacks, stack switching will
202+
/// also invalidate a `PlaceTy`.
197203
#[derive(Clone)]
198204
pub struct PlaceTy<'tcx, Prov: Provenance = CtfeProvenance> {
199205
place: Place<Prov>, // Keep this private; it helps enforce invariants.
@@ -495,16 +501,6 @@ where
495501
Ok((mplace, len))
496502
}
497503

498-
/// Converts a repr(simd) place into a place where `place_index` accesses the SIMD elements.
499-
/// Also returns the number of elements.
500-
pub fn place_to_simd(
501-
&mut self,
502-
place: &PlaceTy<'tcx, M::Provenance>,
503-
) -> InterpResult<'tcx, (MPlaceTy<'tcx, M::Provenance>, u64)> {
504-
let mplace = self.force_allocation(place)?;
505-
self.mplace_to_simd(&mplace)
506-
}
507-
508504
pub fn local_to_place(
509505
&self,
510506
frame: usize,

compiler/rustc_const_eval/src/interpret/terminator.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
153153
),
154154
};
155155

156-
let destination = self.eval_place(destination)?;
156+
let destination = self.force_allocation(&self.eval_place(destination)?)?;
157157
self.eval_fn_call(
158158
fn_val,
159159
(fn_sig.abi, fn_abi),
@@ -497,7 +497,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
497497
(caller_abi, caller_fn_abi): (Abi, &FnAbi<'tcx, Ty<'tcx>>),
498498
args: &[FnArg<'tcx, M::Provenance>],
499499
with_caller_location: bool,
500-
destination: &PlaceTy<'tcx, M::Provenance>,
500+
destination: &MPlaceTy<'tcx, M::Provenance>,
501501
target: Option<mir::BasicBlock>,
502502
mut unwind: mir::UnwindAction,
503503
) -> InterpResult<'tcx> {
@@ -726,7 +726,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
726726
});
727727
}
728728
// Protect return place for in-place return value passing.
729-
M::protect_in_place_function_argument(self, destination)?;
729+
M::protect_in_place_function_argument(self, &destination.clone().into())?;
730730

731731
// Don't forget to mark "initially live" locals as live.
732732
self.storage_live_for_always_live_locals()?;

compiler/rustc_driver_impl/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ fn run_compiler(
418418
}
419419

420420
// Make sure name resolution and macro expansion is run.
421-
queries.global_ctxt()?.enter(|tcx| tcx.resolver_for_lowering(()));
421+
queries.global_ctxt()?.enter(|tcx| tcx.resolver_for_lowering());
422422

423423
if callbacks.after_expansion(compiler, queries) == Compilation::Stop {
424424
return early_exit();

compiler/rustc_driver_impl/src/pretty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ impl<'tcx> PrintExtra<'tcx> {
229229
{
230230
match self {
231231
PrintExtra::AfterParsing { krate, .. } => f(krate),
232-
PrintExtra::NeedsAstMap { tcx } => f(&tcx.resolver_for_lowering(()).borrow().1),
232+
PrintExtra::NeedsAstMap { tcx } => f(&tcx.resolver_for_lowering().borrow().1),
233233
}
234234
}
235235

@@ -281,7 +281,7 @@ pub fn print<'tcx>(sess: &Session, ppm: PpMode, ex: PrintExtra<'tcx>) {
281281
}
282282
AstTreeExpanded => {
283283
debug!("pretty-printing expanded AST");
284-
format!("{:#?}", ex.tcx().resolver_for_lowering(()).borrow().1)
284+
format!("{:#?}", ex.tcx().resolver_for_lowering().borrow().1)
285285
}
286286
Hir(s) => {
287287
debug!("pretty printing HIR {:?}", s);

compiler/rustc_feature/src/accepted.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ declare_features! (
146146
(accepted, derive_default_enum, "1.62.0", Some(86985)),
147147
/// Allows the use of destructuring assignments.
148148
(accepted, destructuring_assignment, "1.59.0", Some(71126)),
149+
/// Allows using the `#[diagnostic]` attribute tool namespace
150+
(accepted, diagnostic_namespace, "CURRENT_RUSTC_VERSION", Some(111996)),
149151
/// Allows `#[doc(alias = "...")]`.
150152
(accepted, doc_alias, "1.48.0", Some(50146)),
151153
/// Allows `..` in tuple (struct) patterns.

compiler/rustc_feature/src/unstable.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,6 @@ declare_features! (
436436
(unstable, deprecated_safe, "1.61.0", Some(94978)),
437437
/// Allows having using `suggestion` in the `#[deprecated]` attribute.
438438
(unstable, deprecated_suggestion, "1.61.0", Some(94785)),
439-
/// Allows using the `#[diagnostic]` attribute tool namespace
440-
(unstable, diagnostic_namespace, "1.73.0", Some(111996)),
441439
/// Controls errors in trait implementations.
442440
(unstable, do_not_recommend, "1.67.0", Some(51992)),
443441
/// Tells rustdoc to automatically generate `#[doc(cfg(...))]`.

0 commit comments

Comments
 (0)