@@ -2889,3 +2889,79 @@ $DIR/short-error-format.rs:8:7: error[E0599]: no method named `salut` found for
28892889        . anonymized_line_numbers ( true ) ; 
28902890    assert_data_eq ! ( renderer. render( input) ,  expected) ; 
28912891} 
2892+ 
2893+ #[ test]  
2894+ #[ should_panic( expected = "range end index 47 out of range for slice of length 26" ) ]  
2895+ fn  rustdoc_ui_diagnostic_width ( )  { 
2896+     // tests/rustdoc-ui/diagnostic-width.rs 
2897+ 
2898+     let  source_0 = r#"//@ compile-flags: --diagnostic-width=10 
2899+ #![deny(rustdoc::bare_urls)] 
2900+ 
2901+ /// This is a long line that contains a http://link.com 
2902+ pub struct Foo; //~^ ERROR 
2903+ "# ; 
2904+     let  source_1 = r#"/// This is a long line that contains a http://link.com 
2905+ "# ; 
2906+ 
2907+     let  input = Level :: ERROR 
2908+         . header ( "this URL is not a hyperlink" ) 
2909+         . group ( 
2910+             Group :: new ( ) 
2911+                 . element ( 
2912+                     Snippet :: source ( source_0) 
2913+                         . origin ( "$DIR/diagnostic-width.rs" ) 
2914+                         . fold ( true ) 
2915+                         . annotation ( AnnotationKind :: Primary . span ( 111 ..126 ) ) , 
2916+                 ) 
2917+                 . element ( 
2918+                     Level :: NOTE 
2919+                         . title ( "bare URLs are not automatically turned into clickable links" ) , 
2920+                 ) , 
2921+         ) 
2922+         . group ( 
2923+             Group :: new ( ) 
2924+                 . element ( Level :: NOTE . title ( "the lint level is defined here" ) ) 
2925+                 . element ( 
2926+                     Snippet :: source ( source_0) 
2927+                         . origin ( "$DIR/diagnostic-width.rs" ) 
2928+                         . fold ( true ) 
2929+                         . annotation ( AnnotationKind :: Primary . span ( 49 ..67 ) ) , 
2930+                 ) , 
2931+         ) 
2932+         . group ( 
2933+             Group :: new ( ) 
2934+                 . element ( Level :: HELP . title ( "use an automatic link instead" ) ) 
2935+                 . element ( 
2936+                     Snippet :: source ( source_1) 
2937+                         . origin ( "$DIR/diagnostic-width.rs" ) 
2938+                         . line_start ( 4 ) 
2939+                         . fold ( true ) 
2940+                         . patch ( Patch :: new ( 40 ..40 ,  "<" ) ) 
2941+                         . patch ( Patch :: new ( 55 ..55 ,  ">" ) ) , 
2942+                 ) , 
2943+         ) ; 
2944+ 
2945+     let  expected = str![ [ r#" 
2946+ error: this URL is not a hyperlink 
2947+   --> $DIR/diagnostic-width.rs:4:41 
2948+    | 
2949+ LL | ... a http://link.com 
2950+    |       ^^^^^^^^^^^^^^^ 
2951+    | 
2952+    = note: bare URLs are not automatically turned into clickable links 
2953+ note: the lint level is defined here 
2954+   --> $DIR/diagnostic-width.rs:2:9 
2955+    | 
2956+ LL | ...ny(ru...are_urls)] 
2957+    |       ^^...^^^^^^^^ 
2958+ help: use an automatic link instead 
2959+    | 
2960+ LL | /// This is a long line that contains a <http://link.com> 
2961+    |                                         +               + 
2962+ "# ] ] ; 
2963+     let  renderer = Renderer :: plain ( ) 
2964+         . anonymized_line_numbers ( true ) 
2965+         . term_width ( 10 ) ; 
2966+     assert_data_eq ! ( renderer. render( input) ,  expected) ; 
2967+ } 
0 commit comments