-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Unsafe extern blocks #124482
Unsafe extern blocks #124482
Conversation
|
This comment has been minimized.
This comment has been minimized.
Ohh I forgot to mention this. I'd need to land some PRs, at least to stdarch so it doesn't warn for the usages of |
eff0aa5
to
4db4aac
Compare
This comment has been minimized.
This comment has been minimized.
4db4aac
to
109be86
Compare
This comment has been minimized.
This comment has been minimized.
109be86
to
429a626
Compare
This comment has been minimized.
This comment has been minimized.
429a626
to
b4828d8
Compare
This comment has been minimized.
This comment has been minimized.
b4828d8
to
e7d5d4e
Compare
This comment has been minimized.
This comment has been minimized.
e7d5d4e
to
cc91d7f
Compare
This comment has been minimized.
This comment has been minimized.
cc91d7f
to
542a307
Compare
This comment has been minimized.
This comment has been minimized.
542a307
to
7b82197
Compare
This comment has been minimized.
This comment has been minimized.
7b82197
to
8f0c075
Compare
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (2d28b63): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)Results (primary 0.7%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
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: 672.766s -> 672.761s (-0.00%) |
This adds a new feature, so a small regression is probably to be expected. Marking as triaged. @rustbot label: +perf-regression-triaged |
👍, anyway there's a pre-existing issue in the way we use ItemKind and convert to ForeignItemKind for the sake of code reuse that this PR made slightly worser and may cause such small perf regression. I have this in my todo list to address. |
…li-obk Unsafe extern blocks This implements RFC 3484. Tracking issue rust-lang#123743 and RFC rust-lang/rfcs#3484 This is better reviewed commit by commit.
Properly gate `safe` keyword in pre-expansion This PR gates `safe` keyword in pre-expansion contexts. Should mitigate the fallout of rust-lang#126755, which is that `safe` is now usable on beta lol. r? `@spastorino` or `@oli-obk` cc rust-lang#124482 tracking rust-lang#123743
Properly gate `safe` keyword in pre-expansion This PR gates `safe` keyword in pre-expansion contexts. Should mitigate the fallout of rust-lang#126755, which is that `safe` is now usable on beta lol. r? ``@spastorino`` or ``@oli-obk`` cc rust-lang#124482 tracking rust-lang#123743
This includes both `ast::StaticItem` and `ast::StaticForeignItem`. `safety` was added to both `ast::StaticItem` and `ast::SaticForeignItem` in rust-lang/rust#124482.
This includes both `ast::StaticItem` and `ast::StaticForeignItem`. `safety` was added to both `ast::StaticItem` and `ast::SaticForeignItem` in rust-lang/rust#124482.
Properly gate `safe` keyword in pre-expansion This PR gates `safe` keyword in pre-expansion contexts. Should mitigate the fallout of rust-lang#126755, which is that `safe` is now usable on beta lol. r? `@spastorino` or `@oli-obk` cc rust-lang#124482 tracking rust-lang#123743
This includes both `ast::StaticItem` and `ast::StaticForeignItem`. `safety` was added to both `ast::StaticItem` and `ast::SaticForeignItem` in rust-lang/rust#124482.
… r=spastorino rustdoc: Add support for `missing_unsafe_on_extern` feature Follow-up of rust-lang#124482. Not sure if the `safe` keyword is supposed to be displayed or not though? For now I didn't add it in the generated doc, only `unsafe` as usual. cc `@spastorino` r? `@fmease`
…li-obk Unsafe extern blocks This implements RFC 3484. Tracking issue rust-lang#123743 and RFC rust-lang/rfcs#3484 This is better reviewed commit by commit.
…rino rustdoc: Add support for `missing_unsafe_on_extern` feature Follow-up of rust-lang/rust#124482. Not sure if the `safe` keyword is supposed to be displayed or not though? For now I didn't add it in the generated doc, only `unsafe` as usual. cc `@spastorino` r? `@fmease`
…rino rustdoc: Add support for `missing_unsafe_on_extern` feature Follow-up of rust-lang/rust#124482. Not sure if the `safe` keyword is supposed to be displayed or not though? For now I didn't add it in the generated doc, only `unsafe` as usual. cc `@spastorino` r? `@fmease`
…-blocks, r=compiler-errors Stabilize unsafe extern blocks (RFC 3484) # Stabilization report ## Summary This is a tracking issue for the RFC 3484: Unsafe Extern Blocks We are stabilizing `#![feature(unsafe_extern_blocks)]`, as described in [Unsafe Extern Blocks RFC 3484](rust-lang/rfcs#3484). This feature makes explicit that declaring an extern block is unsafe. Starting in Rust 2024, all extern blocks must be marked as unsafe. In all editions, items within unsafe extern blocks may be marked as safe to use. RFC: rust-lang/rfcs#3484 Tracking issue: rust-lang#123743 ## What is stabilized ### Summary of stabilization We now need extern blocks to be marked as unsafe and items inside can also have safety modifiers (unsafe or safe), by default items with no modifiers are unsafe to offer easy migration without surprising results. ```rust unsafe extern { // sqrt (from libm) may be called with any `f64` pub safe fn sqrt(x: f64) -> f64; // strlen (from libc) requires a valid pointer, // so we mark it as being an unsafe fn pub unsafe fn strlen(p: *const c_char) -> usize; // this function doesn't say safe or unsafe, so it defaults to unsafe pub fn free(p: *mut core::ffi::c_void); pub safe static IMPORTANT_BYTES: [u8; 256]; pub safe static LINES: SyncUnsafeCell<i32>; } ``` ## Tests The relevant tests are in `tests/ui/rust-2024/unsafe-extern-blocks`. ## History - rust-lang#124482 - rust-lang#124455 - rust-lang#125077 - rust-lang#125522 - rust-lang#126738 - rust-lang#126749 - rust-lang#126755 - rust-lang#126757 - rust-lang#126758 - rust-lang#126756 - rust-lang#126973 - rust-lang#127535 - rust-lang/rustfmt#6204 ## Unresolved questions I am not aware of any unresolved questions.
…-blocks, r=compiler-errors Stabilize unsafe extern blocks (RFC 3484) # Stabilization report ## Summary This is a tracking issue for the RFC 3484: Unsafe Extern Blocks We are stabilizing `#![feature(unsafe_extern_blocks)]`, as described in [Unsafe Extern Blocks RFC 3484](rust-lang/rfcs#3484). This feature makes explicit that declaring an extern block is unsafe. Starting in Rust 2024, all extern blocks must be marked as unsafe. In all editions, items within unsafe extern blocks may be marked as safe to use. RFC: rust-lang/rfcs#3484 Tracking issue: rust-lang#123743 ## What is stabilized ### Summary of stabilization We now need extern blocks to be marked as unsafe and items inside can also have safety modifiers (unsafe or safe), by default items with no modifiers are unsafe to offer easy migration without surprising results. ```rust unsafe extern { // sqrt (from libm) may be called with any `f64` pub safe fn sqrt(x: f64) -> f64; // strlen (from libc) requires a valid pointer, // so we mark it as being an unsafe fn pub unsafe fn strlen(p: *const c_char) -> usize; // this function doesn't say safe or unsafe, so it defaults to unsafe pub fn free(p: *mut core::ffi::c_void); pub safe static IMPORTANT_BYTES: [u8; 256]; pub safe static LINES: SyncUnsafeCell<i32>; } ``` ## Tests The relevant tests are in `tests/ui/rust-2024/unsafe-extern-blocks`. ## History - rust-lang#124482 - rust-lang#124455 - rust-lang#125077 - rust-lang#125522 - rust-lang#126738 - rust-lang#126749 - rust-lang#126755 - rust-lang#126757 - rust-lang#126758 - rust-lang#126756 - rust-lang#126973 - rust-lang#127535 - rust-lang/rustfmt#6204 ## Unresolved questions I am not aware of any unresolved questions.
Rollup merge of rust-lang#127921 - spastorino:stabilize-unsafe-extern-blocks, r=compiler-errors Stabilize unsafe extern blocks (RFC 3484) # Stabilization report ## Summary This is a tracking issue for the RFC 3484: Unsafe Extern Blocks We are stabilizing `#![feature(unsafe_extern_blocks)]`, as described in [Unsafe Extern Blocks RFC 3484](rust-lang/rfcs#3484). This feature makes explicit that declaring an extern block is unsafe. Starting in Rust 2024, all extern blocks must be marked as unsafe. In all editions, items within unsafe extern blocks may be marked as safe to use. RFC: rust-lang/rfcs#3484 Tracking issue: rust-lang#123743 ## What is stabilized ### Summary of stabilization We now need extern blocks to be marked as unsafe and items inside can also have safety modifiers (unsafe or safe), by default items with no modifiers are unsafe to offer easy migration without surprising results. ```rust unsafe extern { // sqrt (from libm) may be called with any `f64` pub safe fn sqrt(x: f64) -> f64; // strlen (from libc) requires a valid pointer, // so we mark it as being an unsafe fn pub unsafe fn strlen(p: *const c_char) -> usize; // this function doesn't say safe or unsafe, so it defaults to unsafe pub fn free(p: *mut core::ffi::c_void); pub safe static IMPORTANT_BYTES: [u8; 256]; pub safe static LINES: SyncUnsafeCell<i32>; } ``` ## Tests The relevant tests are in `tests/ui/rust-2024/unsafe-extern-blocks`. ## History - rust-lang#124482 - rust-lang#124455 - rust-lang#125077 - rust-lang#125522 - rust-lang#126738 - rust-lang#126749 - rust-lang#126755 - rust-lang#126757 - rust-lang#126758 - rust-lang#126756 - rust-lang#126973 - rust-lang#127535 - rust-lang/rustfmt#6204 ## Unresolved questions I am not aware of any unresolved questions.
This implements RFC 3484.
Tracking issue #123743 and RFC rust-lang/rfcs#3484
This is better reviewed commit by commit.