-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 #81891 - CraftSpider:fn-header, r=jyn514
[rustdoc-json] Make `header` a vec of modifiers, and FunctionPointer consistent Bumps version number and adds tests, this is a breaking change. I can split this into two (`is_unsafe` -> `header` and `header: Vec<Modifiers>`) if desired. Rationale: Modifiers are individual notes on a function, it makes more sense for them to be a list of an independent enum over a String which is inconsistently exposing the HIR representation (prefix_str vs custom literals). Function pointers currently only support `unsafe`, but there has been talk on and off about allowing them to also support `const`, and this makes handling their modifiers consistent with handling those of a function, allowing better shared code. `@rustbot` modify labels: +A-rustdoc-json +T-rustdoc CC: `@HeroicKatora` r? `@jyn514`
- Loading branch information
Showing
7 changed files
with
95 additions
and
17 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
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,5 @@ | ||
// @has header.json "$.index[*][?(@.name=='FnPointer')].inner.type.inner.header" "[]" | ||
pub type FnPointer = fn(); | ||
|
||
// @has - "$.index[*][?(@.name=='UnsafePointer')].inner.type.inner.header" '["unsafe"]' | ||
pub type UnsafePointer = unsafe fn(); |
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,22 @@ | ||
// edition:2018 | ||
|
||
// @has header.json "$.index[*][?(@.name=='nothing_fn')].inner.header" "[]" | ||
pub fn nothing_fn() {} | ||
|
||
// @has - "$.index[*][?(@.name=='const_fn')].inner.header" '["const"]' | ||
pub const fn const_fn() {} | ||
|
||
// @has - "$.index[*][?(@.name=='async_fn')].inner.header" '["async"]' | ||
pub async fn async_fn() {} | ||
|
||
// @count - "$.index[*][?(@.name=='async_unsafe_fn')].inner.header[*]" 2 | ||
// @has - "$.index[*][?(@.name=='async_unsafe_fn')].inner.header[*]" '"async"' | ||
// @has - "$.index[*][?(@.name=='async_unsafe_fn')].inner.header[*]" '"unsafe"' | ||
pub async unsafe fn async_unsafe_fn() {} | ||
|
||
// @count - "$.index[*][?(@.name=='const_unsafe_fn')].inner.header[*]" 2 | ||
// @has - "$.index[*][?(@.name=='const_unsafe_fn')].inner.header[*]" '"const"' | ||
// @has - "$.index[*][?(@.name=='const_unsafe_fn')].inner.header[*]" '"unsafe"' | ||
pub const unsafe fn const_unsafe_fn() {} | ||
|
||
// It's impossible for a function to be both const and async, so no test for that |
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,26 @@ | ||
// edition:2018 | ||
|
||
pub struct Foo; | ||
|
||
impl Foo { | ||
// @has header.json "$.index[*][?(@.name=='nothing_meth')].inner.header" "[]" | ||
pub fn nothing_meth() {} | ||
|
||
// @has - "$.index[*][?(@.name=='const_meth')].inner.header" '["const"]' | ||
pub const fn const_meth() {} | ||
|
||
// @has - "$.index[*][?(@.name=='async_meth')].inner.header" '["async"]' | ||
pub async fn async_meth() {} | ||
|
||
// @count - "$.index[*][?(@.name=='async_unsafe_meth')].inner.header[*]" 2 | ||
// @has - "$.index[*][?(@.name=='async_unsafe_meth')].inner.header[*]" '"async"' | ||
// @has - "$.index[*][?(@.name=='async_unsafe_meth')].inner.header[*]" '"unsafe"' | ||
pub async unsafe fn async_unsafe_meth() {} | ||
|
||
// @count - "$.index[*][?(@.name=='const_unsafe_meth')].inner.header[*]" 2 | ||
// @has - "$.index[*][?(@.name=='const_unsafe_meth')].inner.header[*]" '"const"' | ||
// @has - "$.index[*][?(@.name=='const_unsafe_meth')].inner.header[*]" '"unsafe"' | ||
pub const unsafe fn const_unsafe_meth() {} | ||
|
||
// It's impossible for a method to be both const and async, so no test for that | ||
} |