@@ -314,25 +314,6 @@ crate fn strip_path(path: &Path) -> Path {
314
314
Path { global : path. global , res : path. res , segments }
315
315
}
316
316
317
- crate fn qpath_to_string ( p : & hir:: QPath < ' _ > ) -> String {
318
- let segments = match * p {
319
- hir:: QPath :: Resolved ( _, ref path) => & path. segments ,
320
- hir:: QPath :: TypeRelative ( _, ref segment) => return segment. ident . to_string ( ) ,
321
- hir:: QPath :: LangItem ( lang_item, ..) => return lang_item. name ( ) . to_string ( ) ,
322
- } ;
323
-
324
- let mut s = String :: new ( ) ;
325
- for ( i, seg) in segments. iter ( ) . enumerate ( ) {
326
- if i > 0 {
327
- s. push_str ( "::" ) ;
328
- }
329
- if seg. ident . name != kw:: PathRoot {
330
- s. push_str ( & seg. ident . as_str ( ) ) ;
331
- }
332
- }
333
- s
334
- }
335
-
336
317
crate fn build_deref_target_impls ( cx : & DocContext < ' _ > , items : & [ Item ] , ret : & mut Vec < Item > ) {
337
318
let tcx = cx. tcx ;
338
319
@@ -376,57 +357,6 @@ impl ToSource for rustc_span::Span {
376
357
}
377
358
}
378
359
379
- crate fn name_from_pat ( p : & hir:: Pat < ' _ > ) -> Symbol {
380
- use rustc_hir:: * ;
381
- debug ! ( "trying to get a name from pattern: {:?}" , p) ;
382
-
383
- Symbol :: intern ( & match p. kind {
384
- PatKind :: Wild => return kw:: Underscore ,
385
- PatKind :: Binding ( _, _, ident, _) => return ident. name ,
386
- PatKind :: TupleStruct ( ref p, ..) | PatKind :: Path ( ref p) => qpath_to_string ( p) ,
387
- PatKind :: Struct ( ref name, ref fields, etc) => format ! (
388
- "{} {{ {}{} }}" ,
389
- qpath_to_string( name) ,
390
- fields
391
- . iter( )
392
- . map( |fp| format!( "{}: {}" , fp. ident, name_from_pat( & fp. pat) ) )
393
- . collect:: <Vec <String >>( )
394
- . join( ", " ) ,
395
- if etc { ", .." } else { "" }
396
- ) ,
397
- PatKind :: Or ( ref pats) => pats
398
- . iter ( )
399
- . map ( |p| name_from_pat ( & * * p) . to_string ( ) )
400
- . collect :: < Vec < String > > ( )
401
- . join ( " | " ) ,
402
- PatKind :: Tuple ( ref elts, _) => format ! (
403
- "({})" ,
404
- elts. iter( )
405
- . map( |p| name_from_pat( & * * p) . to_string( ) )
406
- . collect:: <Vec <String >>( )
407
- . join( ", " )
408
- ) ,
409
- PatKind :: Box ( ref p) => return name_from_pat ( & * * p) ,
410
- PatKind :: Ref ( ref p, _) => return name_from_pat ( & * * p) ,
411
- PatKind :: Lit ( ..) => {
412
- warn ! (
413
- "tried to get argument name from PatKind::Lit, which is silly in function arguments"
414
- ) ;
415
- return Symbol :: intern ( "()" ) ;
416
- }
417
- PatKind :: Range ( ..) => panic ! (
418
- "tried to get argument name from PatKind::Range, \
419
- which is not allowed in function arguments"
420
- ) ,
421
- PatKind :: Slice ( ref begin, ref mid, ref end) => {
422
- let begin = begin. iter ( ) . map ( |p| name_from_pat ( & * * p) . to_string ( ) ) ;
423
- let mid = mid. as_ref ( ) . map ( |p| format ! ( "..{}" , name_from_pat( & * * p) ) ) . into_iter ( ) ;
424
- let end = end. iter ( ) . map ( |p| name_from_pat ( & * * p) . to_string ( ) ) ;
425
- format ! ( "[{}]" , begin. chain( mid) . chain( end) . collect:: <Vec <_>>( ) . join( ", " ) )
426
- }
427
- } )
428
- }
429
-
430
360
crate fn print_const ( cx : & DocContext < ' _ > , n : & ' tcx ty:: Const < ' _ > ) -> String {
431
361
match n. val {
432
362
ty:: ConstKind :: Unevaluated ( def, _, promoted) => {
0 commit comments