From 10b5c9951af4cc787905ca26f95509e059931067 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 11 Apr 2024 11:51:32 -0700 Subject: [PATCH] Drop support for compilers older than 1.47 --- build.rs | 27 --------------------------- src/receiver.rs | 21 +++++++++------------ 2 files changed, 9 insertions(+), 39 deletions(-) delete mode 100644 build.rs diff --git a/build.rs b/build.rs deleted file mode 100644 index 04c6250..0000000 --- a/build.rs +++ /dev/null @@ -1,27 +0,0 @@ -use std::env; -use std::process::Command; -use std::str; - -fn main() { - println!("cargo:rerun-if-changed=build.rs"); - - let compiler = match rustc_minor_version() { - Some(compiler) => compiler, - None => return, - }; - - if compiler < 47 { - println!("cargo:rustc-cfg=self_span_hack"); - } -} - -fn rustc_minor_version() -> Option { - let rustc = env::var_os("RUSTC")?; - let output = Command::new(rustc).arg("--version").output().ok()?; - let version = str::from_utf8(&output.stdout).ok()?; - let mut pieces = version.split('.'); - if pieces.next() != Some("rustc 1") { - return None; - } - pieces.next()?.parse().ok() -} diff --git a/src/receiver.rs b/src/receiver.rs index e032dc1..e4627f1 100644 --- a/src/receiver.rs +++ b/src/receiver.rs @@ -80,18 +80,15 @@ impl VisitMut for HasSelf { pub struct ReplaceSelf; -impl ReplaceSelf { - #[cfg_attr(not(self_span_hack), allow(clippy::unused_self))] - fn prepend_underscore_to_self(&self, ident: &mut Ident) -> bool { - let modified = ident == "self"; - if modified { - *ident = Ident::new("__self", ident.span()); - #[cfg(self_span_hack)] - ident.set_span(self.0); - } - modified +fn prepend_underscore_to_self(ident: &mut Ident) -> bool { + let modified = ident == "self"; + if modified { + *ident = Ident::new("__self", ident.span()); } + modified +} +impl ReplaceSelf { fn visit_token_stream(&mut self, tokens: &mut TokenStream) -> bool { let mut out = Vec::new(); let mut modified = false; @@ -110,7 +107,7 @@ impl ReplaceSelf { for tt in tokens { match tt { TokenTree::Ident(mut ident) => { - *modified |= visitor.prepend_underscore_to_self(&mut ident); + *modified |= prepend_underscore_to_self(&mut ident); out.push(TokenTree::Ident(ident)); } TokenTree::Group(group) => { @@ -129,7 +126,7 @@ impl ReplaceSelf { impl VisitMut for ReplaceSelf { fn visit_ident_mut(&mut self, i: &mut Ident) { - self.prepend_underscore_to_self(i); + prepend_underscore_to_self(i); } fn visit_path_mut(&mut self, p: &mut Path) {