mirror of
https://gitee.com/openharmony/third_party_rust_proc-macro2
synced 2024-11-23 07:19:41 +00:00
Use field init shorthand
This commit is contained in:
parent
e02a294818
commit
f081412819
4
build.rs
4
build.rs
@ -102,9 +102,7 @@ fn rustc_version() -> Option<RustcVersion> {
|
||||
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 {
|
||||
|
@ -314,22 +314,19 @@ impl SourceMap {
|
||||
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 @@ pub struct Group {
|
||||
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 @@ impl Ident {
|
||||
|
||||
Ident {
|
||||
sym: string.to_owned(),
|
||||
span: span,
|
||||
raw: raw,
|
||||
span,
|
||||
raw,
|
||||
}
|
||||
}
|
||||
|
||||
@ -671,7 +668,7 @@ macro_rules! unsuffixed_numbers {
|
||||
impl Literal {
|
||||
fn _new(text: String) -> Literal {
|
||||
Literal {
|
||||
text: text,
|
||||
text,
|
||||
span: Span::call_site(),
|
||||
}
|
||||
}
|
||||
@ -837,7 +834,7 @@ fn spanned<'a, T>(
|
||||
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)))
|
||||
}
|
||||
|
||||
|
26
src/lib.rs
26
src/lib.rs
@ -136,7 +136,7 @@ pub struct LexError {
|
||||
impl TokenStream {
|
||||
fn _new(inner: imp::TokenStream) -> TokenStream {
|
||||
TokenStream {
|
||||
inner: inner,
|
||||
inner,
|
||||
_marker: marker::PhantomData,
|
||||
}
|
||||
}
|
||||
@ -268,7 +268,7 @@ pub struct SourceFile {
|
||||
impl SourceFile {
|
||||
fn _new(inner: imp::SourceFile) -> Self {
|
||||
SourceFile {
|
||||
inner: inner,
|
||||
inner,
|
||||
_marker: marker::PhantomData,
|
||||
}
|
||||
}
|
||||
@ -328,7 +328,7 @@ pub struct Span {
|
||||
impl Span {
|
||||
fn _new(inner: imp::Span) -> Span {
|
||||
Span {
|
||||
inner: inner,
|
||||
inner,
|
||||
_marker: marker::PhantomData,
|
||||
}
|
||||
}
|
||||
@ -411,10 +411,7 @@ impl Span {
|
||||
#[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 @@ impl Span {
|
||||
#[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 @@ pub enum Delimiter {
|
||||
|
||||
impl Group {
|
||||
fn _new(inner: imp::Group) -> Self {
|
||||
Group { inner: inner }
|
||||
Group { inner }
|
||||
}
|
||||
|
||||
fn _new_stable(inner: fallback::Group) -> Self {
|
||||
@ -709,8 +703,8 @@ impl Punct {
|
||||
/// 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 @@ pub struct Ident {
|
||||
impl Ident {
|
||||
fn _new(inner: imp::Ident) -> Ident {
|
||||
Ident {
|
||||
inner: inner,
|
||||
inner,
|
||||
_marker: marker::PhantomData,
|
||||
}
|
||||
}
|
||||
@ -999,7 +993,7 @@ macro_rules! unsuffixed_int_literals {
|
||||
impl Literal {
|
||||
fn _new(inner: imp::Literal) -> Literal {
|
||||
Literal {
|
||||
inner: inner,
|
||||
inner,
|
||||
_marker: marker::PhantomData,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user