Skip to content

Commit 5085fe3

Browse files
committed
Auto merge of rust-lang#2977 - RalfJung:rustup, r=RalfJung
Rustup
2 parents 3ea096a + d1e1f76 commit 5085fe3

File tree

304 files changed

+3862
-1620
lines changed

Some content is hidden

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

304 files changed

+3862
-1620
lines changed

.github/workflows/ci.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ jobs:
315315
NO_DEBUG_ASSERTIONS: 1
316316
NO_OVERFLOW_CHECKS: 1
317317
DIST_REQUIRE_ALL_TOOLS: 1
318-
os: macos-latest
318+
os: macos-13
319319
- name: dist-apple-various
320320
env:
321321
SCRIPT: "./x.py dist bootstrap --include-default-paths --host='' --target=aarch64-apple-ios,x86_64-apple-ios,aarch64-apple-ios-sim"
@@ -326,7 +326,7 @@ jobs:
326326
NO_LLVM_ASSERTIONS: 1
327327
NO_DEBUG_ASSERTIONS: 1
328328
NO_OVERFLOW_CHECKS: 1
329-
os: macos-latest
329+
os: macos-13
330330
- name: dist-x86_64-apple-alt
331331
env:
332332
SCRIPT: "./x.py dist bootstrap --include-default-paths"
@@ -337,7 +337,7 @@ jobs:
337337
NO_LLVM_ASSERTIONS: 1
338338
NO_DEBUG_ASSERTIONS: 1
339339
NO_OVERFLOW_CHECKS: 1
340-
os: macos-latest
340+
os: macos-13
341341
- name: x86_64-apple-1
342342
env:
343343
SCRIPT: "./x.py --stage 2 test --exclude tests/ui --exclude tests/rustdoc --exclude tests/run-make-fulldeps"
@@ -348,7 +348,7 @@ jobs:
348348
NO_LLVM_ASSERTIONS: 1
349349
NO_DEBUG_ASSERTIONS: 1
350350
NO_OVERFLOW_CHECKS: 1
351-
os: macos-latest
351+
os: macos-13
352352
- name: x86_64-apple-2
353353
env:
354354
SCRIPT: "./x.py --stage 2 test tests/ui tests/rustdoc tests/run-make-fulldeps"
@@ -359,7 +359,7 @@ jobs:
359359
NO_LLVM_ASSERTIONS: 1
360360
NO_DEBUG_ASSERTIONS: 1
361361
NO_OVERFLOW_CHECKS: 1
362-
os: macos-latest
362+
os: macos-13
363363
- name: dist-aarch64-apple
364364
env:
365365
SCRIPT: "./x.py dist bootstrap --include-default-paths --stage 2"
@@ -374,7 +374,7 @@ jobs:
374374
NO_OVERFLOW_CHECKS: 1
375375
DIST_REQUIRE_ALL_TOOLS: 1
376376
JEMALLOC_SYS_WITH_LG_PAGE: 14
377-
os: macos-latest
377+
os: macos-13
378378
- name: x86_64-msvc
379379
env:
380380
RUST_CONFIGURE_ARGS: "--build=x86_64-pc-windows-msvc --enable-profiler"

Cargo.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -3021,7 +3021,6 @@ dependencies = [
30213021
name = "rls"
30223022
version = "2.0.0"
30233023
dependencies = [
3024-
"serde",
30253024
"serde_json",
30263025
]
30273026

@@ -4234,6 +4233,7 @@ dependencies = [
42344233
"rustc_hir",
42354234
"rustc_middle",
42364235
"rustc_span",
4236+
"rustc_target",
42374237
"scoped-tls",
42384238
"tracing",
42394239
]

compiler/rustc_ast_passes/src/ast_validation.rs

+16-15
Original file line numberDiff line numberDiff line change
@@ -1300,33 +1300,34 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
13001300
});
13011301
}
13021302
}
1303-
AssocItemKind::Type(box TyAlias {
1304-
generics,
1305-
where_clauses,
1306-
where_predicates_split,
1307-
bounds,
1308-
ty,
1309-
..
1310-
}) => {
1303+
AssocItemKind::Type(box TyAlias { bounds, ty, .. }) => {
13111304
if ty.is_none() {
13121305
self.session.emit_err(errors::AssocTypeWithoutBody {
13131306
span: item.span,
13141307
replace_span: self.ending_semi_or_hi(item.span),
13151308
});
13161309
}
13171310
self.check_type_no_bounds(bounds, "`impl`s");
1318-
if ty.is_some() {
1319-
self.check_gat_where(
1320-
item.id,
1321-
generics.where_clause.predicates.split_at(*where_predicates_split).0,
1322-
*where_clauses,
1323-
);
1324-
}
13251311
}
13261312
_ => {}
13271313
}
13281314
}
13291315

1316+
if let AssocItemKind::Type(box TyAlias {
1317+
generics,
1318+
where_clauses,
1319+
where_predicates_split,
1320+
ty: Some(_),
1321+
..
1322+
}) = &item.kind
1323+
{
1324+
self.check_gat_where(
1325+
item.id,
1326+
generics.where_clause.predicates.split_at(*where_predicates_split).0,
1327+
*where_clauses,
1328+
);
1329+
}
1330+
13301331
if ctxt == AssocCtxt::Trait || self.in_trait_impl {
13311332
self.visibility_not_permitted(&item.vis, errors::VisibilityNotPermittedNote::TraitImpl);
13321333
if let AssocItemKind::Fn(box Fn { sig, .. }) = &item.kind {

compiler/rustc_borrowck/src/type_check/liveness/polonius.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct UseFactsExtractor<'me, 'tcx> {
2020
}
2121

2222
// A Visitor to walk through the MIR and extract point-wise facts
23-
impl UseFactsExtractor<'_, '_> {
23+
impl<'tcx> UseFactsExtractor<'_, 'tcx> {
2424
fn location_to_index(&self, location: Location) -> LocationIndex {
2525
self.location_table.mid_index(location)
2626
}
@@ -45,7 +45,7 @@ impl UseFactsExtractor<'_, '_> {
4545
self.path_accessed_at_base.push((path, self.location_to_index(location)));
4646
}
4747

48-
fn place_to_mpi(&self, place: &Place<'_>) -> Option<MovePathIndex> {
48+
fn place_to_mpi(&self, place: &Place<'tcx>) -> Option<MovePathIndex> {
4949
match self.move_data.rev_lookup.find(place.as_ref()) {
5050
LookupResult::Exact(mpi) => Some(mpi),
5151
LookupResult::Parent(mmpi) => mmpi,

compiler/rustc_codegen_llvm/src/common.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
290290
}
291291
};
292292
let llval = unsafe {
293-
llvm::LLVMRustConstInBoundsGEP2(
293+
llvm::LLVMConstInBoundsGEP2(
294294
self.type_i8(),
295295
self.const_bitcast(base_addr, self.type_i8p_ext(base_addr_space)),
296296
&self.const_usize(offset.bytes()),
@@ -320,7 +320,7 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
320320

321321
fn const_ptr_byte_offset(&self, base_addr: Self::Value, offset: abi::Size) -> Self::Value {
322322
unsafe {
323-
llvm::LLVMRustConstInBoundsGEP2(
323+
llvm::LLVMConstInBoundsGEP2(
324324
self.type_i8(),
325325
self.const_bitcast(base_addr, self.type_i8p()),
326326
&self.const_usize(offset.bytes()),

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,7 @@ extern "C" {
11551155
pub fn LLVMConstVector(ScalarConstantVals: *const &Value, Size: c_uint) -> &Value;
11561156

11571157
// Constant expressions
1158-
pub fn LLVMRustConstInBoundsGEP2<'a>(
1158+
pub fn LLVMConstInBoundsGEP2<'a>(
11591159
ty: &'a Type,
11601160
ConstantVal: &'a Value,
11611161
ConstantIndices: *const &'a Value,

compiler/rustc_codegen_ssa/src/back/metadata.rs

+13-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use object::{
1212

1313
use snap::write::FrameEncoder;
1414

15-
use object::elf::NT_GNU_PROPERTY_TYPE_0;
1615
use rustc_data_structures::memmap::Mmap;
1716
use rustc_data_structures::owned_slice::{try_slice_owned, OwnedSlice};
1817
use rustc_metadata::fs::METADATA_FILENAME;
@@ -124,7 +123,7 @@ fn add_gnu_property_note(
124123
let mut data: Vec<u8> = Vec::new();
125124
let n_namsz: u32 = 4; // Size of the n_name field
126125
let n_descsz: u32 = 16; // Size of the n_desc field
127-
let n_type: u32 = NT_GNU_PROPERTY_TYPE_0; // Type of note descriptor
126+
let n_type: u32 = object::elf::NT_GNU_PROPERTY_TYPE_0; // Type of note descriptor
128127
let header_values = [n_namsz, n_descsz, n_type];
129128
header_values.iter().for_each(|v| {
130129
data.extend_from_slice(&match endianness {
@@ -134,8 +133,8 @@ fn add_gnu_property_note(
134133
});
135134
data.extend_from_slice(b"GNU\0"); // Owner of the program property note
136135
let pr_type: u32 = match architecture {
137-
Architecture::X86_64 => 0xc0000002,
138-
Architecture::Aarch64 => 0xc0000000,
136+
Architecture::X86_64 => object::elf::GNU_PROPERTY_X86_FEATURE_1_AND,
137+
Architecture::Aarch64 => object::elf::GNU_PROPERTY_AARCH64_FEATURE_1_AND,
139138
_ => unreachable!(),
140139
};
141140
let pr_datasz: u32 = 4; //size of the pr_data field
@@ -243,8 +242,16 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
243242
s if s.contains("r6") => elf::EF_MIPS_ARCH_32R6,
244243
_ => elf::EF_MIPS_ARCH_32R2,
245244
};
246-
// The only ABI LLVM supports for 32-bit MIPS CPUs is o32.
247-
let mut e_flags = elf::EF_MIPS_CPIC | elf::EF_MIPS_ABI_O32 | arch;
245+
246+
let mut e_flags = elf::EF_MIPS_CPIC | arch;
247+
248+
// If the ABI is explicitly given, use it or default to O32.
249+
match sess.target.options.llvm_abiname.to_lowercase().as_str() {
250+
"n32" => e_flags |= elf::EF_MIPS_ABI2,
251+
"o32" => e_flags |= elf::EF_MIPS_ABI_O32,
252+
_ => e_flags |= elf::EF_MIPS_ABI_O32,
253+
};
254+
248255
if sess.target.options.relocation_model != RelocModel::Static {
249256
e_flags |= elf::EF_MIPS_PIC;
250257
}

compiler/rustc_const_eval/src/const_eval/machine.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use rustc_target::spec::abi::Abi as CallAbi;
2222

2323
use crate::errors::{LongRunning, LongRunningWarn};
2424
use crate::interpret::{
25-
self, compile_time_machine, AllocId, ConstAllocation, FnVal, Frame, ImmTy, InterpCx,
25+
self, compile_time_machine, AllocId, ConstAllocation, FnArg, FnVal, Frame, ImmTy, InterpCx,
2626
InterpResult, OpTy, PlaceTy, Pointer, Scalar,
2727
};
2828
use crate::{errors, fluent_generated as fluent};
@@ -201,7 +201,7 @@ impl<'mir, 'tcx: 'mir> CompileTimeEvalContext<'mir, 'tcx> {
201201
fn hook_special_const_fn(
202202
&mut self,
203203
instance: ty::Instance<'tcx>,
204-
args: &[OpTy<'tcx>],
204+
args: &[FnArg<'tcx>],
205205
dest: &PlaceTy<'tcx>,
206206
ret: Option<mir::BasicBlock>,
207207
) -> InterpResult<'tcx, Option<ty::Instance<'tcx>>> {
@@ -210,6 +210,7 @@ impl<'mir, 'tcx: 'mir> CompileTimeEvalContext<'mir, 'tcx> {
210210
if Some(def_id) == self.tcx.lang_items().panic_display()
211211
|| Some(def_id) == self.tcx.lang_items().begin_panic_fn()
212212
{
213+
let args = self.copy_fn_args(args)?;
213214
// &str or &&str
214215
assert!(args.len() == 1);
215216

@@ -236,8 +237,9 @@ impl<'mir, 'tcx: 'mir> CompileTimeEvalContext<'mir, 'tcx> {
236237

237238
return Ok(Some(new_instance));
238239
} else if Some(def_id) == self.tcx.lang_items().align_offset_fn() {
240+
let args = self.copy_fn_args(args)?;
239241
// For align_offset, we replace the function call if the pointer has no address.
240-
match self.align_offset(instance, args, dest, ret)? {
242+
match self.align_offset(instance, &args, dest, ret)? {
241243
ControlFlow::Continue(()) => return Ok(Some(instance)),
242244
ControlFlow::Break(()) => return Ok(None),
243245
}
@@ -293,7 +295,7 @@ impl<'mir, 'tcx: 'mir> CompileTimeEvalContext<'mir, 'tcx> {
293295
self.eval_fn_call(
294296
FnVal::Instance(instance),
295297
(CallAbi::Rust, fn_abi),
296-
&[addr, align],
298+
&[FnArg::Copy(addr), FnArg::Copy(align)],
297299
/* with_caller_location = */ false,
298300
dest,
299301
ret,
@@ -427,7 +429,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
427429
ecx: &mut InterpCx<'mir, 'tcx, Self>,
428430
instance: ty::Instance<'tcx>,
429431
_abi: CallAbi,
430-
args: &[OpTy<'tcx>],
432+
args: &[FnArg<'tcx>],
431433
dest: &PlaceTy<'tcx>,
432434
ret: Option<mir::BasicBlock>,
433435
_unwind: mir::UnwindAction, // unwinding is not supported in consts

compiler/rustc_const_eval/src/interpret/eval_context.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -682,11 +682,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
682682
return_to_block: StackPopCleanup,
683683
) -> InterpResult<'tcx> {
684684
trace!("body: {:#?}", body);
685-
// Clobber previous return place contents, nobody is supposed to be able to see them any more
686-
// This also checks dereferenceable, but not align. We rely on all constructed places being
687-
// sufficiently aligned (in particular we rely on `deref_operand` checking alignment).
688-
self.write_uninit(return_place)?;
689-
// first push a stack frame so we have access to the local substs
685+
// First push a stack frame so we have access to the local substs
690686
let pre_frame = Frame {
691687
body,
692688
loc: Right(body.span), // Span used for errors caused during preamble.
@@ -805,6 +801,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
805801
throw_ub_custom!(fluent::const_eval_unwind_past_top);
806802
}
807803

804+
M::before_stack_pop(self, self.frame())?;
805+
808806
// Copy return value. Must of course happen *before* we deallocate the locals.
809807
let copy_ret_result = if !unwinding {
810808
let op = self

compiler/rustc_const_eval/src/interpret/intern.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use super::{
3030
use crate::const_eval;
3131
use crate::errors::{DanglingPtrInFinal, UnsupportedUntypedPointer};
3232

33-
pub trait CompileTimeMachine<'mir, 'tcx, T> = Machine<
33+
pub trait CompileTimeMachine<'mir, 'tcx: 'mir, T> = Machine<
3434
'mir,
3535
'tcx,
3636
MemoryKind = T,

compiler/rustc_const_eval/src/interpret/machine.rs

+25-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_target::spec::abi::Abi as CallAbi;
1717
use crate::const_eval::CheckAlignment;
1818

1919
use super::{
20-
AllocBytes, AllocId, AllocRange, Allocation, ConstAllocation, Frame, ImmTy, InterpCx,
20+
AllocBytes, AllocId, AllocRange, Allocation, ConstAllocation, FnArg, Frame, ImmTy, InterpCx,
2121
InterpResult, MemoryKind, OpTy, Operand, PlaceTy, Pointer, Provenance, Scalar,
2222
};
2323

@@ -84,7 +84,7 @@ pub trait AllocMap<K: Hash + Eq, V> {
8484

8585
/// Methods of this trait signifies a point where CTFE evaluation would fail
8686
/// and some use case dependent behaviour can instead be applied.
87-
pub trait Machine<'mir, 'tcx>: Sized {
87+
pub trait Machine<'mir, 'tcx: 'mir>: Sized {
8888
/// Additional memory kinds a machine wishes to distinguish from the builtin ones
8989
type MemoryKind: Debug + std::fmt::Display + MayLeak + Eq + 'static;
9090

@@ -182,7 +182,7 @@ pub trait Machine<'mir, 'tcx>: Sized {
182182
ecx: &mut InterpCx<'mir, 'tcx, Self>,
183183
instance: ty::Instance<'tcx>,
184184
abi: CallAbi,
185-
args: &[OpTy<'tcx, Self::Provenance>],
185+
args: &[FnArg<'tcx, Self::Provenance>],
186186
destination: &PlaceTy<'tcx, Self::Provenance>,
187187
target: Option<mir::BasicBlock>,
188188
unwind: mir::UnwindAction,
@@ -194,7 +194,7 @@ pub trait Machine<'mir, 'tcx>: Sized {
194194
ecx: &mut InterpCx<'mir, 'tcx, Self>,
195195
fn_val: Self::ExtraFnVal,
196196
abi: CallAbi,
197-
args: &[OpTy<'tcx, Self::Provenance>],
197+
args: &[FnArg<'tcx, Self::Provenance>],
198198
destination: &PlaceTy<'tcx, Self::Provenance>,
199199
target: Option<mir::BasicBlock>,
200200
unwind: mir::UnwindAction,
@@ -418,6 +418,18 @@ pub trait Machine<'mir, 'tcx>: Sized {
418418
Ok(())
419419
}
420420

421+
/// Called on places used for in-place function argument and return value handling.
422+
///
423+
/// These places need to be protected to make sure the program cannot tell whether the
424+
/// argument/return value was actually copied or passed in-place..
425+
fn protect_in_place_function_argument(
426+
ecx: &mut InterpCx<'mir, 'tcx, Self>,
427+
place: &PlaceTy<'tcx, Self::Provenance>,
428+
) -> InterpResult<'tcx> {
429+
// Without an aliasing model, all we can do is put `Uninit` into the place.
430+
ecx.write_uninit(place)
431+
}
432+
421433
/// Called immediately before a new stack frame gets pushed.
422434
fn init_frame_extra(
423435
ecx: &mut InterpCx<'mir, 'tcx, Self>,
@@ -439,6 +451,14 @@ pub trait Machine<'mir, 'tcx>: Sized {
439451
Ok(())
440452
}
441453

454+
/// Called just before the return value is copied to the caller-provided return place.
455+
fn before_stack_pop(
456+
_ecx: &InterpCx<'mir, 'tcx, Self>,
457+
_frame: &Frame<'mir, 'tcx, Self::Provenance, Self::FrameExtra>,
458+
) -> InterpResult<'tcx> {
459+
Ok(())
460+
}
461+
442462
/// Called immediately after a stack frame got popped, but before jumping back to the caller.
443463
/// The `locals` have already been destroyed!
444464
fn after_stack_pop(
@@ -484,7 +504,7 @@ pub macro compile_time_machine(<$mir: lifetime, $tcx: lifetime>) {
484504
_ecx: &mut InterpCx<$mir, $tcx, Self>,
485505
fn_val: !,
486506
_abi: CallAbi,
487-
_args: &[OpTy<$tcx>],
507+
_args: &[FnArg<$tcx>],
488508
_destination: &PlaceTy<$tcx, Self::Provenance>,
489509
_target: Option<mir::BasicBlock>,
490510
_unwind: mir::UnwindAction,

compiler/rustc_const_eval/src/interpret/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pub use self::machine::{compile_time_machine, AllocMap, Machine, MayLeak, StackP
2626
pub use self::memory::{AllocKind, AllocRef, AllocRefMut, FnVal, Memory, MemoryKind};
2727
pub use self::operand::{ImmTy, Immediate, OpTy, Operand};
2828
pub use self::place::{MPlaceTy, MemPlace, MemPlaceMeta, Place, PlaceTy};
29+
pub use self::terminator::FnArg;
2930
pub use self::validity::{CtfeValidationMode, RefTracking};
3031
pub use self::visitor::{MutValueVisitor, Value, ValueVisitor};
3132

compiler/rustc_const_eval/src/interpret/operand.rs

-8
Original file line numberDiff line numberDiff line change
@@ -575,14 +575,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
575575
Ok(op)
576576
}
577577

578-
/// Evaluate a bunch of operands at once
579-
pub(super) fn eval_operands(
580-
&self,
581-
ops: &[mir::Operand<'tcx>],
582-
) -> InterpResult<'tcx, Vec<OpTy<'tcx, M::Provenance>>> {
583-
ops.iter().map(|op| self.eval_operand(op, None)).collect()
584-
}
585-
586578
fn eval_ty_constant(
587579
&self,
588580
val: ty::Const<'tcx>,

0 commit comments

Comments
 (0)