Skip to content

Commit

Permalink
update meta item checking test
Browse files Browse the repository at this point in the history
  • Loading branch information
csmoe committed Oct 20, 2018
1 parent d3b018c commit fb7c76b
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/libsyntax/attr/builtin.rs
Expand Up @@ -390,7 +390,9 @@ fn find_stability_generic<'a, I>(sess: &ParseSess,
handle_errors(
sess,
meta.span,
AttrError::UnknownMetaItem(mi.name(), &["since", "note"]),
AttrError::UnknownMetaItem(
mi.name(), &["since", "note"],
),
false,
);
continue 'outer
Expand Down
Expand Up @@ -19,14 +19,17 @@ struct S6;
#[cfg(a())] //~ ERROR invalid predicate `a`
struct S7;

#[cfg(a = 10)] //~ ERROR literal in `cfg` predicate value must be a string
#[cfg(a = 10)] //~ ERROR unsupported literal
struct S8;

macro_rules! generate_s9 {
#[deprecated(since = b"1.30", note = "hi")] //~ ERROR E0565
struct S9;

macro_rules! generate_s10 {
($expr: expr) => {
#[cfg(feature = $expr)] //~ ERROR `cfg` is not a well-formed meta-item
struct S9;
struct S10;
}
}

generate_s9!(concat!("nonexistent"));
generate_s10!(concat!("nonexistent"));
Expand Up @@ -40,10 +40,10 @@ error[E0537]: invalid predicate `a`
LL | #[cfg(a())] //~ ERROR invalid predicate `a`
| ^^^

error: literal in `cfg` predicate value must be a string
error[E0565]: unsupported literal
--> $DIR/cfg-attr-syntax-validation.rs:22:11
|
LL | #[cfg(a = 10)] //~ ERROR literal in `cfg` predicate value must be a string
LL | #[cfg(a = 10)] //~ ERROR unsupported literal
| ^^

error: `cfg` is not a well-formed meta-item
Expand All @@ -57,4 +57,5 @@ LL | generate_s9!(concat!("nonexistent"));

error: aborting due to 9 previous errors

For more information about this error, try `rustc --explain E0537`.
Some errors occurred: E0537, E0565.
For more information about an error, try `rustc --explain E0537`.
15 changes: 15 additions & 0 deletions src/test/ui/error-codes/E0565-2.rs
@@ -0,0 +1,15 @@
// 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.

// repr currently doesn't support literals
#[deprecated(since = b"1.29", note = "hi")] //~ ERROR E0565
struct A { }

fn main() { }
9 changes: 9 additions & 0 deletions src/test/ui/error-codes/E0565-2.stderr
@@ -0,0 +1,9 @@
error[E0565]: unsupported literal
--> $DIR/E0565-2.rs:12:22
|
LL | #[deprecated(since = b"1.29", note = "hi")] //~ ERROR E0565
| ^^^^^^^ help: consider removing the prefix: `"1.29"`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0565`.

0 comments on commit fb7c76b

Please sign in to comment.