Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 5 pull requests #94935

Merged
merged 16 commits into from
Mar 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions compiler/rustc_codegen_llvm/src/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,6 @@ pub fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> SmallVec<[&'a str; 2]
("x86", "avx512gfni") => smallvec!["gfni"],
("x86", "avx512vpclmulqdq") => smallvec!["vpclmulqdq"],
("aarch64", "fp") => smallvec!["fp-armv8"],
("aarch64", "fp16") => smallvec!["fullfp16"],
("aarch64", "fhm") => smallvec!["fp16fml"],
("aarch64", "rcpc2") => smallvec!["rcpc-immo"],
("aarch64", "dpb") => smallvec!["ccpp"],
("aarch64", "dpb2") => smallvec!["ccdp"],
Expand All @@ -198,6 +196,19 @@ pub fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> SmallVec<[&'a str; 2]
("aarch64", "pmuv3") => smallvec!["perfmon"],
("aarch64", "paca") => smallvec!["pauth"],
("aarch64", "pacg") => smallvec!["pauth"],
// Rust ties fp and neon together. In LLVM neon implicitly enables fp,
// but we manually enable neon when a feature only implicitly enables fp
("aarch64", "f32mm") => smallvec!["f32mm", "neon"],
("aarch64", "f64mm") => smallvec!["f64mm", "neon"],
("aarch64", "fhm") => smallvec!["fp16fml", "neon"],
("aarch64", "fp16") => smallvec!["fullfp16", "neon"],
("aarch64", "jsconv") => smallvec!["jsconv", "neon"],
("aarch64", "sve") => smallvec!["sve", "neon"],
("aarch64", "sve2") => smallvec!["sve2", "neon"],
("aarch64", "sve2-aes") => smallvec!["sve2-aes", "neon"],
("aarch64", "sve2-sm4") => smallvec!["sve2-sm4", "neon"],
("aarch64", "sve2-sha3") => smallvec!["sve2-sha3", "neon"],
("aarch64", "sve2-bitperm") => smallvec!["sve2-bitperm", "neon"],
(_, s) => smallvec![s],
}
}
Expand Down Expand Up @@ -490,7 +501,7 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec<Str
if RUSTC_SPECIFIC_FEATURES.contains(&feature) {
return SmallVec::<[_; 2]>::new();
}
// ... otherwise though we run through `to_llvm_feature when
// ... otherwise though we run through `to_llvm_features` when
// passing requests down to LLVM. This means that all in-language
// features also work on the command line instead of having two
// different names when the LLVM name and the Rust name differ.
Expand Down
109 changes: 56 additions & 53 deletions compiler/rustc_codegen_ssa/src/target_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,105 +44,108 @@ const ARM_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[

const AARCH64_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
// FEAT_AdvSimd
("neon", Some(sym::aarch64_target_feature)),
("neon", None),
// FEAT_FP
("fp", Some(sym::aarch64_target_feature)),
("fp", None),
// FEAT_FP16
("fp16", Some(sym::aarch64_target_feature)),
("fp16", None),
// FEAT_SVE
("sve", Some(sym::aarch64_target_feature)),
("sve", None),
// FEAT_CRC
("crc", Some(sym::aarch64_target_feature)),
("crc", None),
// FEAT_RAS
("ras", Some(sym::aarch64_target_feature)),
("ras", None),
// FEAT_LSE
("lse", Some(sym::aarch64_target_feature)),
("lse", None),
// FEAT_RDM
("rdm", Some(sym::aarch64_target_feature)),
("rdm", None),
// FEAT_RCPC
("rcpc", Some(sym::aarch64_target_feature)),
("rcpc", None),
// FEAT_RCPC2
("rcpc2", Some(sym::aarch64_target_feature)),
("rcpc2", None),
// FEAT_DotProd
("dotprod", Some(sym::aarch64_target_feature)),
("dotprod", None),
// FEAT_TME
("tme", Some(sym::aarch64_target_feature)),
("tme", None),
// FEAT_FHM
("fhm", Some(sym::aarch64_target_feature)),
("fhm", None),
// FEAT_DIT
("dit", Some(sym::aarch64_target_feature)),
("dit", None),
// FEAT_FLAGM
("flagm", Some(sym::aarch64_target_feature)),
("flagm", None),
// FEAT_SSBS
("ssbs", Some(sym::aarch64_target_feature)),
("ssbs", None),
// FEAT_SB
("sb", Some(sym::aarch64_target_feature)),
("sb", None),
// FEAT_PAUTH (address authentication)
("paca", Some(sym::aarch64_target_feature)),
("paca", None),
// FEAT_PAUTH (generic authentication)
("pacg", Some(sym::aarch64_target_feature)),
("pacg", None),
// FEAT_DPB
("dpb", Some(sym::aarch64_target_feature)),
("dpb", None),
// FEAT_DPB2
("dpb2", Some(sym::aarch64_target_feature)),
("dpb2", None),
// FEAT_SVE2
("sve2", Some(sym::aarch64_target_feature)),
("sve2", None),
// FEAT_SVE2_AES
("sve2-aes", Some(sym::aarch64_target_feature)),
("sve2-aes", None),
// FEAT_SVE2_SM4
("sve2-sm4", Some(sym::aarch64_target_feature)),
("sve2-sm4", None),
// FEAT_SVE2_SHA3
("sve2-sha3", Some(sym::aarch64_target_feature)),
("sve2-sha3", None),
// FEAT_SVE2_BitPerm
("sve2-bitperm", Some(sym::aarch64_target_feature)),
("sve2-bitperm", None),
// FEAT_FRINTTS
("frintts", Some(sym::aarch64_target_feature)),
("frintts", None),
// FEAT_I8MM
("i8mm", Some(sym::aarch64_target_feature)),
("i8mm", None),
// FEAT_F32MM
("f32mm", Some(sym::aarch64_target_feature)),
("f32mm", None),
// FEAT_F64MM
("f64mm", Some(sym::aarch64_target_feature)),
("f64mm", None),
// FEAT_BF16
("bf16", Some(sym::aarch64_target_feature)),
("bf16", None),
// FEAT_RAND
("rand", Some(sym::aarch64_target_feature)),
("rand", None),
// FEAT_BTI
("bti", Some(sym::aarch64_target_feature)),
("bti", None),
// FEAT_MTE
("mte", Some(sym::aarch64_target_feature)),
("mte", None),
// FEAT_JSCVT
("jsconv", Some(sym::aarch64_target_feature)),
("jsconv", None),
// FEAT_FCMA
("fcma", Some(sym::aarch64_target_feature)),
("fcma", None),
// FEAT_AES
("aes", Some(sym::aarch64_target_feature)),
("aes", None),
// FEAT_SHA1 & FEAT_SHA256
("sha2", Some(sym::aarch64_target_feature)),
("sha2", None),
// FEAT_SHA512 & FEAT_SHA3
("sha3", Some(sym::aarch64_target_feature)),
("sha3", None),
// FEAT_SM3 & FEAT_SM4
("sm4", Some(sym::aarch64_target_feature)),
("sm4", None),
// FEAT_PAN
("pan", Some(sym::aarch64_target_feature)),
("pan", None),
// FEAT_LOR
("lor", Some(sym::aarch64_target_feature)),
("lor", None),
// FEAT_VHE
("vh", Some(sym::aarch64_target_feature)),
("vh", None),
// FEAT_PMUv3
("pmuv3", Some(sym::aarch64_target_feature)),
("pmuv3", None),
// FEAT_SPE
("spe", Some(sym::aarch64_target_feature)),
("v8.1a", Some(sym::aarch64_target_feature)),
("v8.2a", Some(sym::aarch64_target_feature)),
("v8.3a", Some(sym::aarch64_target_feature)),
("v8.4a", Some(sym::aarch64_target_feature)),
("v8.5a", Some(sym::aarch64_target_feature)),
("v8.6a", Some(sym::aarch64_target_feature)),
("v8.7a", Some(sym::aarch64_target_feature)),
("spe", None),
("v8.1a", Some(sym::aarch64_ver_target_feature)),
("v8.2a", Some(sym::aarch64_ver_target_feature)),
("v8.3a", Some(sym::aarch64_ver_target_feature)),
("v8.4a", Some(sym::aarch64_ver_target_feature)),
("v8.5a", Some(sym::aarch64_ver_target_feature)),
("v8.6a", Some(sym::aarch64_ver_target_feature)),
("v8.7a", Some(sym::aarch64_ver_target_feature)),
];

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

const X86_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
("adx", Some(sym::adx_target_feature)),
Expand Down
25 changes: 24 additions & 1 deletion compiler/rustc_errors/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use crate::Substitution;
use crate::SubstitutionPart;
use crate::SuggestionStyle;
use crate::ToolMetadata;
use rustc_lint_defs::Applicability;
use rustc_data_structures::stable_map::FxHashMap;
use rustc_lint_defs::{Applicability, LintExpectationId};
use rustc_serialize::json::Json;
use rustc_span::edition::LATEST_STABLE_EDITION;
use rustc_span::{MultiSpan, Span, DUMMY_SP};
Expand Down Expand Up @@ -138,6 +139,28 @@ impl Diagnostic {
}
}

pub fn update_unstable_expectation_id(
&mut self,
unstable_to_stable: &FxHashMap<LintExpectationId, LintExpectationId>,
) {
if let Level::Expect(expectation_id) = &mut self.level {
if expectation_id.is_stable() {
return;
}

// The unstable to stable map only maps the unstable `AttrId` to a stable `HirId` with an attribute index.
// The lint index inside the attribute is manually transferred here.
let lint_index = expectation_id.get_lint_index();
expectation_id.set_lint_index(None);
let mut stable_id = *unstable_to_stable
.get(&expectation_id)
.expect("each unstable `LintExpectationId` must have a matching stable id");

stable_id.set_lint_index(lint_index);
*expectation_id = stable_id;
}
}

pub fn has_future_breakage(&self) -> bool {
match self.code {
Some(DiagnosticId::Lint { has_future_breakage, .. }) => has_future_breakage,
Expand Down
30 changes: 18 additions & 12 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,11 @@ impl Drop for HandlerInner {
"no warnings or errors encountered even though `delayed_good_path_bugs` issued",
);
}

assert!(
self.unstable_expect_diagnostics.is_empty(),
"all diagnostics with unstable expectations should have been converted",
);
}
}

Expand Down Expand Up @@ -942,29 +947,30 @@ impl Handler {

let mut inner = self.inner.borrow_mut();
for mut diag in diags.into_iter() {
let mut unstable_id = diag
diag.update_unstable_expectation_id(unstable_to_stable);

let stable_id = diag
.level
.get_expectation_id()
.expect("all diagnostics inside `unstable_expect_diagnostics` must have a `LintExpectationId`");

// The unstable to stable map only maps the unstable `AttrId` to a stable `HirId` with an attribute index.
// The lint index inside the attribute is manually transferred here.
let lint_index = unstable_id.get_lint_index();
unstable_id.set_lint_index(None);
let mut stable_id = *unstable_to_stable
.get(&unstable_id)
.expect("each unstable `LintExpectationId` must have a matching stable id");

stable_id.set_lint_index(lint_index);
diag.level = Level::Expect(stable_id);
inner.fulfilled_expectations.insert(stable_id);

(*TRACK_DIAGNOSTICS)(&diag);
}

inner
.stashed_diagnostics
.values_mut()
.for_each(|diag| diag.update_unstable_expectation_id(unstable_to_stable));
inner
.future_breakage_diagnostics
.iter_mut()
.for_each(|diag| diag.update_unstable_expectation_id(unstable_to_stable));
}

/// This methods steals all [`LintExpectationId`]s that are stored inside
/// [`HandlerInner`] and indicate that the linked expectation has been fulfilled.
#[must_use]
pub fn steal_fulfilled_expectation_ids(&self) -> FxHashSet<LintExpectationId> {
assert!(
self.inner.borrow().unstable_expect_diagnostics.is_empty(),
Expand Down
8 changes: 6 additions & 2 deletions compiler/rustc_expand/src/mbe/macro_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,12 @@ fn check_occurrences(
let name = MacroRulesNormalizedIdent::new(name);
check_ops_is_prefix(sess, node_id, macros, binders, ops, span, name);
}
// FIXME(c410-f3r) Check token (https://github.com/rust-lang/rust/issues/93902)
TokenTree::MetaVarExpr(..) => {}
TokenTree::MetaVarExpr(dl, ref mve) => {
let Some(name) = mve.ident().map(MacroRulesNormalizedIdent::new) else {
return;
};
check_ops_is_prefix(sess, node_id, macros, binders, ops, dl.entire(), name);
}
TokenTree::Delimited(_, ref del) => {
check_nested_occurrences(sess, node_id, &del.tts, macros, binders, ops, valid);
}
Expand Down
7 changes: 5 additions & 2 deletions compiler/rustc_expand/src/mbe/macro_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,11 @@ pub(super) fn count_names(ms: &[TokenTree]) -> usize {
TokenTree::Delimited(_, ref delim) => count_names(&delim.tts),
TokenTree::MetaVar(..) => 0,
TokenTree::MetaVarDecl(..) => 1,
// FIXME(c410-f3r) MetaVarExpr should be handled instead of being ignored
// https://github.com/rust-lang/rust/issues/9390
// Panicking here would abort execution because `parse_tree` makes use of this
// function. In other words, RHS meta-variable expressions eventually end-up here.
//
// `0` is still returned to inform that no meta-variable was found. `Meta-variables
// != Meta-variable expressions`
TokenTree::MetaVarExpr(..) => 0,
TokenTree::Sequence(_, ref seq) => seq.num_captures,
TokenTree::Token(..) => 0,
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_expand/src/mbe/metavar_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ impl MetaVarExpr {
Ok(rslt)
}

crate fn ident(&self) -> Option<&Ident> {
match self {
MetaVarExpr::Count(ident, _) | MetaVarExpr::Ignore(ident) => Some(&ident),
crate fn ident(&self) -> Option<Ident> {
match *self {
MetaVarExpr::Count(ident, _) | MetaVarExpr::Ignore(ident) => Some(ident),
MetaVarExpr::Index(..) | MetaVarExpr::Length(..) => None,
}
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_expand/src/mbe/transcribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ fn lockstep_iter_size(
TokenTree::MetaVarExpr(_, ref expr) => {
let default_rslt = LockstepIterSize::Unconstrained;
let Some(ident) = expr.ident() else { return default_rslt; };
let name = MacroRulesNormalizedIdent::new(ident.clone());
let name = MacroRulesNormalizedIdent::new(ident);
match lookup_cur_matched(name, interpolations, repeats) {
Some(MatchedSeq(ref ads)) => {
default_rslt.with(LockstepIterSize::Constraint(ads.len(), name))
Expand Down Expand Up @@ -479,7 +479,7 @@ fn count_repetitions<'a>(
count(cx, 0, depth_opt, matched, sp)
}

/// Returns a `NamedMatch` item declared on the RHS given an arbitrary [Ident]
/// Returns a `NamedMatch` item declared on the LHS given an arbitrary [Ident]
fn matched_from_ident<'ctx, 'interp, 'rslt>(
cx: &ExtCtxt<'ctx>,
ident: Ident,
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ declare_features! (
// feature-group-start: accepted features
// -------------------------------------------------------------------------

/// Allows `#[target_feature(...)]` on aarch64 platforms
(accepted, aarch64_target_feature, "1.61.0", Some(44839), None),
/// Allows the sysV64 ABI to be specified on all platforms
/// instead of just the platforms on which it is the C ABI.
(accepted, abi_sysv64, "1.24.0", Some(36167), None),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_feature/src/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ declare_features! (
// FIXME: Document these and merge with the list below.

// Unstable `#[target_feature]` directives.
(active, aarch64_target_feature, "1.27.0", Some(44839), None),
(active, aarch64_ver_target_feature, "1.27.0", Some(44839), None),
(active, adx_target_feature, "1.32.0", Some(44839), None),
(active, arm_target_feature, "1.27.0", Some(44839), None),
(active, avx512_target_feature, "1.27.0", Some(44839), None),
Expand Down
9 changes: 5 additions & 4 deletions compiler/rustc_lint/src/expect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ fn emit_unfulfilled_expectation_lint(
hir_id: HirId,
expectation: &LintExpectation,
) {
// FIXME: The current implementation doesn't cover cases where the
// `unfulfilled_lint_expectations` is actually expected by another lint
// expectation. This can be added here by checking the lint level and
// retrieving the `LintExpectationId` if it was expected.
tcx.struct_span_lint_hir(
builtin::UNFULFILLED_LINT_EXPECTATIONS,
hir_id,
Expand All @@ -43,6 +39,11 @@ fn emit_unfulfilled_expectation_lint(
if let Some(rationale) = expectation.reason {
diag.note(&rationale.as_str());
}

if expectation.is_unfulfilled_lint_expectations {
diag.note("the `unfulfilled_lint_expectations` lint can't be expected and will always produce this message");
}

diag.emit();
},
);
Expand Down
Loading