File tree Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -728,7 +728,7 @@ pub use macros::Debug;
728728/// ``` 
729729#[ rustc_on_unimplemented(  
730730    on(  
731-         _Self = "std::path::Path" ,  
731+         any ( _Self = "std::path::Path" ,  _Self =  "std::path::PathBuf" ) ,  
732732        label = "`{Self}` cannot be formatted with the default formatter; call `.display()` on it" ,  
733733        note = "call `.display()` or `.to_string_lossy()` to safely print paths, \   
734734                 as they may contain non-Unicode data"
Original file line number Diff line number Diff line change 1- use  std:: path:: Path ; 
1+ use  std:: path:: { Path ,   PathBuf } ; 
22
33fn  main ( )  { 
44    let  path = Path :: new ( "/tmp/foo/bar.txt" ) ; 
55    println ! ( "{}" ,  path) ; 
66    //~^ ERROR E0277 
7+ 
8+     let  path = PathBuf :: from ( "/tmp/foo/bar.txt" ) ; 
9+     println ! ( "{}" ,  path) ; 
10+     //~^ ERROR E0277 
711} 
Original file line number Diff line number Diff line change @@ -8,6 +8,16 @@ LL |     println!("{}", path);
88   = note: call `.display()` or `.to_string_lossy()` to safely print paths, as they may contain non-Unicode data
99   = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
1010
11- error: aborting due to previous error
11+ error[E0277]: `PathBuf` doesn't implement `std::fmt::Display`
12+   --> $DIR/path-display.rs:9:20
13+    |
14+ LL |     println!("{}", path);
15+    |                    ^^^^ `PathBuf` cannot be formatted with the default formatter; call `.display()` on it
16+    |
17+    = help: the trait `std::fmt::Display` is not implemented for `PathBuf`
18+    = note: call `.display()` or `.to_string_lossy()` to safely print paths, as they may contain non-Unicode data
19+    = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
20+ 
21+ error: aborting due to 2 previous errors
1222
1323For more information about this error, try `rustc --explain E0277`.
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments