-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #101386 - aDotInTheVoid:rdj-discriminant, r=GuillaumeGomez
Rustdoc-Json: Add enum discriminant Does the first part of #101337, by adding it to `clean`, but doesn't change HTML output, as 1. [No Consensus has appeared on the UI for this](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Enum.20discriminant.20values.20in.20HTML.20output) 2. [When inlining across crates, information is lost](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/.60clean_variant_def.20.60vs.20.60clean_variant_data.60) JSON doesn't have either of these limitations. r? `@GuillaumeGomez`
- Loading branch information
Showing
13 changed files
with
213 additions
and
21 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
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,12 @@ | ||
#[repr(i8)] | ||
pub enum Ordering { | ||
// @is "$.index[*][?(@.name=='Less')].inner.variant_inner.expr" '"-1"' | ||
// @is "$.index[*][?(@.name=='Less')].inner.variant_inner.value" '"-1"' | ||
Less = -1, | ||
// @is "$.index[*][?(@.name=='Equal')].inner.variant_inner.expr" '"0"' | ||
// @is "$.index[*][?(@.name=='Equal')].inner.variant_inner.value" '"0"' | ||
Equal = 0, | ||
// @is "$.index[*][?(@.name=='Greater')].inner.variant_inner.expr" '"1"' | ||
// @is "$.index[*][?(@.name=='Greater')].inner.variant_inner.value" '"1"' | ||
Greater = 1, | ||
} |
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 @@ | ||
pub enum Foo { | ||
// @is "$.index[*][?(@.name=='Addition')].inner.variant_inner.value" '"0"' | ||
// @is "$.index[*][?(@.name=='Addition')].inner.variant_inner.expr" '"{ _ }"' | ||
Addition = 0 + 0, | ||
// @is "$.index[*][?(@.name=='Bin')].inner.variant_inner.value" '"1"' | ||
// @is "$.index[*][?(@.name=='Bin')].inner.variant_inner.expr" '"0b1"' | ||
Bin = 0b1, | ||
// @is "$.index[*][?(@.name=='Oct')].inner.variant_inner.value" '"2"' | ||
// @is "$.index[*][?(@.name=='Oct')].inner.variant_inner.expr" '"0o2"' | ||
Oct = 0o2, | ||
// @is "$.index[*][?(@.name=='PubConst')].inner.variant_inner.value" '"3"' | ||
// @is "$.index[*][?(@.name=='PubConst')].inner.variant_inner.expr" '"THREE"' | ||
PubConst = THREE, | ||
// @is "$.index[*][?(@.name=='Hex')].inner.variant_inner.value" '"4"' | ||
// @is "$.index[*][?(@.name=='Hex')].inner.variant_inner.expr" '"0x4"' | ||
Hex = 0x4, | ||
// @is "$.index[*][?(@.name=='Cast')].inner.variant_inner.value" '"5"' | ||
// @is "$.index[*][?(@.name=='Cast')].inner.variant_inner.expr" '"{ _ }"' | ||
Cast = 5 as isize, | ||
// @is "$.index[*][?(@.name=='PubCall')].inner.variant_inner.value" '"6"' | ||
// @is "$.index[*][?(@.name=='PubCall')].inner.variant_inner.expr" '"{ _ }"' | ||
PubCall = six(), | ||
// @is "$.index[*][?(@.name=='PrivCall')].inner.variant_inner.value" '"7"' | ||
// @is "$.index[*][?(@.name=='PrivCall')].inner.variant_inner.expr" '"{ _ }"' | ||
PrivCall = seven(), | ||
// @is "$.index[*][?(@.name=='PrivConst')].inner.variant_inner.value" '"8"' | ||
// @is "$.index[*][?(@.name=='PrivConst')].inner.variant_inner.expr" '"EIGHT"' | ||
PrivConst = EIGHT, | ||
} | ||
|
||
pub const THREE: isize = 3; | ||
const EIGHT: isize = 8; | ||
|
||
pub const fn six() -> isize { | ||
6 | ||
} | ||
const fn seven() -> isize { | ||
7 | ||
} |
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,43 @@ | ||
// ignore-tidy-linelength | ||
#![feature(repr128)] | ||
#![allow(incomplete_features)] | ||
|
||
#[repr(u64)] | ||
pub enum U64 { | ||
// @is "$.index[*][?(@.name=='U64Min')].inner.variant_inner.value" '"0"' | ||
// @is "$.index[*][?(@.name=='U64Min')].inner.variant_inner.expr" '"u64::MIN"' | ||
U64Min = u64::MIN, | ||
// @is "$.index[*][?(@.name=='U64Max')].inner.variant_inner.value" '"18446744073709551615"' | ||
// @is "$.index[*][?(@.name=='U64Max')].inner.variant_inner.expr" '"u64::MAX"' | ||
U64Max = u64::MAX, | ||
} | ||
|
||
#[repr(i64)] | ||
pub enum I64 { | ||
// @is "$.index[*][?(@.name=='I64Min')].inner.variant_inner.value" '"-9223372036854775808"' | ||
// @is "$.index[*][?(@.name=='I64Min')].inner.variant_inner.expr" '"i64::MIN"' | ||
I64Min = i64::MIN, | ||
// @is "$.index[*][?(@.name=='I64Max')].inner.variant_inner.value" '"9223372036854775807"' | ||
// @is "$.index[*][?(@.name=='I64Max')].inner.variant_inner.expr" '"i64::MAX"' | ||
I64Max = i64::MAX, | ||
} | ||
|
||
#[repr(u128)] | ||
pub enum U128 { | ||
// @is "$.index[*][?(@.name=='U128Min')].inner.variant_inner.value" '"0"' | ||
// @is "$.index[*][?(@.name=='U128Min')].inner.variant_inner.expr" '"u128::MIN"' | ||
U128Min = u128::MIN, | ||
// @is "$.index[*][?(@.name=='U128Max')].inner.variant_inner.value" '"340282366920938463463374607431768211455"' | ||
// @is "$.index[*][?(@.name=='U128Max')].inner.variant_inner.expr" '"u128::MAX"' | ||
U128Max = u128::MAX, | ||
} | ||
|
||
#[repr(i128)] | ||
pub enum I128 { | ||
// @is "$.index[*][?(@.name=='I128Min')].inner.variant_inner.value" '"-170141183460469231731687303715884105728"' | ||
// @is "$.index[*][?(@.name=='I128Min')].inner.variant_inner.expr" '"i128::MIN"' | ||
I128Min = i128::MIN, | ||
// @is "$.index[*][?(@.name=='I128Max')].inner.variant_inner.value" '"170141183460469231731687303715884105727"' | ||
// @is "$.index[*][?(@.name=='I128Max')].inner.variant_inner.expr" '"i128::MAX"' | ||
I128Max = i128::MAX, | ||
} |
15 changes: 15 additions & 0 deletions
15
src/test/rustdoc-json/enums/discriminant/num_underscore_and_suffix.rs
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,15 @@ | ||
#[repr(u32)] | ||
pub enum Foo { | ||
// @is "$.index[*][?(@.name=='Basic')].inner.variant_inner.value" '"0"' | ||
// @is "$.index[*][?(@.name=='Basic')].inner.variant_inner.expr" '"0"' | ||
Basic = 0, | ||
// @is "$.index[*][?(@.name=='Suffix')].inner.variant_inner.value" '"10"' | ||
// @is "$.index[*][?(@.name=='Suffix')].inner.variant_inner.expr" '"10u32"' | ||
Suffix = 10u32, | ||
// @is "$.index[*][?(@.name=='Underscore')].inner.variant_inner.value" '"100"' | ||
// @is "$.index[*][?(@.name=='Underscore')].inner.variant_inner.expr" '"1_0_0"' | ||
Underscore = 1_0_0, | ||
// @is "$.index[*][?(@.name=='SuffixUnderscore')].inner.variant_inner.value" '"1000"' | ||
// @is "$.index[*][?(@.name=='SuffixUnderscore')].inner.variant_inner.expr" '"1_0_0_0u32"' | ||
SuffixUnderscore = 1_0_0_0u32, | ||
} |
10 changes: 10 additions & 0 deletions
10
src/test/rustdoc-json/enums/discriminant/only_some_have_discriminant.rs
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,10 @@ | ||
pub enum Foo { | ||
// @is "$.index[*][?(@.name=='Has')].inner.variant_inner" '{"expr":"0", "value":"0"}' | ||
Has = 0, | ||
// @is "$.index[*][?(@.name=='Doesnt')].inner.variant_inner" null | ||
Doesnt, | ||
// @is "$.index[*][?(@.name=='AlsoDoesnt')].inner.variant_inner" null | ||
AlsoDoesnt, | ||
// @is "$.index[*][?(@.name=='AlsoHas')].inner.variant_inner" '{"expr":"44", "value":"44"}' | ||
AlsoHas = 44, | ||
} |