mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
Fix clippy lints in proc-macro-srv
This commit is contained in:
parent
c9314d4aff
commit
8a86fa01ac
6 changed files with 12 additions and 11 deletions
|
@ -69,7 +69,7 @@ fn run() -> io::Result<()> {
|
||||||
|
|
||||||
let write_response = |msg: msg::Response| msg.write(write_json, &mut io::stdout().lock());
|
let write_response = |msg: msg::Response| msg.write(write_json, &mut io::stdout().lock());
|
||||||
|
|
||||||
let env = EnvSnapshot::new();
|
let env = EnvSnapshot::default();
|
||||||
let mut srv = proc_macro_srv::ProcMacroSrv::new(&env);
|
let mut srv = proc_macro_srv::ProcMacroSrv::new(&env);
|
||||||
let mut buf = String::new();
|
let mut buf = String::new();
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#![cfg(any(feature = "sysroot-abi", rust_analyzer))]
|
#![cfg(any(feature = "sysroot-abi", rust_analyzer))]
|
||||||
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
|
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
|
||||||
#![feature(proc_macro_internals, proc_macro_diagnostic, proc_macro_span)]
|
#![feature(proc_macro_internals, proc_macro_diagnostic, proc_macro_span)]
|
||||||
#![allow(unreachable_pub, internal_features)]
|
#![allow(unreachable_pub, internal_features, clippy::disallowed_types, clippy::print_stderr)]
|
||||||
|
|
||||||
extern crate proc_macro;
|
extern crate proc_macro;
|
||||||
#[cfg(feature = "in-rust-tree")]
|
#[cfg(feature = "in-rust-tree")]
|
||||||
|
@ -65,7 +65,7 @@ impl<'env> ProcMacroSrv<'env> {
|
||||||
|
|
||||||
const EXPANDER_STACK_SIZE: usize = 8 * 1024 * 1024;
|
const EXPANDER_STACK_SIZE: usize = 8 * 1024 * 1024;
|
||||||
|
|
||||||
impl<'env> ProcMacroSrv<'env> {
|
impl ProcMacroSrv<'_> {
|
||||||
pub fn set_span_mode(&mut self, span_mode: SpanMode) {
|
pub fn set_span_mode(&mut self, span_mode: SpanMode) {
|
||||||
self.span_mode = span_mode;
|
self.span_mode = span_mode;
|
||||||
}
|
}
|
||||||
|
@ -248,8 +248,8 @@ pub struct EnvSnapshot {
|
||||||
vars: HashMap<OsString, OsString>,
|
vars: HashMap<OsString, OsString>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EnvSnapshot {
|
impl Default for EnvSnapshot {
|
||||||
pub fn new() -> EnvSnapshot {
|
fn default() -> EnvSnapshot {
|
||||||
EnvSnapshot { vars: env::vars_os().collect() }
|
EnvSnapshot { vars: env::vars_os().collect() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -305,7 +305,7 @@ impl Drop for EnvChange<'_> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(dir) = &self.prev_working_dir {
|
if let Some(dir) = &self.prev_working_dir {
|
||||||
if let Err(err) = std::env::set_current_dir(&dir) {
|
if let Err(err) = std::env::set_current_dir(dir) {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"Failed to set the current working dir to {}. Error: {:?}",
|
"Failed to set the current working dir to {}. Error: {:?}",
|
||||||
dir.display(),
|
dir.display(),
|
||||||
|
|
|
@ -13,7 +13,7 @@ pub(crate) struct ProcMacros {
|
||||||
|
|
||||||
impl From<bridge::PanicMessage> for crate::PanicMessage {
|
impl From<bridge::PanicMessage> for crate::PanicMessage {
|
||||||
fn from(p: bridge::PanicMessage) -> Self {
|
fn from(p: bridge::PanicMessage) -> Self {
|
||||||
Self { message: p.as_str().map(|s| s.to_string()) }
|
Self { message: p.as_str().map(|s| s.to_owned()) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -498,7 +498,7 @@ mod tests {
|
||||||
})),
|
})),
|
||||||
tt::TokenTree::Leaf(tt::Leaf::Ident(tt::Ident {
|
tt::TokenTree::Leaf(tt::Leaf::Ident(tt::Ident {
|
||||||
sym: Symbol::intern("T"),
|
sym: Symbol::intern("T"),
|
||||||
span: span,
|
span,
|
||||||
is_raw: tt::IdentIsRaw::No,
|
is_raw: tt::IdentIsRaw::No,
|
||||||
})),
|
})),
|
||||||
tt::TokenTree::Subtree(tt::Subtree {
|
tt::TokenTree::Subtree(tt::Subtree {
|
||||||
|
|
|
@ -99,7 +99,7 @@ pub(super) struct TokenStreamBuilder<S> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// pub(super)lic implementation details for the `TokenStream` type, such as iterators.
|
/// pub(super)lic implementation details for the `TokenStream` type, such as iterators.
|
||||||
pub(super) mod token_stream {
|
pub(super) mod token_stream_impls {
|
||||||
|
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
|
|
||||||
|
@ -137,6 +137,7 @@ pub(super) mod token_stream {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::to_string_trait_impl)]
|
||||||
impl<S> ToString for TokenStream<S> {
|
impl<S> ToString for TokenStream<S> {
|
||||||
fn to_string(&self) -> String {
|
fn to_string(&self) -> String {
|
||||||
::tt::pretty(&self.token_trees)
|
::tt::pretty(&self.token_trees)
|
||||||
|
@ -150,7 +151,7 @@ impl<S> TokenStreamBuilder<S> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn push(&mut self, stream: TokenStream<S>) {
|
pub(super) fn push(&mut self, stream: TokenStream<S>) {
|
||||||
self.acc.extend(stream.into_iter())
|
self.acc.extend(stream)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn build(self) -> TokenStream<S> {
|
pub(super) fn build(self) -> TokenStream<S> {
|
||||||
|
|
|
@ -97,7 +97,7 @@ fn assert_expand_impl(
|
||||||
|
|
||||||
pub(crate) fn list() -> Vec<String> {
|
pub(crate) fn list() -> Vec<String> {
|
||||||
let dylib_path = proc_macro_test_dylib_path();
|
let dylib_path = proc_macro_test_dylib_path();
|
||||||
let env = EnvSnapshot::new();
|
let env = EnvSnapshot::default();
|
||||||
let mut srv = ProcMacroSrv::new(&env);
|
let mut srv = ProcMacroSrv::new(&env);
|
||||||
let res = srv.list_macros(&dylib_path).unwrap();
|
let res = srv.list_macros(&dylib_path).unwrap();
|
||||||
res.into_iter().map(|(name, kind)| format!("{name} [{kind:?}]")).collect()
|
res.into_iter().map(|(name, kind)| format!("{name} [{kind:?}]")).collect()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue