Skip to content
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

rustc update: Remove variant visibility #332

Merged
merged 1 commit into from
Sep 19, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,6 @@ impl<'a> FmtVisitor<'a> {

let result = match field.node.kind {
ast::VariantKind::TupleVariantKind(ref types) => {
let vis = format_visibility(field.node.vis);
self.buffer.push_str(vis);
let name = field.node.name.to_string();
self.buffer.push_str(&name);

Expand All @@ -531,8 +529,7 @@ impl<'a> FmtVisitor<'a> {

result.push('(');

let indent = self.block_indent + vis.len() + field.node.name.to_string().len() +
1; // Open paren
let indent = self.block_indent + field.node.name.to_string().len() + "(".len();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rustfmt didn't like the statement with or without line break, so I got a bit creative. It yields the same code under -O.


let comma_cost = if self.config.enum_trailing_comma {
1
Expand Down Expand Up @@ -565,9 +562,8 @@ impl<'a> FmtVisitor<'a> {
result.push_str(&expr_snippet);

// Make sure we do not exceed column limit
// 4 = " = ,"
assert!(self.config.max_width >=
vis.len() + name.len() + expr_snippet.len() + 4,
name.len() + expr_snippet.len() + " = ,".len(),
"Enum variant exceeded column limit");
}

Expand All @@ -577,7 +573,7 @@ impl<'a> FmtVisitor<'a> {
// TODO: Should limit the width, as we have a trailing comma
let struct_rewrite = self.format_struct("",
field.node.name,
field.node.vis,
ast::Visibility::Inherited,
struct_def,
None,
field.span,
Expand Down