@@ -5,10 +5,12 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
5
5
use rustc_hir as hir;
6
6
use rustc_hir:: def:: CtorKind ;
7
7
use rustc_hir:: def_id:: DefId ;
8
+ use rustc_index:: IndexVec ;
8
9
use rustc_middle:: middle:: stability;
9
10
use rustc_middle:: ty:: { self , TyCtxt } ;
10
11
use rustc_span:: hygiene:: MacroKind ;
11
12
use rustc_span:: symbol:: { kw, sym, Symbol } ;
13
+ use rustc_target:: abi:: VariantIdx ;
12
14
use std:: cell:: { RefCell , RefMut } ;
13
15
use std:: cmp:: Ordering ;
14
16
use std:: fmt;
@@ -1442,9 +1444,7 @@ fn item_enum(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, e: &clean::
1442
1444
1443
1445
/// It'll return true if all variants are C-like variants and if at least one of them has a value
1444
1446
/// set.
1445
- fn should_show_c_like_variants_value (
1446
- variants : & rustc_index:: IndexVec < rustc_target:: abi:: VariantIdx , clean:: Item > ,
1447
- ) -> bool {
1447
+ fn should_show_enum_discriminant ( variants : & IndexVec < VariantIdx , clean:: Item > ) -> bool {
1448
1448
let mut has_variants_with_value = false ;
1449
1449
for variant in variants {
1450
1450
if let clean:: VariantItem ( ref var) = * variant. kind &&
@@ -1463,14 +1463,14 @@ fn display_c_like_variant(
1463
1463
cx : & mut Context < ' _ > ,
1464
1464
item : & clean:: Item ,
1465
1465
variant : & clean:: Variant ,
1466
- index : rustc_target :: abi :: VariantIdx ,
1467
- should_show_c_like_variants_value : bool ,
1466
+ index : VariantIdx ,
1467
+ should_show_enum_discriminant : bool ,
1468
1468
enum_def_id : DefId ,
1469
1469
) {
1470
1470
let name = item. name . unwrap ( ) ;
1471
1471
if let Some ( ref value) = variant. discriminant {
1472
1472
write ! ( w, "{} = {}" , name. as_str( ) , value. value( cx. tcx( ) , true ) ) ;
1473
- } else if should_show_c_like_variants_value {
1473
+ } else if should_show_enum_discriminant {
1474
1474
let adt_def = cx. tcx ( ) . adt_def ( enum_def_id) ;
1475
1475
let discr = adt_def. discriminant_for_variant ( cx. tcx ( ) , index) ;
1476
1476
if discr. ty . is_signed ( ) {
@@ -1487,13 +1487,13 @@ fn render_enum_fields(
1487
1487
mut w : & mut Buffer ,
1488
1488
cx : & mut Context < ' _ > ,
1489
1489
g : Option < & clean:: Generics > ,
1490
- variants : & rustc_index :: IndexVec < rustc_target :: abi :: VariantIdx , clean:: Item > ,
1490
+ variants : & IndexVec < VariantIdx , clean:: Item > ,
1491
1491
count_variants : usize ,
1492
1492
has_stripped_entries : bool ,
1493
1493
is_non_exhaustive : bool ,
1494
1494
enum_def_id : DefId ,
1495
1495
) {
1496
- let should_show_c_like_variants_value = should_show_c_like_variants_value ( variants) ;
1496
+ let should_show_enum_discriminant = should_show_enum_discriminant ( variants) ;
1497
1497
if !g. is_some_and ( |g| print_where_clause_and_check ( w, g, cx) ) {
1498
1498
// If there wasn't a `where` clause, we add a whitespace.
1499
1499
w. write_str ( " " ) ;
@@ -1522,7 +1522,7 @@ fn render_enum_fields(
1522
1522
v,
1523
1523
var,
1524
1524
index,
1525
- should_show_c_like_variants_value ,
1525
+ should_show_enum_discriminant ,
1526
1526
enum_def_id,
1527
1527
) ,
1528
1528
clean:: VariantKind :: Tuple ( ref s) => {
@@ -1551,7 +1551,7 @@ fn item_variants(
1551
1551
w : & mut Buffer ,
1552
1552
cx : & mut Context < ' _ > ,
1553
1553
it : & clean:: Item ,
1554
- variants : & rustc_index :: IndexVec < rustc_target :: abi :: VariantIdx , clean:: Item > ,
1554
+ variants : & IndexVec < VariantIdx , clean:: Item > ,
1555
1555
) {
1556
1556
let tcx = cx. tcx ( ) ;
1557
1557
write ! (
@@ -1564,7 +1564,7 @@ fn item_variants(
1564
1564
document_non_exhaustive_header( it) ,
1565
1565
document_non_exhaustive( it)
1566
1566
) ;
1567
- let should_show_c_like_variants_value = should_show_c_like_variants_value ( variants) ;
1567
+ let should_show_enum_discriminant = should_show_enum_discriminant ( variants) ;
1568
1568
for ( index, variant) in variants. iter_enumerated ( ) {
1569
1569
if variant. is_stripped ( ) {
1570
1570
continue ;
@@ -1593,7 +1593,7 @@ fn item_variants(
1593
1593
variant,
1594
1594
var,
1595
1595
index,
1596
- should_show_c_like_variants_value ,
1596
+ should_show_enum_discriminant ,
1597
1597
it. def_id ( ) . unwrap ( ) ,
1598
1598
) ;
1599
1599
} else {
0 commit comments