Skip to content

Commit a01f37c

Browse files
committed
Merge from rustc
2 parents ce7a560 + 6689597 commit a01f37c

File tree

167 files changed

+5528
-2604
lines changed

Some content is hidden

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

167 files changed

+5528
-2604
lines changed

compiler/rustc_abi/src/lib.rs

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

compiler/rustc_ast_lowering/src/asm.rs

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

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

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

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

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

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

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

compiler/rustc_codegen_cranelift/scripts/test_bootstrap.sh

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

compiler/rustc_codegen_cranelift/src/abi/comments.rs

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

compiler/rustc_codegen_cranelift/src/abi/mod.rs

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

compiler/rustc_codegen_cranelift/src/abi/pass_mode.rs

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

0 commit comments

Comments
 (0)