diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2021-06-09 12:04:08 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-09 12:04:08 +0900 |
| commit | 3a9609b936a302566b1fc76aded105e13d1a8f43 (patch) | |
| tree | 69d80779afca95855f2879c5c0e011280eee4fff | |
| parent | e163e3c0434041dae60c575854758dd68ddb6b16 (diff) | |
| parent | 58e0889bf58672da36673982de510045557de2c9 (diff) | |
| download | rust-3a9609b936a302566b1fc76aded105e13d1a8f43.tar.gz rust-3a9609b936a302566b1fc76aded105e13d1a8f43.zip | |
Rollup merge of #86142 - m-ou-se:proc-macro-subspan-bound-cloned-cleanup, r=petrochenkov
Simplify proc_macro code using Bound::cloned().
| -rw-r--r-- | library/proc_macro/src/lib.rs | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/library/proc_macro/src/lib.rs b/library/proc_macro/src/lib.rs index 3990826ce42..26fbf50e2df 100644 --- a/library/proc_macro/src/lib.rs +++ b/library/proc_macro/src/lib.rs @@ -31,6 +31,7 @@ #![feature(restricted_std)] #![feature(rustc_attrs)] #![feature(min_specialization)] +#![feature(bound_cloned)] #![recursion_limit = "256"] #[unstable(feature = "proc_macro_internals", issue = "27812")] @@ -43,7 +44,7 @@ mod diagnostic; pub use diagnostic::{Diagnostic, Level, MultiSpan}; use std::cmp::Ordering; -use std::ops::{Bound, RangeBounds}; +use std::ops::RangeBounds; use std::path::PathBuf; use std::str::FromStr; use std::{error, fmt, iter, mem}; @@ -1162,16 +1163,7 @@ impl Literal { // was 'c' or whether it was '\u{63}'. #[unstable(feature = "proc_macro_span", issue = "54725")] pub fn subspan<R: RangeBounds<usize>>(&self, range: R) -> Option<Span> { - // HACK(eddyb) something akin to `Option::cloned`, but for `Bound<&T>`. - fn cloned_bound<T: Clone>(bound: Bound<&T>) -> Bound<T> { - match bound { - Bound::Included(x) => Bound::Included(x.clone()), - Bound::Excluded(x) => Bound::Excluded(x.clone()), - Bound::Unbounded => Bound::Unbounded, - } - } - - self.0.subspan(cloned_bound(range.start_bound()), cloned_bound(range.end_bound())).map(Span) + self.0.subspan(range.start_bound().cloned(), range.end_bound().cloned()).map(Span) } } |
