Repository navigation
Make unsafe unknown diagnostic attributes an error again - #165782
Conversation
|
Some changes occurred in compiler/rustc_attr_parsing |
|
@traviscross has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns. |
|
🔔 This is now entering its final comment period, as per the review above. 🔔 |
|
If I'm reading this right, this means that That sounds good to me, since the point of the diagnostics namespace is that it cannot have semantic effect and thus necessarily cannot ever have preconditions. @rfcbot reviewed |
Before this PR, unknown unsafe diagnostic attributes don't produce an error. |
|
Tool attributes in general cannot be unsafe. |
|
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. |
Make unsafe unknown diagnostic attributes an error again Fixes rust-lang#165692 On existing diagnostic attributes, unsafe attributes produce an error: ```rust #[unsafe(diagnostic::on_unimplemented(message = "xyz"))] //~ ERROR `diagnostic::on_unimplemented` is not an unsafe attribute trait Test1 {} ``` On non-existing diagnostic attributes, it is ignored: ```rust #[unsafe(diagnostic::invalid)] //~ WARN unknown diagnostic attribute trait Test2 {} ``` This is a problem because it means introducing new diagnostic attributes is a breaking change, technically. This bug was introduced in rust 1.99, in 1.98 and earlier both examples produced an error. This PR makes it an error again. We did not find any occurrences of this pattern on Github and it's rather contrived, so we believe nobody is affected by this. An alternative way to address this is to make both examples trigger the `unused_unsafe` lint, instead of emitting an error. However we'd prefer restoring the error behavior, as tool attributes, `diagnostic` included, should never effect behavior, so the effect they can never be unsafe. r? @JonathanBrouwer
Make unsafe unknown diagnostic attributes an error again Fixes rust-lang#165692 On existing diagnostic attributes, unsafe attributes produce an error: ```rust #[unsafe(diagnostic::on_unimplemented(message = "xyz"))] //~ ERROR `diagnostic::on_unimplemented` is not an unsafe attribute trait Test1 {} ``` On non-existing diagnostic attributes, it is ignored: ```rust #[unsafe(diagnostic::invalid)] //~ WARN unknown diagnostic attribute trait Test2 {} ``` This is a problem because it means introducing new diagnostic attributes is a breaking change, technically. This bug was introduced in rust 1.99, in 1.98 and earlier both examples produced an error. This PR makes it an error again. We did not find any occurrences of this pattern on Github and it's rather contrived, so we believe nobody is affected by this. An alternative way to address this is to make both examples trigger the `unused_unsafe` lint, instead of emitting an error. However we'd prefer restoring the error behavior, as tool attributes, `diagnostic` included, should never effect behavior, so the effect they can never be unsafe. r? @JonathanBrouwer
…uwer Rollup of 19 pull requests Successful merges: - #166266 (miri subtree update) - #164878 (Don't require `extern "llvm-intrinsic"` return structs to be `#[repr(packed)]`) - #165008 (Support `NonNull` pointers as `asm!` input operands) - #165892 (`rustc_builtin_macros` cleanup, part 10) - #165930 (Add red-green mark when dumping dep graph. Show DefIds if available) - #166280 (std: also mark doctests with skip_unsupported_miri_tests) - #166295 (use `cfg!(overflow_checks)` in `overflow_checks` intrinsic instead of `cfg!(debug_assertions)`) - #164485 (Stabilize unchecked `nonzero_ops`) - #165618 (Implement RangeIntersect on core::range types) - #165782 (Make unsafe unknown diagnostic attributes an error again) - #165833 (Deallocate with the right provenance on Windows) - #165834 (Implement tidy alphabetical --bless on Windows) - #165889 (Fix docs of alloc fn: Allocator API stabilized) - #165923 (Don't load/store a LLVM aggregate type when returning an array from a generic SIMD intrinsic) - #166012 (Added more queries to AdtDef in rustc_public to check for rust language types) - #166186 (OpenOptions::append: clarify docs) - #166216 (Stop using #![no_core] in profiler_builtins) - #166259 (fmt: Improve `Debug` for `FormattingOptions`) - #166263 (Show slice split results for empty and singleton slices)
…uwer Rollup of 18 pull requests Successful merges: - #164878 (Don't require `extern "llvm-intrinsic"` return structs to be `#[repr(packed)]`) - #165008 (Support `NonNull` pointers as `asm!` input operands) - #165892 (`rustc_builtin_macros` cleanup, part 10) - #165930 (Add red-green mark when dumping dep graph. Show DefIds if available) - #166280 (std: also mark doctests with skip_unsupported_miri_tests) - #166295 (use `cfg!(overflow_checks)` in `overflow_checks` intrinsic instead of `cfg!(debug_assertions)`) - #164485 (Stabilize unchecked `nonzero_ops`) - #165618 (Implement RangeIntersect on core::range types) - #165782 (Make unsafe unknown diagnostic attributes an error again) - #165833 (Deallocate with the right provenance on Windows) - #165834 (Implement tidy alphabetical --bless on Windows) - #165889 (Fix docs of alloc fn: Allocator API stabilized) - #165923 (Don't load/store a LLVM aggregate type when returning an array from a generic SIMD intrinsic) - #166012 (Added more queries to AdtDef in rustc_public to check for rust language types) - #166186 (OpenOptions::append: clarify docs) - #166216 (Stop using #![no_core] in profiler_builtins) - #166259 (fmt: Improve `Debug` for `FormattingOptions`) - #166263 (Show slice split results for empty and singleton slices)
…uwer Rollup of 18 pull requests Successful merges: - #164878 (Don't require `extern "llvm-intrinsic"` return structs to be `#[repr(packed)]`) - #165008 (Support `NonNull` pointers as `asm!` input operands) - #165892 (`rustc_builtin_macros` cleanup, part 10) - #165930 (Add red-green mark when dumping dep graph. Show DefIds if available) - #166280 (std: also mark doctests with skip_unsupported_miri_tests) - #166295 (use `cfg!(overflow_checks)` in `overflow_checks` intrinsic instead of `cfg!(debug_assertions)`) - #164485 (Stabilize unchecked `nonzero_ops`) - #165618 (Implement RangeIntersect on core::range types) - #165782 (Make unsafe unknown diagnostic attributes an error again) - #165833 (Deallocate with the right provenance on Windows) - #165834 (Implement tidy alphabetical --bless on Windows) - #165889 (Fix docs of alloc fn: Allocator API stabilized) - #165923 (Don't load/store a LLVM aggregate type when returning an array from a generic SIMD intrinsic) - #166012 (Added more queries to AdtDef in rustc_public to check for rust language types) - #166186 (OpenOptions::append: clarify docs) - #166216 (Stop using #![no_core] in profiler_builtins) - #166259 (fmt: Improve `Debug` for `FormattingOptions`) - #166263 (Show slice split results for empty and singleton slices)
Rollup merge of #165782 - mejrs:unsafe_attrs, r=JonathanBrouwer Make unsafe unknown diagnostic attributes an error again Fixes #165692 On existing diagnostic attributes, unsafe attributes produce an error: ```rust #[unsafe(diagnostic::on_unimplemented(message = "xyz"))] //~ ERROR `diagnostic::on_unimplemented` is not an unsafe attribute trait Test1 {} ``` On non-existing diagnostic attributes, it is ignored: ```rust #[unsafe(diagnostic::invalid)] //~ WARN unknown diagnostic attribute trait Test2 {} ``` This is a problem because it means introducing new diagnostic attributes is a breaking change, technically. This bug was introduced in rust 1.99, in 1.98 and earlier both examples produced an error. This PR makes it an error again. We did not find any occurrences of this pattern on Github and it's rather contrived, so we believe nobody is affected by this. An alternative way to address this is to make both examples trigger the `unused_unsafe` lint, instead of emitting an error. However we'd prefer restoring the error behavior, as tool attributes, `diagnostic` included, should never effect behavior, so the effect they can never be unsafe. r? @JonathanBrouwer
…uwer Rollup of 18 pull requests Successful merges: - rust-lang/rust#164878 (Don't require `extern "llvm-intrinsic"` return structs to be `#[repr(packed)]`) - rust-lang/rust#165008 (Support `NonNull` pointers as `asm!` input operands) - rust-lang/rust#165892 (`rustc_builtin_macros` cleanup, part 10) - rust-lang/rust#165930 (Add red-green mark when dumping dep graph. Show DefIds if available) - rust-lang/rust#166280 (std: also mark doctests with skip_unsupported_miri_tests) - rust-lang/rust#166295 (use `cfg!(overflow_checks)` in `overflow_checks` intrinsic instead of `cfg!(debug_assertions)`) - rust-lang/rust#164485 (Stabilize unchecked `nonzero_ops`) - rust-lang/rust#165618 (Implement RangeIntersect on core::range types) - rust-lang/rust#165782 (Make unsafe unknown diagnostic attributes an error again) - rust-lang/rust#165833 (Deallocate with the right provenance on Windows) - rust-lang/rust#165834 (Implement tidy alphabetical --bless on Windows) - rust-lang/rust#165889 (Fix docs of alloc fn: Allocator API stabilized) - rust-lang/rust#165923 (Don't load/store a LLVM aggregate type when returning an array from a generic SIMD intrinsic) - rust-lang/rust#166012 (Added more queries to AdtDef in rustc_public to check for rust language types) - rust-lang/rust#166186 (OpenOptions::append: clarify docs) - rust-lang/rust#166216 (Stop using #![no_core] in profiler_builtins) - rust-lang/rust#166259 (fmt: Improve `Debug` for `FormattingOptions`) - rust-lang/rust#166263 (Show slice split results for empty and singleton slices)
Fixes #165692
On existing diagnostic attributes, unsafe attributes produce an error:
On non-existing diagnostic attributes, it is ignored:
This is a problem because it means introducing new diagnostic attributes is a breaking change, technically.
This bug was introduced in rust 1.99, in 1.98 and earlier both examples produced an error. This PR makes it an error again. We did not find any occurrences of this pattern on Github and it's rather contrived, so we believe nobody is affected by this.
An alternative way to address this is to make both examples trigger the
unused_unsafelint, instead of emitting an error.However we'd prefer restoring the error behavior, as tool attributes,
diagnosticincluded, should never effect behavior, so the effect they can never be unsafe.r? @JonathanBrouwer