Use field init shorthand
diff --git a/build.rs b/build.rs
index 1cc8b3b..b093a37 100644
--- a/build.rs
+++ b/build.rs
@@ -102,9 +102,7 @@
let version = otry!(str::from_utf8(&output.stdout).ok());
let nightly = version.contains("nightly");
- Some(RustcVersion {
- nightly: nightly,
- })
+ Some(RustcVersion { nightly })
}
fn feature_allowed(feature: &str) -> bool {
diff --git a/src/fallback.rs b/src/fallback.rs
index 4859dd3..c4298d6 100644
--- a/src/fallback.rs
+++ b/src/fallback.rs
@@ -314,22 +314,19 @@
let lo = self.next_start_pos();
// XXX(nika): Shouild we bother doing a checked cast or checked add here?
let span = Span {
- lo: lo,
+ lo,
hi: lo + (src.len() as u32),
};
#[cfg(procmacro2_semver_exempt)]
self.files.push(FileInfo {
name: name.to_owned(),
- span: span,
- lines: lines,
+ span,
+ lines,
});
#[cfg(not(procmacro2_semver_exempt))]
- self.files.push(FileInfo {
- span: span,
- lines: lines,
- });
+ self.files.push(FileInfo { span, lines });
let _ = name;
span
@@ -453,8 +450,8 @@
impl Group {
pub fn new(delimiter: Delimiter, stream: TokenStream) -> Group {
Group {
- delimiter: delimiter,
- stream: stream,
+ delimiter,
+ stream,
span: Span::call_site(),
}
}
@@ -527,8 +524,8 @@
Ident {
sym: string.to_owned(),
- span: span,
- raw: raw,
+ span,
+ raw,
}
}
@@ -671,7 +668,7 @@
impl Literal {
fn _new(text: String) -> Literal {
Literal {
- text: text,
+ text,
span: Span::call_site(),
}
}
@@ -837,7 +834,7 @@
let lo = input.off;
let (a, b) = f(input)?;
let hi = a.off;
- let span = ::Span::_new_stable(Span { lo: lo, hi: hi });
+ let span = ::Span::_new_stable(Span { lo, hi });
Ok((a, (b, span)))
}
diff --git a/src/lib.rs b/src/lib.rs
index 9c44ea7..190916d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -136,7 +136,7 @@
impl TokenStream {
fn _new(inner: imp::TokenStream) -> TokenStream {
TokenStream {
- inner: inner,
+ inner,
_marker: marker::PhantomData,
}
}
@@ -268,7 +268,7 @@
impl SourceFile {
fn _new(inner: imp::SourceFile) -> Self {
SourceFile {
- inner: inner,
+ inner,
_marker: marker::PhantomData,
}
}
@@ -328,7 +328,7 @@
impl Span {
fn _new(inner: imp::Span) -> Span {
Span {
- inner: inner,
+ inner,
_marker: marker::PhantomData,
}
}
@@ -411,10 +411,7 @@
#[cfg(span_locations)]
pub fn start(&self) -> LineColumn {
let imp::LineColumn { line, column } = self.inner.start();
- LineColumn {
- line: line,
- column: column,
- }
+ LineColumn { line, column }
}
/// Get the ending line/column in the source file for this span.
@@ -423,10 +420,7 @@
#[cfg(span_locations)]
pub fn end(&self) -> LineColumn {
let imp::LineColumn { line, column } = self.inner.end();
- LineColumn {
- line: line,
- column: column,
- }
+ LineColumn { line, column }
}
/// Create a new span encompassing `self` and `other`.
@@ -583,7 +577,7 @@
impl Group {
fn _new(inner: imp::Group) -> Self {
- Group { inner: inner }
+ Group { inner }
}
fn _new_stable(inner: fallback::Group) -> Self {
@@ -709,8 +703,8 @@
/// which can be further configured with the `set_span` method below.
pub fn new(op: char, spacing: Spacing) -> Punct {
Punct {
- op: op,
- spacing: spacing,
+ op,
+ spacing,
span: Span::call_site(),
}
}
@@ -831,7 +825,7 @@
impl Ident {
fn _new(inner: imp::Ident) -> Ident {
Ident {
- inner: inner,
+ inner,
_marker: marker::PhantomData,
}
}
@@ -999,7 +993,7 @@
impl Literal {
fn _new(inner: imp::Literal) -> Literal {
Literal {
- inner: inner,
+ inner,
_marker: marker::PhantomData,
}
}