Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9a0c856
Specify that split_ascii_whitespace uses the same definition as is_as…
SimonSapin May 12, 2025
8f0522d
Fix confusing WTF surrogate safety docs
teor2345 May 12, 2025
e139d26
Introduce some typedefs to improve readability.
nnethercote May 1, 2025
5b808b7
Simplify `Accepts`.
nnethercote May 1, 2025
1525f54
Fix up some comments.
nnethercote May 1, 2025
354b1cb
Avoid `rustc_span::` qualifiers.
nnethercote May 19, 2025
ec5e841
ci: move PR job x86_64-gnu-tools to codebuild
marcoieni May 24, 2025
6d47489
improve the `std::fs::create_dir_all` docs related to atomicity
fluiderson May 23, 2025
c299e29
Implement normalize lexically
ChrisDenton Dec 23, 2024
5f857a9
Rename `clean::Enum::variants` method into `non_stripped_variants`
GuillaumeGomez May 9, 2025
560aec1
Unify rendering of type aliases without ADT items
GuillaumeGomez May 9, 2025
4194745
Split `Item::attributes` method into three
GuillaumeGomez May 9, 2025
eb9f054
Rename the `document_*` argument/field into `is_type_alias`
GuillaumeGomez May 9, 2025
4f3dd7b
Tweak attribute rendering depending on wether or not it is a type alias
GuillaumeGomez May 9, 2025
2b292d1
Add regression test for #140739
GuillaumeGomez May 9, 2025
3646a09
Improve code
GuillaumeGomez May 21, 2025
ec97b0f
Update to new API
GuillaumeGomez May 25, 2025
cf9ac0e
const-check: stop recommending the use of rustc_allow_const_fn_unstable
RalfJung May 25, 2025
6341f4e
Rollup merge of #134696 - ChrisDenton:normalize-lexically, r=workingj…
jhpratt May 26, 2025
761e546
Rollup merge of #140539 - nnethercote:simplify-attribute_groups, r=jd…
jhpratt May 26, 2025
6257d2f
Rollup merge of #140863 - GuillaumeGomez:cleanup-tyalias-render, r=lo…
jhpratt May 26, 2025
9aae60b
Rollup merge of #140936 - teor2345:wtf-surrogate-docs, r=workingjubilee
jhpratt May 26, 2025
8624f9c
Rollup merge of #140952 - SimonSapin:ascii_whitespace_definition, r=d…
jhpratt May 26, 2025
a49ae1c
Rollup merge of #141472 - fluiderson:dev, r=workingjubilee
jhpratt May 26, 2025
905b46a
Rollup merge of #141502 - marcoieni:x86_64-gnu-tools-codebuild, r=Kobzol
jhpratt May 26, 2025
5a8cb6f
Rollup merge of #141559 - RalfJung:less-rustc_allow_const_fn_unstable…
jhpratt May 26, 2025
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
Prev Previous commit
Next Next commit
Simplify Accepts.
There only needs to be one `Fn` per symbol, not multiple.
  • Loading branch information
nnethercote committed May 19, 2025
commit 5b808b7da8df062f1c4d5d73c98e19e6cc4b283b
17 changes: 7 additions & 10 deletions compiler/rustc_attr_parsing/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ macro_rules! attribute_groups {
) => {
type Accepts = BTreeMap<
&'static [Symbol],
Vec<Box<dyn Send + Sync + Fn(&AcceptContext<'_>, &ArgParser<'_>)>>
Box<dyn Send + Sync + Fn(&AcceptContext<'_>, &ArgParser<'_>)>
>;
type Finalizes = Vec<
Box<dyn Send + Sync + Fn(&FinalizeContext<'_>) -> Option<AttributeKind>>
Expand All @@ -43,11 +43,12 @@ macro_rules! attribute_groups {
};

for (k, v) in <$names>::ATTRIBUTES {
accepts.entry(*k).or_default().push(Box::new(|cx, args| {
let old = accepts.insert(*k, Box::new(|cx, args| {
STATE_OBJECT.with_borrow_mut(|s| {
v(s, cx, args)
})
}));
assert!(old.is_none());
}

finalizes.push(Box::new(|cx| {
Expand Down Expand Up @@ -267,15 +268,11 @@ impl<'sess> AttributeParser<'sess> {
let (path, args) = parser.deconstruct();
let parts = path.segments().map(|i| i.name).collect::<Vec<_>>();

if let Some(accepts) = ATTRIBUTE_MAPPING.0.get(parts.as_slice()) {
for f in accepts {
let cx = AcceptContext {
group_cx: &group_cx,
attr_span: lower_span(attr.span),
};
if let Some(accept) = ATTRIBUTE_MAPPING.0.get(parts.as_slice()) {
let cx =
AcceptContext { group_cx: &group_cx, attr_span: lower_span(attr.span) };

f(&cx, &args)
}
accept(&cx, &args)
} else {
// if we're here, we must be compiling a tool attribute... Or someone forgot to
// parse their fancy new attribute. Let's warn them in any case. If you are that
Expand Down