Skip to content

Conversation

@anforowicz
Copy link
Contributor

This PR is an implementation of the RFC tracked in #151425

@rustbot
Copy link
Collaborator

rustbot commented Jan 20, 2026

Some changes occurred in compiler/rustc_hir/src/attrs

cc @jdonszelmann, @JonathanBrouwer

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann, @JonathanBrouwer

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann, @JonathanBrouwer

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 20, 2026
@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jan 20, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 20, 2026

r? @chenyukang

rustbot has assigned @chenyukang.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@Kivooeo
Copy link
Member

Kivooeo commented Jan 20, 2026

i had a quick look, mostly looks good, but i'd like to maybe @JonathanBrouwer take a look on this as well, i may overlooked something

r? JonathanBrouwer

@JonathanBrouwer
Copy link
Contributor

Would like to take a look, will do so tomorrow :)

@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 21, 2026

☔ The latest upstream changes (presumably #151436) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Contributor

@JonathanBrouwer JonathanBrouwer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor questions, looks good on a high level :)

View changes since this review

const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost;
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const ALLOWED_TARGETS: AllowedTargets =
AllowedTargets::AllowListWarnRest(&[Allow(Target::Fn), Allow(Target::Static)]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason you choose WarnRest here?
I'd prefer for new attributes to default to AllowedTargets::AllowList.

return None;
};
let Ok(visibility) = ExportVisibilityAttrValue::from_str(sv.as_str()) else {
cx.emit_err(InvalidExportVisibility {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this use cx.expected_specific_argument_strings instead?
(not sure)

export_visibility_span,
"#[export_visibility = ...]` will be ignored without \
`export_name`, `no_mangle`, or similar attribute",
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make these struct errors?
In my opinion these are still nicer for simple errors like this. If you strongly disagree feel free to keep them like this

fn from_str(s: &str) -> Result<ExportVisibilityAttrValue, Self::Err> {
match s {
"target_default" => Ok(ExportVisibilityAttrValue::TargetDefault),
_ => Err(format!("'{s}' is not a valid value for #[export_visibility = ...]",)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this string used anywhere? If not, could we make the Err type ()?

EiiImpls(..) => No,
ExportName { .. } => Yes,
ExportStable => No,
ExportVisibility { .. } => Yes,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is exporting this attribute needed? (Not sure, genuine question)

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 21, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 21, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants