Skip to content

Commit 79c718f

Browse files
committed
Rename Type::ResolvedPath to Type::Path
At last! The new name is shorter, simpler, and consistent with `hir::Ty`.
1 parent d81deb3 commit 79c718f

File tree

9 files changed

+37
-38
lines changed

9 files changed

+37
-38
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1405,12 +1405,12 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
14051405
};
14061406
inline::record_extern_fqn(cx, did, kind);
14071407
let path = external_path(cx, did, false, vec![], substs);
1408-
Type::ResolvedPath { path }
1408+
Type::Path { path }
14091409
}
14101410
ty::Foreign(did) => {
14111411
inline::record_extern_fqn(cx, did, ItemType::ForeignType);
14121412
let path = external_path(cx, did, false, vec![], InternalSubsts::empty());
1413-
Type::ResolvedPath { path }
1413+
Type::Path { path }
14141414
}
14151415
ty::Dynamic(obj, ref reg) => {
14161416
// HACK: pick the first `did` as the `did` of the trait object. Someone

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

+6-5
Original file line numberDiff line numberDiff line change
@@ -1421,8 +1421,9 @@ crate struct PolyTrait {
14211421
crate enum Type {
14221422
/// A named type, which could be a trait.
14231423
///
1424-
/// This is mostly Rustdoc's version of [`hir::Path`]. It has to be different because Rustdoc's [`PathSegment`] can contain cleaned generics.
1425-
ResolvedPath { path: Path },
1424+
/// This is mostly Rustdoc's version of [`hir::Path`].
1425+
/// It has to be different because Rustdoc's [`PathSegment`] can contain cleaned generics.
1426+
Path { path: Path },
14261427
/// A `dyn Trait` object: `dyn for<'a> Trait<'a> + Send + 'static`
14271428
DynTrait(Vec<PolyTrait>, Option<Lifetime>),
14281429
/// A type parameter.
@@ -1488,7 +1489,7 @@ impl Type {
14881489
/// Checks if this is a `T::Name` path for an associated type.
14891490
crate fn is_assoc_ty(&self) -> bool {
14901491
match self {
1491-
Type::ResolvedPath { path, .. } => path.is_assoc_ty(),
1492+
Type::Path { path, .. } => path.is_assoc_ty(),
14921493
_ => false,
14931494
}
14941495
}
@@ -1502,7 +1503,7 @@ impl Type {
15021503

15031504
crate fn generics(&self) -> Option<Vec<&Type>> {
15041505
match self {
1505-
Type::ResolvedPath { path, .. } => path.generics(),
1506+
Type::Path { path, .. } => path.generics(),
15061507
_ => None,
15071508
}
15081509
}
@@ -1525,7 +1526,7 @@ impl Type {
15251526

15261527
fn inner_def_id(&self, cache: Option<&Cache>) -> Option<DefId> {
15271528
let t: PrimitiveType = match *self {
1528-
Type::ResolvedPath { ref path } => return Some(path.def_id()),
1529+
Type::Path { ref path } => return Some(path.def_id()),
15291530
DynTrait(ref bounds, _) => return Some(bounds[0].trait_.def_id()),
15301531
Primitive(p) => return cache.and_then(|c| c.primitive_locations.get(&p).cloned()),
15311532
BorrowedRef { type_: box Generic(..), .. } => PrimitiveType::Reference,

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ crate fn build_deref_target_impls(cx: &mut DocContext<'_>, items: &[Item], ret:
186186
for &did in prim.impls(tcx).iter().filter(|did| !did.is_local()) {
187187
inline::build_impl(cx, None, did, None, ret);
188188
}
189-
} else if let Type::ResolvedPath { path } = target {
189+
} else if let Type::Path { path } = target {
190190
let did = path.def_id();
191191
if !did.is_local() {
192192
inline::build_impls(cx, None, did, None, ret);
@@ -361,7 +361,7 @@ crate fn resolve_type(cx: &mut DocContext<'_>, path: Path) -> Type {
361361
Res::Def(DefKind::TyParam, _) if path.segments.len() == 1 => Generic(path.segments[0].name),
362362
_ => {
363363
let _ = register_res(cx, path.res);
364-
Type::ResolvedPath { path }
364+
Type::Path { path }
365365
}
366366
}
367367
}

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

+4-6
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use crate::html::render::IndexItem;
2727
#[derive(Default)]
2828
crate struct Cache {
2929
/// Maps a type ID to all known implementations for that type. This is only
30-
/// recognized for intra-crate `ResolvedPath` types, and is used to print
30+
/// recognized for intra-crate [`clean::Type::Path`]s, and is used to print
3131
/// out extra documentation on the page of an enum/struct.
3232
///
3333
/// The values of the map are a list of implementations and documentation
@@ -401,7 +401,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
401401
clean::ImplItem(ref i) => {
402402
self.cache.parent_is_trait_impl = i.trait_.is_some();
403403
match i.for_ {
404-
clean::Type::ResolvedPath { ref path } => {
404+
clean::Type::Path { ref path } => {
405405
self.cache.parent_stack.push(path.def_id());
406406
true
407407
}
@@ -436,10 +436,8 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
436436
// Note: matching twice to restrict the lifetime of the `i` borrow.
437437
let mut dids = FxHashSet::default();
438438
match i.for_ {
439-
clean::Type::ResolvedPath { ref path }
440-
| clean::BorrowedRef {
441-
type_: box clean::Type::ResolvedPath { ref path }, ..
442-
} => {
439+
clean::Type::Path { ref path }
440+
| clean::BorrowedRef { type_: box clean::Type::Path { ref path }, .. } => {
443441
dids.insert(path.def_id());
444442
}
445443
clean::DynTrait(ref bounds, _)

Diff for: src/librustdoc/html/format.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -607,8 +607,7 @@ crate fn href_relative_parts<'a>(fqp: &'a [String], relative_to_fqp: &'a [String
607607
}
608608
}
609609

610-
/// Used when rendering a `ResolvedPath` structure. This invokes the `path`
611-
/// rendering function with the necessary arguments for linking to a local path.
610+
/// Used to render a [`clean::Path`].
612611
fn resolved_path<'cx>(
613612
w: &mut fmt::Formatter<'_>,
614613
did: DefId,
@@ -762,7 +761,7 @@ fn fmt_type<'cx>(
762761

763762
match *t {
764763
clean::Generic(name) => write!(f, "{}", name),
765-
clean::Type::ResolvedPath { ref path } => {
764+
clean::Type::Path { ref path } => {
766765
// Paths like `T::Output` and `Self::Output` should be rendered with all segments.
767766
let did = path.def_id();
768767
resolved_path(f, did, path, path.is_assoc_ty(), use_absolute, cx)

Diff for: src/librustdoc/html/render/cache.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ fn get_index_type(clean_type: &clean::Type, generics: Vec<TypeWithKind>) -> Rend
218218

219219
fn get_index_type_name(clean_type: &clean::Type, accept_generic: bool) -> Option<Symbol> {
220220
match *clean_type {
221-
clean::Type::ResolvedPath { ref path, .. } => {
221+
clean::Type::Path { ref path, .. } => {
222222
let path_segment = path.segments.last().unwrap();
223223
Some(path_segment.name)
224224
}
@@ -371,7 +371,7 @@ crate fn get_real_types<'tcx>(
371371
let mut ty_generics = Vec::new();
372372
for bound in bound.get_bounds().unwrap_or(&[]) {
373373
if let Some(path) = bound.get_trait_path() {
374-
let ty = Type::ResolvedPath { path };
374+
let ty = Type::Path { path };
375375
get_real_types(generics, &ty, tcx, recurse + 1, &mut ty_generics, cache);
376376
}
377377
}

Diff for: src/librustdoc/html/render/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1227,7 +1227,7 @@ fn should_render_item(item: &clean::Item, deref_mut_: bool, tcx: TyCtxt<'_>) ->
12271227
| SelfTy::SelfExplicit(clean::BorrowedRef { mutability, .. }) => {
12281228
(mutability == Mutability::Mut, false, false)
12291229
}
1230-
SelfTy::SelfExplicit(clean::Type::ResolvedPath { path }) => {
1230+
SelfTy::SelfExplicit(clean::Type::Path { path }) => {
12311231
(false, Some(path.def_id()) == tcx.lang_items().owned_box(), false)
12321232
}
12331233
SelfTy::SelfValue => (false, false, true),
@@ -2520,7 +2520,7 @@ fn collect_paths_for_type(first_ty: clean::Type, cache: &Cache) -> Vec<String> {
25202520
}
25212521

25222522
match ty {
2523-
clean::Type::ResolvedPath { path } => process_path(path.def_id()),
2523+
clean::Type::Path { path } => process_path(path.def_id()),
25242524
clean::Type::Tuple(tys) => {
25252525
work.extend(tys.into_iter());
25262526
}

Diff for: src/librustdoc/html/render/print_item.rs

+13-12
Original file line numberDiff line numberDiff line change
@@ -727,10 +727,10 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
727727
let mut implementor_dups: FxHashMap<Symbol, (DefId, bool)> = FxHashMap::default();
728728
for implementor in implementors {
729729
match implementor.inner_impl().for_ {
730-
clean::Type::ResolvedPath { ref path }
731-
| clean::BorrowedRef {
732-
type_: box clean::Type::ResolvedPath { ref path }, ..
733-
} if !path.is_assoc_ty() => {
730+
clean::Type::Path { ref path }
731+
| clean::BorrowedRef { type_: box clean::Type::Path { ref path }, .. }
732+
if !path.is_assoc_ty() =>
733+
{
734734
let did = path.def_id();
735735
let &mut (prev_did, ref mut has_duplicates) =
736736
implementor_dups.entry(path.last()).or_insert((did, false));
@@ -1452,14 +1452,15 @@ fn render_implementor(
14521452
) {
14531453
// If there's already another implementor that has the same abridged name, use the
14541454
// full path, for example in `std::iter::ExactSizeIterator`
1455-
let use_absolute =
1456-
match implementor.inner_impl().for_ {
1457-
clean::Type::ResolvedPath { ref path, .. }
1458-
| clean::BorrowedRef {
1459-
type_: box clean::Type::ResolvedPath { ref path, .. }, ..
1460-
} if !path.is_assoc_ty() => implementor_dups[&path.last()].1,
1461-
_ => false,
1462-
};
1455+
let use_absolute = match implementor.inner_impl().for_ {
1456+
clean::Type::Path { ref path, .. }
1457+
| clean::BorrowedRef { type_: box clean::Type::Path { ref path, .. }, .. }
1458+
if !path.is_assoc_ty() =>
1459+
{
1460+
implementor_dups[&path.last()].1
1461+
}
1462+
_ => false,
1463+
};
14631464
render_impl(
14641465
w,
14651466
cx,

Diff for: src/librustdoc/json/conversions.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ impl FromWithTcx<clean::GenericBound> for GenericBound {
365365
match bound {
366366
TraitBound(clean::PolyTrait { trait_, generic_params }, modifier) => {
367367
// FIXME: should `trait_` be a clean::Path equivalent in JSON?
368-
let trait_ = clean::Type::ResolvedPath { path: trait_ }.into_tcx(tcx);
368+
let trait_ = clean::Type::Path { path: trait_ }.into_tcx(tcx);
369369
GenericBound::TraitBound {
370370
trait_,
371371
generic_params: generic_params.into_iter().map(|x| x.into_tcx(tcx)).collect(),
@@ -394,7 +394,7 @@ impl FromWithTcx<clean::Type> for Type {
394394
};
395395

396396
match ty {
397-
clean::Type::ResolvedPath { path } => Type::ResolvedPath {
397+
clean::Type::Path { path } => Type::ResolvedPath {
398398
name: path.whole_name(),
399399
id: from_item_id(path.def_id().into()),
400400
args: path.segments.last().map(|args| Box::new(args.clone().args.into_tcx(tcx))),
@@ -439,7 +439,7 @@ impl FromWithTcx<clean::Type> for Type {
439439
},
440440
QPath { name, self_type, trait_, .. } => {
441441
// FIXME: should `trait_` be a clean::Path equivalent in JSON?
442-
let trait_ = clean::Type::ResolvedPath { path: trait_ }.into_tcx(tcx);
442+
let trait_ = clean::Type::Path { path: trait_ }.into_tcx(tcx);
443443
Type::QualifiedPath {
444444
name: name.to_string(),
445445
self_type: Box::new((*self_type).into_tcx(tcx)),
@@ -505,7 +505,7 @@ impl FromWithTcx<clean::Impl> for Impl {
505505
let provided_trait_methods = impl_.provided_trait_methods(tcx);
506506
let clean::Impl { unsafety, generics, trait_, for_, items, polarity, kind } = impl_;
507507
// FIXME: should `trait_` be a clean::Path equivalent in JSON?
508-
let trait_ = trait_.map(|path| clean::Type::ResolvedPath { path }.into_tcx(tcx));
508+
let trait_ = trait_.map(|path| clean::Type::Path { path }.into_tcx(tcx));
509509
// FIXME: use something like ImplKind in JSON?
510510
let (synthetic, blanket_impl) = match kind {
511511
clean::ImplKind::Normal => (false, None),

0 commit comments

Comments
 (0)