@@ -20,10 +20,10 @@ const LOCAL_CRATE_ID: u32 = 0;
2020/// It is made of several parts.
2121///
2222/// - `check_*`: These take a type from [`rustdoc_json_types`], and check that
23- /// it is well formed. This involves calling `check_*` functions on
24- /// fields of that item, and `add_*` functions on [`Id`]s.
23+ /// it is well formed. This involves calling `check_*` functions on
24+ /// fields of that item, and `add_*` functions on [`Id`]s.
2525/// - `add_*`: These add an [`Id`] to the worklist, after validating it to check if
26- /// the `Id` is a kind expected in this situation.
26+ /// the `Id` is a kind expected in this situation.
2727#[ derive( Debug ) ]
2828pub struct Validator < ' a > {
2929 pub ( crate ) errs : Vec < Error > ,
@@ -262,17 +262,17 @@ impl<'a> Validator<'a> {
262262 Type :: Generic ( _) => { }
263263 Type :: Primitive ( _) => { }
264264 Type :: Pat { type_, __pat_unstable_do_not_use : _ } => self . check_type ( type_) ,
265- Type :: FunctionPointer ( fp) => self . check_function_pointer ( & * * fp) ,
265+ Type :: FunctionPointer ( fp) => self . check_function_pointer ( fp) ,
266266 Type :: Tuple ( tys) => tys. iter ( ) . for_each ( |ty| self . check_type ( ty) ) ,
267- Type :: Slice ( inner) => self . check_type ( & * * inner) ,
268- Type :: Array { type_, len : _ } => self . check_type ( & * * type_) ,
267+ Type :: Slice ( inner) => self . check_type ( inner) ,
268+ Type :: Array { type_, len : _ } => self . check_type ( type_) ,
269269 Type :: ImplTrait ( bounds) => bounds. iter ( ) . for_each ( |b| self . check_generic_bound ( b) ) ,
270270 Type :: Infer => { }
271- Type :: RawPointer { is_mutable : _, type_ } => self . check_type ( & * * type_) ,
272- Type :: BorrowedRef { lifetime : _, is_mutable : _, type_ } => self . check_type ( & * * type_) ,
271+ Type :: RawPointer { is_mutable : _, type_ } => self . check_type ( type_) ,
272+ Type :: BorrowedRef { lifetime : _, is_mutable : _, type_ } => self . check_type ( type_) ,
273273 Type :: QualifiedPath { name : _, args, self_type, trait_ } => {
274- self . check_opt_generic_args ( & args) ;
275- self . check_type ( & * * self_type) ;
274+ self . check_opt_generic_args ( args) ;
275+ self . check_type ( self_type) ;
276276 if let Some ( trait_) = trait_ {
277277 self . check_path ( trait_, PathKind :: Trait ) ;
278278 }
@@ -404,7 +404,7 @@ impl<'a> Validator<'a> {
404404 // which encodes rustc implementation details.
405405 if item_info. crate_id == LOCAL_CRATE_ID && !self . krate . index . contains_key ( id) {
406406 self . errs . push ( Error {
407- id : id . clone ( ) ,
407+ id : * id ,
408408 kind : ErrorKind :: Custom (
409409 "Id for local item in `paths` but not in `index`" . to_owned ( ) ,
410410 ) ,
@@ -483,16 +483,14 @@ impl<'a> Validator<'a> {
483483 }
484484
485485 fn fail ( & mut self , id : & Id , kind : ErrorKind ) {
486- self . errs . push ( Error { id : id . clone ( ) , kind } ) ;
486+ self . errs . push ( Error { id : * id , kind } ) ;
487487 }
488488
489489 fn kind_of ( & mut self , id : & Id ) -> Option < Kind > {
490490 if let Some ( item) = self . krate . index . get ( id) {
491491 Some ( Kind :: from_item ( item) )
492- } else if let Some ( summary) = self . krate . paths . get ( id) {
493- Some ( Kind :: from_summary ( summary) )
494492 } else {
495- None
493+ self . krate . paths . get ( id ) . map ( Kind :: from_summary )
496494 }
497495 }
498496}
0 commit comments