Skip to content

Commit c38f001

Browse files
committed
Auto merge of #77743 - bugadani:idl-cleanup, r=bugadani
Clean up in intra-doc link collector This PR makes the following changes in intra-doc links: - clean up hard to follow closure-based logic in `check_full_res` - fix a FIXME comment by figuring out that `true` and `false` need to be resolved separately - refactor path resolution by extracting common code to a helper method and trying to reduce the number of unnecessary early returns - primitive types are now defined by their symbols, not their name strings - re-enables a commented-out test case Closes #77267 (cc `@Stupremee)` r? `@jyn514`
2 parents c6bebc1 + 725e3d1 commit c38f001

File tree

5 files changed

+198
-160
lines changed

5 files changed

+198
-160
lines changed

src/librustdoc/clean/types.rs

+23
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use std::{slice, vec};
1212
use rustc_ast::attr;
1313
use rustc_ast::util::comments::beautify_doc_string;
1414
use rustc_ast::{self as ast, AttrStyle};
15+
use rustc_ast::{FloatTy, IntTy, UintTy};
1516
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1617
use rustc_hir as hir;
1718
use rustc_hir::def::Res;
@@ -1279,6 +1280,28 @@ impl GetDefId for Type {
12791280
}
12801281

12811282
impl PrimitiveType {
1283+
pub fn from_hir(prim: hir::PrimTy) -> PrimitiveType {
1284+
match prim {
1285+
hir::PrimTy::Int(IntTy::Isize) => PrimitiveType::Isize,
1286+
hir::PrimTy::Int(IntTy::I8) => PrimitiveType::I8,
1287+
hir::PrimTy::Int(IntTy::I16) => PrimitiveType::I16,
1288+
hir::PrimTy::Int(IntTy::I32) => PrimitiveType::I32,
1289+
hir::PrimTy::Int(IntTy::I64) => PrimitiveType::I64,
1290+
hir::PrimTy::Int(IntTy::I128) => PrimitiveType::I128,
1291+
hir::PrimTy::Uint(UintTy::Usize) => PrimitiveType::Usize,
1292+
hir::PrimTy::Uint(UintTy::U8) => PrimitiveType::U8,
1293+
hir::PrimTy::Uint(UintTy::U16) => PrimitiveType::U16,
1294+
hir::PrimTy::Uint(UintTy::U32) => PrimitiveType::U32,
1295+
hir::PrimTy::Uint(UintTy::U64) => PrimitiveType::U64,
1296+
hir::PrimTy::Uint(UintTy::U128) => PrimitiveType::U128,
1297+
hir::PrimTy::Float(FloatTy::F32) => PrimitiveType::F32,
1298+
hir::PrimTy::Float(FloatTy::F64) => PrimitiveType::F64,
1299+
hir::PrimTy::Str => PrimitiveType::Str,
1300+
hir::PrimTy::Bool => PrimitiveType::Bool,
1301+
hir::PrimTy::Char => PrimitiveType::Char,
1302+
}
1303+
}
1304+
12821305
pub fn from_symbol(s: Symbol) -> Option<PrimitiveType> {
12831306
match s {
12841307
sym::isize => Some(PrimitiveType::Isize),

0 commit comments

Comments
 (0)