Compare commits

...

4 Commits

Author SHA1 Message Date
David Tolnay 6502838f27 Release 1.0.170 2023-07-09 11:17:30 -07:00
David Tolnay c93a0f335a Merge pull request #2499 from dtolnay/strsuffix
Reject suffixed string literals inside serde attrs
2023-07-09 11:16:31 -07:00
David Tolnay 8264e002a7 Reject suffixed string literals inside serde attrs 2023-07-09 11:13:24 -07:00
David Tolnay 117ef22142 Add ui test with suffixed string literals in attribute 2023-07-09 11:09:38 -07:00
10 changed files with 37 additions and 9 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
[package]
name = "serde"
version = "1.0.169" # remember to update html_root_url and serde_derive dependency
version = "1.0.170" # remember to update html_root_url and serde_derive dependency
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
build = "build.rs"
categories = ["encoding", "no-std", "no-std::no-alloc"]
@@ -15,7 +15,7 @@ repository = "https://github.com/serde-rs/serde"
rust-version = "1.19"
[dependencies]
serde_derive = { version = "=1.0.169", optional = true, path = "../serde_derive" }
serde_derive = { version = "=1.0.170", optional = true, path = "../serde_derive" }
[dev-dependencies]
serde_derive = { version = "1.0", path = "../serde_derive" }
+1 -1
View File
@@ -93,7 +93,7 @@
////////////////////////////////////////////////////////////////////////////////
// Serde types in rustdoc of other crates get linked to here.
#![doc(html_root_url = "https://docs.rs/serde/1.0.169")]
#![doc(html_root_url = "https://docs.rs/serde/1.0.170")]
// Support using Serde without the standard library!
#![cfg_attr(not(feature = "std"), no_std)]
// Unstable functionality only if the user asks for it. For tracking and
+2 -2
View File
@@ -1,6 +1,6 @@
[package]
name = "serde_derive"
version = "1.0.169" # remember to update html_root_url
version = "1.0.170" # remember to update html_root_url
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
categories = ["no-std", "no-std::no-alloc"]
description = "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]"
@@ -24,7 +24,7 @@ proc-macro = true
[dependencies]
proc-macro2 = "1.0"
quote = "1.0"
syn = "2.0.24"
syn = "2.0.25"
[dev-dependencies]
serde = { version = "1.0", path = "../serde" }
+7
View File
@@ -1418,6 +1418,13 @@ fn get_lit_str2(
..
}) = value
{
let suffix = lit.suffix();
if !suffix.is_empty() {
cx.error_spanned_by(
lit,
format!("unexpected suffix `{}` on string literal", suffix),
);
}
Ok(Some(lit.clone()))
} else {
cx.error_spanned_by(
+1 -1
View File
@@ -13,7 +13,7 @@
//!
//! [https://serde.rs/derive.html]: https://serde.rs/derive.html
#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.169")]
#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.170")]
#![allow(unknown_lints, bare_trait_objects)]
// Ignored clippy lints
#![allow(
+1 -1
View File
@@ -17,7 +17,7 @@ path = "lib.rs"
[dependencies]
proc-macro2 = "1.0"
quote = "1.0"
syn = { version = "2.0.24", default-features = false, features = ["clone-impls", "derive", "parsing", "printing"] }
syn = { version = "2.0.25", default-features = false, features = ["clone-impls", "derive", "parsing", "printing"] }
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "serde_test"
version = "1.0.169" # remember to update html_root_url
version = "1.0.170" # remember to update html_root_url
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
build = "build.rs"
categories = ["development-tools::testing"]
+1 -1
View File
@@ -144,7 +144,7 @@
//! # }
//! ```
#![doc(html_root_url = "https://docs.rs/serde_test/1.0.169")]
#![doc(html_root_url = "https://docs.rs/serde_test/1.0.170")]
#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
// Ignored clippy lints
#![cfg_attr(feature = "cargo-clippy", allow(float_cmp, needless_doctest_main))]
@@ -0,0 +1,10 @@
use serde::Serialize;
#[derive(Serialize)]
#[serde(bound = ""huh)]
pub struct Struct {
#[serde(rename = ""what)]
pub field: i32,
}
fn main() {}
@@ -0,0 +1,11 @@
error: unexpected suffix `huh` on string literal
--> tests/ui/malformed/str_suffix.rs:4:17
|
4 | #[serde(bound = ""huh)]
| ^^^^^
error: unexpected suffix `what` on string literal
--> tests/ui/malformed/str_suffix.rs:6:22
|
6 | #[serde(rename = ""what)]
| ^^^^^^