Skip to content

Commit a839fbf

Browse files
authored
Merge pull request #4021 from RalfJung/rustup
Rustup
2 parents 5ff90d0 + a01f37c commit a839fbf

File tree

168 files changed

+5529
-2605
lines changed

Some content is hidden

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

168 files changed

+5529
-2605
lines changed

Diff for: compiler/rustc_abi/src/lib.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -1743,15 +1743,23 @@ pub enum PointerKind {
17431743
Box { unpin: bool, global: bool },
17441744
}
17451745

1746-
/// Note that this information is advisory only, and backends are free to ignore it.
1747-
/// It can only be used to encode potential optimizations, but no critical information.
1746+
/// Encodes extra information we have about a pointer.
1747+
/// Note that this information is advisory only, and backends are free to ignore it:
1748+
/// if the information is wrong, that can cause UB, but if the information is absent,
1749+
/// that must always be okay.
17481750
#[derive(Copy, Clone, Debug)]
17491751
pub struct PointeeInfo {
1750-
pub size: Size,
1751-
pub align: Align,
17521752
/// If this is `None`, then this is a raw pointer, so size and alignment are not guaranteed to
17531753
/// be reliable.
17541754
pub safe: Option<PointerKind>,
1755+
/// If `safe` is `Some`, then the pointer is either null or dereferenceable for this many bytes.
1756+
/// On a function argument, "dereferenceable" here means "dereferenceable for the entire duration
1757+
/// of this function call", i.e. it is UB for the memory that this pointer points to to be freed
1758+
/// while this function is still running.
1759+
/// The size can be zero if the pointer is not dereferenceable.
1760+
pub size: Size,
1761+
/// If `safe` is `Some`, then the pointer is aligned as indicated.
1762+
pub align: Align,
17551763
}
17561764

17571765
impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {

Diff for: compiler/rustc_ast_lowering/src/asm.rs

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
4848
| asm::InlineAsmArch::RiscV32
4949
| asm::InlineAsmArch::RiscV64
5050
| asm::InlineAsmArch::LoongArch64
51+
| asm::InlineAsmArch::S390x
5152
);
5253
if !is_stable && !self.tcx.features().asm_experimental_arch() {
5354
feature_err(

Diff for: compiler/rustc_borrowck/src/region_infer/opaque_types.rs

+1-89
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
use rustc_data_structures::fx::FxIndexMap;
22
use rustc_errors::ErrorGuaranteed;
3-
use rustc_hir::OpaqueTyOrigin;
4-
use rustc_hir::def::DefKind;
53
use rustc_hir::def_id::LocalDefId;
64
use rustc_infer::infer::{InferCtxt, NllRegionVariableOrigin, TyCtxtInferExt as _};
7-
use rustc_infer::traits::{Obligation, ObligationCause};
85
use rustc_macros::extension;
96
use rustc_middle::ty::visit::TypeVisitableExt;
107
use rustc_middle::ty::{
118
self, GenericArgKind, GenericArgs, OpaqueHiddenType, OpaqueTypeKey, Ty, TyCtxt, TypeFoldable,
129
TypingMode,
1310
};
1411
use rustc_span::Span;
15-
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
1612
use rustc_trait_selection::traits::ObligationCtxt;
1713
use tracing::{debug, instrument};
1814

@@ -303,91 +299,7 @@ impl<'tcx> InferCtxt<'tcx> {
303299
return Ty::new_error(self.tcx, e);
304300
}
305301

306-
// `definition_ty` does not live in of the current inference context,
307-
// so lets make sure that we don't accidentally misuse our current `infcx`.
308-
match check_opaque_type_well_formed(
309-
self.tcx,
310-
self.next_trait_solver(),
311-
opaque_type_key.def_id,
312-
instantiated_ty.span,
313-
definition_ty,
314-
) {
315-
Ok(hidden_ty) => hidden_ty,
316-
Err(guar) => Ty::new_error(self.tcx, guar),
317-
}
318-
}
319-
}
320-
321-
/// This logic duplicates most of `check_opaque_meets_bounds`.
322-
/// FIXME(oli-obk): Also do region checks here and then consider removing
323-
/// `check_opaque_meets_bounds` entirely.
324-
fn check_opaque_type_well_formed<'tcx>(
325-
tcx: TyCtxt<'tcx>,
326-
next_trait_solver: bool,
327-
def_id: LocalDefId,
328-
definition_span: Span,
329-
definition_ty: Ty<'tcx>,
330-
) -> Result<Ty<'tcx>, ErrorGuaranteed> {
331-
// Only check this for TAIT. RPIT already supports `tests/ui/impl-trait/nested-return-type2.rs`
332-
// on stable and we'd break that.
333-
let opaque_ty_hir = tcx.hir().expect_opaque_ty(def_id);
334-
let OpaqueTyOrigin::TyAlias { .. } = opaque_ty_hir.origin else {
335-
return Ok(definition_ty);
336-
};
337-
let param_env = tcx.param_env(def_id);
338-
339-
let mut parent_def_id = def_id;
340-
while tcx.def_kind(parent_def_id) == DefKind::OpaqueTy {
341-
parent_def_id = tcx.local_parent(parent_def_id);
342-
}
343-
344-
// FIXME(#132279): This should eventually use the already defined hidden types
345-
// instead. Alternatively we'll entirely remove this function given we also check
346-
// the opaque in `check_opaque_meets_bounds` later.
347-
let infcx = tcx
348-
.infer_ctxt()
349-
.with_next_trait_solver(next_trait_solver)
350-
.build(TypingMode::analysis_in_body(tcx, parent_def_id));
351-
let ocx = ObligationCtxt::new_with_diagnostics(&infcx);
352-
let identity_args = GenericArgs::identity_for_item(tcx, def_id);
353-
354-
// Require that the hidden type actually fulfills all the bounds of the opaque type, even without
355-
// the bounds that the function supplies.
356-
let opaque_ty = Ty::new_opaque(tcx, def_id.to_def_id(), identity_args);
357-
ocx.eq(&ObligationCause::misc(definition_span, def_id), param_env, opaque_ty, definition_ty)
358-
.map_err(|err| {
359-
infcx
360-
.err_ctxt()
361-
.report_mismatched_types(
362-
&ObligationCause::misc(definition_span, def_id),
363-
param_env,
364-
opaque_ty,
365-
definition_ty,
366-
err,
367-
)
368-
.emit()
369-
})?;
370-
371-
// Require the hidden type to be well-formed with only the generics of the opaque type.
372-
// Defining use functions may have more bounds than the opaque type, which is ok, as long as the
373-
// hidden type is well formed even without those bounds.
374-
let predicate = ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(
375-
definition_ty.into(),
376-
)));
377-
ocx.register_obligation(Obligation::misc(tcx, definition_span, def_id, param_env, predicate));
378-
379-
// Check that all obligations are satisfied by the implementation's
380-
// version.
381-
let errors = ocx.select_all_or_error();
382-
383-
// This is fishy, but we check it again in `check_opaque_meets_bounds`.
384-
// Remove once we can prepopulate with known hidden types.
385-
let _ = infcx.take_opaque_types();
386-
387-
if errors.is_empty() {
388-
Ok(definition_ty)
389-
} else {
390-
Err(infcx.err_ctxt().report_fulfillment_errors(errors))
302+
definition_ty
391303
}
392304
}
393305

Diff for: compiler/rustc_codegen_cranelift/patches/0022-coretests-Disable-not-compiling-tests.patch

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ index 42a26ae..5ac1042 100644
3838
@@ -1,3 +1,4 @@
3939
+#![cfg(test)]
4040
// tidy-alphabetical-start
41+
#![cfg_attr(bootstrap, feature(const_three_way_compare))]
4142
#![cfg_attr(bootstrap, feature(strict_provenance))]
42-
#![cfg_attr(not(bootstrap), feature(strict_provenance_lints))]
4343
--
4444
2.21.0 (Apple Git-122)

Diff for: compiler/rustc_codegen_cranelift/patches/0027-coretests-128bit-atomic-operations.patch

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ index 1e336bf..35e6f54 100644
1515
--- a/lib.rs
1616
+++ b/lib.rs
1717
@@ -2,7 +2,6 @@
18-
// tidy-alphabetical-start
18+
#![cfg_attr(bootstrap, feature(const_three_way_compare))]
1919
#![cfg_attr(bootstrap, feature(strict_provenance))]
2020
#![cfg_attr(not(bootstrap), feature(strict_provenance_lints))]
2121
-#![cfg_attr(target_has_atomic = "128", feature(integer_atomics))]

Diff for: compiler/rustc_codegen_cranelift/rust-toolchain

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[toolchain]
2-
channel = "nightly-2024-11-02"
2+
channel = "nightly-2024-11-09"
33
components = ["rust-src", "rustc-dev", "llvm-tools"]
44
profile = "minimal"

Diff for: compiler/rustc_codegen_cranelift/scripts/test_bootstrap.sh

+17
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,22 @@ rm -r compiler/rustc_codegen_cranelift/{Cargo.*,src}
1111
cp ../Cargo.* compiler/rustc_codegen_cranelift/
1212
cp -r ../src compiler/rustc_codegen_cranelift/src
1313

14+
# FIXME(rust-lang/rust#132719) remove once it doesn't break without this patch
15+
cat <<EOF | git apply -
16+
diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs
17+
index 3394f2a84a0..cb980dd4d7c 100644
18+
--- a/src/bootstrap/src/core/build_steps/compile.rs
19+
+++ b/src/bootstrap/src/core/build_steps/compile.rs
20+
@@ -1976,7 +1976,7 @@ fn run(self, builder: &Builder<'_>) -> Compiler {
21+
}
22+
}
23+
24+
- {
25+
+ if builder.config.llvm_enabled(target_compiler.host) && builder.config.llvm_tools_enabled {
26+
// \`llvm-strip\` is used by rustc, which is actually just a symlink to \`llvm-objcopy\`,
27+
// so copy and rename \`llvm-objcopy\`.
28+
let src_exe = exe("llvm-objcopy", target_compiler.host);
29+
EOF
30+
1431
./x.py build --stage 1 library/std
1532
popd

Diff for: compiler/rustc_codegen_cranelift/src/abi/comments.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
use std::borrow::Cow;
55

6-
use rustc_target::abi::call::PassMode;
6+
use rustc_target::callconv::PassMode;
77

88
use crate::prelude::*;
99

Diff for: compiler/rustc_codegen_cranelift/src/abi/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use std::mem;
1010
use cranelift_codegen::ir::{ArgumentPurpose, SigRef};
1111
use cranelift_codegen::isa::CallConv;
1212
use cranelift_module::ModuleError;
13+
use rustc_abi::ExternAbi;
1314
use rustc_codegen_ssa::base::is_call_from_compiler_builtins_to_upstream_monomorphization;
1415
use rustc_codegen_ssa::errors::CompilerBuiltinsCannotCall;
1516
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
@@ -18,8 +19,7 @@ use rustc_middle::ty::layout::FnAbiOf;
1819
use rustc_middle::ty::print::with_no_trimmed_paths;
1920
use rustc_session::Session;
2021
use rustc_span::source_map::Spanned;
21-
use rustc_target::abi::call::{Conv, FnAbi, PassMode};
22-
use rustc_target::spec::abi::Abi;
22+
use rustc_target::callconv::{Conv, FnAbi, PassMode};
2323

2424
use self::pass_mode::*;
2525
pub(crate) use self::returning::codegen_return;
@@ -443,7 +443,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
443443
RevealAllLayoutCx(fx.tcx).fn_abi_of_fn_ptr(fn_sig, extra_args)
444444
};
445445

446-
let is_cold = if fn_sig.abi() == Abi::RustCold {
446+
let is_cold = if fn_sig.abi() == ExternAbi::RustCold {
447447
true
448448
} else {
449449
instance.is_some_and(|inst| {
@@ -458,7 +458,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
458458
}
459459

460460
// Unpack arguments tuple for closures
461-
let mut args = if fn_sig.abi() == Abi::RustCall {
461+
let mut args = if fn_sig.abi() == ExternAbi::RustCall {
462462
let (self_arg, pack_arg) = match args {
463463
[pack_arg] => (None, codegen_call_argument_operand(fx, &pack_arg.node)),
464464
[self_arg, pack_arg] => (

Diff for: compiler/rustc_codegen_cranelift/src/abi/pass_mode.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
//! Argument passing
22
33
use cranelift_codegen::ir::{ArgumentExtension, ArgumentPurpose};
4-
use rustc_target::abi::call::{
5-
ArgAbi, ArgAttributes, ArgExtension as RustcArgExtension, CastTarget, PassMode, Reg, RegKind,
4+
use rustc_abi::{Reg, RegKind};
5+
use rustc_target::callconv::{
6+
ArgAbi, ArgAttributes, ArgExtension as RustcArgExtension, CastTarget, PassMode,
67
};
78
use smallvec::{SmallVec, smallvec};
89

Diff for: compiler/rustc_codegen_cranelift/src/abi/returning.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Return value handling
22
3-
use rustc_target::abi::call::{ArgAbi, PassMode};
3+
use rustc_target::callconv::{ArgAbi, PassMode};
44
use smallvec::{SmallVec, smallvec};
55

66
use crate::prelude::*;

Diff for: compiler/rustc_codegen_cranelift/src/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ fn codegen_stmt<'tcx>(
934934
let dst = codegen_operand(fx, dst);
935935
let pointee = dst
936936
.layout()
937-
.pointee_info_at(fx, rustc_target::abi::Size::ZERO)
937+
.pointee_info_at(fx, rustc_abi::Size::ZERO)
938938
.expect("Expected pointer");
939939
let dst = dst.load_scalar(fx);
940940
let src = codegen_operand(fx, src).load_scalar(fx);

Diff for: compiler/rustc_codegen_cranelift/src/common.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use cranelift_codegen::isa::TargetFrontendConfig;
22
use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext};
3+
use rustc_abi::{Float, Integer, Primitive};
34
use rustc_index::IndexVec;
45
use rustc_middle::ty::TypeFoldable;
56
use rustc_middle::ty::layout::{
67
self, FnAbiError, FnAbiOfHelpers, FnAbiRequest, LayoutError, LayoutOfHelpers,
78
};
89
use rustc_span::source_map::Spanned;
9-
use rustc_target::abi::call::FnAbi;
10-
use rustc_target::abi::{Float, Integer, Primitive};
10+
use rustc_target::callconv::FnAbi;
1111
use rustc_target::spec::{HasTargetSpec, Target};
1212

1313
use crate::constant::ConstantCx;
@@ -162,8 +162,8 @@ pub(crate) fn codegen_icmp_imm(
162162
pub(crate) fn codegen_bitcast(fx: &mut FunctionCx<'_, '_, '_>, dst_ty: Type, val: Value) -> Value {
163163
let mut flags = MemFlags::new();
164164
flags.set_endianness(match fx.tcx.data_layout.endian {
165-
rustc_target::abi::Endian::Big => cranelift_codegen::ir::Endianness::Big,
166-
rustc_target::abi::Endian::Little => cranelift_codegen::ir::Endianness::Little,
165+
rustc_abi::Endian::Big => cranelift_codegen::ir::Endianness::Big,
166+
rustc_abi::Endian::Little => cranelift_codegen::ir::Endianness::Little,
167167
});
168168
fx.bcx.ins().bitcast(dst_ty, flags, val)
169169
}
@@ -333,8 +333,8 @@ impl<'tcx> layout::HasTyCtxt<'tcx> for FunctionCx<'_, '_, 'tcx> {
333333
}
334334
}
335335

336-
impl<'tcx> rustc_target::abi::HasDataLayout for FunctionCx<'_, '_, 'tcx> {
337-
fn data_layout(&self) -> &rustc_target::abi::TargetDataLayout {
336+
impl<'tcx> rustc_abi::HasDataLayout for FunctionCx<'_, '_, 'tcx> {
337+
fn data_layout(&self) -> &rustc_abi::TargetDataLayout {
338338
&self.tcx.data_layout
339339
}
340340
}
@@ -491,8 +491,8 @@ impl<'tcx> layout::HasTyCtxt<'tcx> for RevealAllLayoutCx<'tcx> {
491491
}
492492
}
493493

494-
impl<'tcx> rustc_target::abi::HasDataLayout for RevealAllLayoutCx<'tcx> {
495-
fn data_layout(&self) -> &rustc_target::abi::TargetDataLayout {
494+
impl<'tcx> rustc_abi::HasDataLayout for RevealAllLayoutCx<'tcx> {
495+
fn data_layout(&self) -> &rustc_abi::TargetDataLayout {
496496
&self.0.data_layout
497497
}
498498
}

Diff for: compiler/rustc_codegen_cranelift/src/debuginfo/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use rustc_hir::def::DefKind;
2020
use rustc_hir::def_id::DefIdMap;
2121
use rustc_session::Session;
2222
use rustc_span::{FileNameDisplayPreference, SourceFileHash, StableSourceFileId};
23-
use rustc_target::abi::call::FnAbi;
23+
use rustc_target::callconv::FnAbi;
2424

2525
pub(crate) use self::emit::{DebugReloc, DebugRelocName};
2626
pub(crate) use self::types::TypeDebugContext;

Diff for: compiler/rustc_codegen_cranelift/src/driver/aot.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//! standalone executable.
33
44
use std::fs::{self, File};
5+
use std::io::BufWriter;
56
use std::path::{Path, PathBuf};
67
use std::sync::Arc;
78
use std::thread::JoinHandle;
@@ -397,14 +398,19 @@ fn emit_module(
397398
}
398399

399400
let tmp_file = output_filenames.temp_path(OutputType::Object, Some(&name));
400-
let mut file = match File::create(&tmp_file) {
401+
let file = match File::create(&tmp_file) {
401402
Ok(file) => file,
402403
Err(err) => return Err(format!("error creating object file: {}", err)),
403404
};
404405

406+
let mut file = BufWriter::new(file);
405407
if let Err(err) = object.write_stream(&mut file) {
406408
return Err(format!("error writing object file: {}", err));
407409
}
410+
let file = match file.into_inner() {
411+
Ok(file) => file,
412+
Err(err) => return Err(format!("error writing object file: {}", err)),
413+
};
408414

409415
prof.artifact_size("object_file", &*name, file.metadata().unwrap().len());
410416

Diff for: compiler/rustc_codegen_cranelift/src/inline_asm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ impl<'tcx> InlineAssemblyGenerator<'_, 'tcx> {
464464
let new_slot_fn = |slot_size: &mut Size, reg_class: InlineAsmRegClass| {
465465
let reg_size =
466466
reg_class.supported_types(self.arch).iter().map(|(ty, _)| ty.size()).max().unwrap();
467-
let align = rustc_target::abi::Align::from_bytes(reg_size.bytes()).unwrap();
467+
let align = rustc_abi::Align::from_bytes(reg_size.bytes()).unwrap();
468468
let offset = slot_size.align_to(align);
469469
*slot_size = offset + reg_size;
470470
offset

Diff for: compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Codegen SIMD intrinsics.
22
33
use cranelift_codegen::ir::immediates::Offset32;
4-
use rustc_target::abi::Endian;
4+
use rustc_abi::Endian;
55

66
use super::*;
77
use crate::prelude::*;

Diff for: compiler/rustc_codegen_cranelift/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ impl CodegenBackend for CraneliftCodegenBackend {
241241
sess: &Session,
242242
outputs: &OutputFilenames,
243243
) -> (CodegenResults, FxIndexMap<WorkProductId, WorkProduct>) {
244+
let _timer = sess.timer("finish_ongoing_codegen");
245+
244246
ongoing_codegen.downcast::<driver::aot::OngoingCodegen>().unwrap().join(
245247
sess,
246248
outputs,

Diff for: compiler/rustc_codegen_cranelift/src/pointer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//! operations.
33
44
use cranelift_codegen::ir::immediates::Offset32;
5-
use rustc_target::abi::Align;
5+
use rustc_abi::Align;
66

77
use crate::prelude::*;
88

0 commit comments

Comments
 (0)