-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Rustfmt-ing librustc_front. #29075
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rustfmt-ing librustc_front. #29075
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1073,7 +1073,6 @@ pub type ViewPath = Spanned<ViewPath_>; | |
|
||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] | ||
pub enum ViewPath_ { | ||
|
||
/// `foo::bar::baz as quux` | ||
/// | ||
/// or just | ||
|
@@ -1185,32 +1184,48 @@ pub type FieldIter<'a> = iter::FlatMap<option::IntoIter<&'a Vec<StructField>>, | |
|
||
impl VariantData { | ||
pub fn fields(&self) -> FieldIter { | ||
fn vec_iter<T>(v: &Vec<T>) -> slice::Iter<T> { v.iter() } | ||
fn vec_iter<T>(v: &Vec<T>) -> slice::Iter<T> { | ||
v.iter() | ||
} | ||
match *self { | ||
VariantData::Struct(ref fields, _) | VariantData::Tuple(ref fields, _) => Some(fields), | ||
_ => None, | ||
}.into_iter().flat_map(vec_iter) | ||
} | ||
.into_iter() | ||
.flat_map(vec_iter) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm pretty sure the above is worse than original. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rustfmt fix is in the works... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be fixed now |
||
} | ||
pub fn id(&self) -> NodeId { | ||
match *self { | ||
VariantData::Struct(_, id) | VariantData::Tuple(_, id) | VariantData::Unit(id) => id | ||
VariantData::Struct(_, id) | VariantData::Tuple(_, id) | VariantData::Unit(id) => id, | ||
} | ||
} | ||
pub fn is_struct(&self) -> bool { | ||
if let VariantData::Struct(..) = *self { true } else { false } | ||
if let VariantData::Struct(..) = *self { | ||
true | ||
} else { | ||
false | ||
} | ||
} | ||
pub fn is_tuple(&self) -> bool { | ||
if let VariantData::Tuple(..) = *self { true } else { false } | ||
if let VariantData::Tuple(..) = *self { | ||
true | ||
} else { | ||
false | ||
} | ||
} | ||
pub fn is_unit(&self) -> bool { | ||
if let VariantData::Unit(..) = *self { true } else { false } | ||
if let VariantData::Unit(..) = *self { | ||
true | ||
} else { | ||
false | ||
} | ||
} | ||
} | ||
|
||
/* | ||
FIXME (#3300): Should allow items to be anonymous. Right now | ||
we just use dummy names for anon items. | ||
*/ | ||
// | ||
// FIXME (#3300): Should allow items to be anonymous. Right now | ||
// we just use dummy names for anon items. | ||
// | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://github.com/nrc/rustfmt/issues/539 Could you fix this manually for now please? |
||
/// An item | ||
/// | ||
/// The name might be a dummy name in case of anonymous items | ||
|
@@ -1253,7 +1268,7 @@ pub enum Item_ { | |
ItemTrait(Unsafety, Generics, TyParamBounds, Vec<P<TraitItem>>), | ||
|
||
// Default trait implementations | ||
/// | ||
// | ||
// `impl Trait for .. {}` | ||
ItemDefaultImpl(Unsafety, TraitRef), | ||
/// An implementation, eg `impl<A> Trait for Foo { .. }` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, I dislike the current formatting of struct literals/struct patterns. I'd even say it discourages their use somewhat.
Compare struct patterns and tuple patterns: