Skip to content

Commit

Permalink
Add tests for a new feature 'tool_attributes'
Browse files Browse the repository at this point in the history
  • Loading branch information
topecongiro authored and flip1995 committed May 2, 2018
1 parent c1168be commit e27d20a
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/test/compile-fail/feature-gate-tool_attributes.rs
Original file line number Diff line number Diff line change
@@ -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.

fn main() {
#[rustfmt::skip] //~ ERROR scoped attribute `rustfmt::skip` is experimental
let x =
3;
}
16 changes: 16 additions & 0 deletions src/test/compile-fail/unknown-tool-name.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// 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.

#![feature(tool_attributes)]

#![foo::bar] //~ ERROR An unkown tool name found in scoped attributes: `foo::bar`. [E0693]

#[foo::bar] //~ ERROR An unkown tool name found in scoped attributes: `foo::bar`. [E0693]
fn main() {}
18 changes: 18 additions & 0 deletions src/test/compile-fail/unknown_tool_attributes-1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// 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.

// Make sure that 'custom_attributes' feature does not allow scoped attributes.

#![feature(custom_attributes)]

#[foo::bar]
//~^ ERROR scoped attribute `foo::bar` is experimental (see issue #44690) [E0658]
//~^^ ERROR An unkown tool name found in scoped attributes: `foo::bar`. [E0693]
fn main() {}
23 changes: 23 additions & 0 deletions src/test/run-pass/tool_attributes.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// 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.

// Scoped attributes should not trigger an unused attributes lint.

#![feature(tool_attributes)]
#![deny(unused_attributes)]

fn main() {
#[rustfmt::skip]
foo ();
}

fn foo() {
assert!(true);
}
15 changes: 15 additions & 0 deletions src/test/ui/feature-gate-tool_attributes.rs
Original file line number Diff line number Diff line change
@@ -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.

fn main() {
#[rustfmt::skip] //~ ERROR scoped attribute `rustfmt::skip` is experimental
let x = 3
;
}
10 changes: 10 additions & 0 deletions src/test/ui/feature-gate-tool_attributes.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error[E0658]: scoped attribute `rustfmt::skip` is experimental (see issue #44690)
--> $DIR/feature-gate-tool_attributes.rs:12:5
|
12 | #[rustfmt::skip] //~ ERROR scoped attribute `rustfmt::skip` is experimental
| ^^^^^^^^^^^^^^^^
|
= help: add #![feature(tool_attributes)] to the crate attributes to enable

error: aborting due to previous error

0 comments on commit e27d20a

Please sign in to comment.