-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
More unsafe attr verification #127543
More unsafe attr verification #127543
Conversation
@@ -373,7 +373,7 @@ impl<'a> Parser<'a> { | |||
/// MetaItem = SimplePath ( '=' UNSUFFIXED_LIT | '(' MetaSeq? ')' )? ; | |||
/// MetaSeq = MetaItemInner (',' MetaItemInner)* ','? ; | |||
/// ``` | |||
pub fn parse_meta_item(&mut self) -> PResult<'a, ast::MetaItem> { | |||
pub fn parse_meta_item(&mut self, allow_leading_unsafe: bool) -> PResult<'a, ast::MetaItem> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of a bool
, can we make this an enum AllowLeadingUnsafe { Yes, No }
? It makes it easier to read the calls in isolation without having to check the signature.
error: `cfg` is not an unsafe attribute | ||
--> $DIR/extraneous-unsafe-attributes.rs:5:3 | ||
| | ||
LL | #[unsafe(cfg(any()))] | ||
| ^^^^^^ | ||
| | ||
= note: extraneous unsafe is not allowed in attributes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error: `cfg` is not an unsafe attribute | |
--> $DIR/extraneous-unsafe-attributes.rs:5:3 | |
| | |
LL | #[unsafe(cfg(any()))] | |
| ^^^^^^ | |
| | |
= note: extraneous unsafe is not allowed in attributes | |
error: `cfg` is not an unsafe attribute | |
--> $DIR/extraneous-unsafe-attributes.rs:5:3 | |
| | |
LL | #[unsafe(cfg(any()))] | |
| ^^^^^^ --- this is not an unsafe attribute | |
| | | |
| extraneous unsafe is not allowed in attributes |
r=me after the |
☔ The latest upstream changes (presumably #127706) made this pull request unmergeable. Please resolve the merge conflicts. |
bd94a21
to
95d1101
Compare
@rustbot reviewer |
@rustbot review |
Oh I did that already, oops. |
🌲 The tree is currently closed for pull requests below priority 100. This pull request will be tested once the tree is reopened. |
☔ The latest upstream changes (presumably #125443) made this pull request unmergeable. Please resolve the merge conflicts. |
…iaskrgr Rollup of 5 pull requests Successful merges: - rust-lang#109174 (Replace `io::Cursor::{remaining_slice, is_empty}`) - rust-lang#127290 (Fully document `rustdoc-json-types`) - rust-lang#128055 (std: unsafe-wrap personality::dwarf::eh) - rust-lang#128269 (improve cargo invocations on bootstrap) - rust-lang#128310 (Add missing periods on `BTreeMap` cursor `peek_next` docs) Failed merges: - rust-lang#127543 (More unsafe attr verification) - rust-lang#128182 (handle no_std targets on std builds) r? `@ghost` `@rustbot` modify labels: rollup
95d1101
to
5bd483d
Compare
This comment has been minimized.
This comment has been minimized.
5bd483d
to
71c1060
Compare
This comment has been minimized.
This comment has been minimized.
71c1060
to
989b363
Compare
This comment has been minimized.
This comment has been minimized.
989b363
to
8eaf51b
Compare
…ification, r=estebank,traviscross More unsafe attr verification This code denies unsafe on attributes such as `#[test]` and `#[ignore]`, while also changing the `MetaItem` parsing so `unsafe` in args like `#[allow(unsafe(dead_code))]` is not accidentally allowed. Tracking: - rust-lang#123757
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#127543 (More unsafe attr verification) - rust-lang#128357 (Detect non-lifetime binder params shadowing item params) - rust-lang#128367 (CI: rfl: build the generated doctests and documentation) - rust-lang#128376 (Mark `Parser::eat`/`check` methods as `#[must_use]`) - rust-lang#128379 (the output in stderr expects panic-unwind) - rust-lang#128380 (make `///` doc comments compatible with naked functions) - rust-lang#128382 (cargo-miri: better error when we seem to run inside bootstrap but something is wrong) - rust-lang#128398 (tidy: Fix quote in error message) r? `@ghost` `@rustbot` modify labels: rollup
@bors r- rollup=iffy |
This makes it possible for the `unsafe(...)` syntax to only be valid at the top level, and the `NestedMetaItem`s will automatically reject `unsafe(...)`.
8eaf51b
to
49db8a5
Compare
@carbotaniuman pushed a fix; let's try again... |
☀️ Test successful - checks-actions |
Finished benchmarking commit (c0e3298): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 758.41s -> 756.519s (-0.25%) |
This code denies unsafe on attributes such as
#[test]
and#[ignore]
, while also changing theMetaItem
parsing sounsafe
in args like#[allow(unsafe(dead_code))]
is not accidentally allowed.Tracking: