mirror of
				https://github.com/rust-lang/rust-analyzer.git
				synced 2025-11-03 13:13:18 +00:00 
			
		
		
		
	fix: Fix builtin includes rejecting raw string literals
This commit is contained in:
		
							parent
							
								
									fab30c45cb
								
							
						
					
					
						commit
						ad71abb9ad
					
				@ -439,7 +439,7 @@ macro_rules! include_bytes {
 | 
				
			|||||||
    ($file:expr,) => {{ /* compiler built-in */ }};
 | 
					    ($file:expr,) => {{ /* compiler built-in */ }};
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
fn main() { include_bytes("foo"); }
 | 
					fn main() { include_bytes("foo");include_bytes(r"foo"); }
 | 
				
			||||||
"#,
 | 
					"#,
 | 
				
			||||||
        expect![[r##"
 | 
					        expect![[r##"
 | 
				
			||||||
#[rustc_builtin_macro]
 | 
					#[rustc_builtin_macro]
 | 
				
			||||||
@ -448,7 +448,7 @@ macro_rules! include_bytes {
 | 
				
			|||||||
    ($file:expr,) => {{ /* compiler built-in */ }};
 | 
					    ($file:expr,) => {{ /* compiler built-in */ }};
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
fn main() { include_bytes("foo"); }
 | 
					fn main() { include_bytes("foo");include_bytes(r"foo"); }
 | 
				
			||||||
"##]],
 | 
					"##]],
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -714,6 +714,12 @@ fn parse_string(tt: &tt::Subtree) -> Result<(Symbol, Span), ExpandError> {
 | 
				
			|||||||
                kind: tt::LitKind::Str,
 | 
					                kind: tt::LitKind::Str,
 | 
				
			||||||
                suffix: _,
 | 
					                suffix: _,
 | 
				
			||||||
            })) => Ok((unescape_str(text), *span)),
 | 
					            })) => Ok((unescape_str(text), *span)),
 | 
				
			||||||
 | 
					            tt::TokenTree::Leaf(tt::Leaf::Literal(tt::Literal {
 | 
				
			||||||
 | 
					                symbol: text,
 | 
				
			||||||
 | 
					                span,
 | 
				
			||||||
 | 
					                kind: tt::LitKind::StrRaw(_),
 | 
				
			||||||
 | 
					                suffix: _,
 | 
				
			||||||
 | 
					            })) => Ok((text.clone(), *span)),
 | 
				
			||||||
            // FIXME: We wrap expression fragments in parentheses which can break this expectation
 | 
					            // FIXME: We wrap expression fragments in parentheses which can break this expectation
 | 
				
			||||||
            // here
 | 
					            // here
 | 
				
			||||||
            // Remove this once we handle none delims correctly
 | 
					            // Remove this once we handle none delims correctly
 | 
				
			||||||
@ -725,6 +731,12 @@ fn parse_string(tt: &tt::Subtree) -> Result<(Symbol, Span), ExpandError> {
 | 
				
			|||||||
                        kind: tt::LitKind::Str,
 | 
					                        kind: tt::LitKind::Str,
 | 
				
			||||||
                        suffix: _,
 | 
					                        suffix: _,
 | 
				
			||||||
                    })) => Some((unescape_str(text), *span)),
 | 
					                    })) => Some((unescape_str(text), *span)),
 | 
				
			||||||
 | 
					                    tt::TokenTree::Leaf(tt::Leaf::Literal(tt::Literal {
 | 
				
			||||||
 | 
					                        symbol: text,
 | 
				
			||||||
 | 
					                        span,
 | 
				
			||||||
 | 
					                        kind: tt::LitKind::StrRaw(_),
 | 
				
			||||||
 | 
					                        suffix: _,
 | 
				
			||||||
 | 
					                    })) => Some((text.clone(), *span)),
 | 
				
			||||||
                    _ => None,
 | 
					                    _ => None,
 | 
				
			||||||
                })
 | 
					                })
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user