diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2018-05-22 08:01:21 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2018-05-22 11:56:41 -0700 |
| commit | a137d00ce52e9db78bb803d1384fdf3a4c4e63ea (patch) | |
| tree | f262aeefdcdae7d68afcc9eb797e579b7aed7dbd /src/test | |
| parent | ff8fa5cc69db5567b32ceca1ee4ac0dcfa3a81bc (diff) | |
| download | rust-a137d00ce52e9db78bb803d1384fdf3a4c4e63ea.tar.gz rust-a137d00ce52e9db78bb803d1384fdf3a4c4e63ea.zip | |
rustc: Correctly pretty-print macro delimiters
This commit updates the `Mac_` AST structure to keep track of the delimiters that it originally had for its invocation. This allows us to faithfully pretty-print macro invocations not using parentheses (e.g. `vec![...]`). This in turn helps procedural macros due to #43081. Closes #50840
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui-fulldeps/proc-macro/auxiliary/macro-brackets.rs | 22 | ||||
| -rw-r--r-- | src/test/ui-fulldeps/proc-macro/macro-brackets.rs | 26 | ||||
| -rw-r--r-- | src/test/ui-fulldeps/proc-macro/macro-brackets.stderr | 9 |
3 files changed, 57 insertions, 0 deletions
diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/macro-brackets.rs b/src/test/ui-fulldeps/proc-macro/auxiliary/macro-brackets.rs new file mode 100644 index 00000000000..ab1cfe1dbd6 --- /dev/null +++ b/src/test/ui-fulldeps/proc-macro/auxiliary/macro-brackets.rs @@ -0,0 +1,22 @@ +// 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. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] +#![feature(proc_macro)] + +extern crate proc_macro; +use proc_macro::*; + +#[proc_macro_attribute] +pub fn doit(_: TokenStream, input: TokenStream) -> TokenStream { + input.into_iter().collect() +} diff --git a/src/test/ui-fulldeps/proc-macro/macro-brackets.rs b/src/test/ui-fulldeps/proc-macro/macro-brackets.rs new file mode 100644 index 00000000000..cb734e2d10b --- /dev/null +++ b/src/test/ui-fulldeps/proc-macro/macro-brackets.rs @@ -0,0 +1,26 @@ +// 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:macro-brackets.rs + +#![feature(proc_macro)] + +extern crate macro_brackets as bar; +use bar::doit; + +macro_rules! id { + ($($t:tt)*) => ($($t)*) +} + +#[doit] +id![static X: u32 = 'a';]; //~ ERROR: mismatched types + + +fn main() {} diff --git a/src/test/ui-fulldeps/proc-macro/macro-brackets.stderr b/src/test/ui-fulldeps/proc-macro/macro-brackets.stderr new file mode 100644 index 00000000000..1f31a034913 --- /dev/null +++ b/src/test/ui-fulldeps/proc-macro/macro-brackets.stderr @@ -0,0 +1,9 @@ +error[E0308]: mismatched types + --> $DIR/macro-brackets.rs:23:21 + | +LL | id![static X: u32 = 'a';]; //~ ERROR: mismatched types + | ^^^ expected u32, found char + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. |
