forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#133715 - aDotInTheVoid:rdj-static, r=GuillaumeGomez rustdoc-json: Include safety of `static`s `static`s in an `extern` block can have an associated safety annotation ["because there is nothing guaranteeing that the bit pattern at the static’s memory is valid for the type it is declared with"](https://doc.rust-lang.org/reference/items/external-blocks.html#statics). Rustdoc already knows this and displays in for HTML. This PR also includes it in JSON. Inspired by obi1kenobi/cargo-semver-checks#975 which needs this, but it's probably useful in other places. r? `@GuillaumeGomez.` Possibly easier to review commit-by-commit.
- Loading branch information
Showing
4 changed files
with
84 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// ignore-tidy-linelength | ||
//@ edition: 2021 | ||
|
||
extern "C" { | ||
//@ is '$.index[*][?(@.name=="A")].inner.static.is_unsafe' true | ||
//@ is '$.index[*][?(@.name=="A")].inner.static.is_mutable' false | ||
pub static A: i32; | ||
//@ is '$.index[*][?(@.name=="B")].inner.static.is_unsafe' true | ||
//@ is '$.index[*][?(@.name=="B")].inner.static.is_mutable' true | ||
pub static mut B: i32; | ||
|
||
// items in unadorned `extern` blocks cannot have safety qualifiers | ||
} | ||
|
||
unsafe extern "C" { | ||
//@ is '$.index[*][?(@.name=="C")].inner.static.is_unsafe' true | ||
//@ is '$.index[*][?(@.name=="C")].inner.static.is_mutable' false | ||
pub static C: i32; | ||
//@ is '$.index[*][?(@.name=="D")].inner.static.is_unsafe' true | ||
//@ is '$.index[*][?(@.name=="D")].inner.static.is_mutable' true | ||
pub static mut D: i32; | ||
|
||
//@ is '$.index[*][?(@.name=="E")].inner.static.is_unsafe' false | ||
//@ is '$.index[*][?(@.name=="E")].inner.static.is_mutable' false | ||
pub safe static E: i32; | ||
//@ is '$.index[*][?(@.name=="F")].inner.static.is_unsafe' false | ||
//@ is '$.index[*][?(@.name=="F")].inner.static.is_mutable' true | ||
pub safe static mut F: i32; | ||
|
||
//@ is '$.index[*][?(@.name=="G")].inner.static.is_unsafe' true | ||
//@ is '$.index[*][?(@.name=="G")].inner.static.is_mutable' false | ||
pub unsafe static G: i32; | ||
//@ is '$.index[*][?(@.name=="H")].inner.static.is_unsafe' true | ||
//@ is '$.index[*][?(@.name=="H")].inner.static.is_mutable' true | ||
pub unsafe static mut H: i32; | ||
} | ||
|
||
//@ ismany '$.index[*][?(@.inner.static)].inner.static.expr' '""' '""' '""' '""' '""' '""' '""' '""' | ||
//@ ismany '$.index[*][?(@.inner.static)].inner.static.type.primitive' '"i32"' '"i32"' '"i32"' '"i32"' '"i32"' '"i32"' '"i32"' '"i32"' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//@ is '$.index[*][?(@.name=="A")].inner.static.type.primitive' '"i32"' | ||
//@ is '$.index[*][?(@.name=="A")].inner.static.is_mutable' false | ||
//@ is '$.index[*][?(@.name=="A")].inner.static.expr' '"5"' | ||
//@ is '$.index[*][?(@.name=="A")].inner.static.is_unsafe' false | ||
pub static A: i32 = 5; | ||
|
||
//@ is '$.index[*][?(@.name=="B")].inner.static.type.primitive' '"u32"' | ||
//@ is '$.index[*][?(@.name=="B")].inner.static.is_mutable' true | ||
// Expr value isn't gaurenteed, it'd be fine to change it. | ||
//@ is '$.index[*][?(@.name=="B")].inner.static.expr' '"_"' | ||
//@ is '$.index[*][?(@.name=="B")].inner.static.is_unsafe' false | ||
pub static mut B: u32 = 2 + 3; |