mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
4220: Introduce LowerCtx r=matklad a=edwin0cheng This PR introduces `LowerCtx` for path lowering. After this PR, there are only 2 places remains for using deprecated `Path::from_ast`, which is related to `AstTransform` I am not familiar. I would like to change these in another PR by others ;) related disscusiion: https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Path.3A.3Afrom_src And also fixed part of https://github.com/rust-analyzer/rust-analyzer/issues/4176#issuecomment-620672930 4240: Bump deps r=matklad a=lnicola Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com> Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
This commit is contained in:
commit
3232fd5179
24 changed files with 293 additions and 127 deletions
|
@ -180,7 +180,7 @@ fn rustc_token_kind_to_syntax_kind(
|
|||
return (syntax_kind, None);
|
||||
|
||||
fn match_literal_kind(kind: &rustc_lexer::LiteralKind) -> (SyntaxKind, Option<&'static str>) {
|
||||
use rustc_lexer::LiteralKind as LK;
|
||||
use rustc_lexer::{LexRawStrError, LiteralKind as LK};
|
||||
|
||||
#[rustfmt::skip]
|
||||
let syntax_kind = match *kind {
|
||||
|
@ -215,21 +215,28 @@ fn rustc_token_kind_to_syntax_kind(
|
|||
return (BYTE_STRING, Some("Missing trailing `\"` symbol to terminate the byte string literal"))
|
||||
}
|
||||
|
||||
LK::RawStr { started: true, terminated: true, .. } => RAW_STRING,
|
||||
LK::RawStr { started: true, terminated: false, .. } => {
|
||||
return (RAW_STRING, Some("Missing trailing `\"` with `#` symbols to terminate the raw string literal"))
|
||||
}
|
||||
LK::RawStr { started: false, .. } => {
|
||||
return (RAW_STRING, Some("Missing `\"` symbol after `#` symbols to begin the raw string literal"))
|
||||
}
|
||||
LK::RawStr(str) => match str.validate() {
|
||||
Ok(_) => RAW_STRING,
|
||||
Err(LexRawStrError::InvalidStarter) => return (RAW_STRING, Some("Missing `\"` symbol after `#` symbols to begin the raw string literal")),
|
||||
Err(LexRawStrError::NoTerminator { expected, found, .. }) => if expected == found {
|
||||
return (RAW_STRING, Some("Missing trailing `\"` to terminate the raw string literal"))
|
||||
} else {
|
||||
return (RAW_STRING, Some("Missing trailing `\"` with `#` symbols to terminate the raw string literal"))
|
||||
|
||||
LK::RawByteStr { started: true, terminated: true, .. } => RAW_BYTE_STRING,
|
||||
LK::RawByteStr { started: true, terminated: false, .. } => {
|
||||
return (RAW_BYTE_STRING, Some("Missing trailing `\"` with `#` symbols to terminate the raw byte string literal"))
|
||||
}
|
||||
LK::RawByteStr { started: false, .. } => {
|
||||
return (RAW_BYTE_STRING, Some("Missing `\"` symbol after `#` symbols to begin the raw byte string literal"))
|
||||
}
|
||||
},
|
||||
Err(LexRawStrError::TooManyDelimiters { .. }) => return (RAW_STRING, Some("Too many `#` symbols: raw strings may be delimited by up to 65535 `#` symbols")),
|
||||
},
|
||||
LK::RawByteStr(str) => match str.validate() {
|
||||
Ok(_) => RAW_BYTE_STRING,
|
||||
Err(LexRawStrError::InvalidStarter) => return (RAW_BYTE_STRING, Some("Missing `\"` symbol after `#` symbols to begin the raw byte string literal")),
|
||||
Err(LexRawStrError::NoTerminator { expected, found, .. }) => if expected == found {
|
||||
return (RAW_BYTE_STRING, Some("Missing trailing `\"` to terminate the raw byte string literal"))
|
||||
} else {
|
||||
return (RAW_BYTE_STRING, Some("Missing trailing `\"` with `#` symbols to terminate the raw byte string literal"))
|
||||
|
||||
},
|
||||
Err(LexRawStrError::TooManyDelimiters { .. }) => return (RAW_BYTE_STRING, Some("Too many `#` symbols: raw byte strings may be delimited by up to 65535 `#` symbols")),
|
||||
},
|
||||
};
|
||||
|
||||
(syntax_kind, None)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue