deps: Update syntex_syntax to 0.31.0
Most of the churn on this bump comes from the `Visibility` enum changing from pub enum Visibility { Public, Inherited, } to pub enum Visibility { Public, Crate, Restricted { path: P<Path>, id: NodeId }, Inherited, } which require taking `Visibility` by reference in most places. The new variants are not handled at this point. Refs #970
This commit is contained in:
parent
5092eec081
commit
fd38acb86f
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -9,7 +9,7 @@ dependencies = [
|
||||
"regex 0.1.63 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"strings 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syntex_syntax 0.30.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syntex_syntax 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"term 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"toml 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-segmentation 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -111,7 +111,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "syntex_syntax"
|
||||
version = "0.30.0"
|
||||
version = "0.31.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -21,7 +21,7 @@ regex = "0.1"
|
||||
term = "0.4"
|
||||
strings = "0.0.1"
|
||||
diff = "0.1"
|
||||
syntex_syntax = "0.30"
|
||||
syntex_syntax = "0.31"
|
||||
log = "0.3"
|
||||
env_logger = "0.3"
|
||||
getopts = "0.2"
|
||||
|
65
src/items.rs
65
src/items.rs
@ -126,7 +126,7 @@ impl<'a> FmtVisitor<'a> {
|
||||
// These are not actually rust functions,
|
||||
// but we format them as such.
|
||||
abi::Abi::Rust,
|
||||
item.vis,
|
||||
&item.vis,
|
||||
span,
|
||||
false,
|
||||
false);
|
||||
@ -148,7 +148,7 @@ impl<'a> FmtVisitor<'a> {
|
||||
""
|
||||
};
|
||||
let prefix = format!("{}static {}{}: ",
|
||||
format_visibility(item.vis),
|
||||
format_visibility(&item.vis),
|
||||
mut_str,
|
||||
item.ident);
|
||||
let offset = self.block_indent + prefix.len();
|
||||
@ -179,7 +179,7 @@ impl<'a> FmtVisitor<'a> {
|
||||
unsafety: ast::Unsafety,
|
||||
constness: ast::Constness,
|
||||
abi: abi::Abi,
|
||||
vis: ast::Visibility,
|
||||
vis: &ast::Visibility,
|
||||
span: Span,
|
||||
block: &ast::Block)
|
||||
-> Option<String> {
|
||||
@ -244,7 +244,7 @@ impl<'a> FmtVisitor<'a> {
|
||||
sig.unsafety,
|
||||
sig.constness,
|
||||
sig.abi,
|
||||
ast::Visibility::Inherited,
|
||||
&ast::Visibility::Inherited,
|
||||
span,
|
||||
false,
|
||||
false));
|
||||
@ -303,7 +303,7 @@ impl<'a> FmtVisitor<'a> {
|
||||
|
||||
pub fn visit_enum(&mut self,
|
||||
ident: ast::Ident,
|
||||
vis: ast::Visibility,
|
||||
vis: &ast::Visibility,
|
||||
enum_def: &ast::EnumDef,
|
||||
generics: &ast::Generics,
|
||||
span: Span) {
|
||||
@ -414,7 +414,7 @@ impl<'a> FmtVisitor<'a> {
|
||||
format_struct(&context,
|
||||
"",
|
||||
field.node.name,
|
||||
ast::Visibility::Inherited,
|
||||
&ast::Visibility::Inherited,
|
||||
&field.node.data,
|
||||
None,
|
||||
field.span,
|
||||
@ -451,7 +451,7 @@ pub fn format_impl(context: &RewriteContext, item: &ast::Item, offset: Indent) -
|
||||
ref self_ty,
|
||||
ref items) = item.node {
|
||||
let mut result = String::new();
|
||||
result.push_str(format_visibility(item.vis));
|
||||
result.push_str(format_visibility(&item.vis));
|
||||
result.push_str(format_unsafety(unsafety));
|
||||
result.push_str("impl");
|
||||
|
||||
@ -583,7 +583,7 @@ fn is_impl_single_line(context: &RewriteContext,
|
||||
pub fn format_struct(context: &RewriteContext,
|
||||
item_name: &str,
|
||||
ident: ast::Ident,
|
||||
vis: ast::Visibility,
|
||||
vis: &ast::Visibility,
|
||||
struct_def: &ast::VariantData,
|
||||
generics: Option<&ast::Generics>,
|
||||
span: Span,
|
||||
@ -619,7 +619,7 @@ pub fn format_trait(context: &RewriteContext, item: &ast::Item, offset: Indent)
|
||||
item.node {
|
||||
let mut result = String::new();
|
||||
let header = format!("{}{}trait {}",
|
||||
format_visibility(item.vis),
|
||||
format_visibility(&item.vis),
|
||||
format_unsafety(unsafety),
|
||||
item.ident);
|
||||
|
||||
@ -741,7 +741,7 @@ pub fn format_trait(context: &RewriteContext, item: &ast::Item, offset: Indent)
|
||||
}
|
||||
}
|
||||
|
||||
fn format_unit_struct(item_name: &str, ident: ast::Ident, vis: ast::Visibility) -> Option<String> {
|
||||
fn format_unit_struct(item_name: &str, ident: ast::Ident, vis: &ast::Visibility) -> Option<String> {
|
||||
let mut result = String::with_capacity(1024);
|
||||
|
||||
let header_str = format_header(item_name, ident, vis);
|
||||
@ -754,7 +754,7 @@ fn format_unit_struct(item_name: &str, ident: ast::Ident, vis: ast::Visibility)
|
||||
fn format_struct_struct(context: &RewriteContext,
|
||||
item_name: &str,
|
||||
ident: ast::Ident,
|
||||
vis: ast::Visibility,
|
||||
vis: &ast::Visibility,
|
||||
fields: &[ast::StructField],
|
||||
generics: Option<&ast::Generics>,
|
||||
span: Span,
|
||||
@ -804,13 +804,13 @@ fn format_struct_struct(context: &RewriteContext,
|
||||
"}",
|
||||
|field| {
|
||||
// Include attributes and doc comments, if present
|
||||
if !field.node.attrs.is_empty() {
|
||||
field.node.attrs[0].span.lo
|
||||
if !field.attrs.is_empty() {
|
||||
field.attrs[0].span.lo
|
||||
} else {
|
||||
field.span.lo
|
||||
}
|
||||
},
|
||||
|field| field.node.ty.span.hi,
|
||||
|field| field.ty.span.hi,
|
||||
|field| field.rewrite(context, item_budget, item_indent),
|
||||
context.codemap.span_after(span, "{"),
|
||||
span.hi);
|
||||
@ -835,7 +835,7 @@ fn format_struct_struct(context: &RewriteContext,
|
||||
fn format_tuple_struct(context: &RewriteContext,
|
||||
item_name: &str,
|
||||
ident: ast::Ident,
|
||||
vis: ast::Visibility,
|
||||
vis: &ast::Visibility,
|
||||
fields: &[ast::StructField],
|
||||
generics: Option<&ast::Generics>,
|
||||
span: Span,
|
||||
@ -890,13 +890,13 @@ fn format_tuple_struct(context: &RewriteContext,
|
||||
")",
|
||||
|field| {
|
||||
// Include attributes and doc comments, if present
|
||||
if !field.node.attrs.is_empty() {
|
||||
field.node.attrs[0].span.lo
|
||||
if !field.attrs.is_empty() {
|
||||
field.attrs[0].span.lo
|
||||
} else {
|
||||
field.span.lo
|
||||
}
|
||||
},
|
||||
|field| field.node.ty.span.hi,
|
||||
|field| field.ty.span.hi,
|
||||
|field| field.rewrite(context, item_budget, item_indent),
|
||||
context.codemap.span_after(span, "("),
|
||||
span.hi);
|
||||
@ -924,12 +924,12 @@ pub fn rewrite_type_alias(context: &RewriteContext,
|
||||
ident: ast::Ident,
|
||||
ty: &ast::Ty,
|
||||
generics: &ast::Generics,
|
||||
vis: ast::Visibility,
|
||||
vis: &ast::Visibility,
|
||||
span: Span)
|
||||
-> Option<String> {
|
||||
let mut result = String::new();
|
||||
|
||||
result.push_str(&format_visibility(vis));
|
||||
result.push_str(&format_visibility(&vis));
|
||||
result.push_str("type ");
|
||||
result.push_str(&ident.to_string());
|
||||
|
||||
@ -991,21 +991,14 @@ pub fn rewrite_type_alias(context: &RewriteContext,
|
||||
|
||||
impl Rewrite for ast::StructField {
|
||||
fn rewrite(&self, context: &RewriteContext, width: usize, offset: Indent) -> Option<String> {
|
||||
if contains_skip(&self.node.attrs) {
|
||||
let span = context.snippet(mk_sp(self.node.attrs[0].span.lo, self.span.hi));
|
||||
if contains_skip(&self.attrs) {
|
||||
let span = context.snippet(mk_sp(self.attrs[0].span.lo, self.span.hi));
|
||||
return wrap_str(span, context.config.max_width, width, offset);
|
||||
}
|
||||
|
||||
let name = match self.node.kind {
|
||||
ast::StructFieldKind::NamedField(ident, _) => Some(ident.to_string()),
|
||||
ast::StructFieldKind::UnnamedField(_) => None,
|
||||
};
|
||||
let vis = match self.node.kind {
|
||||
ast::StructFieldKind::NamedField(_, vis) |
|
||||
ast::StructFieldKind::UnnamedField(vis) => format_visibility(vis),
|
||||
};
|
||||
let mut attr_str = try_opt!(self.node
|
||||
.attrs
|
||||
let name = self.ident;
|
||||
let vis = format_visibility(&self.vis);
|
||||
let mut attr_str = try_opt!(self.attrs
|
||||
.rewrite(context, context.config.max_width - offset.width(), offset));
|
||||
if !attr_str.is_empty() {
|
||||
attr_str.push('\n');
|
||||
@ -1019,13 +1012,13 @@ impl Rewrite for ast::StructField {
|
||||
|
||||
let last_line_width = last_line_width(&result);
|
||||
let budget = try_opt!(width.checked_sub(last_line_width));
|
||||
let rewrite = try_opt!(self.node.ty.rewrite(context, budget, offset + last_line_width));
|
||||
let rewrite = try_opt!(self.ty.rewrite(context, budget, offset + last_line_width));
|
||||
Some(result + &rewrite)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn rewrite_static(prefix: &str,
|
||||
vis: ast::Visibility,
|
||||
vis: &ast::Visibility,
|
||||
ident: ast::Ident,
|
||||
ty: &ast::Ty,
|
||||
mutability: ast::Mutability,
|
||||
@ -1239,7 +1232,7 @@ fn rewrite_fn_base(context: &RewriteContext,
|
||||
unsafety: ast::Unsafety,
|
||||
constness: ast::Constness,
|
||||
abi: abi::Abi,
|
||||
vis: ast::Visibility,
|
||||
vis: &ast::Visibility,
|
||||
span: Span,
|
||||
newline_brace: bool,
|
||||
has_body: bool)
|
||||
@ -1808,7 +1801,7 @@ fn rewrite_where_clause(context: &RewriteContext,
|
||||
}
|
||||
}
|
||||
|
||||
fn format_header(item_name: &str, ident: ast::Ident, vis: ast::Visibility) -> String {
|
||||
fn format_header(item_name: &str, ident: ast::Ident, vis: &ast::Visibility) -> String {
|
||||
format!("{}{}{}", format_visibility(vis), item_name, ident)
|
||||
}
|
||||
|
||||
|
@ -67,10 +67,13 @@ pub fn extra_offset(text: &str, offset: Indent) -> usize {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn format_visibility(vis: Visibility) -> &'static str {
|
||||
match vis {
|
||||
pub fn format_visibility(vis: &Visibility) -> &'static str {
|
||||
match *vis {
|
||||
Visibility::Public => "pub ",
|
||||
Visibility::Inherited => "",
|
||||
// TODO(#970): Handle new visibility types.
|
||||
Visibility::Crate => unimplemented!(),
|
||||
Visibility::Restricted { .. } => unimplemented!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ impl<'a> FmtVisitor<'a> {
|
||||
sig.unsafety,
|
||||
sig.constness,
|
||||
sig.abi,
|
||||
vis.unwrap_or(ast::Visibility::Inherited),
|
||||
vis.unwrap_or(&ast::Visibility::Inherited),
|
||||
codemap::mk_sp(s.lo, b.span.lo),
|
||||
&b)
|
||||
}
|
||||
@ -198,7 +198,7 @@ impl<'a> FmtVisitor<'a> {
|
||||
|
||||
match item.node {
|
||||
ast::ItemKind::Use(ref vp) => {
|
||||
self.format_import(item.vis, vp, item.span);
|
||||
self.format_import(&item.vis, vp, item.span);
|
||||
}
|
||||
ast::ItemKind::Impl(..) => {
|
||||
self.format_missing_with_indent(item.span.lo);
|
||||
@ -229,7 +229,7 @@ impl<'a> FmtVisitor<'a> {
|
||||
::items::format_struct(&context,
|
||||
"struct ",
|
||||
item.ident,
|
||||
item.vis,
|
||||
&item.vis,
|
||||
def,
|
||||
Some(generics),
|
||||
item.span,
|
||||
@ -245,12 +245,12 @@ impl<'a> FmtVisitor<'a> {
|
||||
}
|
||||
ast::ItemKind::Enum(ref def, ref generics) => {
|
||||
self.format_missing_with_indent(item.span.lo);
|
||||
self.visit_enum(item.ident, item.vis, def, generics, item.span);
|
||||
self.visit_enum(item.ident, &item.vis, def, generics, item.span);
|
||||
self.last_pos = item.span.hi;
|
||||
}
|
||||
ast::ItemKind::Mod(ref module) => {
|
||||
self.format_missing_with_indent(item.span.lo);
|
||||
self.format_mod(module, item.vis, item.span, item.ident);
|
||||
self.format_mod(module, &item.vis, item.span, item.ident);
|
||||
}
|
||||
ast::ItemKind::Mac(ref mac) => {
|
||||
self.format_missing_with_indent(item.span.lo);
|
||||
@ -262,7 +262,7 @@ impl<'a> FmtVisitor<'a> {
|
||||
}
|
||||
ast::ItemKind::Static(ref ty, mutability, ref expr) => {
|
||||
let rewrite = rewrite_static("static",
|
||||
item.vis,
|
||||
&item.vis,
|
||||
item.ident,
|
||||
ty,
|
||||
mutability,
|
||||
@ -272,7 +272,7 @@ impl<'a> FmtVisitor<'a> {
|
||||
}
|
||||
ast::ItemKind::Const(ref ty, ref expr) => {
|
||||
let rewrite = rewrite_static("const",
|
||||
item.vis,
|
||||
&item.vis,
|
||||
item.ident,
|
||||
ty,
|
||||
ast::Mutability::Immutable,
|
||||
@ -289,7 +289,7 @@ impl<'a> FmtVisitor<'a> {
|
||||
unsafety,
|
||||
constness,
|
||||
abi,
|
||||
item.vis),
|
||||
&item.vis),
|
||||
decl,
|
||||
body,
|
||||
item.span,
|
||||
@ -301,7 +301,7 @@ impl<'a> FmtVisitor<'a> {
|
||||
item.ident,
|
||||
ty,
|
||||
generics,
|
||||
item.vis,
|
||||
&item.vis,
|
||||
item.span);
|
||||
self.push_rewrite(item.span, rewrite);
|
||||
}
|
||||
@ -316,7 +316,7 @@ impl<'a> FmtVisitor<'a> {
|
||||
match ti.node {
|
||||
ast::TraitItemKind::Const(ref ty, ref expr_opt) => {
|
||||
let rewrite = rewrite_static("const",
|
||||
ast::Visibility::Inherited,
|
||||
&ast::Visibility::Inherited,
|
||||
ti.ident,
|
||||
ty,
|
||||
ast::Mutability::Immutable,
|
||||
@ -354,7 +354,7 @@ impl<'a> FmtVisitor<'a> {
|
||||
|
||||
match ii.node {
|
||||
ast::ImplItemKind::Method(ref sig, ref body) => {
|
||||
self.visit_fn(visit::FnKind::Method(ii.ident, sig, Some(ii.vis)),
|
||||
self.visit_fn(visit::FnKind::Method(ii.ident, sig, Some(&ii.vis)),
|
||||
&sig.decl,
|
||||
body,
|
||||
ii.span,
|
||||
@ -362,7 +362,7 @@ impl<'a> FmtVisitor<'a> {
|
||||
}
|
||||
ast::ImplItemKind::Const(ref ty, ref expr) => {
|
||||
let rewrite = rewrite_static("const",
|
||||
ii.vis,
|
||||
&ii.vis,
|
||||
ii.ident,
|
||||
ty,
|
||||
ast::Mutability::Immutable,
|
||||
@ -462,7 +462,7 @@ impl<'a> FmtVisitor<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn format_mod(&mut self, m: &ast::Mod, vis: ast::Visibility, s: Span, ident: ast::Ident) {
|
||||
fn format_mod(&mut self, m: &ast::Mod, vis: &ast::Visibility, s: Span, ident: ast::Ident) {
|
||||
// Decide whether this is an inline mod or an external mod.
|
||||
let local_file_name = self.codemap.span_to_filename(s);
|
||||
let is_internal = local_file_name == self.codemap.span_to_filename(m.inner);
|
||||
@ -501,7 +501,7 @@ impl<'a> FmtVisitor<'a> {
|
||||
self.format_missing(filemap.end_pos);
|
||||
}
|
||||
|
||||
fn format_import(&mut self, vis: ast::Visibility, vp: &ast::ViewPath, span: Span) {
|
||||
fn format_import(&mut self, vis: &ast::Visibility, vp: &ast::ViewPath, span: Span) {
|
||||
let vis = utils::format_visibility(vis);
|
||||
let mut offset = self.block_indent;
|
||||
offset.alignment += vis.len() + "use ".len();
|
||||
|
Loading…
x
Reference in New Issue
Block a user