Skip to content

Commit 68a2fbd

Browse files
committed
Update rustc-ap-* crates to 581.0.0
1 parent 1ded995 commit 68a2fbd

16 files changed

+208
-132
lines changed

Cargo.lock

+86-43
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ env_logger = "0.6"
4848
getopts = "0.2"
4949
derive-new = "0.5"
5050
cargo_metadata = "0.8"
51-
rustc-ap-rustc_target = "546.0.0"
52-
rustc-ap-syntax = "546.0.0"
53-
rustc-ap-syntax_pos = "546.0.0"
51+
rustc-ap-rustc_target = "581.0.0"
52+
rustc-ap-syntax = "581.0.0"
53+
rustc-ap-syntax_pos = "581.0.0"
5454
failure = "0.1.3"
5555
bytecount = "0.5"
5656
unicode-width = "0.1.5"

src/attr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ impl Rewrite for ast::Attribute {
340340

341341
let literal_str = literal.as_str();
342342
let doc_comment_formatter =
343-
DocCommentFormatter::new(literal_str.get(), comment_style);
343+
DocCommentFormatter::new(&*literal_str, comment_style);
344344
let doc_comment = format!("{}", doc_comment_formatter);
345345
return rewrite_doc_comment(
346346
&doc_comment,

src/expr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1316,8 +1316,8 @@ pub(crate) fn can_be_overflowed_expr(
13161316
context.config.overflow_delimited_expr()
13171317
|| (context.use_block_indent() && args_len == 1)
13181318
}
1319-
ast::ExprKind::Mac(ref macro_) => {
1320-
match (macro_.node.delim, context.config.overflow_delimited_expr()) {
1319+
ast::ExprKind::Mac(ref mac) => {
1320+
match (mac.delim, context.config.overflow_delimited_expr()) {
13211321
(ast::MacDelimiter::Bracket, true) | (ast::MacDelimiter::Brace, true) => true,
13221322
_ => context.use_block_indent() && args_len == 1,
13231323
}

src/items.rs

+59-33
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,8 @@ impl<'a> FmtVisitor<'a> {
473473
let discr_ident_lens: Vec<usize> = enum_def
474474
.variants
475475
.iter()
476-
.filter(|var| var.node.disr_expr.is_some())
477-
.map(|var| rewrite_ident(&self.get_context(), var.node.ident).len())
476+
.filter(|var| var.disr_expr.is_some())
477+
.map(|var| rewrite_ident(&self.get_context(), var.ident).len())
478478
.collect();
479479
// cut the list at the point of longest discrim shorter than the threshold
480480
// All of the discrims under the threshold will get padded, and all above - left as is.
@@ -491,8 +491,8 @@ impl<'a> FmtVisitor<'a> {
491491
"}",
492492
",",
493493
|f| {
494-
if !f.node.attrs.is_empty() {
495-
f.node.attrs[0].span.lo()
494+
if !f.attrs.is_empty() {
495+
f.attrs[0].span.lo()
496496
} else {
497497
f.span.lo()
498498
}
@@ -533,34 +533,33 @@ impl<'a> FmtVisitor<'a> {
533533
one_line_width: usize,
534534
pad_discrim_ident_to: usize,
535535
) -> Option<String> {
536-
if contains_skip(&field.node.attrs) {
537-
let lo = field.node.attrs[0].span.lo();
536+
if contains_skip(&field.attrs) {
537+
let lo = field.attrs[0].span.lo();
538538
let span = mk_sp(lo, field.span.hi());
539539
return Some(self.snippet(span).to_owned());
540540
}
541541

542542
let context = self.get_context();
543543
// 1 = ','
544544
let shape = self.shape().sub_width(1)?;
545-
let attrs_str = field.node.attrs.rewrite(&context, shape)?;
545+
let attrs_str = field.attrs.rewrite(&context, shape)?;
546546
let lo = field
547-
.node
548547
.attrs
549548
.last()
550549
.map_or(field.span.lo(), |attr| attr.span.hi());
551550
let span = mk_sp(lo, field.span.lo());
552551

553-
let variant_body = match field.node.data {
552+
let variant_body = match field.data {
554553
ast::VariantData::Tuple(..) | ast::VariantData::Struct(..) => format_struct(
555554
&context,
556555
&StructParts::from_variant(field),
557556
self.block_indent,
558557
Some(one_line_width),
559558
)?,
560-
ast::VariantData::Unit(..) => rewrite_ident(&context, field.node.ident).to_owned(),
559+
ast::VariantData::Unit(..) => rewrite_ident(&context, field.ident).to_owned(),
561560
};
562561

563-
let variant_body = if let Some(ref expr) = field.node.disr_expr {
562+
let variant_body = if let Some(ref expr) = field.disr_expr {
564563
let lhs = format!("{:1$} =", variant_body, pad_discrim_ident_to);
565564
rewrite_assign_rhs_with(
566565
&context,
@@ -585,27 +584,27 @@ impl<'a> FmtVisitor<'a> {
585584
buffer.push((self.buffer.clone(), item.clone()));
586585
self.buffer.clear();
587586
}
588-
// type -> existential -> const -> macro -> method
587+
// type -> opaque -> const -> macro -> method
589588
use crate::ast::ImplItemKind::*;
590589
fn need_empty_line(a: &ast::ImplItemKind, b: &ast::ImplItemKind) -> bool {
591590
match (a, b) {
592-
(Type(..), Type(..))
591+
(TyAlias(..), TyAlias(..))
593592
| (Const(..), Const(..))
594-
| (Existential(..), Existential(..)) => false,
593+
| (OpaqueTy(..), OpaqueTy(..)) => false,
595594
_ => true,
596595
}
597596
}
598597

599598
buffer.sort_by(|(_, a), (_, b)| match (&a.node, &b.node) {
600-
(Type(..), Type(..))
599+
(TyAlias(..), TyAlias(..))
601600
| (Const(..), Const(..))
602601
| (Macro(..), Macro(..))
603-
| (Existential(..), Existential(..)) => a.ident.as_str().cmp(&b.ident.as_str()),
602+
| (OpaqueTy(..), OpaqueTy(..)) => a.ident.as_str().cmp(&b.ident.as_str()),
604603
(Method(..), Method(..)) => a.span.lo().cmp(&b.span.lo()),
605-
(Type(..), _) => Ordering::Less,
606-
(_, Type(..)) => Ordering::Greater,
607-
(Existential(..), _) => Ordering::Less,
608-
(_, Existential(..)) => Ordering::Greater,
604+
(TyAlias(..), _) => Ordering::Less,
605+
(_, TyAlias(..)) => Ordering::Greater,
606+
(OpaqueTy(..), _) => Ordering::Less,
607+
(_, OpaqueTy(..)) => Ordering::Greater,
609608
(Const(..), _) => Ordering::Less,
610609
(_, Const(..)) => Ordering::Greater,
611610
(Macro(..), _) => Ordering::Less,
@@ -920,9 +919,9 @@ impl<'a> StructParts<'a> {
920919
fn from_variant(variant: &'a ast::Variant) -> Self {
921920
StructParts {
922921
prefix: "",
923-
ident: variant.node.ident,
922+
ident: variant.ident,
924923
vis: &DEFAULT_VISIBILITY,
925-
def: &variant.node.data,
924+
def: &variant.data,
926925
generics: None,
927926
span: variant.span,
928927
}
@@ -1517,7 +1516,7 @@ pub(crate) fn rewrite_type_alias(
15171516
rewrite_type_item(context, indent, "type", " =", ident, ty, generics, vis)
15181517
}
15191518

1520-
pub(crate) fn rewrite_existential_type(
1519+
pub(crate) fn rewrite_opaque_type(
15211520
context: &RewriteContext<'_>,
15221521
indent: Indent,
15231522
ident: ast::Ident,
@@ -1528,8 +1527,8 @@ pub(crate) fn rewrite_existential_type(
15281527
rewrite_type_item(
15291528
context,
15301529
indent,
1531-
"existential type",
1532-
":",
1530+
"type",
1531+
" =",
15331532
ident,
15341533
generic_bounds,
15351534
generics,
@@ -1786,15 +1785,42 @@ pub(crate) fn rewrite_associated_type(
17861785
}
17871786
}
17881787

1789-
pub(crate) fn rewrite_existential_impl_type(
1788+
struct OpaqueType<'a> {
1789+
bounds: &'a ast::GenericBounds,
1790+
}
1791+
1792+
impl<'a> Rewrite for OpaqueType<'a> {
1793+
fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
1794+
let shape = shape.offset_left(5)?; // `impl `
1795+
self.bounds
1796+
.rewrite(context, shape)
1797+
.map(|s| format!("impl {}", s))
1798+
}
1799+
}
1800+
1801+
pub(crate) fn rewrite_opaque_impl_type(
17901802
context: &RewriteContext<'_>,
17911803
ident: ast::Ident,
17921804
generics: &ast::Generics,
17931805
generic_bounds: &ast::GenericBounds,
17941806
indent: Indent,
17951807
) -> Option<String> {
1796-
rewrite_associated_type(ident, None, generics, Some(generic_bounds), context, indent)
1797-
.map(|s| format!("existential {}", s))
1808+
let ident_str = rewrite_ident(context, ident);
1809+
// 5 = "type "
1810+
let generics_shape = Shape::indented(indent, context.config).offset_left(5)?;
1811+
let generics_str = rewrite_generics(context, ident_str, generics, generics_shape)?;
1812+
let prefix = format!("type {} =", generics_str);
1813+
let rhs = OpaqueType {
1814+
bounds: generic_bounds,
1815+
};
1816+
1817+
rewrite_assign_rhs(
1818+
context,
1819+
&prefix,
1820+
&rhs,
1821+
Shape::indented(indent, context.config).sub_width(1)?,
1822+
)
1823+
.map(|s| s + ";")
17981824
}
17991825

18001826
pub(crate) fn rewrite_associated_impl_type(
@@ -1877,7 +1903,7 @@ fn get_missing_arg_comments(
18771903
(comment_before_colon, comment_after_colon)
18781904
}
18791905

1880-
impl Rewrite for ast::Arg {
1906+
impl Rewrite for ast::Param {
18811907
fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
18821908
if let Some(ref explicit_self) = self.to_self() {
18831909
rewrite_explicit_self(context, explicit_self)
@@ -1941,23 +1967,23 @@ fn rewrite_explicit_self(
19411967
}
19421968
}
19431969

1944-
pub(crate) fn span_lo_for_arg(arg: &ast::Arg) -> BytePos {
1970+
pub(crate) fn span_lo_for_arg(arg: &ast::Param) -> BytePos {
19451971
if is_named_arg(arg) {
19461972
arg.pat.span.lo()
19471973
} else {
19481974
arg.ty.span.lo()
19491975
}
19501976
}
19511977

1952-
pub(crate) fn span_hi_for_arg(context: &RewriteContext<'_>, arg: &ast::Arg) -> BytePos {
1978+
pub(crate) fn span_hi_for_arg(context: &RewriteContext<'_>, arg: &ast::Param) -> BytePos {
19531979
match arg.ty.node {
19541980
ast::TyKind::Infer if context.snippet(arg.ty.span) == "_" => arg.ty.span.hi(),
19551981
ast::TyKind::Infer if is_named_arg(arg) => arg.pat.span.hi(),
19561982
_ => arg.ty.span.hi(),
19571983
}
19581984
}
19591985

1960-
pub(crate) fn is_named_arg(arg: &ast::Arg) -> bool {
1986+
pub(crate) fn is_named_arg(arg: &ast::Param) -> bool {
19611987
if let ast::PatKind::Ident(_, ident, _) = arg.pat.node {
19621988
ident.name != symbol::kw::Invalid
19631989
} else {
@@ -2349,7 +2375,7 @@ impl WhereClauseOption {
23492375

23502376
fn rewrite_args(
23512377
context: &RewriteContext<'_>,
2352-
args: &[ast::Arg],
2378+
args: &[ast::Param],
23532379
one_line_budget: usize,
23542380
multi_line_budget: usize,
23552381
indent: Indent,

src/macros.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ pub(crate) fn rewrite_macro(
199199
) -> Option<String> {
200200
let should_skip = context
201201
.skip_context
202-
.skip_macro(&context.snippet(mac.node.path.span).to_owned());
202+
.skip_macro(&context.snippet(mac.path.span).to_owned());
203203
if should_skip {
204204
None
205205
} else {
@@ -235,7 +235,7 @@ fn check_keyword<'a, 'b: 'a>(parser: &'a mut Parser<'b>) -> Option<MacroArg> {
235235
{
236236
parser.bump();
237237
let macro_arg =
238-
MacroArg::Keyword(ast::Ident::with_empty_ctxt(keyword), parser.prev_span);
238+
MacroArg::Keyword(ast::Ident::with_dummy_span(keyword), parser.prev_span);
239239
return Some(macro_arg);
240240
}
241241
}
@@ -259,15 +259,15 @@ fn rewrite_macro_inner(
259259

260260
let original_style = macro_style(mac, context);
261261

262-
let macro_name = rewrite_macro_name(context, &mac.node.path, extra_ident);
262+
let macro_name = rewrite_macro_name(context, &mac.path, extra_ident);
263263

264264
let style = if FORCED_BRACKET_MACROS.contains(&&macro_name[..]) && !is_nested_macro {
265265
DelimToken::Bracket
266266
} else {
267267
original_style
268268
};
269269

270-
let ts: TokenStream = mac.node.stream();
270+
let ts: TokenStream = mac.stream();
271271
let has_comment = contains_comment(context.snippet(mac.span));
272272
if ts.is_empty() && !has_comment {
273273
return match style {
@@ -1190,8 +1190,8 @@ fn next_space(tok: &TokenKind) -> SpaceState {
11901190
/// when the macro is not an instance of `try!` (or parsing the inner expression
11911191
/// failed).
11921192
pub(crate) fn convert_try_mac(mac: &ast::Mac, context: &RewriteContext<'_>) -> Option<ast::Expr> {
1193-
if &mac.node.path.to_string() == "try" {
1194-
let ts: TokenStream = mac.node.tts.clone();
1193+
if &mac.path.to_string() == "try" {
1194+
let ts: TokenStream = mac.tts.clone();
11951195
let mut parser = new_parser_from_tts(context.parse_session, ts.trees().collect());
11961196

11971197
Some(ast::Expr {
@@ -1532,7 +1532,7 @@ fn rewrite_macro_with_items(
15321532
Some(result)
15331533
}
15341534

1535-
const RUST_KW: [Symbol; 60] = [
1535+
const RUST_KW: [Symbol; 59] = [
15361536
kw::PathRoot,
15371537
kw::DollarCrate,
15381538
kw::Underscore,
@@ -1591,6 +1591,5 @@ const RUST_KW: [Symbol; 60] = [
15911591
kw::Auto,
15921592
kw::Catch,
15931593
kw::Default,
1594-
kw::Existential,
15951594
kw::Union,
15961595
];

src/modules.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ fn parse_inner_attributes<'a>(parser: &mut parser::Parser<'a>) -> PResult<'a, Ve
442442
}
443443
TokenKind::DocComment(s) => {
444444
// we need to get the position of this token before we bump.
445-
let attr = attr::mk_sugared_doc_attr(attr::mk_attr_id(), s, parser.token.span);
445+
let attr = attr::mk_sugared_doc_attr(s, parser.token.span);
446446
if attr.style == ast::AttrStyle::Inner {
447447
attrs.push(attr);
448448
parser.bump();
@@ -478,7 +478,7 @@ fn parse_mod_items<'a>(parser: &mut parser::Parser<'a>, inner_lo: Span) -> PResu
478478
fn is_cfg_if(item: &ast::Item) -> bool {
479479
match item.node {
480480
ast::ItemKind::Mac(ref mac) => {
481-
if let Some(first_segment) = mac.node.path.segments.first() {
481+
if let Some(first_segment) = mac.path.segments.first() {
482482
if first_segment.ident.name == Symbol::intern("cfg_if") {
483483
return true;
484484
}

src/modules/visitor.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl<'a, 'ast: 'a> CfgIfVisitor<'a> {
5454
// extern crate cfg_if;
5555
// cfg_if! {..}
5656
// ```
57-
match mac.node.path.segments.first() {
57+
match mac.path.segments.first() {
5858
Some(first_segment) => {
5959
if first_segment.ident.name != Symbol::intern("cfg_if") {
6060
return Err("Expected cfg_if");
@@ -65,11 +65,8 @@ impl<'a, 'ast: 'a> CfgIfVisitor<'a> {
6565
}
6666
};
6767

68-
let mut parser = stream_to_parser_with_base_dir(
69-
self.parse_sess,
70-
mac.node.tts.clone(),
71-
self.base_dir.clone(),
72-
);
68+
let mut parser =
69+
stream_to_parser_with_base_dir(self.parse_sess, mac.tts.clone(), self.base_dir.clone());
7370
parser.cfg_mods = false;
7471
let mut process_if_cfg = true;
7572

0 commit comments

Comments
 (0)