Skip to content

Commit 036baf2

Browse files
rustdoc: normalise type/field names in clean/rustdoc-json-types/jsondoclint
1 parent 8b38707 commit 036baf2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+433
-419
lines changed

Diff for: src/librustdoc/clean/inline.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ pub(crate) fn try_inline(
104104
})
105105
}
106106
Res::Def(DefKind::ForeignTy, did) => {
107-
record_extern_fqn(cx, did, ItemType::ForeignType);
107+
record_extern_fqn(cx, did, ItemType::ExternType);
108108
cx.with_param_env(did, |cx| {
109109
build_impls(cx, did, attrs_without_docs, &mut ret);
110-
clean::ForeignTypeItem
110+
clean::ExternTypeItem
111111
})
112112
}
113113
// Never inline enum variants but leave them shown as re-exports.
@@ -679,7 +679,7 @@ fn build_module_items(
679679
// We can use the item's `DefId` directly since the only information ever used
680680
// from it is `DefId.krate`.
681681
item_id: ItemId::DefId(did),
682-
kind: Box::new(clean::ImportItem(clean::Import::new_simple(
682+
kind: Box::new(clean::UseItem(clean::Use::new_simple(
683683
item.ident.name,
684684
clean::ImportSource {
685685
path: clean::Path {

Diff for: src/librustdoc/clean/mod.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ fn clean_generic_param_def<'tcx>(
540540
GenericParamDefKind::Type {
541541
bounds: ThinVec::new(), // These are filled in from the where-clauses.
542542
default: default.map(Box::new),
543-
synthetic,
543+
is_synthetic: synthetic,
544544
},
545545
)
546546
}
@@ -567,7 +567,7 @@ fn clean_generic_param_def<'tcx>(
567567
} else {
568568
None
569569
},
570-
synthetic,
570+
is_synthetic: synthetic,
571571
},
572572
),
573573
};
@@ -619,7 +619,7 @@ fn clean_generic_param<'tcx>(
619619
GenericParamDefKind::Type {
620620
bounds,
621621
default: default.map(|t| clean_ty(t, cx)).map(Box::new),
622-
synthetic,
622+
is_synthetic: synthetic,
623623
},
624624
)
625625
}
@@ -630,7 +630,7 @@ fn clean_generic_param<'tcx>(
630630
default: default.map(|ct| {
631631
Box::new(ty::Const::from_const_arg(cx.tcx, ct, ty::FeedConstTy::No).to_string())
632632
}),
633-
synthetic,
633+
is_synthetic: synthetic,
634634
},
635635
),
636636
};
@@ -743,7 +743,7 @@ pub(crate) fn clean_generics<'tcx>(
743743
}
744744
}
745745
}
746-
GenericParamDefKind::Type { bounds, synthetic: false, .. } => {
746+
GenericParamDefKind::Type { bounds, is_synthetic: false, .. } => {
747747
if let Some(bound_pred) = bound_predicates.get_mut(&Type::Generic(p.name)) {
748748
// We merge bounds in the `where` clause.
749749
for bound in bounds.drain(..) {
@@ -1143,7 +1143,7 @@ fn clean_fn_decl_with_args<'tcx>(
11431143
decl: &hir::FnDecl<'tcx>,
11441144
header: Option<&hir::FnHeader>,
11451145
args: Arguments,
1146-
) -> FnDecl {
1146+
) -> FunctionSignature {
11471147
let mut output = match decl.output {
11481148
hir::FnRetTy::Return(typ) => clean_ty(typ, cx),
11491149
hir::FnRetTy::DefaultReturn(..) => Type::Tuple(Vec::new()),
@@ -1153,14 +1153,14 @@ fn clean_fn_decl_with_args<'tcx>(
11531153
{
11541154
output = output.sugared_async_return_type();
11551155
}
1156-
FnDecl { inputs: args, output, c_variadic: decl.c_variadic }
1156+
FunctionSignature { inputs: args, output, is_c_variadic: decl.c_variadic }
11571157
}
11581158

11591159
fn clean_poly_fn_sig<'tcx>(
11601160
cx: &mut DocContext<'tcx>,
11611161
did: Option<DefId>,
11621162
sig: ty::PolyFnSig<'tcx>,
1163-
) -> FnDecl {
1163+
) -> FunctionSignature {
11641164
let mut names = did.map_or(&[] as &[_], |did| cx.tcx.fn_arg_names(did)).iter();
11651165

11661166
// We assume all empty tuples are default return type. This theoretically can discard `-> ()`,
@@ -1177,9 +1177,9 @@ fn clean_poly_fn_sig<'tcx>(
11771177
output = output.sugared_async_return_type();
11781178
}
11791179

1180-
FnDecl {
1180+
FunctionSignature {
11811181
output,
1182-
c_variadic: sig.skip_binder().c_variadic,
1182+
is_c_variadic: sig.skip_binder().c_variadic,
11831183
inputs: Arguments {
11841184
values: sig
11851185
.inputs()
@@ -2094,7 +2094,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
20942094
Type::Path { path }
20952095
}
20962096
ty::Foreign(did) => {
2097-
inline::record_extern_fqn(cx, did, ItemType::ForeignType);
2097+
inline::record_extern_fqn(cx, did, ItemType::ExternType);
20982098
let path = clean_middle_path(
20992099
cx,
21002100
did,
@@ -3052,7 +3052,7 @@ fn clean_use_statement_inner<'tcx>(
30523052
return items;
30533053
}
30543054
}
3055-
Import::new_glob(resolve_use_source(cx, path), true)
3055+
Use::new_glob(resolve_use_source(cx, path), true)
30563056
} else {
30573057
if inline_attr.is_none()
30583058
&& let Res::Def(DefKind::Mod, did) = path.res
@@ -3075,15 +3075,15 @@ fn clean_use_statement_inner<'tcx>(
30753075
items.push(Item::from_def_id_and_parts(
30763076
import_def_id,
30773077
None,
3078-
ImportItem(Import::new_simple(name, resolve_use_source(cx, path), false)),
3078+
UseItem(Use::new_simple(name, resolve_use_source(cx, path), false)),
30793079
cx,
30803080
));
30813081
return items;
30823082
}
3083-
Import::new_simple(name, resolve_use_source(cx, path), true)
3083+
Use::new_simple(name, resolve_use_source(cx, path), true)
30843084
};
30853085

3086-
vec![Item::from_def_id_and_parts(import_def_id, None, ImportItem(inner), cx)]
3086+
vec![Item::from_def_id_and_parts(import_def_id, None, UseItem(inner), cx)]
30873087
}
30883088

30893089
fn clean_maybe_renamed_foreign_item<'tcx>(
@@ -3108,7 +3108,7 @@ fn clean_maybe_renamed_foreign_item<'tcx>(
31083108
Static { type_: Box::new(clean_ty(ty, cx)), mutability, expr: None },
31093109
safety,
31103110
),
3111-
hir::ForeignItemKind::Type => ForeignTypeItem,
3111+
hir::ForeignItemKind::Type => ExternTypeItem,
31123112
};
31133113

31143114
Item::from_def_id_and_parts(
@@ -3158,7 +3158,7 @@ fn clean_bound_vars<'tcx>(
31583158
kind: GenericParamDefKind::Type {
31593159
bounds: ThinVec::new(),
31603160
default: None,
3161-
synthetic: false,
3161+
is_synthetic: false,
31623162
},
31633163
})
31643164
}

Diff for: src/librustdoc/clean/types.rs

+22-22
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ impl Item {
546546
self.type_() == ItemType::Union
547547
}
548548
pub(crate) fn is_import(&self) -> bool {
549-
self.type_() == ItemType::Import
549+
self.type_() == ItemType::Use
550550
}
551551
pub(crate) fn is_extern_crate(&self) -> bool {
552552
self.type_() == ItemType::ExternCrate
@@ -557,7 +557,7 @@ impl Item {
557557
pub(crate) fn is_stripped(&self) -> bool {
558558
match *self.kind {
559559
StrippedItem(..) => true,
560-
ImportItem(ref i) => !i.should_be_displayed,
560+
UseItem(ref i) => !i.should_be_displayed,
561561
_ => false,
562562
}
563563
}
@@ -816,7 +816,7 @@ pub(crate) enum ItemKind {
816816
/// The crate's name, *not* the name it's imported as.
817817
src: Option<Symbol>,
818818
},
819-
ImportItem(Import),
819+
UseItem(Use),
820820
StructItem(Struct),
821821
UnionItem(Union),
822822
EnumItem(Enum),
@@ -840,7 +840,7 @@ pub(crate) enum ItemKind {
840840
/// `static`s from an extern block
841841
ForeignStaticItem(Static, hir::Safety),
842842
/// `type`s from an extern block
843-
ForeignTypeItem,
843+
ExternTypeItem,
844844
MacroItem(Macro),
845845
ProcMacroItem(ProcMacro),
846846
PrimitiveItem(PrimitiveType),
@@ -877,7 +877,7 @@ impl ItemKind {
877877
ImplItem(i) => i.items.iter(),
878878
ModuleItem(m) => m.items.iter(),
879879
ExternCrateItem { .. }
880-
| ImportItem(_)
880+
| UseItem(_)
881881
| FunctionItem(_)
882882
| TypeAliasItem(_)
883883
| StaticItem(_)
@@ -888,7 +888,7 @@ impl ItemKind {
888888
| StructFieldItem(_)
889889
| ForeignFunctionItem(_, _)
890890
| ForeignStaticItem(_, _)
891-
| ForeignTypeItem
891+
| ExternTypeItem
892892
| MacroItem(_)
893893
| ProcMacroItem(_)
894894
| PrimitiveItem(_)
@@ -918,7 +918,7 @@ impl ItemKind {
918918
| TraitAliasItem(_)
919919
| ForeignFunctionItem(_, _)
920920
| ForeignStaticItem(_, _)
921-
| ForeignTypeItem
921+
| ExternTypeItem
922922
| MacroItem(_)
923923
| ProcMacroItem(_)
924924
| PrimitiveItem(_)
@@ -1313,9 +1313,9 @@ impl WherePredicate {
13131313
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
13141314
pub(crate) enum GenericParamDefKind {
13151315
Lifetime { outlives: ThinVec<Lifetime> },
1316-
Type { bounds: ThinVec<GenericBound>, default: Option<Box<Type>>, synthetic: bool },
1316+
Type { bounds: ThinVec<GenericBound>, default: Option<Box<Type>>, is_synthetic: bool },
13171317
// Option<Box<String>> makes this type smaller than `Option<String>` would.
1318-
Const { ty: Box<Type>, default: Option<Box<String>>, synthetic: bool },
1318+
Const { ty: Box<Type>, default: Option<Box<String>>, is_synthetic: bool },
13191319
}
13201320

13211321
impl GenericParamDefKind {
@@ -1339,8 +1339,8 @@ impl GenericParamDef {
13391339
pub(crate) fn is_synthetic_param(&self) -> bool {
13401340
match self.kind {
13411341
GenericParamDefKind::Lifetime { .. } => false,
1342-
GenericParamDefKind::Const { synthetic: is_host_effect, .. } => is_host_effect,
1343-
GenericParamDefKind::Type { synthetic, .. } => synthetic,
1342+
GenericParamDefKind::Const { is_synthetic: is_host_effect, .. } => is_host_effect,
1343+
GenericParamDefKind::Type { is_synthetic, .. } => is_synthetic,
13441344
}
13451345
}
13461346

@@ -1371,18 +1371,18 @@ impl Generics {
13711371

13721372
#[derive(Clone, Debug)]
13731373
pub(crate) struct Function {
1374-
pub(crate) decl: FnDecl,
1374+
pub(crate) decl: FunctionSignature,
13751375
pub(crate) generics: Generics,
13761376
}
13771377

13781378
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
1379-
pub(crate) struct FnDecl {
1379+
pub(crate) struct FunctionSignature {
13801380
pub(crate) inputs: Arguments,
13811381
pub(crate) output: Type,
1382-
pub(crate) c_variadic: bool,
1382+
pub(crate) is_c_variadic: bool,
13831383
}
13841384

1385-
impl FnDecl {
1385+
impl FunctionSignature {
13861386
pub(crate) fn receiver_type(&self) -> Option<&Type> {
13871387
self.inputs.values.get(0).and_then(|v| v.to_receiver())
13881388
}
@@ -2321,7 +2321,7 @@ pub(crate) struct TypeAlias {
23212321
pub(crate) struct BareFunctionDecl {
23222322
pub(crate) safety: hir::Safety,
23232323
pub(crate) generic_params: Vec<GenericParamDef>,
2324-
pub(crate) decl: FnDecl,
2324+
pub(crate) decl: FunctionSignature,
23252325
pub(crate) abi: Abi,
23262326
}
23272327

@@ -2478,24 +2478,24 @@ impl ImplKind {
24782478
}
24792479

24802480
#[derive(Clone, Debug)]
2481-
pub(crate) struct Import {
2482-
pub(crate) kind: ImportKind,
2481+
pub(crate) struct Use {
2482+
pub(crate) kind: UseKind,
24832483
/// The item being re-exported.
24842484
pub(crate) source: ImportSource,
24852485
pub(crate) should_be_displayed: bool,
24862486
}
24872487

2488-
impl Import {
2488+
impl Use {
24892489
pub(crate) fn new_simple(
24902490
name: Symbol,
24912491
source: ImportSource,
24922492
should_be_displayed: bool,
24932493
) -> Self {
2494-
Self { kind: ImportKind::Simple(name), source, should_be_displayed }
2494+
Self { kind: UseKind::Simple(name), source, should_be_displayed }
24952495
}
24962496

24972497
pub(crate) fn new_glob(source: ImportSource, should_be_displayed: bool) -> Self {
2498-
Self { kind: ImportKind::Glob, source, should_be_displayed }
2498+
Self { kind: UseKind::Glob, source, should_be_displayed }
24992499
}
25002500

25012501
pub(crate) fn imported_item_is_doc_hidden(&self, tcx: TyCtxt<'_>) -> bool {
@@ -2504,7 +2504,7 @@ impl Import {
25042504
}
25052505

25062506
#[derive(Clone, Debug)]
2507-
pub(crate) enum ImportKind {
2507+
pub(crate) enum UseKind {
25082508
// use source as str;
25092509
Simple(Symbol),
25102510
// use source::*;

Diff for: src/librustdoc/fold.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub(crate) trait DocFolder: Sized {
7575
TypeAliasItem(typealias)
7676
}
7777
ExternCrateItem { src: _ }
78-
| ImportItem(_)
78+
| UseItem(_)
7979
| FunctionItem(_)
8080
| StaticItem(_)
8181
| ConstantItem(..)
@@ -85,7 +85,7 @@ pub(crate) trait DocFolder: Sized {
8585
| StructFieldItem(_)
8686
| ForeignFunctionItem(..)
8787
| ForeignStaticItem(..)
88-
| ForeignTypeItem
88+
| ExternTypeItem
8989
| MacroItem(_)
9090
| ProcMacroItem(_)
9191
| PrimitiveItem(_)

Diff for: src/librustdoc/formats/cache.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
262262
// Index this method for searching later on.
263263
let search_name = if !item.is_stripped() {
264264
item.name.or_else(|| {
265-
if let clean::ImportItem(ref i) = *item.kind
266-
&& let clean::ImportKind::Simple(s) = i.kind
265+
if let clean::UseItem(ref i) = *item.kind
266+
&& let clean::UseKind::Simple(s) = i.kind
267267
{
268268
Some(s)
269269
} else {
@@ -299,7 +299,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
299299
| clean::ConstantItem(..)
300300
| clean::StaticItem(..)
301301
| clean::UnionItem(..)
302-
| clean::ForeignTypeItem
302+
| clean::ExternTypeItem
303303
| clean::MacroItem(..)
304304
| clean::ProcMacroItem(..)
305305
| clean::VariantItem(..) => {
@@ -330,7 +330,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
330330
}
331331

332332
clean::ExternCrateItem { .. }
333-
| clean::ImportItem(..)
333+
| clean::UseItem(..)
334334
| clean::ImplItem(..)
335335
| clean::TyMethodItem(..)
336336
| clean::MethodItem(..)
@@ -352,7 +352,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
352352
let (item, parent_pushed) = match *item.kind {
353353
clean::TraitItem(..)
354354
| clean::EnumItem(..)
355-
| clean::ForeignTypeItem
355+
| clean::ExternTypeItem
356356
| clean::StructItem(..)
357357
| clean::UnionItem(..)
358358
| clean::VariantItem(..)
@@ -528,7 +528,7 @@ fn add_item_to_search_index(tcx: TyCtxt<'_>, cache: &mut Cache, item: &clean::It
528528
// - It's got the same name
529529
// - Both of them have the same exact path
530530
let defid = match &*item.kind {
531-
clean::ItemKind::ImportItem(import) => import.source.did.unwrap_or(item_def_id),
531+
clean::ItemKind::UseItem(import) => import.source.did.unwrap_or(item_def_id),
532532
_ => item_def_id,
533533
};
534534
let path = join_with_double_colon(parent_path);

0 commit comments

Comments
 (0)