File tree 3 files changed +14
-3
lines changed
compiler/rustc_parse_format/src
3 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -730,7 +730,7 @@ fn find_skips_from_snippet(
730
730
str_style : Option < usize > ,
731
731
) -> ( Vec < usize > , bool ) {
732
732
let snippet = match snippet {
733
- Some ( ref s) if s. starts_with ( '"' ) || s. starts_with ( "r#" ) => s,
733
+ Some ( ref s) if s. starts_with ( '"' ) || s. starts_with ( "r\" " ) || s . starts_with ( "r #") => s,
734
734
_ => return ( vec ! [ ] , false ) ,
735
735
} ;
736
736
Original file line number Diff line number Diff line change 5
5
fn main ( ) {
6
6
named_argument_takes_precedence_to_captured ( ) ;
7
7
formatting_parameters_can_be_captured ( ) ;
8
+ capture_raw_strings_and_idents ( ) ;
8
9
9
10
#[ cfg( panic = "unwind" ) ]
10
11
{
@@ -25,6 +26,16 @@ fn named_argument_takes_precedence_to_captured() {
25
26
assert_eq ! ( & s, "positional-named-captured" ) ;
26
27
}
27
28
29
+ fn capture_raw_strings_and_idents ( ) {
30
+ let r#type = "apple" ;
31
+ let s = format ! ( r#"The fruit is an {type}"# ) ;
32
+ assert_eq ! ( & s, "The fruit is an apple" ) ;
33
+
34
+ let r#type = "orange" ;
35
+ let s = format ! ( r"The fruit is an {type}" ) ;
36
+ assert_eq ! ( & s, "The fruit is an orange" ) ;
37
+ }
38
+
28
39
#[ cfg( panic = "unwind" ) ]
29
40
fn panic_with_single_argument_does_not_get_formatted ( ) {
30
41
// panic! with a single argument does not perform string formatting.
Original file line number Diff line number Diff line change 1
1
error: invalid reference to positional arguments 1 and 2 (there is 1 argument)
2
- --> $DIR/issue-75307.rs:2:13
2
+ --> $DIR/issue-75307.rs:2:17
3
3
|
4
4
LL | format!(r"{}{}{}", named_arg=1);
5
- | ^^^^^ ^^^^
5
+ | ^^^^
6
6
|
7
7
= note: positional arguments are zero-based
8
8
You can’t perform that action at this time.
0 commit comments