Skip to content

Commit 2184c7c

Browse files
committed
Auto merge of rust-lang#94935 - matthiaskrgr:rollup-2o2kyz6, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - rust-lang#90621 (Stabilise `aarch64_target_feature`) - rust-lang#93977 (Type params and assoc types have unit metadata if they are sized) - rust-lang#94670 (Improve `expect` impl and handle `#[expect(unfulfilled_lint_expectations)]` (RFC 2383)) - rust-lang#94884 (Fix remaining meta-variable expression TODOs) - rust-lang#94931 (update miri) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 285fa7e + 4753f24 commit 2184c7c

File tree

28 files changed

+397
-117
lines changed

28 files changed

+397
-117
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

+14-3
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,6 @@ pub fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> SmallVec<[&'a str; 2]
188188
("x86", "avx512gfni") => smallvec!["gfni"],
189189
("x86", "avx512vpclmulqdq") => smallvec!["vpclmulqdq"],
190190
("aarch64", "fp") => smallvec!["fp-armv8"],
191-
("aarch64", "fp16") => smallvec!["fullfp16"],
192-
("aarch64", "fhm") => smallvec!["fp16fml"],
193191
("aarch64", "rcpc2") => smallvec!["rcpc-immo"],
194192
("aarch64", "dpb") => smallvec!["ccpp"],
195193
("aarch64", "dpb2") => smallvec!["ccdp"],
@@ -198,6 +196,19 @@ pub fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> SmallVec<[&'a str; 2]
198196
("aarch64", "pmuv3") => smallvec!["perfmon"],
199197
("aarch64", "paca") => smallvec!["pauth"],
200198
("aarch64", "pacg") => smallvec!["pauth"],
199+
// Rust ties fp and neon together. In LLVM neon implicitly enables fp,
200+
// but we manually enable neon when a feature only implicitly enables fp
201+
("aarch64", "f32mm") => smallvec!["f32mm", "neon"],
202+
("aarch64", "f64mm") => smallvec!["f64mm", "neon"],
203+
("aarch64", "fhm") => smallvec!["fp16fml", "neon"],
204+
("aarch64", "fp16") => smallvec!["fullfp16", "neon"],
205+
("aarch64", "jsconv") => smallvec!["jsconv", "neon"],
206+
("aarch64", "sve") => smallvec!["sve", "neon"],
207+
("aarch64", "sve2") => smallvec!["sve2", "neon"],
208+
("aarch64", "sve2-aes") => smallvec!["sve2-aes", "neon"],
209+
("aarch64", "sve2-sm4") => smallvec!["sve2-sm4", "neon"],
210+
("aarch64", "sve2-sha3") => smallvec!["sve2-sha3", "neon"],
211+
("aarch64", "sve2-bitperm") => smallvec!["sve2-bitperm", "neon"],
201212
(_, s) => smallvec![s],
202213
}
203214
}
@@ -490,7 +501,7 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec<Str
490501
if RUSTC_SPECIFIC_FEATURES.contains(&feature) {
491502
return SmallVec::<[_; 2]>::new();
492503
}
493-
// ... otherwise though we run through `to_llvm_feature when
504+
// ... otherwise though we run through `to_llvm_features` when
494505
// passing requests down to LLVM. This means that all in-language
495506
// features also work on the command line instead of having two
496507
// different names when the LLVM name and the Rust name differ.

compiler/rustc_codegen_ssa/src/target_features.rs

+56-53
Original file line numberDiff line numberDiff line change
@@ -44,105 +44,108 @@ const ARM_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
4444

4545
const AARCH64_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
4646
// FEAT_AdvSimd
47-
("neon", Some(sym::aarch64_target_feature)),
47+
("neon", None),
4848
// FEAT_FP
49-
("fp", Some(sym::aarch64_target_feature)),
49+
("fp", None),
5050
// FEAT_FP16
51-
("fp16", Some(sym::aarch64_target_feature)),
51+
("fp16", None),
5252
// FEAT_SVE
53-
("sve", Some(sym::aarch64_target_feature)),
53+
("sve", None),
5454
// FEAT_CRC
55-
("crc", Some(sym::aarch64_target_feature)),
55+
("crc", None),
5656
// FEAT_RAS
57-
("ras", Some(sym::aarch64_target_feature)),
57+
("ras", None),
5858
// FEAT_LSE
59-
("lse", Some(sym::aarch64_target_feature)),
59+
("lse", None),
6060
// FEAT_RDM
61-
("rdm", Some(sym::aarch64_target_feature)),
61+
("rdm", None),
6262
// FEAT_RCPC
63-
("rcpc", Some(sym::aarch64_target_feature)),
63+
("rcpc", None),
6464
// FEAT_RCPC2
65-
("rcpc2", Some(sym::aarch64_target_feature)),
65+
("rcpc2", None),
6666
// FEAT_DotProd
67-
("dotprod", Some(sym::aarch64_target_feature)),
67+
("dotprod", None),
6868
// FEAT_TME
69-
("tme", Some(sym::aarch64_target_feature)),
69+
("tme", None),
7070
// FEAT_FHM
71-
("fhm", Some(sym::aarch64_target_feature)),
71+
("fhm", None),
7272
// FEAT_DIT
73-
("dit", Some(sym::aarch64_target_feature)),
73+
("dit", None),
7474
// FEAT_FLAGM
75-
("flagm", Some(sym::aarch64_target_feature)),
75+
("flagm", None),
7676
// FEAT_SSBS
77-
("ssbs", Some(sym::aarch64_target_feature)),
77+
("ssbs", None),
7878
// FEAT_SB
79-
("sb", Some(sym::aarch64_target_feature)),
79+
("sb", None),
8080
// FEAT_PAUTH (address authentication)
81-
("paca", Some(sym::aarch64_target_feature)),
81+
("paca", None),
8282
// FEAT_PAUTH (generic authentication)
83-
("pacg", Some(sym::aarch64_target_feature)),
83+
("pacg", None),
8484
// FEAT_DPB
85-
("dpb", Some(sym::aarch64_target_feature)),
85+
("dpb", None),
8686
// FEAT_DPB2
87-
("dpb2", Some(sym::aarch64_target_feature)),
87+
("dpb2", None),
8888
// FEAT_SVE2
89-
("sve2", Some(sym::aarch64_target_feature)),
89+
("sve2", None),
9090
// FEAT_SVE2_AES
91-
("sve2-aes", Some(sym::aarch64_target_feature)),
91+
("sve2-aes", None),
9292
// FEAT_SVE2_SM4
93-
("sve2-sm4", Some(sym::aarch64_target_feature)),
93+
("sve2-sm4", None),
9494
// FEAT_SVE2_SHA3
95-
("sve2-sha3", Some(sym::aarch64_target_feature)),
95+
("sve2-sha3", None),
9696
// FEAT_SVE2_BitPerm
97-
("sve2-bitperm", Some(sym::aarch64_target_feature)),
97+
("sve2-bitperm", None),
9898
// FEAT_FRINTTS
99-
("frintts", Some(sym::aarch64_target_feature)),
99+
("frintts", None),
100100
// FEAT_I8MM
101-
("i8mm", Some(sym::aarch64_target_feature)),
101+
("i8mm", None),
102102
// FEAT_F32MM
103-
("f32mm", Some(sym::aarch64_target_feature)),
103+
("f32mm", None),
104104
// FEAT_F64MM
105-
("f64mm", Some(sym::aarch64_target_feature)),
105+
("f64mm", None),
106106
// FEAT_BF16
107-
("bf16", Some(sym::aarch64_target_feature)),
107+
("bf16", None),
108108
// FEAT_RAND
109-
("rand", Some(sym::aarch64_target_feature)),
109+
("rand", None),
110110
// FEAT_BTI
111-
("bti", Some(sym::aarch64_target_feature)),
111+
("bti", None),
112112
// FEAT_MTE
113-
("mte", Some(sym::aarch64_target_feature)),
113+
("mte", None),
114114
// FEAT_JSCVT
115-
("jsconv", Some(sym::aarch64_target_feature)),
115+
("jsconv", None),
116116
// FEAT_FCMA
117-
("fcma", Some(sym::aarch64_target_feature)),
117+
("fcma", None),
118118
// FEAT_AES
119-
("aes", Some(sym::aarch64_target_feature)),
119+
("aes", None),
120120
// FEAT_SHA1 & FEAT_SHA256
121-
("sha2", Some(sym::aarch64_target_feature)),
121+
("sha2", None),
122122
// FEAT_SHA512 & FEAT_SHA3
123-
("sha3", Some(sym::aarch64_target_feature)),
123+
("sha3", None),
124124
// FEAT_SM3 & FEAT_SM4
125-
("sm4", Some(sym::aarch64_target_feature)),
125+
("sm4", None),
126126
// FEAT_PAN
127-
("pan", Some(sym::aarch64_target_feature)),
127+
("pan", None),
128128
// FEAT_LOR
129-
("lor", Some(sym::aarch64_target_feature)),
129+
("lor", None),
130130
// FEAT_VHE
131-
("vh", Some(sym::aarch64_target_feature)),
131+
("vh", None),
132132
// FEAT_PMUv3
133-
("pmuv3", Some(sym::aarch64_target_feature)),
133+
("pmuv3", None),
134134
// FEAT_SPE
135-
("spe", Some(sym::aarch64_target_feature)),
136-
("v8.1a", Some(sym::aarch64_target_feature)),
137-
("v8.2a", Some(sym::aarch64_target_feature)),
138-
("v8.3a", Some(sym::aarch64_target_feature)),
139-
("v8.4a", Some(sym::aarch64_target_feature)),
140-
("v8.5a", Some(sym::aarch64_target_feature)),
141-
("v8.6a", Some(sym::aarch64_target_feature)),
142-
("v8.7a", Some(sym::aarch64_target_feature)),
135+
("spe", None),
136+
("v8.1a", Some(sym::aarch64_ver_target_feature)),
137+
("v8.2a", Some(sym::aarch64_ver_target_feature)),
138+
("v8.3a", Some(sym::aarch64_ver_target_feature)),
139+
("v8.4a", Some(sym::aarch64_ver_target_feature)),
140+
("v8.5a", Some(sym::aarch64_ver_target_feature)),
141+
("v8.6a", Some(sym::aarch64_ver_target_feature)),
142+
("v8.7a", Some(sym::aarch64_ver_target_feature)),
143143
];
144144

145-
const AARCH64_TIED_FEATURES: &[&[&str]] = &[&["paca", "pacg"]];
145+
const AARCH64_TIED_FEATURES: &[&[&str]] = &[
146+
&["fp", "neon"], // Silicon always has both, so avoid needless complications
147+
&["paca", "pacg"], // Together these represent `pauth` in LLVM
148+
];
146149

147150
const X86_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
148151
("adx", Some(sym::adx_target_feature)),

compiler/rustc_errors/src/diagnostic.rs

+24-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ use crate::Substitution;
55
use crate::SubstitutionPart;
66
use crate::SuggestionStyle;
77
use crate::ToolMetadata;
8-
use rustc_lint_defs::Applicability;
8+
use rustc_data_structures::stable_map::FxHashMap;
9+
use rustc_lint_defs::{Applicability, LintExpectationId};
910
use rustc_serialize::json::Json;
1011
use rustc_span::edition::LATEST_STABLE_EDITION;
1112
use rustc_span::{MultiSpan, Span, DUMMY_SP};
@@ -138,6 +139,28 @@ impl Diagnostic {
138139
}
139140
}
140141

142+
pub fn update_unstable_expectation_id(
143+
&mut self,
144+
unstable_to_stable: &FxHashMap<LintExpectationId, LintExpectationId>,
145+
) {
146+
if let Level::Expect(expectation_id) = &mut self.level {
147+
if expectation_id.is_stable() {
148+
return;
149+
}
150+
151+
// The unstable to stable map only maps the unstable `AttrId` to a stable `HirId` with an attribute index.
152+
// The lint index inside the attribute is manually transferred here.
153+
let lint_index = expectation_id.get_lint_index();
154+
expectation_id.set_lint_index(None);
155+
let mut stable_id = *unstable_to_stable
156+
.get(&expectation_id)
157+
.expect("each unstable `LintExpectationId` must have a matching stable id");
158+
159+
stable_id.set_lint_index(lint_index);
160+
*expectation_id = stable_id;
161+
}
162+
}
163+
141164
pub fn has_future_breakage(&self) -> bool {
142165
match self.code {
143166
Some(DiagnosticId::Lint { has_future_breakage, .. }) => has_future_breakage,

compiler/rustc_errors/src/lib.rs

+18-12
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,11 @@ impl Drop for HandlerInner {
522522
"no warnings or errors encountered even though `delayed_good_path_bugs` issued",
523523
);
524524
}
525+
526+
assert!(
527+
self.unstable_expect_diagnostics.is_empty(),
528+
"all diagnostics with unstable expectations should have been converted",
529+
);
525530
}
526531
}
527532

@@ -942,29 +947,30 @@ impl Handler {
942947

943948
let mut inner = self.inner.borrow_mut();
944949
for mut diag in diags.into_iter() {
945-
let mut unstable_id = diag
950+
diag.update_unstable_expectation_id(unstable_to_stable);
951+
952+
let stable_id = diag
946953
.level
947954
.get_expectation_id()
948955
.expect("all diagnostics inside `unstable_expect_diagnostics` must have a `LintExpectationId`");
949-
950-
// The unstable to stable map only maps the unstable `AttrId` to a stable `HirId` with an attribute index.
951-
// The lint index inside the attribute is manually transferred here.
952-
let lint_index = unstable_id.get_lint_index();
953-
unstable_id.set_lint_index(None);
954-
let mut stable_id = *unstable_to_stable
955-
.get(&unstable_id)
956-
.expect("each unstable `LintExpectationId` must have a matching stable id");
957-
958-
stable_id.set_lint_index(lint_index);
959-
diag.level = Level::Expect(stable_id);
960956
inner.fulfilled_expectations.insert(stable_id);
961957

962958
(*TRACK_DIAGNOSTICS)(&diag);
963959
}
960+
961+
inner
962+
.stashed_diagnostics
963+
.values_mut()
964+
.for_each(|diag| diag.update_unstable_expectation_id(unstable_to_stable));
965+
inner
966+
.future_breakage_diagnostics
967+
.iter_mut()
968+
.for_each(|diag| diag.update_unstable_expectation_id(unstable_to_stable));
964969
}
965970

966971
/// This methods steals all [`LintExpectationId`]s that are stored inside
967972
/// [`HandlerInner`] and indicate that the linked expectation has been fulfilled.
973+
#[must_use]
968974
pub fn steal_fulfilled_expectation_ids(&self) -> FxHashSet<LintExpectationId> {
969975
assert!(
970976
self.inner.borrow().unstable_expect_diagnostics.is_empty(),

compiler/rustc_expand/src/mbe/macro_check.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,12 @@ fn check_occurrences(
337337
let name = MacroRulesNormalizedIdent::new(name);
338338
check_ops_is_prefix(sess, node_id, macros, binders, ops, span, name);
339339
}
340-
// FIXME(c410-f3r) Check token (https://github.com/rust-lang/rust/issues/93902)
341-
TokenTree::MetaVarExpr(..) => {}
340+
TokenTree::MetaVarExpr(dl, ref mve) => {
341+
let Some(name) = mve.ident().map(MacroRulesNormalizedIdent::new) else {
342+
return;
343+
};
344+
check_ops_is_prefix(sess, node_id, macros, binders, ops, dl.entire(), name);
345+
}
342346
TokenTree::Delimited(_, ref del) => {
343347
check_nested_occurrences(sess, node_id, &del.tts, macros, binders, ops, valid);
344348
}

compiler/rustc_expand/src/mbe/macro_parser.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,11 @@ pub(super) fn count_names(ms: &[TokenTree]) -> usize {
324324
TokenTree::Delimited(_, ref delim) => count_names(&delim.tts),
325325
TokenTree::MetaVar(..) => 0,
326326
TokenTree::MetaVarDecl(..) => 1,
327-
// FIXME(c410-f3r) MetaVarExpr should be handled instead of being ignored
328-
// https://github.com/rust-lang/rust/issues/9390
327+
// Panicking here would abort execution because `parse_tree` makes use of this
328+
// function. In other words, RHS meta-variable expressions eventually end-up here.
329+
//
330+
// `0` is still returned to inform that no meta-variable was found. `Meta-variables
331+
// != Meta-variable expressions`
329332
TokenTree::MetaVarExpr(..) => 0,
330333
TokenTree::Sequence(_, ref seq) => seq.num_captures,
331334
TokenTree::Token(..) => 0,

compiler/rustc_expand/src/mbe/metavar_expr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ impl MetaVarExpr {
6262
Ok(rslt)
6363
}
6464

65-
crate fn ident(&self) -> Option<&Ident> {
66-
match self {
67-
MetaVarExpr::Count(ident, _) | MetaVarExpr::Ignore(ident) => Some(&ident),
65+
crate fn ident(&self) -> Option<Ident> {
66+
match *self {
67+
MetaVarExpr::Count(ident, _) | MetaVarExpr::Ignore(ident) => Some(ident),
6868
MetaVarExpr::Index(..) | MetaVarExpr::Length(..) => None,
6969
}
7070
}

compiler/rustc_expand/src/mbe/transcribe.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ fn lockstep_iter_size(
399399
TokenTree::MetaVarExpr(_, ref expr) => {
400400
let default_rslt = LockstepIterSize::Unconstrained;
401401
let Some(ident) = expr.ident() else { return default_rslt; };
402-
let name = MacroRulesNormalizedIdent::new(ident.clone());
402+
let name = MacroRulesNormalizedIdent::new(ident);
403403
match lookup_cur_matched(name, interpolations, repeats) {
404404
Some(MatchedSeq(ref ads)) => {
405405
default_rslt.with(LockstepIterSize::Constraint(ads.len(), name))
@@ -479,7 +479,7 @@ fn count_repetitions<'a>(
479479
count(cx, 0, depth_opt, matched, sp)
480480
}
481481

482-
/// Returns a `NamedMatch` item declared on the RHS given an arbitrary [Ident]
482+
/// Returns a `NamedMatch` item declared on the LHS given an arbitrary [Ident]
483483
fn matched_from_ident<'ctx, 'interp, 'rslt>(
484484
cx: &ExtCtxt<'ctx>,
485485
ident: Ident,

compiler/rustc_feature/src/accepted.rs

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ declare_features! (
4646
// feature-group-start: accepted features
4747
// -------------------------------------------------------------------------
4848

49+
/// Allows `#[target_feature(...)]` on aarch64 platforms
50+
(accepted, aarch64_target_feature, "1.61.0", Some(44839), None),
4951
/// Allows the sysV64 ABI to be specified on all platforms
5052
/// instead of just the platforms on which it is the C ABI.
5153
(accepted, abi_sysv64, "1.24.0", Some(36167), None),

compiler/rustc_feature/src/active.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ declare_features! (
243243
// FIXME: Document these and merge with the list below.
244244

245245
// Unstable `#[target_feature]` directives.
246-
(active, aarch64_target_feature, "1.27.0", Some(44839), None),
246+
(active, aarch64_ver_target_feature, "1.27.0", Some(44839), None),
247247
(active, adx_target_feature, "1.32.0", Some(44839), None),
248248
(active, arm_target_feature, "1.27.0", Some(44839), None),
249249
(active, avx512_target_feature, "1.27.0", Some(44839), None),

compiler/rustc_lint/src/expect.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ fn emit_unfulfilled_expectation_lint(
3030
hir_id: HirId,
3131
expectation: &LintExpectation,
3232
) {
33-
// FIXME: The current implementation doesn't cover cases where the
34-
// `unfulfilled_lint_expectations` is actually expected by another lint
35-
// expectation. This can be added here by checking the lint level and
36-
// retrieving the `LintExpectationId` if it was expected.
3733
tcx.struct_span_lint_hir(
3834
builtin::UNFULFILLED_LINT_EXPECTATIONS,
3935
hir_id,
@@ -43,6 +39,11 @@ fn emit_unfulfilled_expectation_lint(
4339
if let Some(rationale) = expectation.reason {
4440
diag.note(&rationale.as_str());
4541
}
42+
43+
if expectation.is_unfulfilled_lint_expectations {
44+
diag.note("the `unfulfilled_lint_expectations` lint can't be expected and will always produce this message");
45+
}
46+
4647
diag.emit();
4748
},
4849
);

0 commit comments

Comments
 (0)