2019-07-26 16:54:25 -05:00
|
|
|
// run-pass
|
2019-07-26 18:07:23 -05:00
|
|
|
// aux-build:attr-stmt-expr-rpass.rs
|
2018-03-16 01:20:56 -05:00
|
|
|
|
2018-07-05 20:09:35 -05:00
|
|
|
#![feature(stmt_expr_attributes, proc_macro_hygiene)]
|
2018-03-16 01:20:56 -05:00
|
|
|
|
2019-07-26 18:07:23 -05:00
|
|
|
extern crate attr_stmt_expr_rpass as attr_stmt_expr;
|
2018-04-02 19:21:37 -05:00
|
|
|
use attr_stmt_expr::{expect_let, expect_print_stmt, expect_expr, expect_print_expr,
|
|
|
|
no_output, noop};
|
2018-03-16 01:20:56 -05:00
|
|
|
|
|
|
|
fn print_str(string: &'static str) {
|
|
|
|
// macros are handled a bit differently
|
|
|
|
#[expect_print_expr]
|
|
|
|
println!("{}", string)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
#[expect_let]
|
|
|
|
let string = "Hello, world!";
|
|
|
|
|
|
|
|
#[expect_print_stmt]
|
|
|
|
println!("{}", string);
|
|
|
|
|
2018-04-02 19:21:37 -05:00
|
|
|
let _: () = {
|
|
|
|
#[no_output]
|
|
|
|
"Hello, world!"
|
|
|
|
};
|
|
|
|
|
|
|
|
let _: &'static str = #[noop] "Hello, world!";
|
|
|
|
|
|
|
|
let _: &'static str = {
|
|
|
|
#[noop] "Hello, world!"
|
|
|
|
};
|
|
|
|
|
2018-03-16 01:20:56 -05:00
|
|
|
#[expect_expr]
|
|
|
|
print_str("string")
|
|
|
|
}
|