Skip to content

Rollup of 28 pull requests #145773

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

Merged
merged 98 commits into from
Aug 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
7804d94
fix: wasm-bare targets compiling x86 builtins
JayAndJef Feb 22, 2025
e2d2926
fix: install correct cc for wasm32-unknown-emscripten
JayAndJef Mar 15, 2025
2a0fdef
fix: error message
JayAndJef Jul 1, 2025
8b1dbac
fix: remove unneeded(?) install script
JayAndJef Jul 1, 2025
dee1b19
fix: allow emcc
JayAndJef Jul 3, 2025
e772f7a
corrected lifetime in core::panic::Location::file return type
ijchen Oct 24, 2024
9c4a35e
added regression test for `core::panic::Location::file`'s lifetime
ijchen Oct 24, 2024
5577370
corrected lifetime in core::panic::Location::file return type
ijchen Oct 24, 2024
8a0438f
moved new test to updated test location
ijchen Aug 2, 2025
792ec3b
updated line number in test
ijchen Aug 2, 2025
d710a8e
reorganize rwlock file
connortsui20 Jul 19, 2025
4b7e904
add `nonpoison::rwlock` implementation
connortsui20 Jul 20, 2025
d8a0df0
reorganize rwlock tests
connortsui20 Jul 21, 2025
ad499d0
add nonpoison and poison rwlock tests
connortsui20 Jul 29, 2025
9aa8cfa
Convert moves of references to copies in RefProp
saethlin Jun 7, 2025
12eb1a0
feat(lldb debug info): improve enum value formatting in lldb
nilptr Aug 10, 2025
c39ebea
feat(lldb debug info): deref pointer types for more accurate rust typ…
nilptr Aug 10, 2025
6be749b
fix: python formatting error
nilptr Aug 10, 2025
d0841c7
Fix typos in LocalKey documentation
qxzcode Aug 19, 2025
14022c8
Adjust wording for conciseness
qxzcode Aug 19, 2025
e84d292
Tweak wording again
qxzcode Aug 19, 2025
37e7f52
Introduce ProjectionElem::try_map.
cjgillot Jul 2, 2025
9e28de2
Add codegen regression tests
okaneco Aug 14, 2025
d07009c
Fix the ABI parameter inconsistency issue in debug.rs for LoongArch64
heiher Aug 21, 2025
53b775d
rustdoc-search: GUI tests check for `//` in URL
notriddle Aug 20, 2025
719880d
Introduce reborrow unstable feature
aapoalas Aug 21, 2025
ead9f58
make primitive:pointer work in type-based search.
lolbinarycat Aug 21, 2025
5af3591
Introduce Reborrow lang item and trait
aapoalas Aug 21, 2025
fd44708
Add reborrow feature gate test
aapoalas Aug 21, 2025
4b730a2
rustdoc search: accept *mut T syntax for raw pointers
lolbinarycat Aug 21, 2025
ae9845f
add special formatting for displaying raw pointers in signatures
lolbinarycat Aug 21, 2025
eeaad50
unbox raw pointers in type-based search
lolbinarycat Aug 21, 2025
3501e4f
rustdoc: add tests for raw pointers in type-based search
lolbinarycat Aug 21, 2025
291da71
Add an experimental unsafe(force_target_feature) attribute.
veluca93 Aug 18, 2025
e5bd01b
Correct comments.
cjgillot Aug 21, 2025
42d6330
triagebot: Update style team reviewers
joshtriplett Aug 22, 2025
401f40f
tests/rustdoc-js-std/parser-errors.js: remove syntax that is now valid
lolbinarycat Aug 22, 2025
689171d
Uplift rustc_mir_transform::coverage::counters::union_find to rustc_d…
cjgillot Aug 22, 2025
5d28ce4
typecheck window.searchIndex
lolbinarycat Aug 22, 2025
4b73a7e
typecheck window.rr_
lolbinarycat Aug 22, 2025
6c22ef5
typecheck window.NOTABLE_TRAITS
lolbinarycat Aug 22, 2025
1e5b5ba
print raw lifetime idents with `r#`
fee1-dead Aug 4, 2025
30bb704
don't print invalid labels with `r#`
fee1-dead Aug 4, 2025
4970127
address review comments
fee1-dead Aug 22, 2025
e1d4f09
doc: fix some typos in comment
xihuwenhua Aug 22, 2025
d61353f
tests: Ignore basic-stepping.rs on LoongArch
heiher Aug 22, 2025
c993201
Refactor lint buffering to avoid requiring a giant enum
joshtriplett Aug 22, 2025
b5c714c
Migrate `BuiltinLintDiag::UnexpectedBuiltinCfg` to use `LintDiagnosti…
joshtriplett Aug 22, 2025
690a578
Migrate `BuiltinLintDiag::MissingAbi` to use `LintDiagnostic` directly
joshtriplett Aug 22, 2025
863387c
Remove unused `BuiltinLintDiag` variant `InnerAttributeUnstable`
joshtriplett Aug 22, 2025
52fadd8
Migrate `BuiltinLintDiag::HiddenUnicodeCodepoints` to use `LintDiagno…
joshtriplett Aug 22, 2025
774d96a
resolve: `early_resolve_ident_in_lexical_scope` -> `resolve_ident_in_…
petrochenkov Aug 19, 2025
b82b947
resolve: Remove `Module` from `ScopeSet::Late`
petrochenkov Aug 19, 2025
a47c372
resolve: Remove derive fallback lint id from `ScopeSet::Late`
petrochenkov Aug 19, 2025
e26b175
resolve: Remove `ScopeSet::Late`
petrochenkov Aug 19, 2025
9b0ddec
test(frontmatter): Show current hyphen behavior
epage Aug 22, 2025
f43f974
fix(lexer): Allow '-' in the infostring continue set
epage Aug 22, 2025
dfec2bb
typecheck window.CURRENT_TOOLTIP_ELEMENT
lolbinarycat Aug 22, 2025
cb572cb
typecheck tooltipBlurHandler
lolbinarycat Aug 22, 2025
4a2d6df
typecheck: add nonnull around element known to exist
lolbinarycat Aug 22, 2025
771c641
main.js: only call window.rustdocToggleSrcSidebar if it exists
lolbinarycat Aug 22, 2025
049c327
On E0277, point at type that doesn't implement bound
estebank Aug 19, 2025
6584749
Add aarch64_be-unknown-hermit target
Gelbpunkt Aug 22, 2025
7785efd
Rename `llvm_config` to `host_llvm_config` to avoid confusion
Kobzol Aug 22, 2025
c064521
Ship LLVM tools for the correct target when cross-compiling
Kobzol Aug 22, 2025
6315b49
Add warning to the `Builder::llvm_config` function
Kobzol Aug 22, 2025
6caa586
Recover param: Ty = EXPR
compiler-errors Feb 21, 2025
1f587e4
Revert "Detect method not being present that is present in other tupl…
lqd Aug 22, 2025
f6ac728
convert strings to symbols in attr diagnostics
jdonszelmann Aug 22, 2025
5a2b70b
add regression test for issue 142488
lqd Aug 22, 2025
dbc38ee
Rollup merge of #132087 - ijchen:issue-131770-fix, r=dtolnay
jhpratt Aug 23, 2025
85c9af5
Rollup merge of #137396 - compiler-errors:param-default, r=fmease
jhpratt Aug 23, 2025
467c89c
Rollup merge of #137457 - JayAndJef:issue-132802-fix, r=Kobzol
jhpratt Aug 23, 2025
bc4a643
Rollup merge of #142185 - saethlin:refprop-moves, r=cjgillot
jhpratt Aug 23, 2025
2bd3922
Rollup merge of #144648 - connortsui20:nonpoison_rwlock, r=Mark-Simul…
jhpratt Aug 23, 2025
2dbd411
Rollup merge of #144897 - fee1-dead-contrib:raw_lifetimes_printing, r…
jhpratt Aug 23, 2025
5cfdbd6
Rollup merge of #145218 - nilptr:nilptr/feat/lldb-enum-pretty-printer…
jhpratt Aug 23, 2025
f0a4148
Rollup merge of #145380 - okaneco:add-codegen-tests, r=Mark-Simulacrum
jhpratt Aug 23, 2025
45d5109
Rollup merge of #145573 - veluca93:unsafe-force-target-feature, r=dav…
jhpratt Aug 23, 2025
8066e76
Rollup merge of #145597 - petrochenkov:nolateset, r=b-naber
jhpratt Aug 23, 2025
6991786
Rollup merge of #145633 - qxzcode:patch-1, r=jhpratt
jhpratt Aug 23, 2025
15eedde
Rollup merge of #145641 - estebank:point-at-type-in-e0277, r=davidtwco
jhpratt Aug 23, 2025
77f980f
Rollup merge of #145669 - notriddle:test-js-search-scripts-path, r=Gu…
jhpratt Aug 23, 2025
c80e77f
Rollup merge of #145695 - cjgillot:place-elem-map, r=oli-obk,lcnr
jhpratt Aug 23, 2025
0cd557b
Rollup merge of #145710 - heiher:issue-145692-2, r=nnethercote
jhpratt Aug 23, 2025
566c13c
Rollup merge of #145726 - aapoalas:reborrow-lang-experiment, r=petroc…
jhpratt Aug 23, 2025
7798185
Rollup merge of #145731 - lolbinarycat:rustdoc-search-generic-pointer…
jhpratt Aug 23, 2025
a3d5d65
Rollup merge of #145736 - joshtriplett:triagebot-style, r=traviscross
jhpratt Aug 23, 2025
ca6415d
Rollup merge of #145738 - cjgillot:union-find-uplift, r=Zalathar
jhpratt Aug 23, 2025
2d1da7c
Rollup merge of #145742 - lolbinarycat:rustdoc-search-type-cleanup-co…
jhpratt Aug 23, 2025
c9b4c33
Rollup merge of #145743 - xihuwenhua:master, r=petrochenkov
jhpratt Aug 23, 2025
561656d
Rollup merge of #145745 - heiher:ignore-basic-stepping, r=lqd
jhpratt Aug 23, 2025
d3c9908
Rollup merge of #145747 - joshtriplett:builtin-diag-dyn, r=jdonszelmann
jhpratt Aug 23, 2025
8cabd61
Rollup merge of #145751 - epage:infostring, r=joshtriplett
jhpratt Aug 23, 2025
02a2175
Rollup merge of #145761 - Gelbpunkt:hermit-aarch64_be, r=wesleywiser
jhpratt Aug 23, 2025
87f49e4
Rollup merge of #145762 - jdonszelmann:attrs-strings-to-symbols, r=lqd
jhpratt Aug 23, 2025
676d383
Rollup merge of #145763 - Kobzol:llvm-bindir-cross, r=Mark-Simulacrum
jhpratt Aug 23, 2025
418bbb2
Rollup merge of #145765 - lqd:revert-142034, r=fmease
jhpratt Aug 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3797,6 +3797,7 @@ dependencies = [
"annotate-snippets 0.11.5",
"derive_setters",
"rustc_abi",
"rustc_ast",
"rustc_data_structures",
"rustc_error_codes",
"rustc_error_messages",
Expand Down Expand Up @@ -4134,7 +4135,6 @@ dependencies = [
name = "rustc_lint_defs"
version = "0.0.0"
dependencies = [
"rustc_abi",
"rustc_ast",
"rustc_data_structures",
"rustc_error_messages",
Expand Down
22 changes: 16 additions & 6 deletions compiler/rustc_ast/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub use NtPatKind::*;
pub use TokenKind::*;
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use rustc_span::edition::Edition;
use rustc_span::symbol::IdentPrintMode;
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span, kw, sym};
#[allow(clippy::useless_attribute)] // FIXME: following use of `hidden_glob_reexports` incorrectly triggers `useless_attribute` lint.
#[allow(hidden_glob_reexports)]
Expand Down Expand Up @@ -344,15 +345,24 @@ pub enum IdentIsRaw {
Yes,
}

impl From<bool> for IdentIsRaw {
fn from(b: bool) -> Self {
if b { Self::Yes } else { Self::No }
impl IdentIsRaw {
pub fn to_print_mode_ident(self) -> IdentPrintMode {
match self {
IdentIsRaw::No => IdentPrintMode::Normal,
IdentIsRaw::Yes => IdentPrintMode::RawIdent,
}
}
pub fn to_print_mode_lifetime(self) -> IdentPrintMode {
match self {
IdentIsRaw::No => IdentPrintMode::Normal,
IdentIsRaw::Yes => IdentPrintMode::RawLifetime,
}
}
}

impl From<IdentIsRaw> for bool {
fn from(is_raw: IdentIsRaw) -> bool {
matches!(is_raw, IdentIsRaw::Yes)
impl From<bool> for IdentIsRaw {
fn from(b: bool) -> Self {
if b { Self::Yes } else { Self::No }
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1596,7 +1596,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
let safety = self.lower_safety(h.safety, default_safety);

// Treat safe `#[target_feature]` functions as unsafe, but also remember that we did so.
let safety = if find_attr!(attrs, AttributeKind::TargetFeature { .. })
let safety = if find_attr!(attrs, AttributeKind::TargetFeature { was_forced: false, .. })
&& safety.is_safe()
&& !self.tcx.sess.target.is_like_wasm
{
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_ast_passes/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ ast_passes_extern_without_abi = `extern` declarations without an explicit ABI ar
.suggestion = specify an ABI
.help = prior to Rust 2024, a default ABI was inferred
ast_passes_extern_without_abi_sugg = `extern` declarations without an explicit ABI are deprecated
.label = ABI should be specified here
.suggestion = explicitly specify the {$default_abi} ABI
ast_passes_feature_on_non_nightly = `#![feature]` may not be used on the {$channel} release channel
.suggestion = remove the attribute
.stable_since = the feature `{$name}` has been stable since `{$since}` and no longer requires an attribute to enable
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ use rustc_ast::*;
use rustc_ast_pretty::pprust::{self, State};
use rustc_attr_parsing::validate_attr;
use rustc_data_structures::fx::FxIndexMap;
use rustc_errors::DiagCtxtHandle;
use rustc_errors::{DiagCtxtHandle, LintBuffer};
use rustc_feature::Features;
use rustc_session::Session;
use rustc_session::lint::BuiltinLintDiag;
use rustc_session::lint::builtin::{
DEPRECATED_WHERE_CLAUSE_LOCATION, MISSING_ABI, MISSING_UNSAFE_ON_EXTERN,
PATTERNS_IN_FNS_WITHOUT_BODY,
};
use rustc_session::lint::{BuiltinLintDiag, LintBuffer};
use rustc_span::{Ident, Span, kw, sym};
use rustc_target::spec::{AbiMap, AbiMapping};
use thin_vec::thin_vec;
Expand Down Expand Up @@ -876,7 +876,7 @@ impl<'a> AstValidator<'a> {
MISSING_ABI,
id,
span,
BuiltinLintDiag::MissingAbi(span, ExternAbi::FALLBACK),
errors::MissingAbiSugg { span, default_abi: ExternAbi::FALLBACK },
)
}
}
Expand Down
10 changes: 9 additions & 1 deletion compiler/rustc_ast_passes/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use rustc_abi::ExternAbi;
use rustc_ast::ParamKindOrd;
use rustc_errors::codes::*;
use rustc_errors::{Applicability, Diag, EmissionGuarantee, Subdiagnostic};
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
use rustc_span::{Ident, Span, Symbol};

use crate::fluent_generated as fluent;
Expand Down Expand Up @@ -815,6 +815,14 @@ pub(crate) struct MissingAbi {
pub span: Span,
}

#[derive(LintDiagnostic)]
#[diag(ast_passes_extern_without_abi_sugg)]
pub(crate) struct MissingAbiSugg {
#[suggestion(code = "extern {default_abi}", applicability = "machine-applicable")]
pub span: Span,
pub default_abi: ExternAbi,
}

#[derive(Diagnostic)]
#[diag(ast_passes_abi_custom_safe_foreign_function)]
pub(crate) struct AbiCustomSafeForeignFunction {
Expand Down
17 changes: 8 additions & 9 deletions compiler/rustc_ast_pretty/src/pprust/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::borrow::Cow;
use std::sync::Arc;

use rustc_ast::attr::AttrIdGenerator;
use rustc_ast::token::{self, CommentKind, Delimiter, IdentIsRaw, Token, TokenKind};
use rustc_ast::token::{self, CommentKind, Delimiter, Token, TokenKind};
use rustc_ast::tokenstream::{Spacing, TokenStream, TokenTree};
use rustc_ast::util::classify;
use rustc_ast::util::comments::{Comment, CommentStyle};
Expand Down Expand Up @@ -441,7 +441,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
fn print_generic_args(&mut self, args: &ast::GenericArgs, colons_before_params: bool);

fn print_ident(&mut self, ident: Ident) {
self.word(IdentPrinter::for_ast_ident(ident, ident.is_raw_guess()).to_string());
self.word(IdentPrinter::for_ast_ident(ident, ident.guess_print_mode()).to_string());
self.ann_post(ident)
}

Expand Down Expand Up @@ -1015,17 +1015,16 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere

/* Name components */
token::Ident(name, is_raw) => {
IdentPrinter::new(name, is_raw.into(), convert_dollar_crate).to_string().into()
IdentPrinter::new(name, is_raw.to_print_mode_ident(), convert_dollar_crate)
.to_string()
.into()
}
token::NtIdent(ident, is_raw) => {
IdentPrinter::for_ast_ident(ident, is_raw.into()).to_string().into()
IdentPrinter::for_ast_ident(ident, is_raw.to_print_mode_ident()).to_string().into()
}

token::Lifetime(name, IdentIsRaw::No)
| token::NtLifetime(Ident { name, .. }, IdentIsRaw::No) => name.to_string().into(),
token::Lifetime(name, IdentIsRaw::Yes)
| token::NtLifetime(Ident { name, .. }, IdentIsRaw::Yes) => {
format!("'r#{}", &name.as_str()[1..]).into()
token::Lifetime(name, is_raw) | token::NtLifetime(Ident { name, .. }, is_raw) => {
IdentPrinter::new(name, is_raw.to_print_mode_lifetime(), None).to_string().into()
}

/* Other */
Expand Down
127 changes: 83 additions & 44 deletions compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl<S: Stage> SingleAttributeParser<S> for OptimizeParser {
Some(sym::speed) => OptimizeAttr::Speed,
Some(sym::none) => OptimizeAttr::DoNotOptimize,
_ => {
cx.expected_specific_argument(single.span(), vec!["size", "speed", "none"]);
cx.expected_specific_argument(single.span(), &[sym::size, sym::speed, sym::none]);
OptimizeAttr::Default
}
};
Expand Down Expand Up @@ -82,7 +82,7 @@ impl<S: Stage> SingleAttributeParser<S> for CoverageParser {

fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
let Some(args) = args.list() else {
cx.expected_specific_argument_and_list(cx.attr_span, vec!["on", "off"]);
cx.expected_specific_argument_and_list(cx.attr_span, &[sym::on, sym::off]);
return None;
};

Expand All @@ -91,7 +91,8 @@ impl<S: Stage> SingleAttributeParser<S> for CoverageParser {
return None;
};

let fail_incorrect_argument = |span| cx.expected_specific_argument(span, vec!["on", "off"]);
let fail_incorrect_argument =
|span| cx.expected_specific_argument(span, &[sym::on, sym::off]);

let Some(arg) = arg.meta_item() else {
fail_incorrect_argument(args.span);
Expand Down Expand Up @@ -343,7 +344,7 @@ impl<S: Stage> AttributeParser<S> for UsedParser {
UsedBy::Linker
}
_ => {
cx.expected_specific_argument(l.span(), vec!["compiler", "linker"]);
cx.expected_specific_argument(l.span(), &[sym::compiler, sym::linker]);
return;
}
}
Expand Down Expand Up @@ -376,57 +377,68 @@ impl<S: Stage> AttributeParser<S> for UsedParser {
}
}

fn parse_tf_attribute<'c, S: Stage>(
cx: &'c mut AcceptContext<'_, '_, S>,
args: &'c ArgParser<'_>,
) -> impl IntoIterator<Item = (Symbol, Span)> + 'c {
let mut features = Vec::new();
let ArgParser::List(list) = args else {
cx.expected_list(cx.attr_span);
return features;
};
if list.is_empty() {
cx.warn_empty_attribute(cx.attr_span);
return features;
}
for item in list.mixed() {
let Some(name_value) = item.meta_item() else {
cx.expected_name_value(item.span(), Some(sym::enable));
return features;
};

// Validate name
let Some(name) = name_value.path().word_sym() else {
cx.expected_name_value(name_value.path().span(), Some(sym::enable));
return features;
};
if name != sym::enable {
cx.expected_name_value(name_value.path().span(), Some(sym::enable));
return features;
}

// Use value
let Some(name_value) = name_value.args().name_value() else {
cx.expected_name_value(item.span(), Some(sym::enable));
return features;
};
let Some(value_str) = name_value.value_as_str() else {
cx.expected_string_literal(name_value.value_span, Some(name_value.value_as_lit()));
return features;
};
for feature in value_str.as_str().split(",") {
features.push((Symbol::intern(feature), item.span()));
}
}
features
}

pub(crate) struct TargetFeatureParser;

impl<S: Stage> CombineAttributeParser<S> for TargetFeatureParser {
type Item = (Symbol, Span);
const PATH: &[Symbol] = &[sym::target_feature];
const CONVERT: ConvertFn<Self::Item> = |items, span| AttributeKind::TargetFeature(items, span);
const CONVERT: ConvertFn<Self::Item> = |items, span| AttributeKind::TargetFeature {
features: items,
attr_span: span,
was_forced: false,
};
const TEMPLATE: AttributeTemplate = template!(List: &["enable = \"feat1, feat2\""]);

fn extend<'c>(
cx: &'c mut AcceptContext<'_, '_, S>,
args: &'c ArgParser<'_>,
) -> impl IntoIterator<Item = Self::Item> + 'c {
let mut features = Vec::new();
let ArgParser::List(list) = args else {
cx.expected_list(cx.attr_span);
return features;
};
if list.is_empty() {
cx.warn_empty_attribute(cx.attr_span);
return features;
}
for item in list.mixed() {
let Some(name_value) = item.meta_item() else {
cx.expected_name_value(item.span(), Some(sym::enable));
return features;
};

// Validate name
let Some(name) = name_value.path().word_sym() else {
cx.expected_name_value(name_value.path().span(), Some(sym::enable));
return features;
};
if name != sym::enable {
cx.expected_name_value(name_value.path().span(), Some(sym::enable));
return features;
}

// Use value
let Some(name_value) = name_value.args().name_value() else {
cx.expected_name_value(item.span(), Some(sym::enable));
return features;
};
let Some(value_str) = name_value.value_as_str() else {
cx.expected_string_literal(name_value.value_span, Some(name_value.value_as_lit()));
return features;
};
for feature in value_str.as_str().split(",") {
features.push((Symbol::intern(feature), item.span()));
}
}
features
parse_tf_attribute(cx, args)
}

const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
Expand All @@ -440,3 +452,30 @@ impl<S: Stage> CombineAttributeParser<S> for TargetFeatureParser {
Warn(Target::MacroDef),
]);
}

pub(crate) struct ForceTargetFeatureParser;

impl<S: Stage> CombineAttributeParser<S> for ForceTargetFeatureParser {
type Item = (Symbol, Span);
const PATH: &[Symbol] = &[sym::force_target_feature];
const CONVERT: ConvertFn<Self::Item> = |items, span| AttributeKind::TargetFeature {
features: items,
attr_span: span,
was_forced: true,
};
const TEMPLATE: AttributeTemplate = template!(List: &["enable = \"feat1, feat2\""]);

fn extend<'c>(
cx: &'c mut AcceptContext<'_, '_, S>,
args: &'c ArgParser<'_>,
) -> impl IntoIterator<Item = Self::Item> + 'c {
parse_tf_attribute(cx, args)
}

const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
Allow(Target::Fn),
Allow(Target::Method(MethodKind::Inherent)),
Allow(Target::Method(MethodKind::Trait { body: true })),
Allow(Target::Method(MethodKind::TraitImpl)),
]);
}
2 changes: 1 addition & 1 deletion compiler/rustc_attr_parsing/src/attributes/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl<S: Stage> SingleAttributeParser<S> for InlineParser {
Some(AttributeKind::Inline(InlineAttr::Never, cx.attr_span))
}
_ => {
cx.expected_specific_argument(l.span(), vec!["always", "never"]);
cx.expected_specific_argument(l.span(), &[sym::always, sym::never]);
return None;
}
}
Expand Down
20 changes: 10 additions & 10 deletions compiler/rustc_attr_parsing/src/attributes/link_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,16 +206,16 @@ impl<S: Stage> SingleAttributeParser<S> for LinkageParser {
_ => {
cx.expected_specific_argument(
name_value.value_span,
vec![
"available_externally",
"common",
"extern_weak",
"external",
"internal",
"linkonce",
"linkonce_odr",
"weak",
"weak_odr",
&[
sym::available_externally,
sym::common,
sym::extern_weak,
sym::external,
sym::internal,
sym::linkonce,
sym::linkonce_odr,
sym::weak,
sym::weak_odr,
],
);
return None;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ fn parse_derive_like<S: Stage>(
return None;
};
if !attr_list.path().word_is(sym::attributes) {
cx.expected_specific_argument(attrs.span(), vec!["attributes"]);
cx.expected_specific_argument(attrs.span(), &[sym::attributes]);
return None;
}
let Some(attr_list) = attr_list.args().list() else {
Expand Down
Loading
Loading