forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expand attribute macros on statements and expressions.
Retains the `stmt_expr_attributes` feature requirement for attributes on expressions. closes rust-lang#41475 cc rust-lang#38356
- Loading branch information
Showing
16 changed files
with
334 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/test/compile-fail-fulldeps/proc-macro/attr-invalid-exprs.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// 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. | ||
|
||
// aux-build:attr-stmt-expr.rs | ||
// ignore-stage1 | ||
|
||
//! Attributes producing expressions in invalid locations | ||
|
||
#![feature(proc_macro, stmt_expr_attributes)] | ||
|
||
extern crate attr_stmt_expr; | ||
use attr_stmt_expr::{duplicate, no_output}; | ||
|
||
fn main() { | ||
let _ = #[no_output] "Hello, world!"; | ||
//~^ ERROR expected expression, found `<eof>` | ||
|
||
let _ = #[duplicate] "Hello, world!"; | ||
//~^ ERROR macro expansion ignores token `,` and any following | ||
|
||
let _ = { | ||
#[no_output] | ||
"Hello, world!" | ||
}; | ||
|
||
let _ = { | ||
#[duplicate] | ||
//~^ ERROR macro expansion ignores token `,` and any following | ||
"Hello, world!" | ||
}; | ||
} |
38 changes: 38 additions & 0 deletions
38
src/test/compile-fail-fulldeps/proc-macro/attr-stmt-expr.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// 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. | ||
|
||
// aux-build:attr-stmt-expr.rs | ||
// ignore-stage1 | ||
|
||
#![feature(proc_macro)] | ||
|
||
extern crate attr_stmt_expr; | ||
use attr_stmt_expr::{expect_let, expect_print_stmt, expect_expr, expect_print_expr}; | ||
|
||
fn print_str(string: &'static str) { | ||
// macros are handled a bit differently | ||
#[expect_print_expr] | ||
//~^ ERROR attributes on expressions are experimental | ||
//~| HELP add #![feature(stmt_expr_attributes)] to the crate attributes to enable | ||
println!("{}", string) | ||
} | ||
|
||
fn main() { | ||
#[expect_let] | ||
let string = "Hello, world!"; | ||
|
||
#[expect_print_stmt] | ||
println!("{}", string); | ||
|
||
#[expect_expr] | ||
//~^ ERROR attributes on expressions are experimental | ||
//~| HELP add #![feature(stmt_expr_attributes)] to the crate attributes to enable | ||
print_str("string") | ||
} |
Oops, something went wrong.