Skip to content

Commit 1b4c921

Browse files
committedJun 7, 2018
Auto merge of #51426 - kennytm:rollup, r=kennytm
Rollup of 9 pull requests Successful merges: - #51186 (Remove two redundant .nll.stderr files) - #51283 (Deny #[cfg] and #[cfg_attr] on generic parameters.) - #51368 (Fix the use of closures within #[panic_implementation]) - #51380 (Remove dependency on fmt_macros from typeck) - #51389 (rustdoc: Fix missing stability and src links for inlined external macros) - #51399 (NLL performance boost) - #51407 (Update RLS and Rustfmt) - #51417 (Revert #49719) - #51420 (Tries to address the recent network issues) Failed merges:
2 parents c131bdc + 34cd36e commit 1b4c921

File tree

24 files changed

+533
-174
lines changed

24 files changed

+533
-174
lines changed
 

‎.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,6 @@ before_deploy:
301301
rm -rf obj/build/dist/doc &&
302302
cp -r obj/build/dist/* deploy/$TRAVIS_COMMIT;
303303
fi
304-
- travis_retry gem update --system
305304
- ls -la deploy/$TRAVIS_COMMIT
306305

307306
deploy:

‎src/Cargo.lock

+164-39
Large diffs are not rendered by default.

‎src/ci/docker/run.sh

+4
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ fi
118118
# goes ahead and sets it for all builders.
119119
args="$args --privileged"
120120

121+
if [ "$CI" != "" ]; then
122+
args="$args --dns 8.8.8.8 --dns 8.8.4.4 --dns 1.1.1.1 --dns 1.0.0.1"
123+
fi
124+
121125
exec docker \
122126
run \
123127
--volume "$root_dir:/checkout:ro" \

‎src/librustc_mir/borrow_check/nll/type_check/liveness.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,15 @@ impl<'gen, 'typeck, 'flow, 'gcx, 'tcx> TypeLivenessGenerator<'gen, 'typeck, 'flo
104104
location, live_local
105105
);
106106

107-
self.flow_inits.each_state_bit(|mpi_init| {
108-
debug!(
109-
"add_liveness_constraints: location={:?} initialized={:?}",
110-
location,
111-
&self.flow_inits.operator().move_data().move_paths[mpi_init]
112-
);
113-
});
107+
if log_enabled!(::log::Level::Debug) {
108+
self.flow_inits.each_state_bit(|mpi_init| {
109+
debug!(
110+
"add_liveness_constraints: location={:?} initialized={:?}",
111+
location,
112+
&self.flow_inits.operator().move_data().move_paths[mpi_init]
113+
);
114+
});
115+
}
114116

115117
let mpi = self.move_data.rev_lookup.find_local(live_local);
116118
if let Some(initialized_child) = self.flow_inits.has_any_child_of(mpi) {

‎src/librustc_typeck/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ test = false
1313
log = "0.4"
1414
syntax = { path = "../libsyntax" }
1515
arena = { path = "../libarena" }
16-
fmt_macros = { path = "../libfmt_macros" }
1716
rustc = { path = "../librustc" }
1817
rustc_data_structures = { path = "../librustc_data_structures" }
1918
rustc_platform_intrinsics = { path = "../librustc_platform_intrinsics" }

‎src/librustc_typeck/check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
11311131

11321132
// Check that a function marked as `#[panic_implementation]` has signature `fn(&PanicInfo) -> !`
11331133
if let Some(panic_impl_did) = fcx.tcx.lang_items().panic_impl() {
1134-
if panic_impl_did == fn_hir_id.owner_def_id() {
1134+
if panic_impl_did == fcx.tcx.hir.local_def_id(fn_id) {
11351135
if let Some(panic_info_did) = fcx.tcx.lang_items().panic_info() {
11361136
if declared_ret_ty.sty != ty::TyNever {
11371137
fcx.tcx.sess.span_err(

‎src/librustdoc/visit_ast.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,10 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
244244
def_id,
245245
attrs: def.attrs.clone().into(),
246246
name: def.ident.name,
247-
whence: def.span,
247+
whence: self.cx.tcx.def_span(def_id),
248248
matchers,
249-
stab: self.stability(def.id),
250-
depr: self.deprecation(def.id),
249+
stab: self.cx.tcx.lookup_stability(def_id).cloned(),
250+
depr: self.cx.tcx.lookup_deprecation(def_id),
251251
imported_from: Some(imported_from),
252252
})
253253
}

‎src/libsyntax/attr.rs

+18-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub use self::IntType::*;
1717
use ast;
1818
use ast::{AttrId, Attribute, Name, Ident, Path, PathSegment};
1919
use ast::{MetaItem, MetaItemKind, NestedMetaItem, NestedMetaItemKind};
20-
use ast::{Lit, LitKind, Expr, ExprKind, Item, Local, Stmt, StmtKind};
20+
use ast::{Lit, LitKind, Expr, ExprKind, Item, Local, Stmt, StmtKind, GenericParam};
2121
use codemap::{BytePos, Spanned, respan, dummy_spanned};
2222
use syntax_pos::Span;
2323
use errors::{Applicability, Handler};
@@ -1444,6 +1444,22 @@ impl HasAttrs for Stmt {
14441444
}
14451445
}
14461446

1447+
impl HasAttrs for GenericParam {
1448+
fn attrs(&self) -> &[ast::Attribute] {
1449+
match self {
1450+
GenericParam::Lifetime(lifetime) => lifetime.attrs(),
1451+
GenericParam::Type(ty) => ty.attrs(),
1452+
}
1453+
}
1454+
1455+
fn map_attrs<F: FnOnce(Vec<Attribute>) -> Vec<Attribute>>(self, f: F) -> Self {
1456+
match self {
1457+
GenericParam::Lifetime(lifetime) => GenericParam::Lifetime(lifetime.map_attrs(f)),
1458+
GenericParam::Type(ty) => GenericParam::Type(ty.map_attrs(f)),
1459+
}
1460+
}
1461+
}
1462+
14471463
macro_rules! derive_has_attrs {
14481464
($($ty:path),*) => { $(
14491465
impl HasAttrs for $ty {
@@ -1463,5 +1479,5 @@ macro_rules! derive_has_attrs {
14631479

14641480
derive_has_attrs! {
14651481
Item, Expr, Local, ast::ForeignItem, ast::StructField, ast::ImplItem, ast::TraitItem, ast::Arm,
1466-
ast::Field, ast::FieldPat, ast::Variant_
1482+
ast::Field, ast::FieldPat, ast::Variant_, ast::LifetimeDef, ast::TyParam
14671483
}

‎src/libsyntax/config.rs

+16
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,22 @@ impl<'a> StripUnconfigured<'a> {
278278
pattern
279279
})
280280
}
281+
282+
// deny #[cfg] on generic parameters until we decide what to do with it.
283+
// see issue #51279.
284+
pub fn disallow_cfg_on_generic_param(&mut self, param: &ast::GenericParam) {
285+
for attr in param.attrs() {
286+
let offending_attr = if attr.check_name("cfg") {
287+
"cfg"
288+
} else if attr.check_name("cfg_attr") {
289+
"cfg_attr"
290+
} else {
291+
continue;
292+
};
293+
let msg = format!("#[{}] cannot be applied on a generic parameter", offending_attr);
294+
self.sess.span_diagnostic.span_err(attr.span, &msg);
295+
}
296+
}
281297
}
282298

283299
impl<'a> fold::Folder for StripUnconfigured<'a> {

‎src/libsyntax/ext/expand.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1412,6 +1412,11 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> {
14121412
}
14131413
}
14141414

1415+
fn fold_generic_param(&mut self, param: ast::GenericParam) -> ast::GenericParam {
1416+
self.cfg.disallow_cfg_on_generic_param(&param);
1417+
noop_fold_generic_param(param, self)
1418+
}
1419+
14151420
fn fold_attribute(&mut self, at: ast::Attribute) -> Option<ast::Attribute> {
14161421
// turn `#[doc(include="filename")]` attributes into `#[doc(include(file="filename",
14171422
// contents="file contents")]` attributes

‎src/libsyntax/ext/tt/quoted.rs

+67-22
Original file line numberDiff line numberDiff line change
@@ -386,26 +386,72 @@ where
386386
{
387387
// We basically look at two token trees here, denoted as #1 and #2 below
388388
let span = match parse_kleene_op(input, span) {
389-
// #1 is any KleeneOp (`?`)
390-
Ok(Ok(op)) if op == KleeneOp::ZeroOrOne => {
391-
if !features.macro_at_most_once_rep
392-
&& !attr::contains_name(attrs, "allow_internal_unstable")
393-
{
394-
let explain = feature_gate::EXPLAIN_MACRO_AT_MOST_ONCE_REP;
395-
emit_feature_err(
396-
sess,
397-
"macro_at_most_once_rep",
398-
span,
399-
GateIssue::Language,
400-
explain,
401-
);
389+
// #1 is a `+` or `*` KleeneOp
390+
//
391+
// `?` is ambiguous: it could be a separator or a Kleene::ZeroOrOne, so we need to look
392+
// ahead one more token to be sure.
393+
Ok(Ok(op)) if op != KleeneOp::ZeroOrOne => return (None, op),
394+
395+
// #1 is `?` token, but it could be a Kleene::ZeroOrOne without a separator or it could
396+
// be a `?` separator followed by any Kleene operator. We need to look ahead 1 token to
397+
// find out which.
398+
Ok(Ok(op)) => {
399+
assert_eq!(op, KleeneOp::ZeroOrOne);
400+
401+
// Lookahead at #2. If it is a KleenOp, then #1 is a separator.
402+
let is_1_sep = if let Some(&tokenstream::TokenTree::Token(_, ref tok2)) = input.peek() {
403+
kleene_op(tok2).is_some()
404+
} else {
405+
false
406+
};
407+
408+
if is_1_sep {
409+
// #1 is a separator and #2 should be a KleepeOp::*
410+
// (N.B. We need to advance the input iterator.)
411+
match parse_kleene_op(input, span) {
412+
// #2 is a KleeneOp (this is the only valid option) :)
413+
Ok(Ok(op)) if op == KleeneOp::ZeroOrOne => {
414+
if !features.macro_at_most_once_rep
415+
&& !attr::contains_name(attrs, "allow_internal_unstable")
416+
{
417+
let explain = feature_gate::EXPLAIN_MACRO_AT_MOST_ONCE_REP;
418+
emit_feature_err(
419+
sess,
420+
"macro_at_most_once_rep",
421+
span,
422+
GateIssue::Language,
423+
explain,
424+
);
425+
}
426+
return (Some(token::Question), op);
427+
}
428+
Ok(Ok(op)) => return (Some(token::Question), op),
429+
430+
// #2 is a random token (this is an error) :(
431+
Ok(Err((_, span))) => span,
432+
433+
// #2 is not even a token at all :(
434+
Err(span) => span,
435+
}
436+
} else {
437+
if !features.macro_at_most_once_rep
438+
&& !attr::contains_name(attrs, "allow_internal_unstable")
439+
{
440+
let explain = feature_gate::EXPLAIN_MACRO_AT_MOST_ONCE_REP;
441+
emit_feature_err(
442+
sess,
443+
"macro_at_most_once_rep",
444+
span,
445+
GateIssue::Language,
446+
explain,
447+
);
448+
}
449+
450+
// #2 is a random tree and #1 is KleeneOp::ZeroOrOne
451+
return (None, op);
402452
}
403-
return (None, op);
404453
}
405454

406-
// #1 is any KleeneOp (`+`, `*`)
407-
Ok(Ok(op)) => return (None, op),
408-
409455
// #1 is a separator followed by #2, a KleeneOp
410456
Ok(Err((tok, span))) => match parse_kleene_op(input, span) {
411457
// #2 is a KleeneOp :D
@@ -421,11 +467,8 @@ where
421467
GateIssue::Language,
422468
explain,
423469
);
424-
} else {
425-
sess.span_diagnostic
426-
.span_err(span, "`?` macro repetition does not allow a separator");
427470
}
428-
return (None, op);
471+
return (Some(tok), op);
429472
}
430473
Ok(Ok(op)) => return (Some(tok), op),
431474

@@ -440,7 +483,9 @@ where
440483
Err(span) => span,
441484
};
442485

443-
if !features.macro_at_most_once_rep && !attr::contains_name(attrs, "allow_internal_unstable") {
486+
if !features.macro_at_most_once_rep
487+
&& !attr::contains_name(attrs, "allow_internal_unstable")
488+
{
444489
sess.span_diagnostic
445490
.span_err(span, "expected one of: `*`, `+`, or `?`");
446491
} else {

‎src/libsyntax/feature_gate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ declare_features! (
605605
// allow `'_` placeholder lifetimes
606606
(accepted, underscore_lifetimes, "1.26.0", Some(44524), None),
607607
// Allows attributes on lifetime/type formal parameters in generics (RFC 1327)
608-
(accepted, generic_param_attrs, "1.26.0", Some(48848), None),
608+
(accepted, generic_param_attrs, "1.27.0", Some(48848), None),
609609
// Allows cfg(target_feature = "...").
610610
(accepted, cfg_target_feature, "1.27.0", Some(29717), None),
611611
// Allows #[target_feature(...)]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// compile-pass
12+
13+
#![crate_type = "rlib"]
14+
#![no_std]
15+
#![feature(panic_implementation)]
16+
17+
#[panic_implementation]
18+
pub fn panic_fmt(_: &::core::panic::PanicInfo) -> ! {
19+
|x: u8| x;
20+
loop {}
21+
}

‎src/test/run-pass/macro-at-most-once-rep.rs

+23-6
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,25 @@ macro_rules! foo {
3232
} }
3333
}
3434

35+
macro_rules! baz {
36+
($($a:ident),? ; $num:expr) => { { // comma separator is meaningless for `?`
37+
let mut x = 0;
38+
39+
$(
40+
x += $a;
41+
)?
42+
43+
assert_eq!(x, $num);
44+
} }
45+
}
46+
3547
macro_rules! barplus {
3648
($($a:ident)?+ ; $num:expr) => { {
3749
let mut x = 0;
3850

3951
$(
4052
x += $a;
41-
)?
53+
)+
4254

4355
assert_eq!(x, $num);
4456
} }
@@ -50,7 +62,7 @@ macro_rules! barstar {
5062

5163
$(
5264
x += $a;
53-
)?
65+
)*
5466

5567
assert_eq!(x, $num);
5668
} }
@@ -62,10 +74,15 @@ pub fn main() {
6274
// accept 0 or 1 repetitions
6375
foo!( ; 0);
6476
foo!(a ; 1);
77+
baz!( ; 0);
78+
baz!(a ; 1);
6579

6680
// Make sure using ? as a separator works as before
67-
barplus!(+ ; 0);
68-
barplus!(a + ; 1);
69-
barstar!(* ; 0);
70-
barstar!(a * ; 1);
81+
barplus!(a ; 1);
82+
barplus!(a?a ; 2);
83+
barplus!(a?a?a ; 3);
84+
barstar!( ; 0);
85+
barstar!(a ; 1);
86+
barstar!(a?a ; 2);
87+
barstar!(a?a?a ; 3);
7188
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(staged_api)]
12+
13+
#![stable(feature = "rust1", since = "1.0.0")]
14+
15+
/// docs for my_macro
16+
#[unstable(feature = "macro_test", issue = "0")]
17+
#[rustc_deprecated(since = "1.2.3", reason = "text")]
18+
#[macro_export]
19+
macro_rules! my_macro {
20+
() => ()
21+
}
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// aux-build:macros.rs
12+
// build-aux-docs
13+
14+
#![feature(macro_test)]
15+
#![feature(use_extern_macros)]
16+
17+
#![crate_name = "foo"]
18+
19+
extern crate macros;
20+
21+
// @has foo/index.html '//*[@class="docblock-short"]' '[Deprecated] [Experimental]'
22+
23+
// @has foo/macro.my_macro.html
24+
// @has - '//*[@class="docblock"]' 'docs for my_macro'
25+
// @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.2.3: text'
26+
// @has - '//*[@class="stab unstable"]' 'macro_test'
27+
// @has - '//a/@href' '../src/macros/macros.rs.html#19-21'
28+
pub use macros::my_macro;

‎src/test/ui/generator/pattern-borrow.nll.stderr

-11
This file was deleted.

‎src/test/ui/issue-45697.nll.stderr

-34
This file was deleted.

‎src/test/ui/issue-51279.rs

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
pub struct X<#[cfg(none)] 'a, #[cfg(none)] T>(&'a T);
12+
//~^ ERROR #[cfg] cannot be applied on a generic parameter
13+
//~^^ ERROR #[cfg] cannot be applied on a generic parameter
14+
15+
impl<#[cfg(none)] 'a, #[cfg(none)] T> X<'a, T> {}
16+
//~^ ERROR #[cfg] cannot be applied on a generic parameter
17+
//~^^ ERROR #[cfg] cannot be applied on a generic parameter
18+
19+
pub fn f<#[cfg(none)] 'a, #[cfg(none)] T>(_: &'a T) {}
20+
//~^ ERROR #[cfg] cannot be applied on a generic parameter
21+
//~^^ ERROR #[cfg] cannot be applied on a generic parameter
22+
23+
#[cfg(none)]
24+
pub struct Y<#[cfg(none)] T>(T); // shouldn't care when the entire item is stripped out
25+
26+
struct M<T>(*const T);
27+
28+
unsafe impl<#[cfg_attr(none, may_dangle)] T> Drop for M<T> {
29+
//~^ ERROR #[cfg_attr] cannot be applied on a generic parameter
30+
fn drop(&mut self) {}
31+
}
32+
33+
type Z<#[ignored] 'a, #[cfg(none)] T> = X<'a, T>;
34+
//~^ ERROR #[cfg] cannot be applied on a generic parameter

‎src/test/ui/issue-51279.stderr

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
error: #[cfg] cannot be applied on a generic parameter
2+
--> $DIR/issue-51279.rs:11:14
3+
|
4+
LL | pub struct X<#[cfg(none)] 'a, #[cfg(none)] T>(&'a T);
5+
| ^^^^^^^^^^^^
6+
7+
error: #[cfg] cannot be applied on a generic parameter
8+
--> $DIR/issue-51279.rs:11:31
9+
|
10+
LL | pub struct X<#[cfg(none)] 'a, #[cfg(none)] T>(&'a T);
11+
| ^^^^^^^^^^^^
12+
13+
error: #[cfg] cannot be applied on a generic parameter
14+
--> $DIR/issue-51279.rs:15:6
15+
|
16+
LL | impl<#[cfg(none)] 'a, #[cfg(none)] T> X<'a, T> {}
17+
| ^^^^^^^^^^^^
18+
19+
error: #[cfg] cannot be applied on a generic parameter
20+
--> $DIR/issue-51279.rs:15:23
21+
|
22+
LL | impl<#[cfg(none)] 'a, #[cfg(none)] T> X<'a, T> {}
23+
| ^^^^^^^^^^^^
24+
25+
error: #[cfg] cannot be applied on a generic parameter
26+
--> $DIR/issue-51279.rs:19:10
27+
|
28+
LL | pub fn f<#[cfg(none)] 'a, #[cfg(none)] T>(_: &'a T) {}
29+
| ^^^^^^^^^^^^
30+
31+
error: #[cfg] cannot be applied on a generic parameter
32+
--> $DIR/issue-51279.rs:19:27
33+
|
34+
LL | pub fn f<#[cfg(none)] 'a, #[cfg(none)] T>(_: &'a T) {}
35+
| ^^^^^^^^^^^^
36+
37+
error: #[cfg_attr] cannot be applied on a generic parameter
38+
--> $DIR/issue-51279.rs:28:13
39+
|
40+
LL | unsafe impl<#[cfg_attr(none, may_dangle)] T> Drop for M<T> {
41+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
42+
43+
error: #[cfg] cannot be applied on a generic parameter
44+
--> $DIR/issue-51279.rs:33:23
45+
|
46+
LL | type Z<#[ignored] 'a, #[cfg(none)] T> = X<'a, T>;
47+
| ^^^^^^^^^^^^
48+
49+
error: aborting due to 8 previous errors
50+

‎src/test/ui/macros/macro-at-most-once-rep-ambig.rs

+19-15
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,30 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// Tests the behavior of various Kleene operators in macros with respect to `?` terminals. In
12-
// particular, `?` in the position of a separator and of a Kleene operator is tested.
11+
// The logic for parsing Kleene operators in macros has a special case to disambiguate `?`.
12+
// Specifically, `$(pat)?` is the ZeroOrOne operator whereas `$(pat)?+` or `$(pat)?*` are the
13+
// ZeroOrMore and OneOrMore operators using `?` as a separator. These tests are intended to
14+
// exercise that logic in the macro parser.
15+
//
16+
// Moreover, we also throw in some tests for using a separator with `?`, which is meaningless but
17+
// included for consistency with `+` and `*`.
18+
//
19+
// This test focuses on error cases.
1320

1421
#![feature(macro_at_most_once_rep)]
1522

16-
// should match `` and `a`
1723
macro_rules! foo {
1824
($(a)?) => {}
1925
}
2026

2127
macro_rules! baz {
22-
($(a),?) => {} //~ ERROR `?` macro repetition does not allow a separator
28+
($(a),?) => {} // comma separator is meaningless for `?`
2329
}
2430

25-
// should match `+` and `a+`
2631
macro_rules! barplus {
2732
($(a)?+) => {}
2833
}
2934

30-
// should match `*` and `a*`
3135
macro_rules! barstar {
3236
($(a)?*) => {}
3337
}
@@ -36,14 +40,14 @@ pub fn main() {
3640
foo!(a?a?a); //~ ERROR no rules expected the token `?`
3741
foo!(a?a); //~ ERROR no rules expected the token `?`
3842
foo!(a?); //~ ERROR no rules expected the token `?`
43+
baz!(a?a?a); //~ ERROR no rules expected the token `?`
44+
baz!(a?a); //~ ERROR no rules expected the token `?`
45+
baz!(a?); //~ ERROR no rules expected the token `?`
46+
baz!(a,); //~ ERROR unexpected end of macro invocation
47+
baz!(a?a?a,); //~ ERROR no rules expected the token `?`
48+
baz!(a?a,); //~ ERROR no rules expected the token `?`
49+
baz!(a?,); //~ ERROR no rules expected the token `?`
3950
barplus!(); //~ ERROR unexpected end of macro invocation
40-
barstar!(); //~ ERROR unexpected end of macro invocation
41-
barplus!(a?); //~ ERROR no rules expected the token `?`
42-
barplus!(a); //~ ERROR unexpected end of macro invocation
43-
barstar!(a?); //~ ERROR no rules expected the token `?`
44-
barstar!(a); //~ ERROR unexpected end of macro invocation
45-
barplus!(+); // ok
46-
barstar!(*); // ok
47-
barplus!(a+); // ok
48-
barstar!(a*); // ok
51+
barplus!(a?); //~ ERROR unexpected end of macro invocation
52+
barstar!(a?); //~ ERROR unexpected end of macro invocation
4953
}
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,80 @@
1-
error: `?` macro repetition does not allow a separator
2-
--> $DIR/macro-at-most-once-rep-ambig.rs:22:10
3-
|
4-
LL | ($(a),?) => {} //~ ERROR `?` macro repetition does not allow a separator
5-
| ^
6-
71
error: no rules expected the token `?`
8-
--> $DIR/macro-at-most-once-rep-ambig.rs:36:11
2+
--> $DIR/macro-at-most-once-rep-ambig.rs:40:11
93
|
104
LL | foo!(a?a?a); //~ ERROR no rules expected the token `?`
115
| ^
126

137
error: no rules expected the token `?`
14-
--> $DIR/macro-at-most-once-rep-ambig.rs:37:11
8+
--> $DIR/macro-at-most-once-rep-ambig.rs:41:11
159
|
1610
LL | foo!(a?a); //~ ERROR no rules expected the token `?`
1711
| ^
1812

1913
error: no rules expected the token `?`
20-
--> $DIR/macro-at-most-once-rep-ambig.rs:38:11
14+
--> $DIR/macro-at-most-once-rep-ambig.rs:42:11
2115
|
2216
LL | foo!(a?); //~ ERROR no rules expected the token `?`
2317
| ^
2418

25-
error: unexpected end of macro invocation
26-
--> $DIR/macro-at-most-once-rep-ambig.rs:39:5
19+
error: no rules expected the token `?`
20+
--> $DIR/macro-at-most-once-rep-ambig.rs:43:11
2721
|
28-
LL | barplus!(); //~ ERROR unexpected end of macro invocation
29-
| ^^^^^^^^^^^
22+
LL | baz!(a?a?a); //~ ERROR no rules expected the token `?`
23+
| ^
3024

31-
error: unexpected end of macro invocation
32-
--> $DIR/macro-at-most-once-rep-ambig.rs:40:5
25+
error: no rules expected the token `?`
26+
--> $DIR/macro-at-most-once-rep-ambig.rs:44:11
3327
|
34-
LL | barstar!(); //~ ERROR unexpected end of macro invocation
35-
| ^^^^^^^^^^^
28+
LL | baz!(a?a); //~ ERROR no rules expected the token `?`
29+
| ^
3630

3731
error: no rules expected the token `?`
38-
--> $DIR/macro-at-most-once-rep-ambig.rs:41:15
32+
--> $DIR/macro-at-most-once-rep-ambig.rs:45:11
3933
|
40-
LL | barplus!(a?); //~ ERROR no rules expected the token `?`
41-
| ^
34+
LL | baz!(a?); //~ ERROR no rules expected the token `?`
35+
| ^
4236

4337
error: unexpected end of macro invocation
44-
--> $DIR/macro-at-most-once-rep-ambig.rs:42:14
38+
--> $DIR/macro-at-most-once-rep-ambig.rs:46:11
39+
|
40+
LL | baz!(a,); //~ ERROR unexpected end of macro invocation
41+
| ^
42+
43+
error: no rules expected the token `?`
44+
--> $DIR/macro-at-most-once-rep-ambig.rs:47:11
45+
|
46+
LL | baz!(a?a?a,); //~ ERROR no rules expected the token `?`
47+
| ^
48+
49+
error: no rules expected the token `?`
50+
--> $DIR/macro-at-most-once-rep-ambig.rs:48:11
4551
|
46-
LL | barplus!(a); //~ ERROR unexpected end of macro invocation
47-
| ^
52+
LL | baz!(a?a,); //~ ERROR no rules expected the token `?`
53+
| ^
4854

4955
error: no rules expected the token `?`
50-
--> $DIR/macro-at-most-once-rep-ambig.rs:43:15
56+
--> $DIR/macro-at-most-once-rep-ambig.rs:49:11
57+
|
58+
LL | baz!(a?,); //~ ERROR no rules expected the token `?`
59+
| ^
60+
61+
error: unexpected end of macro invocation
62+
--> $DIR/macro-at-most-once-rep-ambig.rs:50:5
63+
|
64+
LL | barplus!(); //~ ERROR unexpected end of macro invocation
65+
| ^^^^^^^^^^^
66+
67+
error: unexpected end of macro invocation
68+
--> $DIR/macro-at-most-once-rep-ambig.rs:51:15
5169
|
52-
LL | barstar!(a?); //~ ERROR no rules expected the token `?`
70+
LL | barplus!(a?); //~ ERROR unexpected end of macro invocation
5371
| ^
5472

5573
error: unexpected end of macro invocation
56-
--> $DIR/macro-at-most-once-rep-ambig.rs:44:14
74+
--> $DIR/macro-at-most-once-rep-ambig.rs:52:15
5775
|
58-
LL | barstar!(a); //~ ERROR unexpected end of macro invocation
59-
| ^
76+
LL | barstar!(a?); //~ ERROR unexpected end of macro invocation
77+
| ^
6078

61-
error: aborting due to 10 previous errors
79+
error: aborting due to 13 previous errors
6280

‎src/tools/rls

Submodule rls updated from 453f5e4 to 7d0bc55

‎src/tools/rustfmt

0 commit comments

Comments
 (0)
Please sign in to comment.