Skip to content

Commit f0d864f

Browse files
committed
Auto merge of rust-lang#3395 - rust-lang:rustup-2024-03-23, r=saethlin
Automatic Rustup
2 parents 2fae357 + 5039f8b commit f0d864f

File tree

219 files changed

+1565
-1091
lines changed

Some content is hidden

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

219 files changed

+1565
-1091
lines changed

.mailmap

+1
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ James Hinshelwood <[email protected]> <[email protected]>
259259
260260
James Perry <[email protected]>
261261
James Sanderson <[email protected]>
262+
262263
Jaro Fietz <[email protected]>
263264
Jason Fager <[email protected]>
264265

Cargo.lock

+32-8
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ version = "0.1.5"
214214
source = "registry+https://github.com/rust-lang/crates.io-index"
215215
checksum = "9792d37ca5173d7e7f4fe453739a0671d0557915a030a383d6b866476bbc3e71"
216216
dependencies = [
217-
"object",
217+
"object 0.32.2",
218218
]
219219

220220
[[package]]
@@ -281,7 +281,7 @@ dependencies = [
281281
"cfg-if",
282282
"libc",
283283
"miniz_oxide",
284-
"object",
284+
"object 0.32.2",
285285
"rustc-demangle",
286286
]
287287

@@ -2636,10 +2636,21 @@ dependencies = [
26362636
"memchr",
26372637
"rustc-std-workspace-alloc",
26382638
"rustc-std-workspace-core",
2639-
"ruzstd",
2639+
"ruzstd 0.5.0",
26402640
"wasmparser",
26412641
]
26422642

2643+
[[package]]
2644+
name = "object"
2645+
version = "0.34.0"
2646+
source = "registry+https://github.com/rust-lang/crates.io-index"
2647+
checksum = "d7090bae93f8585aad99e595b7073c5de9ba89fbd6b4e9f0cdd7a10177273ac8"
2648+
dependencies = [
2649+
"flate2",
2650+
"memchr",
2651+
"ruzstd 0.6.0",
2652+
]
2653+
26432654
[[package]]
26442655
name = "odht"
26452656
version = "0.3.1"
@@ -3323,6 +3334,7 @@ dependencies = [
33233334
name = "run_make_support"
33243335
version = "0.0.0"
33253336
dependencies = [
3337+
"object 0.34.0",
33263338
"wasmparser",
33273339
]
33283340

@@ -3634,7 +3646,7 @@ dependencies = [
36343646
"itertools 0.12.1",
36353647
"libc",
36363648
"measureme",
3637-
"object",
3649+
"object 0.32.2",
36383650
"rustc-demangle",
36393651
"rustc_ast",
36403652
"rustc_attr",
@@ -3670,7 +3682,7 @@ dependencies = [
36703682
"itertools 0.12.1",
36713683
"jobserver",
36723684
"libc",
3673-
"object",
3685+
"object 0.32.2",
36743686
"pathdiff",
36753687
"regex",
36763688
"rustc_arena",
@@ -3686,6 +3698,7 @@ dependencies = [
36863698
"rustc_macros",
36873699
"rustc_metadata",
36883700
"rustc_middle",
3701+
"rustc_monomorphize",
36893702
"rustc_query_system",
36903703
"rustc_serialize",
36913704
"rustc_session",
@@ -4630,7 +4643,7 @@ name = "rustc_target"
46304643
version = "0.0.0"
46314644
dependencies = [
46324645
"bitflags 2.4.2",
4633-
"object",
4646+
"object 0.32.2",
46344647
"rustc_abi",
46354648
"rustc_data_structures",
46364649
"rustc_feature",
@@ -4897,6 +4910,17 @@ dependencies = [
48974910
"twox-hash",
48984911
]
48994912

4913+
[[package]]
4914+
name = "ruzstd"
4915+
version = "0.6.0"
4916+
source = "registry+https://github.com/rust-lang/crates.io-index"
4917+
checksum = "5174a470eeb535a721ae9fdd6e291c2411a906b96592182d05217591d5c5cf7b"
4918+
dependencies = [
4919+
"byteorder",
4920+
"derive_more",
4921+
"twox-hash",
4922+
]
4923+
49004924
[[package]]
49014925
name = "ryu"
49024926
version = "1.0.17"
@@ -5200,7 +5224,7 @@ dependencies = [
52005224
"hermit-abi",
52015225
"libc",
52025226
"miniz_oxide",
5203-
"object",
5227+
"object 0.32.2",
52045228
"panic_abort",
52055229
"panic_unwind",
52065230
"profiler_builtins",
@@ -5517,7 +5541,7 @@ checksum = "4db52ee8fec06e119b692ef3dd2c4cf621a99204c1b8c47407870ed050305b9b"
55175541
dependencies = [
55185542
"gimli",
55195543
"hashbrown",
5520-
"object",
5544+
"object 0.32.2",
55215545
"tracing",
55225546
]
55235547

Cargo.toml

-9
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,6 @@ exclude = [
6666
]
6767

6868
[profile.release.package.compiler_builtins]
69-
# The compiler-builtins crate cannot reference libcore, and its own CI will
70-
# verify that this is the case. This requires, however, that the crate is built
71-
# without overflow checks and debug assertions. Forcefully disable debug
72-
# assertions and overflow checks here which should ensure that even if these
73-
# assertions are enabled for libstd we won't enable them for compiler_builtins
74-
# which should ensure we still link everything correctly.
75-
debug-assertions = false
76-
overflow-checks = false
77-
7869
# For compiler-builtins we always use a high number of codegen units.
7970
# The goal here is to place every single intrinsic into its own object
8071
# file to avoid symbol clashes with the system libgcc if possible. Note

compiler/rustc_borrowck/src/diagnostics/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
366366
Some(variant.fields[field].name.to_string())
367367
}
368368
ty::Tuple(_) => Some(field.index().to_string()),
369-
ty::Ref(_, ty, _) | ty::RawPtr(ty::TypeAndMut { ty, .. }) => {
369+
ty::Ref(_, ty, _) | ty::RawPtr(ty, _) => {
370370
self.describe_field_from_ty(ty, field, variant_index, including_tuple_field)
371371
}
372372
ty::Array(ty, _) | ty::Slice(ty) => {

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -503,10 +503,10 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
503503
ty::VarianceDiagInfo::None => {}
504504
ty::VarianceDiagInfo::Invariant { ty, param_index } => {
505505
let (desc, note) = match ty.kind() {
506-
ty::RawPtr(ty_mut) => {
507-
assert_eq!(ty_mut.mutbl, rustc_hir::Mutability::Mut);
506+
ty::RawPtr(ty, mutbl) => {
507+
assert_eq!(*mutbl, rustc_hir::Mutability::Mut);
508508
(
509-
format!("a mutable pointer to `{}`", ty_mut.ty),
509+
format!("a mutable pointer to `{}`", ty),
510510
"mutable pointers are invariant over their type parameter".to_string(),
511511
)
512512
}

compiler/rustc_borrowck/src/diagnostics/region_name.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -555,8 +555,8 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
555555
search_stack.push((*elem_ty, elem_hir_ty));
556556
}
557557

558-
(ty::RawPtr(mut_ty), hir::TyKind::Ptr(mut_hir_ty)) => {
559-
search_stack.push((mut_ty.ty, &mut_hir_ty.ty));
558+
(ty::RawPtr(mut_ty, _), hir::TyKind::Ptr(mut_hir_ty)) => {
559+
search_stack.push((*mut_ty, &mut_hir_ty.ty));
560560
}
561561

562562
_ => {

compiler/rustc_borrowck/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1649,7 +1649,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
16491649
| ty::Str
16501650
| ty::Array(_, _)
16511651
| ty::Slice(_)
1652-
| ty::RawPtr(_)
1652+
| ty::RawPtr(_, _)
16531653
| ty::Ref(_, _, _)
16541654
| ty::FnDef(_, _)
16551655
| ty::FnPtr(_)
@@ -2284,8 +2284,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
22842284
}
22852285
}
22862286
}
2287-
ty::RawPtr(tnm) => {
2288-
match tnm.mutbl {
2287+
ty::RawPtr(_, mutbl) => {
2288+
match mutbl {
22892289
// `*const` raw pointers are not mutable
22902290
hir::Mutability::Not => Err(place),
22912291
// `*mut` raw pointers are always mutable, regardless of

compiler/rustc_borrowck/src/region_infer/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -2065,7 +2065,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
20652065
from_closure: constraint.from_closure,
20662066
cause: ObligationCause::new(constraint.span, CRATE_DEF_ID, cause_code.clone()),
20672067
variance_info: constraint.variance_info,
2068-
outlives_constraint: *constraint,
20692068
})
20702069
.collect();
20712070
debug!("categorized_path={:#?}", categorized_path);
@@ -2294,5 +2293,4 @@ pub struct BlameConstraint<'tcx> {
22942293
pub from_closure: bool,
22952294
pub cause: ObligationCause<'tcx>,
22962295
pub variance_info: ty::VarianceDiagInfo<'tcx>,
2297-
pub outlives_constraint: OutlivesConstraint<'tcx>,
22982296
}

compiler/rustc_borrowck/src/type_check/canonical.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
8282
) {
8383
self.prove_predicate(
8484
ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::Trait(
85-
ty::TraitPredicate { trait_ref, polarity: ty::ImplPolarity::Positive },
85+
ty::TraitPredicate { trait_ref, polarity: ty::PredicatePolarity::Positive },
8686
))),
8787
locations,
8888
category,

compiler/rustc_borrowck/src/type_check/mod.rs

+8-15
Original file line numberDiff line numberDiff line change
@@ -2157,15 +2157,12 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
21572157
}
21582158

21592159
CastKind::PointerCoercion(PointerCoercion::MutToConstPointer) => {
2160-
let ty::RawPtr(ty::TypeAndMut { ty: ty_from, mutbl: hir::Mutability::Mut }) =
2161-
op.ty(body, tcx).kind()
2160+
let ty::RawPtr(ty_from, hir::Mutability::Mut) = op.ty(body, tcx).kind()
21622161
else {
21632162
span_mirbug!(self, rvalue, "unexpected base type for cast {:?}", ty,);
21642163
return;
21652164
};
2166-
let ty::RawPtr(ty::TypeAndMut { ty: ty_to, mutbl: hir::Mutability::Not }) =
2167-
ty.kind()
2168-
else {
2165+
let ty::RawPtr(ty_to, hir::Mutability::Not) = ty.kind() else {
21692166
span_mirbug!(self, rvalue, "unexpected target type for cast {:?}", ty,);
21702167
return;
21712168
};
@@ -2190,12 +2187,10 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
21902187
let ty_from = op.ty(body, tcx);
21912188

21922189
let opt_ty_elem_mut = match ty_from.kind() {
2193-
ty::RawPtr(ty::TypeAndMut { mutbl: array_mut, ty: array_ty }) => {
2194-
match array_ty.kind() {
2195-
ty::Array(ty_elem, _) => Some((ty_elem, *array_mut)),
2196-
_ => None,
2197-
}
2198-
}
2190+
ty::RawPtr(array_ty, array_mut) => match array_ty.kind() {
2191+
ty::Array(ty_elem, _) => Some((ty_elem, *array_mut)),
2192+
_ => None,
2193+
},
21992194
_ => None,
22002195
};
22012196

@@ -2210,9 +2205,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
22102205
};
22112206

22122207
let (ty_to, ty_to_mut) = match ty.kind() {
2213-
ty::RawPtr(ty::TypeAndMut { mutbl: ty_to_mut, ty: ty_to }) => {
2214-
(ty_to, *ty_to_mut)
2215-
}
2208+
ty::RawPtr(ty_to, ty_to_mut) => (ty_to, *ty_to_mut),
22162209
_ => {
22172210
span_mirbug!(
22182211
self,
@@ -2413,7 +2406,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
24132406
let ty_left = left.ty(body, tcx);
24142407
match ty_left.kind() {
24152408
// Types with regions are comparable if they have a common super-type.
2416-
ty::RawPtr(_) | ty::FnPtr(_) => {
2409+
ty::RawPtr(_, _) | ty::FnPtr(_) => {
24172410
let ty_right = right.ty(body, tcx);
24182411
let common_ty = self.infcx.next_ty_var(TypeVariableOrigin {
24192412
kind: TypeVariableOriginKind::MiscVariable,

compiler/rustc_builtin_macros/src/deriving/debug.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>
5151

5252
let (ident, vdata, fields) = match substr.fields {
5353
Struct(vdata, fields) => (substr.type_ident, *vdata, fields),
54-
EnumMatching(_, _, v, fields) => (v.ident, &v.data, fields),
54+
EnumMatching(_, v, fields) => (v.ident, &v.data, fields),
5555
AllFieldlessEnum(enum_def) => return show_fieldless_enum(cx, span, enum_def, substr),
5656
EnumTag(..) | StaticStruct(..) | StaticEnum(..) => {
5757
cx.dcx().span_bug(span, "nonsensical .fields in `#[derive(Debug)]`")

compiler/rustc_builtin_macros/src/deriving/encodable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ fn encodable_substructure(
226226
BlockOrExpr::new_expr(expr)
227227
}
228228

229-
EnumMatching(idx, _, variant, fields) => {
229+
EnumMatching(idx, variant, fields) => {
230230
// We're not generating an AST that the borrow checker is expecting,
231231
// so we need to generate a unique local variable to take the
232232
// mutable loan out on, otherwise we get conflicts which don't

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,10 @@ pub enum SubstructureFields<'a> {
310310
/// variants has any fields).
311311
AllFieldlessEnum(&'a ast::EnumDef),
312312

313-
/// Matching variants of the enum: variant index, variant count, ast::Variant,
313+
/// Matching variants of the enum: variant index, ast::Variant,
314314
/// fields: the field name is only non-`None` in the case of a struct
315315
/// variant.
316-
EnumMatching(usize, usize, &'a ast::Variant, Vec<FieldInfo>),
316+
EnumMatching(usize, &'a ast::Variant, Vec<FieldInfo>),
317317

318318
/// The tag of an enum. The first field is a `FieldInfo` for the tags, as
319319
/// if they were fields. The second field is the expression to combine the
@@ -1272,7 +1272,7 @@ impl<'a> MethodDef<'a> {
12721272
trait_,
12731273
type_ident,
12741274
nonselflike_args,
1275-
&EnumMatching(0, 1, &variants[0], Vec::new()),
1275+
&EnumMatching(0, &variants[0], Vec::new()),
12761276
);
12771277
}
12781278
}
@@ -1318,7 +1318,7 @@ impl<'a> MethodDef<'a> {
13181318
// expressions for referencing every field of every
13191319
// Self arg, assuming all are instances of VariantK.
13201320
// Build up code associated with such a case.
1321-
let substructure = EnumMatching(index, variants.len(), variant, fields);
1321+
let substructure = EnumMatching(index, variant, fields);
13221322
let arm_expr = self
13231323
.call_substructure_method(
13241324
cx,
@@ -1346,7 +1346,7 @@ impl<'a> MethodDef<'a> {
13461346
trait_,
13471347
type_ident,
13481348
nonselflike_args,
1349-
&EnumMatching(0, variants.len(), v, Vec::new()),
1349+
&EnumMatching(0, v, Vec::new()),
13501350
)
13511351
.into_expr(cx, span),
13521352
)

compiler/rustc_codegen_cranelift/src/abi/mod.rs

+15-5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ use std::borrow::Cow;
88

99
use cranelift_codegen::ir::SigRef;
1010
use cranelift_module::ModuleError;
11+
use rustc_codegen_ssa::errors::CompilerBuiltinsCannotCall;
1112
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
1213
use rustc_middle::ty::layout::FnAbiOf;
14+
use rustc_middle::ty::print::with_no_trimmed_paths;
15+
use rustc_monomorphize::is_call_from_compiler_builtins_to_upstream_monomorphization;
1316
use rustc_session::Session;
1417
use rustc_span::source_map::Spanned;
1518
use rustc_target::abi::call::{Conv, FnAbi};
@@ -372,6 +375,17 @@ pub(crate) fn codegen_terminator_call<'tcx>(
372375
ty::Instance::expect_resolve(fx.tcx, ty::ParamEnv::reveal_all(), def_id, fn_args)
373376
.polymorphize(fx.tcx);
374377

378+
if is_call_from_compiler_builtins_to_upstream_monomorphization(fx.tcx, instance) {
379+
if target.is_some() {
380+
let caller = with_no_trimmed_paths!(fx.tcx.def_path_str(fx.instance.def_id()));
381+
let callee = with_no_trimmed_paths!(fx.tcx.def_path_str(def_id));
382+
fx.tcx.dcx().emit_err(CompilerBuiltinsCannotCall { caller, callee });
383+
} else {
384+
fx.bcx.ins().trap(TrapCode::User(0));
385+
return;
386+
}
387+
}
388+
375389
if fx.tcx.symbol_name(instance).name.starts_with("llvm.") {
376390
crate::intrinsics::codegen_llvm_intrinsic_call(
377391
fx,
@@ -663,11 +677,7 @@ pub(crate) fn codegen_drop<'tcx>(
663677

664678
let arg_value = drop_place.place_ref(
665679
fx,
666-
fx.layout_of(Ty::new_ref(
667-
fx.tcx,
668-
fx.tcx.lifetimes.re_erased,
669-
TypeAndMut { ty, mutbl: crate::rustc_hir::Mutability::Mut },
670-
)),
680+
fx.layout_of(Ty::new_mut_ref(fx.tcx, fx.tcx.lifetimes.re_erased, ty)),
671681
);
672682
let arg_value = adjust_arg_for_abi(fx, arg_value, &fn_abi.args[0], true);
673683

compiler/rustc_codegen_cranelift/src/base.rs

+7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use rustc_index::IndexVec;
88
use rustc_middle::ty::adjustment::PointerCoercion;
99
use rustc_middle::ty::layout::FnAbiOf;
1010
use rustc_middle::ty::print::with_no_trimmed_paths;
11+
use rustc_monomorphize::is_call_from_compiler_builtins_to_upstream_monomorphization;
1112

1213
use crate::constant::ConstantCx;
1314
use crate::debuginfo::FunctionDebugContext;
@@ -999,6 +1000,12 @@ fn codegen_panic_inner<'tcx>(
9991000
let def_id = fx.tcx.require_lang_item(lang_item, span);
10001001

10011002
let instance = Instance::mono(fx.tcx, def_id).polymorphize(fx.tcx);
1003+
1004+
if is_call_from_compiler_builtins_to_upstream_monomorphization(fx.tcx, instance) {
1005+
fx.bcx.ins().trap(TrapCode::User(0));
1006+
return;
1007+
}
1008+
10021009
let symbol_name = fx.tcx.symbol_name(instance).name;
10031010

10041011
fx.lib_call(

0 commit comments

Comments
 (0)