diff options
Diffstat (limited to 'src/test/ui')
| -rw-r--r-- | src/test/ui/generator/pattern-borrow.nll.stderr | 11 | ||||
| -rw-r--r-- | src/test/ui/issue-45697.nll.stderr | 34 | ||||
| -rw-r--r-- | src/test/ui/issue-51279.rs | 34 | ||||
| -rw-r--r-- | src/test/ui/issue-51279.stderr | 50 | ||||
| -rw-r--r-- | src/test/ui/macros/macro-at-most-once-rep-ambig.rs | 34 | ||||
| -rw-r--r-- | src/test/ui/macros/macro-at-most-once-rep-ambig.stderr | 76 |
6 files changed, 150 insertions, 89 deletions
diff --git a/src/test/ui/generator/pattern-borrow.nll.stderr b/src/test/ui/generator/pattern-borrow.nll.stderr deleted file mode 100644 index 48f23486a31..00000000000 --- a/src/test/ui/generator/pattern-borrow.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0626]: borrow may still be in use when generator yields - --> $DIR/pattern-borrow.rs:19:24 - | -LL | if let Test::A(ref _a) = test { //~ ERROR borrow may still be in use when generator yields - | ^^^^^^ -LL | yield (); - | -------- possible yield occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0626`. diff --git a/src/test/ui/issue-45697.nll.stderr b/src/test/ui/issue-45697.nll.stderr deleted file mode 100644 index a85972fcd7a..00000000000 --- a/src/test/ui/issue-45697.nll.stderr +++ /dev/null @@ -1,34 +0,0 @@ -error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Ast) - --> $DIR/issue-45697.rs:30:9 - | -LL | let z = copy_borrowed_ptr(&mut y); - | - borrow of `*y.pointer` occurs here -LL | *y.pointer += 1; - | ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here - -error[E0503]: cannot use `*y.pointer` because it was mutably borrowed (Mir) - --> $DIR/issue-45697.rs:30:9 - | -LL | let z = copy_borrowed_ptr(&mut y); - | ------ borrow of `y` occurs here -LL | *y.pointer += 1; - | ^^^^^^^^^^^^^^^ use of borrowed `y` -... -LL | *z.pointer += 1; - | --------------- borrow later used here - -error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Mir) - --> $DIR/issue-45697.rs:30:9 - | -LL | let z = copy_borrowed_ptr(&mut y); - | ------ borrow of `*y.pointer` occurs here -LL | *y.pointer += 1; - | ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here -... -LL | *z.pointer += 1; - | --------------- borrow later used here - -error: aborting due to 3 previous errors - -Some errors occurred: E0503, E0506. -For more information about an error, try `rustc --explain E0503`. diff --git a/src/test/ui/issue-51279.rs b/src/test/ui/issue-51279.rs new file mode 100644 index 00000000000..4639d73e44d --- /dev/null +++ b/src/test/ui/issue-51279.rs @@ -0,0 +1,34 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct X<#[cfg(none)] 'a, #[cfg(none)] T>(&'a T); +//~^ ERROR #[cfg] cannot be applied on a generic parameter +//~^^ ERROR #[cfg] cannot be applied on a generic parameter + +impl<#[cfg(none)] 'a, #[cfg(none)] T> X<'a, T> {} +//~^ ERROR #[cfg] cannot be applied on a generic parameter +//~^^ ERROR #[cfg] cannot be applied on a generic parameter + +pub fn f<#[cfg(none)] 'a, #[cfg(none)] T>(_: &'a T) {} +//~^ ERROR #[cfg] cannot be applied on a generic parameter +//~^^ ERROR #[cfg] cannot be applied on a generic parameter + +#[cfg(none)] +pub struct Y<#[cfg(none)] T>(T); // shouldn't care when the entire item is stripped out + +struct M<T>(*const T); + +unsafe impl<#[cfg_attr(none, may_dangle)] T> Drop for M<T> { + //~^ ERROR #[cfg_attr] cannot be applied on a generic parameter + fn drop(&mut self) {} +} + +type Z<#[ignored] 'a, #[cfg(none)] T> = X<'a, T>; +//~^ ERROR #[cfg] cannot be applied on a generic parameter diff --git a/src/test/ui/issue-51279.stderr b/src/test/ui/issue-51279.stderr new file mode 100644 index 00000000000..38d5a5acc50 --- /dev/null +++ b/src/test/ui/issue-51279.stderr @@ -0,0 +1,50 @@ +error: #[cfg] cannot be applied on a generic parameter + --> $DIR/issue-51279.rs:11:14 + | +LL | pub struct X<#[cfg(none)] 'a, #[cfg(none)] T>(&'a T); + | ^^^^^^^^^^^^ + +error: #[cfg] cannot be applied on a generic parameter + --> $DIR/issue-51279.rs:11:31 + | +LL | pub struct X<#[cfg(none)] 'a, #[cfg(none)] T>(&'a T); + | ^^^^^^^^^^^^ + +error: #[cfg] cannot be applied on a generic parameter + --> $DIR/issue-51279.rs:15:6 + | +LL | impl<#[cfg(none)] 'a, #[cfg(none)] T> X<'a, T> {} + | ^^^^^^^^^^^^ + +error: #[cfg] cannot be applied on a generic parameter + --> $DIR/issue-51279.rs:15:23 + | +LL | impl<#[cfg(none)] 'a, #[cfg(none)] T> X<'a, T> {} + | ^^^^^^^^^^^^ + +error: #[cfg] cannot be applied on a generic parameter + --> $DIR/issue-51279.rs:19:10 + | +LL | pub fn f<#[cfg(none)] 'a, #[cfg(none)] T>(_: &'a T) {} + | ^^^^^^^^^^^^ + +error: #[cfg] cannot be applied on a generic parameter + --> $DIR/issue-51279.rs:19:27 + | +LL | pub fn f<#[cfg(none)] 'a, #[cfg(none)] T>(_: &'a T) {} + | ^^^^^^^^^^^^ + +error: #[cfg_attr] cannot be applied on a generic parameter + --> $DIR/issue-51279.rs:28:13 + | +LL | unsafe impl<#[cfg_attr(none, may_dangle)] T> Drop for M<T> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: #[cfg] cannot be applied on a generic parameter + --> $DIR/issue-51279.rs:33:23 + | +LL | type Z<#[ignored] 'a, #[cfg(none)] T> = X<'a, T>; + | ^^^^^^^^^^^^ + +error: aborting due to 8 previous errors + diff --git a/src/test/ui/macros/macro-at-most-once-rep-ambig.rs b/src/test/ui/macros/macro-at-most-once-rep-ambig.rs index e25c3ccfcd9..a5660f8b41f 100644 --- a/src/test/ui/macros/macro-at-most-once-rep-ambig.rs +++ b/src/test/ui/macros/macro-at-most-once-rep-ambig.rs @@ -8,26 +8,30 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Tests the behavior of various Kleene operators in macros with respect to `?` terminals. In -// particular, `?` in the position of a separator and of a Kleene operator is tested. +// The logic for parsing Kleene operators in macros has a special case to disambiguate `?`. +// Specifically, `$(pat)?` is the ZeroOrOne operator whereas `$(pat)?+` or `$(pat)?*` are the +// ZeroOrMore and OneOrMore operators using `?` as a separator. These tests are intended to +// exercise that logic in the macro parser. +// +// Moreover, we also throw in some tests for using a separator with `?`, which is meaningless but +// included for consistency with `+` and `*`. +// +// This test focuses on error cases. #![feature(macro_at_most_once_rep)] -// should match `` and `a` macro_rules! foo { ($(a)?) => {} } macro_rules! baz { - ($(a),?) => {} //~ ERROR `?` macro repetition does not allow a separator + ($(a),?) => {} // comma separator is meaningless for `?` } -// should match `+` and `a+` macro_rules! barplus { ($(a)?+) => {} } -// should match `*` and `a*` macro_rules! barstar { ($(a)?*) => {} } @@ -36,14 +40,14 @@ pub fn main() { foo!(a?a?a); //~ ERROR no rules expected the token `?` foo!(a?a); //~ ERROR no rules expected the token `?` foo!(a?); //~ ERROR no rules expected the token `?` + baz!(a?a?a); //~ ERROR no rules expected the token `?` + baz!(a?a); //~ ERROR no rules expected the token `?` + baz!(a?); //~ ERROR no rules expected the token `?` + baz!(a,); //~ ERROR unexpected end of macro invocation + baz!(a?a?a,); //~ ERROR no rules expected the token `?` + baz!(a?a,); //~ ERROR no rules expected the token `?` + baz!(a?,); //~ ERROR no rules expected the token `?` barplus!(); //~ ERROR unexpected end of macro invocation - barstar!(); //~ ERROR unexpected end of macro invocation - barplus!(a?); //~ ERROR no rules expected the token `?` - barplus!(a); //~ ERROR unexpected end of macro invocation - barstar!(a?); //~ ERROR no rules expected the token `?` - barstar!(a); //~ ERROR unexpected end of macro invocation - barplus!(+); // ok - barstar!(*); // ok - barplus!(a+); // ok - barstar!(a*); // ok + barplus!(a?); //~ ERROR unexpected end of macro invocation + barstar!(a?); //~ ERROR unexpected end of macro invocation } diff --git a/src/test/ui/macros/macro-at-most-once-rep-ambig.stderr b/src/test/ui/macros/macro-at-most-once-rep-ambig.stderr index cb1e360471c..d382082a575 100644 --- a/src/test/ui/macros/macro-at-most-once-rep-ambig.stderr +++ b/src/test/ui/macros/macro-at-most-once-rep-ambig.stderr @@ -1,62 +1,80 @@ -error: `?` macro repetition does not allow a separator - --> $DIR/macro-at-most-once-rep-ambig.rs:22:10 - | -LL | ($(a),?) => {} //~ ERROR `?` macro repetition does not allow a separator - | ^ - error: no rules expected the token `?` - --> $DIR/macro-at-most-once-rep-ambig.rs:36:11 + --> $DIR/macro-at-most-once-rep-ambig.rs:40:11 | LL | foo!(a?a?a); //~ ERROR no rules expected the token `?` | ^ error: no rules expected the token `?` - --> $DIR/macro-at-most-once-rep-ambig.rs:37:11 + --> $DIR/macro-at-most-once-rep-ambig.rs:41:11 | LL | foo!(a?a); //~ ERROR no rules expected the token `?` | ^ error: no rules expected the token `?` - --> $DIR/macro-at-most-once-rep-ambig.rs:38:11 + --> $DIR/macro-at-most-once-rep-ambig.rs:42:11 | LL | foo!(a?); //~ ERROR no rules expected the token `?` | ^ -error: unexpected end of macro invocation - --> $DIR/macro-at-most-once-rep-ambig.rs:39:5 +error: no rules expected the token `?` + --> $DIR/macro-at-most-once-rep-ambig.rs:43:11 | -LL | barplus!(); //~ ERROR unexpected end of macro invocation - | ^^^^^^^^^^^ +LL | baz!(a?a?a); //~ ERROR no rules expected the token `?` + | ^ -error: unexpected end of macro invocation - --> $DIR/macro-at-most-once-rep-ambig.rs:40:5 +error: no rules expected the token `?` + --> $DIR/macro-at-most-once-rep-ambig.rs:44:11 | -LL | barstar!(); //~ ERROR unexpected end of macro invocation - | ^^^^^^^^^^^ +LL | baz!(a?a); //~ ERROR no rules expected the token `?` + | ^ error: no rules expected the token `?` - --> $DIR/macro-at-most-once-rep-ambig.rs:41:15 + --> $DIR/macro-at-most-once-rep-ambig.rs:45:11 | -LL | barplus!(a?); //~ ERROR no rules expected the token `?` - | ^ +LL | baz!(a?); //~ ERROR no rules expected the token `?` + | ^ error: unexpected end of macro invocation - --> $DIR/macro-at-most-once-rep-ambig.rs:42:14 + --> $DIR/macro-at-most-once-rep-ambig.rs:46:11 + | +LL | baz!(a,); //~ ERROR unexpected end of macro invocation + | ^ + +error: no rules expected the token `?` + --> $DIR/macro-at-most-once-rep-ambig.rs:47:11 + | +LL | baz!(a?a?a,); //~ ERROR no rules expected the token `?` + | ^ + +error: no rules expected the token `?` + --> $DIR/macro-at-most-once-rep-ambig.rs:48:11 | -LL | barplus!(a); //~ ERROR unexpected end of macro invocation - | ^ +LL | baz!(a?a,); //~ ERROR no rules expected the token `?` + | ^ error: no rules expected the token `?` - --> $DIR/macro-at-most-once-rep-ambig.rs:43:15 + --> $DIR/macro-at-most-once-rep-ambig.rs:49:11 + | +LL | baz!(a?,); //~ ERROR no rules expected the token `?` + | ^ + +error: unexpected end of macro invocation + --> $DIR/macro-at-most-once-rep-ambig.rs:50:5 + | +LL | barplus!(); //~ ERROR unexpected end of macro invocation + | ^^^^^^^^^^^ + +error: unexpected end of macro invocation + --> $DIR/macro-at-most-once-rep-ambig.rs:51:15 | -LL | barstar!(a?); //~ ERROR no rules expected the token `?` +LL | barplus!(a?); //~ ERROR unexpected end of macro invocation | ^ error: unexpected end of macro invocation - --> $DIR/macro-at-most-once-rep-ambig.rs:44:14 + --> $DIR/macro-at-most-once-rep-ambig.rs:52:15 | -LL | barstar!(a); //~ ERROR unexpected end of macro invocation - | ^ +LL | barstar!(a?); //~ ERROR unexpected end of macro invocation + | ^ -error: aborting due to 10 previous errors +error: aborting due to 13 previous errors |
