summaryrefslogtreecommitdiffstats
path: root/vendor/syn/src/lit.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
commitd1b2d29528b7794b41e66fc2136e395a02f8529b (patch)
treea4a17504b260206dec3cf55b2dca82929a348ac2 /vendor/syn/src/lit.rs
parentReleasing progress-linux version 1.72.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.tar.xz
rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.zip
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/syn/src/lit.rs')
-rw-r--r--vendor/syn/src/lit.rs17
1 files changed, 13 insertions, 4 deletions
diff --git a/vendor/syn/src/lit.rs b/vendor/syn/src/lit.rs
index 662ef8b22..4f36cf50b 100644
--- a/vendor/syn/src/lit.rs
+++ b/vendor/syn/src/lit.rs
@@ -228,7 +228,17 @@ impl LitStr {
let mut tokens = TokenStream::from_str(&self.value())?;
tokens = respan_token_stream(tokens, self.span());
- parser.parse2(tokens)
+ let result = parser.parse2(tokens)?;
+
+ let suffix = self.suffix();
+ if !suffix.is_empty() {
+ return Err(Error::new(
+ self.span(),
+ format!("unexpected suffix `{}` on string literal", suffix),
+ ));
+ }
+
+ Ok(result)
}
pub fn span(&self) -> Span {
@@ -1166,7 +1176,7 @@ mod value {
b'x' => {
let (byte, rest) = backslash_x(s);
s = rest;
- assert!(byte <= 0x80, "Invalid \\x byte in string literal");
+ assert!(byte <= 0x7F, "Invalid \\x byte in string literal");
char::from_u32(u32::from(byte)).unwrap()
}
b'u' => {
@@ -1273,8 +1283,7 @@ mod value {
b'"' => b'"',
b'\r' | b'\n' => loop {
let byte = byte(v, 0);
- let ch = char::from_u32(u32::from(byte)).unwrap();
- if ch.is_whitespace() {
+ if matches!(byte, b' ' | b'\t' | b'\n' | b'\r') {
v = &v[1..];
} else {
continue 'outer;