Skip to content

Commit b6b7c57

Browse files
committed
Fix clippy lints in proc-macro-srv
1 parent 1428cf6 commit b6b7c57

File tree

6 files changed

+12
-11
lines changed

6 files changed

+12
-11
lines changed

src/tools/rust-analyzer/crates/proc-macro-srv-cli/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ fn run() -> io::Result<()> {
6969

7070
let write_response = |msg: msg::Response| msg.write(write_json, &mut io::stdout().lock());
7171

72-
let env = EnvSnapshot::new();
72+
let env = EnvSnapshot::default();
7373
let mut srv = proc_macro_srv::ProcMacroSrv::new(&env);
7474
let mut buf = String::new();
7575

src/tools/rust-analyzer/crates/proc-macro-srv/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#![cfg(any(feature = "sysroot-abi", rust_analyzer))]
1414
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
1515
#![feature(proc_macro_internals, proc_macro_diagnostic, proc_macro_span)]
16-
#![allow(unreachable_pub, internal_features)]
16+
#![allow(unreachable_pub, internal_features, clippy::disallowed_types, clippy::print_stderr)]
1717

1818
extern crate proc_macro;
1919
#[cfg(feature = "in-rust-tree")]
@@ -65,7 +65,7 @@ impl<'env> ProcMacroSrv<'env> {
6565

6666
const EXPANDER_STACK_SIZE: usize = 8 * 1024 * 1024;
6767

68-
impl<'env> ProcMacroSrv<'env> {
68+
impl ProcMacroSrv<'_> {
6969
pub fn set_span_mode(&mut self, span_mode: SpanMode) {
7070
self.span_mode = span_mode;
7171
}
@@ -248,8 +248,8 @@ pub struct EnvSnapshot {
248248
vars: HashMap<OsString, OsString>,
249249
}
250250

251-
impl EnvSnapshot {
252-
pub fn new() -> EnvSnapshot {
251+
impl Default for EnvSnapshot {
252+
fn default() -> EnvSnapshot {
253253
EnvSnapshot { vars: env::vars_os().collect() }
254254
}
255255
}
@@ -305,7 +305,7 @@ impl Drop for EnvChange<'_> {
305305
}
306306

307307
if let Some(dir) = &self.prev_working_dir {
308-
if let Err(err) = std::env::set_current_dir(&dir) {
308+
if let Err(err) = std::env::set_current_dir(dir) {
309309
eprintln!(
310310
"Failed to set the current working dir to {}. Error: {:?}",
311311
dir.display(),

src/tools/rust-analyzer/crates/proc-macro-srv/src/proc_macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub(crate) struct ProcMacros {
1313

1414
impl From<bridge::PanicMessage> for crate::PanicMessage {
1515
fn from(p: bridge::PanicMessage) -> Self {
16-
Self { message: p.as_str().map(|s| s.to_string()) }
16+
Self { message: p.as_str().map(|s| s.to_owned()) }
1717
}
1818
}
1919

src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ mod tests {
498498
})),
499499
tt::TokenTree::Leaf(tt::Leaf::Ident(tt::Ident {
500500
sym: Symbol::intern("T"),
501-
span: span,
501+
span,
502502
is_raw: tt::IdentIsRaw::No,
503503
})),
504504
tt::TokenTree::Subtree(tt::Subtree {

src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/token_stream.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub(super) struct TokenStreamBuilder<S> {
9999
}
100100

101101
/// pub(super)lic implementation details for the `TokenStream` type, such as iterators.
102-
pub(super) mod token_stream {
102+
pub(super) mod token_stream_impls {
103103

104104
use core::fmt;
105105

@@ -137,6 +137,7 @@ pub(super) mod token_stream {
137137
}
138138
}
139139

140+
#[allow(clippy::to_string_trait_impl)]
140141
impl<S> ToString for TokenStream<S> {
141142
fn to_string(&self) -> String {
142143
::tt::pretty(&self.token_trees)
@@ -150,7 +151,7 @@ impl<S> TokenStreamBuilder<S> {
150151
}
151152

152153
pub(super) fn push(&mut self, stream: TokenStream<S>) {
153-
self.acc.extend(stream.into_iter())
154+
self.acc.extend(stream)
154155
}
155156

156157
pub(super) fn build(self) -> TokenStream<S> {

src/tools/rust-analyzer/crates/proc-macro-srv/src/tests/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ fn assert_expand_impl(
9797

9898
pub(crate) fn list() -> Vec<String> {
9999
let dylib_path = proc_macro_test_dylib_path();
100-
let env = EnvSnapshot::new();
100+
let env = EnvSnapshot::default();
101101
let mut srv = ProcMacroSrv::new(&env);
102102
let res = srv.list_macros(&dylib_path).unwrap();
103103
res.into_iter().map(|(name, kind)| format!("{name} [{kind:?}]")).collect()

0 commit comments

Comments
 (0)