Skip to content

Commit 30b0a32

Browse files
authored
Merge branch 'main' into fix-delegation-ice
2 parents ba88db0 + f824853 commit 30b0a32

366 files changed

Lines changed: 3014 additions & 2187 deletions

File tree

Some content is hidden

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

Cargo.lock

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,9 +1217,9 @@ dependencies = [
12171217

12181218
[[package]]
12191219
name = "dispatch2"
1220-
version = "0.3.0"
1220+
version = "0.3.1"
12211221
source = "registry+https://github.com/rust-lang/crates.io-index"
1222-
checksum = "89a09f22a6c6069a18470eb92d2298acf25463f14256d24778e1230d789a2aec"
1222+
checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38"
12231223
dependencies = [
12241224
"bitflags",
12251225
"block2",
@@ -4121,7 +4121,7 @@ version = "0.0.0"
41214121
dependencies = [
41224122
"cc",
41234123
"libc",
4124-
"shell-words",
4124+
"shlex",
41254125
]
41264126

41274127
[[package]]
@@ -5116,12 +5116,6 @@ dependencies = [
51165116
"lazy_static",
51175117
]
51185118

5119-
[[package]]
5120-
name = "shell-words"
5121-
version = "1.1.1"
5122-
source = "registry+https://github.com/rust-lang/crates.io-index"
5123-
checksum = "dc6fe69c597f9c37bfeeeeeb33da3530379845f10be461a66d16d03eca2ded77"
5124-
51255119
[[package]]
51265120
name = "shlex"
51275121
version = "1.3.0"

compiler/rustc_abi/src/lib.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2145,21 +2145,22 @@ pub enum PointerKind {
21452145
}
21462146

21472147
/// Encodes extra information we have about a pointer.
2148+
///
21482149
/// Note that this information is advisory only, and backends are free to ignore it:
21492150
/// if the information is wrong, that can cause UB, but if the information is absent,
21502151
/// that must always be okay.
21512152
#[derive(Copy, Clone, Debug)]
21522153
pub struct PointeeInfo {
2153-
/// If this is `None`, then this is a raw pointer, so size and alignment are not guaranteed to
2154-
/// be reliable.
2154+
/// If this is `None`, then this is a raw pointer.
21552155
pub safe: Option<PointerKind>,
2156-
/// If `safe` is `Some`, then the pointer is either null or dereferenceable for this many bytes.
2156+
/// If `size` is not zero, then the pointer is either null or dereferenceable for this many bytes
2157+
/// (independent of `safe`).
2158+
///
21572159
/// On a function argument, "dereferenceable" here means "dereferenceable for the entire duration
21582160
/// of this function call", i.e. it is UB for the memory that this pointer points to be freed
21592161
/// while this function is still running.
2160-
/// The size can be zero if the pointer is not dereferenceable.
21612162
pub size: Size,
2162-
/// If `safe` is `Some`, then the pointer is aligned as indicated.
2163+
/// The pointer is guaranteed to be aligned this much (independent of `safe`).
21632164
pub align: Align,
21642165
}
21652166

compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs

Lines changed: 85 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use rustc_hir::Target;
21
use rustc_hir::attrs::AttributeKind;
2+
use rustc_hir::{MethodKind, Target};
33
use rustc_span::{Span, Symbol, sym};
44

55
use crate::attributes::prelude::Allow;
@@ -25,6 +25,20 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpDefParentsParser {
2525
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDumpDefParents;
2626
}
2727

28+
pub(crate) struct RustcDumpInferredOutlivesParser;
29+
30+
impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpInferredOutlivesParser {
31+
const PATH: &[Symbol] = &[sym::rustc_dump_inferred_outlives];
32+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
33+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
34+
Allow(Target::Struct),
35+
Allow(Target::Enum),
36+
Allow(Target::Union),
37+
Allow(Target::TyAlias),
38+
]);
39+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDumpInferredOutlives;
40+
}
41+
2842
pub(crate) struct RustcDumpItemBoundsParser;
2943

3044
impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpItemBoundsParser {
@@ -34,21 +48,88 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpItemBoundsParser {
3448
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDumpItemBounds;
3549
}
3650

51+
pub(crate) struct RustcDumpObjectLifetimeDefaultsParser;
52+
53+
impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpObjectLifetimeDefaultsParser {
54+
const PATH: &[Symbol] = &[sym::rustc_dump_object_lifetime_defaults];
55+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
56+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
57+
Allow(Target::AssocConst),
58+
Allow(Target::AssocTy),
59+
Allow(Target::Const),
60+
Allow(Target::Enum),
61+
Allow(Target::Fn),
62+
Allow(Target::ForeignFn),
63+
Allow(Target::Impl { of_trait: false }),
64+
Allow(Target::Impl { of_trait: true }),
65+
Allow(Target::Method(MethodKind::Inherent)),
66+
Allow(Target::Method(MethodKind::Trait { body: false })),
67+
Allow(Target::Method(MethodKind::Trait { body: true })),
68+
Allow(Target::Method(MethodKind::TraitImpl)),
69+
Allow(Target::Struct),
70+
Allow(Target::Trait),
71+
Allow(Target::TraitAlias),
72+
Allow(Target::TyAlias),
73+
Allow(Target::Union),
74+
]);
75+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDumpObjectLifetimeDefaults;
76+
}
77+
3778
pub(crate) struct RustcDumpPredicatesParser;
3879

3980
impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpPredicatesParser {
4081
const PATH: &[Symbol] = &[sym::rustc_dump_predicates];
4182
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
4283
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
43-
Allow(Target::Struct),
84+
Allow(Target::AssocConst),
85+
Allow(Target::AssocTy),
86+
Allow(Target::Const),
87+
Allow(Target::Delegation { mac: false }),
88+
Allow(Target::Delegation { mac: true }),
4489
Allow(Target::Enum),
45-
Allow(Target::Union),
90+
Allow(Target::Fn),
91+
Allow(Target::Impl { of_trait: false }),
92+
Allow(Target::Impl { of_trait: true }),
93+
Allow(Target::Method(MethodKind::Inherent)),
94+
Allow(Target::Method(MethodKind::Trait { body: false })),
95+
Allow(Target::Method(MethodKind::Trait { body: true })),
96+
Allow(Target::Method(MethodKind::TraitImpl)),
97+
Allow(Target::Struct),
4698
Allow(Target::Trait),
47-
Allow(Target::AssocTy),
99+
Allow(Target::TraitAlias),
100+
Allow(Target::TyAlias),
101+
Allow(Target::Union),
48102
]);
49103
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDumpPredicates;
50104
}
51105

106+
pub(crate) struct RustcDumpVariancesParser;
107+
108+
impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpVariancesParser {
109+
const PATH: &[Symbol] = &[sym::rustc_dump_variances];
110+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
111+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
112+
Allow(Target::Enum),
113+
Allow(Target::Fn),
114+
Allow(Target::Method(MethodKind::Inherent)),
115+
Allow(Target::Method(MethodKind::Trait { body: false })),
116+
Allow(Target::Method(MethodKind::Trait { body: true })),
117+
Allow(Target::Method(MethodKind::TraitImpl)),
118+
Allow(Target::Struct),
119+
Allow(Target::Union),
120+
]);
121+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDumpVariances;
122+
}
123+
124+
pub(crate) struct RustcDumpVariancesOfOpaquesParser;
125+
126+
impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpVariancesOfOpaquesParser {
127+
const PATH: &[Symbol] = &[sym::rustc_dump_variances_of_opaques];
128+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
129+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
130+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDumpVariancesOfOpaques;
131+
}
132+
52133
pub(crate) struct RustcDumpVtableParser;
53134

54135
impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpVtableParser {

compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -588,15 +588,6 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcLintUntrackedQueryInformationPa
588588
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcLintUntrackedQueryInformation;
589589
}
590590

591-
pub(crate) struct RustcObjectLifetimeDefaultParser;
592-
593-
impl<S: Stage> NoArgsAttributeParser<S> for RustcObjectLifetimeDefaultParser {
594-
const PATH: &[Symbol] = &[sym::rustc_object_lifetime_default];
595-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
596-
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Struct)]);
597-
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcObjectLifetimeDefault;
598-
}
599-
600591
pub(crate) struct RustcSimdMonomorphizeLaneLimitParser;
601592

602593
impl<S: Stage> SingleAttributeParser<S> for RustcSimdMonomorphizeLaneLimitParser {

compiler/rustc_attr_parsing/src/attributes/test_attrs.rs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -93,28 +93,6 @@ impl<S: Stage> SingleAttributeParser<S> for ShouldPanicParser {
9393
}
9494
}
9595

96-
pub(crate) struct RustcVarianceParser;
97-
98-
impl<S: Stage> NoArgsAttributeParser<S> for RustcVarianceParser {
99-
const PATH: &[Symbol] = &[sym::rustc_variance];
100-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
101-
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
102-
Allow(Target::Struct),
103-
Allow(Target::Enum),
104-
Allow(Target::Union),
105-
]);
106-
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcVariance;
107-
}
108-
109-
pub(crate) struct RustcVarianceOfOpaquesParser;
110-
111-
impl<S: Stage> NoArgsAttributeParser<S> for RustcVarianceOfOpaquesParser {
112-
const PATH: &[Symbol] = &[sym::rustc_variance_of_opaques];
113-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
114-
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
115-
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcVarianceOfOpaques;
116-
}
117-
11896
pub(crate) struct ReexportTestHarnessMainParser;
11997

12098
impl<S: Stage> SingleAttributeParser<S> for ReexportTestHarnessMainParser {
@@ -215,20 +193,6 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcEvaluateWhereClausesParser {
215193
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcEvaluateWhereClauses;
216194
}
217195

218-
pub(crate) struct RustcOutlivesParser;
219-
220-
impl<S: Stage> NoArgsAttributeParser<S> for RustcOutlivesParser {
221-
const PATH: &[Symbol] = &[sym::rustc_outlives];
222-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
223-
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
224-
Allow(Target::Struct),
225-
Allow(Target::Enum),
226-
Allow(Target::Union),
227-
Allow(Target::TyAlias),
228-
]);
229-
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcOutlives;
230-
}
231-
232196
pub(crate) struct TestRunnerParser;
233197

234198
impl<S: Stage> SingleAttributeParser<S> for TestRunnerParser {

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,13 @@ attribute_parsers!(
281281
Single<WithoutArgs<RustcDenyExplicitImplParser>>,
282282
Single<WithoutArgs<RustcDoNotConstCheckParser>>,
283283
Single<WithoutArgs<RustcDumpDefParentsParser>>,
284+
Single<WithoutArgs<RustcDumpInferredOutlivesParser>>,
284285
Single<WithoutArgs<RustcDumpItemBoundsParser>>,
286+
Single<WithoutArgs<RustcDumpObjectLifetimeDefaultsParser>>,
285287
Single<WithoutArgs<RustcDumpPredicatesParser>>,
286288
Single<WithoutArgs<RustcDumpUserArgsParser>>,
289+
Single<WithoutArgs<RustcDumpVariancesOfOpaquesParser>>,
290+
Single<WithoutArgs<RustcDumpVariancesParser>>,
287291
Single<WithoutArgs<RustcDumpVtableParser>>,
288292
Single<WithoutArgs<RustcDynIncompatibleTraitParser>>,
289293
Single<WithoutArgs<RustcEffectiveVisibilityParser>>,
@@ -306,9 +310,7 @@ attribute_parsers!(
306310
Single<WithoutArgs<RustcNonConstTraitMethodParser>>,
307311
Single<WithoutArgs<RustcNonnullOptimizationGuaranteedParser>>,
308312
Single<WithoutArgs<RustcNounwindParser>>,
309-
Single<WithoutArgs<RustcObjectLifetimeDefaultParser>>,
310313
Single<WithoutArgs<RustcOffloadKernelParser>>,
311-
Single<WithoutArgs<RustcOutlivesParser>>,
312314
Single<WithoutArgs<RustcParenSugarParser>>,
313315
Single<WithoutArgs<RustcPassByValueParser>>,
314316
Single<WithoutArgs<RustcPassIndirectlyInNonRusticAbisParser>>,
@@ -323,8 +325,6 @@ attribute_parsers!(
323325
Single<WithoutArgs<RustcStrictCoherenceParser>>,
324326
Single<WithoutArgs<RustcTrivialFieldReadsParser>>,
325327
Single<WithoutArgs<RustcUnsafeSpecializationMarkerParser>>,
326-
Single<WithoutArgs<RustcVarianceOfOpaquesParser>>,
327-
Single<WithoutArgs<RustcVarianceParser>>,
328328
Single<WithoutArgs<ThreadLocalParser>>,
329329
Single<WithoutArgs<TrackCallerParser>>,
330330
// tidy-alphabetical-end

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1310,7 +1310,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
13101310
{
13111311
let mut span: MultiSpan = spans.clone().into();
13121312
err.arg("ty", param_ty.to_string());
1313-
let msg = err.dcx.eagerly_translate_to_string(
1313+
let msg = err.dcx.eagerly_format_to_string(
13141314
msg!("`{$ty}` is made to be an `FnOnce` closure here"),
13151315
err.args.iter(),
13161316
);

compiler/rustc_builtin_macros/src/errors.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ pub(crate) struct FormatUnusedArg {
764764
impl Subdiagnostic for FormatUnusedArg {
765765
fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
766766
diag.arg("named", self.named);
767-
let msg = diag.eagerly_translate(msg!(
767+
let msg = diag.eagerly_format(msg!(
768768
"{$named ->
769769
[true] named argument
770770
*[false] argument
@@ -947,8 +947,8 @@ pub(crate) struct AsmClobberNoReg {
947947
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for AsmClobberNoReg {
948948
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
949949
// eager translation as `span_labels` takes `AsRef<str>`
950-
let lbl1 = dcx.eagerly_translate_to_string(msg!("clobber_abi"), [].into_iter());
951-
let lbl2 = dcx.eagerly_translate_to_string(msg!("generic outputs"), [].into_iter());
950+
let lbl1 = dcx.eagerly_format_to_string(msg!("clobber_abi"), [].into_iter());
951+
let lbl2 = dcx.eagerly_format_to_string(msg!("generic outputs"), [].into_iter());
952952
Diag::new(
953953
dcx,
954954
level,

compiler/rustc_codegen_cranelift/src/base.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_data_structures::profiling::SelfProfilerRef;
1010
use rustc_index::IndexVec;
1111
use rustc_middle::ty::TypeVisitableExt;
1212
use rustc_middle::ty::adjustment::PointerCoercion;
13-
use rustc_middle::ty::layout::FnAbiOf;
13+
use rustc_middle::ty::layout::{FnAbiOf, HasTypingEnv as _};
1414
use rustc_middle::ty::print::with_no_trimmed_paths;
1515
use rustc_session::config::OutputFilenames;
1616
use rustc_span::Symbol;
@@ -924,19 +924,26 @@ fn codegen_stmt<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, cur_block: Block, stmt:
924924
count,
925925
}) => {
926926
let dst = codegen_operand(fx, dst);
927-
let pointee = dst
928-
.layout()
929-
.pointee_info_at(fx, rustc_abi::Size::ZERO)
930-
.expect("Expected pointer");
927+
928+
let &ty::RawPtr(pointee, _) = dst.layout().ty.kind() else {
929+
bug!("expected pointer")
930+
};
931+
let pointee_layout = fx
932+
.tcx
933+
.layout_of(fx.typing_env().as_query_input(pointee))
934+
.expect("expected pointee to have a layout");
935+
let elem_size: u64 = pointee_layout.layout.size().bytes();
936+
931937
let dst = dst.load_scalar(fx);
932938
let src = codegen_operand(fx, src).load_scalar(fx);
933939
let count = codegen_operand(fx, count).load_scalar(fx);
934-
let elem_size: u64 = pointee.size.bytes();
940+
935941
let bytes = if elem_size != 1 {
936942
fx.bcx.ins().imul_imm(count, elem_size as i64)
937943
} else {
938944
count
939945
};
946+
940947
fx.bcx.call_memcpy(fx.target_config, dst, src, bytes);
941948
}
942949
},

0 commit comments

Comments
 (0)