Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal: Split serde derive feature into serde_derive usage #18728

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 18 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ pulldown-cmark = { version = "0.9.0", default-features = false }
rayon = "1.8.0"
rustc-hash = "2.0.0"
semver = "1.0.14"
serde = { version = "1.0.192", features = ["derive"] }
serde = { version = "1.0.192" }
serde_derive = { version = "1.0.192" }
serde_json = "1.0.108"
smallvec = { version = "1.10.0", features = [
"const_new",
Expand All @@ -157,7 +158,7 @@ tracing-subscriber = { version = "0.3.18", default-features = false, features =
"time",
"tracing-log",
] }
triomphe = { version = "0.1.10", default-features = false, features = ["std"] }
triomphe = { version = "0.1.14", default-features = false, features = ["std"] }
url = "2.3.1"
xshell = "0.2.5"

Expand Down
3 changes: 1 addition & 2 deletions crates/paths/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ doctest = false

[dependencies]
camino.workspace = true
serde = { workspace = true, optional = true }

[features]
serde1 = ["camino/serde1", "dep:serde"]
serde1 = ["camino/serde1"]

[lints]
workspace = true
1 change: 1 addition & 0 deletions crates/proc-macro-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ doctest = false

[dependencies]
serde.workspace = true
serde_derive.workspace = true
serde_json = { workspace = true, features = ["unbounded_depth"] }
tracing.workspace = true
rustc-hash.workspace = true
Expand Down
5 changes: 3 additions & 2 deletions crates/proc-macro-api/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ pub(crate) mod flat;
use std::io::{self, BufRead, Write};

use paths::Utf8PathBuf;
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use serde::de::DeserializeOwned;
use serde_derive::{Deserialize, Serialize};

use crate::ProcMacroKind;

Expand Down Expand Up @@ -123,7 +124,7 @@ impl ExpnGlobals {
}
}

pub trait Message: Serialize + DeserializeOwned {
pub trait Message: serde::Serialize + DeserializeOwned {
fn read<R: BufRead>(
from_proto: ProtocolRead<R>,
inp: &mut R,
Expand Down
2 changes: 1 addition & 1 deletion crates/proc-macro-api/src/msg/flat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use std::collections::VecDeque;

use intern::Symbol;
use rustc_hash::FxHashMap;
use serde::{Deserialize, Serialize};
use serde_derive::{Deserialize, Serialize};
use span::{EditionedFileId, ErasedFileAstId, Span, SpanAnchor, SyntaxContextId, TextRange};

use crate::msg::EXTENDED_LEAF_DATA;
Expand Down
1 change: 1 addition & 0 deletions crates/project-model/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ rustc-hash.workspace = true
semver.workspace = true
serde_json.workspace = true
serde.workspace = true
serde_derive.workspace = true
tracing.workspace = true
triomphe.workspace = true
la-arena.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/project-model/src/build_dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use itertools::Itertools;
use la_arena::ArenaMap;
use paths::{AbsPath, AbsPathBuf, Utf8PathBuf};
use rustc_hash::{FxHashMap, FxHashSet};
use serde::Deserialize;
use serde::Deserialize as _;
use toolchain::Tool;

use crate::{
Expand Down
2 changes: 1 addition & 1 deletion crates/project-model/src/cargo_workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use cargo_metadata::{CargoOpt, MetadataCommand};
use la_arena::{Arena, Idx};
use paths::{AbsPath, AbsPathBuf, Utf8PathBuf};
use rustc_hash::{FxHashMap, FxHashSet};
use serde::Deserialize;
use serde_derive::Deserialize;
use serde_json::from_value;
use span::Edition;
use toolchain::Tool;
Expand Down
2 changes: 1 addition & 1 deletion crates/ra-salsa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ parking_lot = "0.12.1"
rustc-hash = "2.0.0"
smallvec = "1.0.0"
oorandom = "11"
triomphe = "0.1.11"
triomphe.workspace = true
itertools.workspace = true

ra-salsa-macros = { version = "0.0.0", path = "ra-salsa-macros", package = "salsa-macros" }
Expand Down
1 change: 1 addition & 0 deletions crates/rust-analyzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ rayon.workspace = true
rustc-hash.workspace = true
serde_json = { workspace = true, features = ["preserve_order"] }
serde.workspace = true
serde_derive.workspace = true
tenthash = "0.4.0"
num_cpus = "1.15.0"
mimalloc = { version = "0.1.30", default-features = false, optional = true }
Expand Down
3 changes: 2 additions & 1 deletion crates/rust-analyzer/src/flycheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use std::{fmt, io, process::Command, time::Duration};
use crossbeam_channel::{select_biased, unbounded, Receiver, Sender};
use paths::{AbsPath, AbsPathBuf, Utf8PathBuf};
use rustc_hash::FxHashMap;
use serde::Deserialize;
use serde::Deserialize as _;
use serde_derive::Deserialize;

pub(crate) use cargo_metadata::diagnostic::{
Applicability, Diagnostic, DiagnosticCode, DiagnosticLevel, DiagnosticSpan,
Expand Down
3 changes: 2 additions & 1 deletion crates/rust-analyzer/src/test_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use std::process::Command;

use crossbeam_channel::Sender;
use paths::AbsPath;
use serde::Deserialize;
use serde::Deserialize as _;
use serde_derive::Deserialize;
use toolchain::Tool;

use crate::{
Expand Down
2 changes: 1 addition & 1 deletion crates/rust-analyzer/src/tracing/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ where
fn on_event(&self, _event: &Event<'_>, _ctx: Context<'_, S>) {}

fn on_close(&self, id: Id, ctx: Context<'_, S>) {
#[derive(serde::Serialize)]
#[derive(serde_derive::Serialize)]
struct JsonDataInner {
name: &'static str,
elapsed_ms: u128,
Expand Down
4 changes: 3 additions & 1 deletion crates/span/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,9 @@ pub struct MacroFileId {
/// `MacroCallId` identifies a particular macro invocation, like
/// `println!("Hello, {}", world)`.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct MacroCallId(ra_salsa::InternId);
pub struct MacroCallId(InternId);

#[cfg(feature = "ra-salsa")]
impl ra_salsa::InternKey for MacroCallId {
fn from_intern_id(v: ra_salsa::InternId) -> Self {
MacroCallId(v)
Expand Down Expand Up @@ -362,6 +363,7 @@ mod intern_id_proxy {
use std::fmt;
use std::num::NonZeroU32;

#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub(super) struct InternId {
value: NonZeroU32,
}
Expand Down
5 changes: 3 additions & 2 deletions lib/lsp-server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lsp-server"
version = "0.7.7"
version = "0.7.8"
description = "Generic LSP server scaffold."
license = "MIT OR Apache-2.0"
repository = "https://github.com/rust-lang/rust-analyzer/tree/master/lib/lsp-server"
Expand All @@ -9,7 +9,8 @@ edition = "2021"
[dependencies]
log = "0.4.17"
serde_json = "1.0.108"
serde = { version = "1.0.192", features = ["derive"] }
serde = { version = "1.0.216" }
serde_derive = { version = "1.0.216" }
crossbeam-channel.workspace = true

[dev-dependencies]
Expand Down
9 changes: 5 additions & 4 deletions lib/lsp-server/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use std::{
io::{self, BufRead, Write},
};

use serde::{de::DeserializeOwned, Deserialize, Serialize};
use serde::de::DeserializeOwned;
use serde_derive::{Deserialize, Serialize};

use crate::error::ExtractError;

Expand Down Expand Up @@ -196,7 +197,7 @@ impl Message {
}

impl Response {
pub fn new_ok<R: Serialize>(id: RequestId, result: R) -> Response {
pub fn new_ok<R: serde::Serialize>(id: RequestId, result: R) -> Response {
Response { id, result: Some(serde_json::to_value(result).unwrap()), error: None }
}
pub fn new_err(id: RequestId, code: i32, message: String) -> Response {
Expand All @@ -206,7 +207,7 @@ impl Response {
}

impl Request {
pub fn new<P: Serialize>(id: RequestId, method: String, params: P) -> Request {
pub fn new<P: serde::Serialize>(id: RequestId, method: String, params: P) -> Request {
Request { id, method, params: serde_json::to_value(params).unwrap() }
}
pub fn extract<P: DeserializeOwned>(
Expand All @@ -231,7 +232,7 @@ impl Request {
}

impl Notification {
pub fn new(method: String, params: impl Serialize) -> Notification {
pub fn new(method: String, params: impl serde::Serialize) -> Notification {
Notification { method, params: serde_json::to_value(params).unwrap() }
}
pub fn extract<P: DeserializeOwned>(
Expand Down
4 changes: 1 addition & 3 deletions lib/lsp-server/src/req_queue.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use std::collections::HashMap;

use serde::Serialize;

use crate::{ErrorCode, Request, RequestId, Response, ResponseError};

/// Manages the set of pending requests, both incoming and outgoing.
Expand Down Expand Up @@ -56,7 +54,7 @@ impl<I> Incoming<I> {
}

impl<O> Outgoing<O> {
pub fn register<P: Serialize>(&mut self, method: String, params: P, data: O) -> Request {
pub fn register<P: serde::Serialize>(&mut self, method: String, params: P, data: O) -> Request {
let id = RequestId::from(self.next_id);
self.pending.insert(id.clone(), data);
self.next_id += 1;
Expand Down
3 changes: 2 additions & 1 deletion xtask/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ xflags = "0.3.0"
time = { version = "0.3", default-features = false }
zip = { version = "0.6", default-features = false, features = ["deflate", "time"] }
stdx.workspace = true
proc-macro2 = "1.0.47"
# https://github.com/dtolnay/proc-macro2/issues/475
proc-macro2 = "=1.0.86"
quote = "1.0.20"
ungrammar = "1.16.1"
either.workspace = true
Expand Down
Loading