Auto merge of #82654 - JohnTitor:rollup-nkcdkzp, r=JohnTitor

Rollup of 10 pull requests

Successful merges:

 - #82309 (Propagate RUSTDOCFLAGS in the environment when documenting)
 - #82403 (rustbuild: print out env vars on verbose rustc invocations)
 - #82507 (Rename the `tidy` binary to `rust-tidy`)
 - #82531 (Add GUI tests)
 - #82532 (Add `build.print_step_rusage` to config.toml)
 - #82543 (fix env var name in CI)
 - #82622 (Propagate `--test-args` for `x.py test src/tools/cargo`)
 - #82628 (Try to clarify GlobalAlloc::realloc documentation comment.)
 - #82630 (Fix a typo in the `find_anon_type` doc)
 - #82643 (Add more proc-macro attribute tests)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2021-03-01 08:22:06 +00:00
commit d2731d8e93
29 changed files with 2807 additions and 770 deletions

View File

@ -63,7 +63,7 @@ jobs:
run: "echo \"[CI_PR_NUMBER=$num]\""
env:
num: "${{ github.event.number }}"
if: "success() && !env.SKIP_JOBS && github.event_name == 'pull_request'"
if: "success() && !env.SKIP_JOB && github.event_name == 'pull_request'"
- name: add extra environment variables
run: src/ci/scripts/setup-environment.sh
env:
@ -425,7 +425,7 @@ jobs:
run: "echo \"[CI_PR_NUMBER=$num]\""
env:
num: "${{ github.event.number }}"
if: "success() && !env.SKIP_JOBS && github.event_name == 'pull_request'"
if: "success() && !env.SKIP_JOB && github.event_name == 'pull_request'"
- name: add extra environment variables
run: src/ci/scripts/setup-environment.sh
env:
@ -532,7 +532,7 @@ jobs:
run: "echo \"[CI_PR_NUMBER=$num]\""
env:
num: "${{ github.event.number }}"
if: "success() && !env.SKIP_JOBS && github.event_name == 'pull_request'"
if: "success() && !env.SKIP_JOB && github.event_name == 'pull_request'"
- name: add extra environment variables
run: src/ci/scripts/setup-environment.sh
env:

View File

@ -19,7 +19,7 @@ use rustc_middle::ty::{self, Region, TyCtxt};
/// { x.push(y); }
/// ```
/// The function returns the nested type corresponding to the anonymous region
/// for e.g., `&u8` and Vec<`&u8`.
/// for e.g., `&u8` and `Vec<&u8>`.
pub(crate) fn find_anon_type(
tcx: TyCtxt<'tcx>,
region: Region<'tcx>,

View File

@ -290,6 +290,12 @@ changelog-seen = 2
# tracking over time)
#print-step-timings = false
# Print out resource usage data for each rustbuild step, as defined by the Unix
# struct rusage. (Note that this setting is completely unstable: the data it
# captures, what platforms it supports, the format of its associated output, and
# this setting's very existence, are all subject to change.)
#print-step-rusage = false
# =============================================================================
# General install configuration options
# =============================================================================

View File

@ -122,7 +122,7 @@ pub unsafe trait GlobalAlloc {
/// this allocator,
///
/// * `layout` must be the same layout that was used
/// to allocate that block of memory,
/// to allocate that block of memory.
#[stable(feature = "global_alloc", since = "1.28.0")]
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout);
@ -167,7 +167,10 @@ pub unsafe trait GlobalAlloc {
/// and should be considered unusable (unless of course it was
/// transferred back to the caller again via the return value of
/// this method). The new memory block is allocated with `layout`, but
/// with the `size` updated to `new_size`.
/// with the `size` updated to `new_size`. This new layout should be
/// used when deallocating the new memory block with `dealloc`. The range
/// `0..min(layout.size(), new_size)` of the new memory block is
/// guaranteed to have the same values as the original block.
///
/// If this method returns null, then ownership of the memory
/// block has not been transferred to this allocator, and the

View File

@ -139,6 +139,12 @@ fn main() {
}
if verbose > 1 {
let rust_env_vars =
env::vars().filter(|(k, _)| k.starts_with("RUST") || k.starts_with("CARGO"));
for (i, (k, v)) in rust_env_vars.enumerate() {
eprintln!("rustc env[{}]: {:?}={:?}", i, k, v);
}
eprintln!("rustc working directory: {}", env::current_dir().unwrap().display());
eprintln!(
"rustc command: {:?}={:?} {:?}",
bootstrap::util::dylib_path_var(),
@ -155,16 +161,24 @@ fn main() {
cmd.status().expect(&errmsg)
};
if env::var_os("RUSTC_PRINT_STEP_TIMINGS").is_some() {
if env::var_os("RUSTC_PRINT_STEP_TIMINGS").is_some()
|| env::var_os("RUSTC_PRINT_STEP_RUSAGE").is_some()
{
if let Some(crate_name) = crate_name {
let dur = start.elapsed();
let is_test = args.iter().any(|a| a == "--test");
// If the user requested resource usage data, then
// include that in addition to the timing output.
let rusage_data =
env::var_os("RUSTC_PRINT_STEP_RUSAGE").and_then(|_| format_rusage_data());
eprintln!(
"[RUSTC-TIMING] {} test:{} {}.{:03}",
"[RUSTC-TIMING] {} test:{} {}.{:03}{}{}",
crate_name,
is_test,
dur.as_secs(),
dur.subsec_millis()
dur.subsec_millis(),
if rusage_data.is_some() { " " } else { "" },
rusage_data.unwrap_or(String::new()),
);
}
}
@ -192,3 +206,71 @@ fn main() {
}
}
}
#[cfg(not(unix))]
/// getrusage is not available on non-unix platforms. So for now, we do not
/// bother trying to make a shim for it.
fn format_rusage_data() -> Option<String> {
None
}
#[cfg(unix)]
/// Tries to build a string with human readable data for several of the rusage
/// fields. Note that we are focusing mainly on data that we believe to be
/// supplied on Linux (the `rusage` struct has other fields in it but they are
/// currently unsupported by Linux).
fn format_rusage_data() -> Option<String> {
let rusage: libc::rusage = unsafe {
let mut recv = std::mem::zeroed();
// -1 is RUSAGE_CHILDREN, which means to get the rusage for all children
// (and grandchildren, etc) processes that have respectively terminated
// and been waited for.
let retval = libc::getrusage(-1, &mut recv);
if retval != 0 {
return None;
}
recv
};
// Mac OS X reports the maxrss in bytes, not kb.
let divisor = if env::consts::OS == "macos" { 1024 } else { 1 };
let maxrss = rusage.ru_maxrss + (divisor - 1) / divisor;
let mut init_str = format!(
"user: {USER_SEC}.{USER_USEC:03} \
sys: {SYS_SEC}.{SYS_USEC:03} \
max rss (kb): {MAXRSS}",
USER_SEC = rusage.ru_utime.tv_sec,
USER_USEC = rusage.ru_utime.tv_usec,
SYS_SEC = rusage.ru_stime.tv_sec,
SYS_USEC = rusage.ru_stime.tv_usec,
MAXRSS = maxrss
);
// The remaining rusage stats vary in platform support. So we treat
// uniformly zero values in each category as "not worth printing", since it
// either means no events of that type occurred, or that the platform
// does not support it.
let minflt = rusage.ru_minflt;
let majflt = rusage.ru_majflt;
if minflt != 0 || majflt != 0 {
init_str.push_str(&format!(" page reclaims: {} page faults: {}", minflt, majflt));
}
let inblock = rusage.ru_inblock;
let oublock = rusage.ru_oublock;
if inblock != 0 || oublock != 0 {
init_str.push_str(&format!(" fs block inputs: {} fs block outputs: {}", inblock, oublock));
}
let nvcsw = rusage.ru_nvcsw;
let nivcsw = rusage.ru_nivcsw;
if nvcsw != 0 || nivcsw != 0 {
init_str.push_str(&format!(
" voluntary ctxt switches: {} involuntary ctxt switches: {}",
nvcsw, nivcsw
));
}
return Some(init_str);
}

View File

@ -939,6 +939,12 @@ impl<'a> Builder<'a> {
// but this breaks CI. At the very least, stage0 `rustdoc` needs `--cfg bootstrap`. See
// #71458.
let mut rustdocflags = rustflags.clone();
rustdocflags.propagate_cargo_env("RUSTDOCFLAGS");
if stage == 0 {
rustdocflags.env("RUSTDOCFLAGS_BOOTSTRAP");
} else {
rustdocflags.env("RUSTDOCFLAGS_NOT_BOOTSTRAP");
}
if let Ok(s) = env::var("CARGOFLAGS") {
cargo.args(s.split_whitespace());
@ -1259,6 +1265,10 @@ impl<'a> Builder<'a> {
cargo.env("RUSTC_PRINT_STEP_TIMINGS", "1");
}
if self.config.print_step_rusage {
cargo.env("RUSTC_PRINT_STEP_RUSAGE", "1");
}
if self.config.backtrace_on_ice {
cargo.env("RUSTC_BACKTRACE_ON_ICE", "1");
}
@ -1544,23 +1554,29 @@ impl<'a> Builder<'a> {
mod tests;
#[derive(Debug, Clone)]
struct Rustflags(String);
struct Rustflags(String, TargetSelection);
impl Rustflags {
fn new(target: TargetSelection) -> Rustflags {
let mut ret = Rustflags(String::new());
// Inherit `RUSTFLAGS` by default ...
ret.env("RUSTFLAGS");
// ... and also handle target-specific env RUSTFLAGS if they're
// configured.
let target_specific = format!("CARGO_TARGET_{}_RUSTFLAGS", crate::envify(&target.triple));
ret.env(&target_specific);
let mut ret = Rustflags(String::new(), target);
ret.propagate_cargo_env("RUSTFLAGS");
ret
}
/// By default, cargo will pick up on various variables in the environment. However, bootstrap
/// reuses those variables to pass additional flags to rustdoc, so by default they get overriden.
/// Explicitly add back any previous value in the environment.
///
/// `prefix` is usually `RUSTFLAGS` or `RUSTDOCFLAGS`.
fn propagate_cargo_env(&mut self, prefix: &str) {
// Inherit `RUSTFLAGS` by default ...
self.env(prefix);
// ... and also handle target-specific env RUSTFLAGS if they're configured.
let target_specific = format!("CARGO_TARGET_{}_{}", crate::envify(&self.1.triple), prefix);
self.env(&target_specific);
}
fn env(&mut self, env: &str) {
if let Ok(s) = env::var(env) {
for part in s.split(' ') {

View File

@ -161,6 +161,7 @@ pub struct Config {
pub verbose_tests: bool,
pub save_toolstates: Option<PathBuf>,
pub print_step_timings: bool,
pub print_step_rusage: bool,
pub missing_tools: bool,
// Fallback musl-root for all targets
@ -380,6 +381,7 @@ struct Build {
configure_args: Option<Vec<String>>,
local_rebuild: Option<bool>,
print_step_timings: Option<bool>,
print_step_rusage: Option<bool>,
check_stage: Option<u32>,
doc_stage: Option<u32>,
build_stage: Option<u32>,
@ -679,6 +681,7 @@ impl Config {
set(&mut config.configure_args, build.configure_args);
set(&mut config.local_rebuild, build.local_rebuild);
set(&mut config.print_step_timings, build.print_step_timings);
set(&mut config.print_step_rusage, build.print_step_rusage);
// See https://github.com/rust-lang/compiler-team/issues/326
config.stage = match config.cmd {

View File

@ -212,6 +212,7 @@ impl Step for Cargo {
if !builder.fail_fast {
cargo.arg("--no-fail-fast");
}
cargo.arg("--").args(builder.config.cmd.test_args());
// Don't run cross-compile tests, we may not have cross-compiled libstd libs
// available.

View File

@ -47,7 +47,7 @@ impl Step for ToolBuild {
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
let compiler = self.compiler;
let target = self.target;
let tool = self.tool;
let mut tool = self.tool;
let path = self.path;
let is_optional_tool = self.is_optional_tool;
@ -208,6 +208,12 @@ impl Step for ToolBuild {
None
}
} else {
// HACK(#82501): on Windows, the tools directory gets added to PATH when running tests, and
// compiletest confuses HTML tidy with the in-tree tidy. Name the in-tree tidy something
// different so the problem doesn't come up.
if tool == "tidy" {
tool = "rust-tidy";
}
let cargo_out =
builder.cargo_out(compiler, self.mode, target).join(exe(tool, compiler.host));
let bin = builder.tools_dir(compiler).join(exe(tool, compiler.host));

View File

@ -110,7 +110,7 @@ x--expand-yaml-anchors--remove:
run: echo "[CI_PR_NUMBER=$num]"
env:
num: ${{ github.event.number }}
if: success() && !env.SKIP_JOBS && github.event_name == 'pull_request'
if: success() && !env.SKIP_JOB && github.event_name == 'pull_request'
- name: add extra environment variables
run: src/ci/scripts/setup-environment.sh

View File

@ -0,0 +1,11 @@
// Test to ensure that you can click on the search input, whatever the width.
// The PR which fixed it is: https://github.com/rust-lang/rust/pull/81592
goto: file://|DOC_PATH|/index.html
size: (463, 700)
// We first check that the search input isn't already focused.
assert-false: ("input.search-input:focus")
click: "input.search-input"
reload:
size: (750, 700)
click: "input.search-input"
assert: ("input.search-input:focus")

View File

@ -0,0 +1,26 @@
// Check that the various shortcuts are working.
goto: file://|DOC_PATH|/index.html
// We first check that the search input isn't already focused.
assert-false: "input.search-input:focus"
press-key: "s"
assert: "input.search-input:focus"
press-key: "Escape"
assert-false: "input.search-input:focus"
// We now check for the help popup.
press-key: "?"
assert: ("#help", {"display": "flex"})
assert-false: "#help.hidden"
press-key: "Escape"
assert: ("#help.hidden", {"display": "none"})
// Check for the themes list.
assert: ("#theme-choices", {"display": "none"})
press-key: "t"
assert: ("#theme-choices", {"display": "block"})
press-key: "t"
// We ensure that 't' hides back the menu.
assert: ("#theme-choices", {"display": "none"})
press-key: "t"
assert: ("#theme-choices", {"display": "block"})
press-key: "Escape"
// We ensure that 'Escape' hides the menu too.
assert: ("#theme-choices", {"display": "none"})

View File

@ -0,0 +1,26 @@
// check-pass
// compile-flags: -Z span-debug --error-format human
// aux-build:test-macros.rs
#![feature(stmt_expr_attributes)]
#![feature(custom_inner_attributes)]
#![feature(rustc_attrs)]
#![no_std] // Don't load unnecessary hygiene information from std
extern crate std;
#[macro_use]
extern crate test_macros;
trait MyTrait<T> {}
struct MyStruct<const N: bool>;
#[print_attr]
fn foo<T: MyTrait<MyStruct<{ true }>>>() {}
impl<T> MyTrait<T> for MyStruct<{true}> {
#![print_attr]
#![rustc_dummy]
}
fn main() {}

View File

@ -0,0 +1,171 @@
PRINT-ATTR INPUT (DISPLAY): fn foo < T : MyTrait < MyStruct < { true } >> > () { }
PRINT-ATTR INPUT (DEBUG): TokenStream [
Ident {
ident: "fn",
span: $DIR/attr-complex-fn.rs:19:1: 19:3 (#0),
},
Ident {
ident: "foo",
span: $DIR/attr-complex-fn.rs:19:4: 19:7 (#0),
},
Punct {
ch: '<',
spacing: Alone,
span: $DIR/attr-complex-fn.rs:19:7: 19:8 (#0),
},
Ident {
ident: "T",
span: $DIR/attr-complex-fn.rs:19:8: 19:9 (#0),
},
Punct {
ch: ':',
spacing: Alone,
span: $DIR/attr-complex-fn.rs:19:9: 19:10 (#0),
},
Ident {
ident: "MyTrait",
span: $DIR/attr-complex-fn.rs:19:11: 19:18 (#0),
},
Punct {
ch: '<',
spacing: Alone,
span: $DIR/attr-complex-fn.rs:19:18: 19:19 (#0),
},
Ident {
ident: "MyStruct",
span: $DIR/attr-complex-fn.rs:19:19: 19:27 (#0),
},
Punct {
ch: '<',
spacing: Alone,
span: $DIR/attr-complex-fn.rs:19:27: 19:28 (#0),
},
Group {
delimiter: Brace,
stream: TokenStream [
Ident {
ident: "true",
span: $DIR/attr-complex-fn.rs:19:30: 19:34 (#0),
},
],
span: $DIR/attr-complex-fn.rs:19:28: 19:36 (#0),
},
Punct {
ch: '>',
spacing: Joint,
span: $DIR/attr-complex-fn.rs:19:36: 19:38 (#0),
},
Punct {
ch: '>',
spacing: Joint,
span: $DIR/attr-complex-fn.rs:19:36: 19:38 (#0),
},
Punct {
ch: '>',
spacing: Alone,
span: $DIR/attr-complex-fn.rs:19:38: 19:39 (#0),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [],
span: $DIR/attr-complex-fn.rs:19:39: 19:41 (#0),
},
Group {
delimiter: Brace,
stream: TokenStream [],
span: $DIR/attr-complex-fn.rs:19:42: 19:44 (#0),
},
]
PRINT-ATTR INPUT (DISPLAY): impl < T > MyTrait < T > for MyStruct < { true } > { # ! [rustc_dummy] }
PRINT-ATTR INPUT (DEBUG): TokenStream [
Ident {
ident: "impl",
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0),
},
Punct {
ch: '<',
spacing: Alone,
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0),
},
Ident {
ident: "T",
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0),
},
Punct {
ch: '>',
spacing: Alone,
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0),
},
Ident {
ident: "MyTrait",
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0),
},
Punct {
ch: '<',
spacing: Alone,
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0),
},
Ident {
ident: "T",
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0),
},
Punct {
ch: '>',
spacing: Alone,
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0),
},
Ident {
ident: "for",
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0),
},
Ident {
ident: "MyStruct",
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0),
},
Punct {
ch: '<',
spacing: Alone,
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0),
},
Group {
delimiter: Brace,
stream: TokenStream [
Ident {
ident: "true",
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0),
},
],
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0),
},
Punct {
ch: '>',
spacing: Alone,
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0),
},
Group {
delimiter: Brace,
stream: TokenStream [
Punct {
ch: '#',
spacing: Joint,
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0),
},
Punct {
ch: '!',
spacing: Alone,
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
ident: "rustc_dummy",
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0),
},
],
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0),
},
],
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0),
},
]

View File

@ -128,6 +128,20 @@ pub fn print_attr_args(args: TokenStream, input: TokenStream) -> TokenStream {
input
}
#[proc_macro_attribute]
pub fn print_target_and_args(args: TokenStream, input: TokenStream) -> TokenStream {
print_helper(args, "ATTR_ARGS");
print_helper(input.clone(), "ATTR");
input
}
#[proc_macro_attribute]
pub fn print_target_and_args_consume(args: TokenStream, input: TokenStream) -> TokenStream {
print_helper(args, "ATTR_ARGS");
print_helper(input.clone(), "ATTR");
TokenStream::new()
}
#[proc_macro_derive(Print, attributes(print_helper))]
pub fn print_derive(input: TokenStream) -> TokenStream {
print_helper(input, "DERIVE");

View File

@ -0,0 +1,34 @@
// check-pass
// compile-flags: -Z span-debug --error-format human
// aux-build:test-macros.rs
#![feature(rustc_attrs)]
#![no_std] // Don't load unnecessary hygiene information from std
extern crate std;
#[macro_use]
extern crate test_macros;
macro_rules! expand_to_derive {
($item:item) => {
#[derive(Print)]
struct Foo {
#[cfg(FALSE)] removed: bool,
field: [bool; {
$item
0
}]
}
};
}
expand_to_derive! {
#[cfg_attr(not(FALSE), rustc_dummy)]
struct Inner {
#[cfg(FALSE)] removed_inner_field: bool,
other_inner_field: u8,
}
}
fn main() {}

View File

@ -0,0 +1,109 @@
PRINT-DERIVE INPUT (DISPLAY): struct Foo
{
field :
[bool ; { #[rustc_dummy] struct Inner { other_inner_field : u8, } 0 }],
}
PRINT-DERIVE INPUT (DEBUG): TokenStream [
Ident {
ident: "struct",
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4),
},
Ident {
ident: "Foo",
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4),
},
Group {
delimiter: Brace,
stream: TokenStream [
Ident {
ident: "field",
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4),
},
Punct {
ch: ':',
spacing: Alone,
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
ident: "bool",
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4),
},
Punct {
ch: ';',
spacing: Alone,
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4),
},
Group {
delimiter: Brace,
stream: TokenStream [
Punct {
ch: '#',
spacing: Alone,
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
ident: "rustc_dummy",
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4),
},
],
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4),
},
Ident {
ident: "struct",
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4),
},
Ident {
ident: "Inner",
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4),
},
Group {
delimiter: Brace,
stream: TokenStream [
Ident {
ident: "other_inner_field",
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4),
},
Punct {
ch: ':',
spacing: Alone,
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4),
},
Ident {
ident: "u8",
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4),
},
Punct {
ch: ',',
spacing: Alone,
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4),
},
],
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4),
},
Literal {
kind: Integer,
symbol: "0",
suffix: None,
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4),
},
],
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4),
},
],
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4),
},
Punct {
ch: ',',
spacing: Alone,
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4),
},
],
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4),
},
]

View File

@ -0,0 +1,47 @@
// check-pass
// compile-flags: -Z span-debug --error-format human
// aux-build:test-macros.rs
#![feature(custom_inner_attributes)]
#![feature(proc_macro_hygiene)]
#![feature(stmt_expr_attributes)]
#![no_std] // Don't load unnecessary hygiene information from std
extern crate std;
#[macro_use]
extern crate test_macros;
#[print_target_and_args(first)]
#[print_target_and_args(second)]
fn foo() {
#![print_target_and_args(third)]
#![print_target_and_args(fourth)]
}
struct MyStruct {
field: bool
}
fn bar() {
(#![print_target_and_args(fifth)] 1, 2);
[#![print_target_and_args(sixth)] 1 , 2];
[#![print_target_and_args(seventh)] true ; 5];
match 0 {
#![print_target_and_args(eighth)]
_ => {}
}
MyStruct { #![print_target_and_args(ninth)] field: true };
}
extern {
fn weird_extern() {
#![print_target_and_args_consume(tenth)]
}
}
fn main() {}

View File

@ -0,0 +1,520 @@
PRINT-ATTR_ARGS INPUT (DISPLAY): first
PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [
Ident {
ident: "first",
span: $DIR/inner-attrs.rs:15:25: 15:30 (#0),
},
]
PRINT-ATTR INPUT (DISPLAY): #[print_target_and_args(second)] fn foo()
{ # ! [print_target_and_args(third)] # ! [print_target_and_args(fourth)] }
PRINT-ATTR INPUT (DEBUG): TokenStream [
Punct {
ch: '#',
spacing: Alone,
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
ident: "print_target_and_args",
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
ident: "second",
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
],
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
],
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
Ident {
ident: "fn",
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
Ident {
ident: "foo",
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [],
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
Group {
delimiter: Brace,
stream: TokenStream [
Punct {
ch: '#',
spacing: Joint,
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
Punct {
ch: '!',
spacing: Alone,
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
ident: "print_target_and_args",
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
ident: "third",
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
],
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
],
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
Punct {
ch: '#',
spacing: Joint,
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
Punct {
ch: '!',
spacing: Alone,
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
ident: "print_target_and_args",
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
ident: "fourth",
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
],
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
],
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
],
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
]
PRINT-ATTR_ARGS INPUT (DISPLAY): second
PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [
Ident {
ident: "second",
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
]
PRINT-ATTR INPUT (DISPLAY): fn foo()
{ # ! [print_target_and_args(third)] # ! [print_target_and_args(fourth)] }
PRINT-ATTR INPUT (DEBUG): TokenStream [
Ident {
ident: "fn",
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
Ident {
ident: "foo",
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [],
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
Group {
delimiter: Brace,
stream: TokenStream [
Punct {
ch: '#',
spacing: Joint,
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
Punct {
ch: '!',
spacing: Alone,
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
ident: "print_target_and_args",
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
ident: "third",
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
],
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
],
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
Punct {
ch: '#',
spacing: Joint,
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
Punct {
ch: '!',
spacing: Alone,
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
ident: "print_target_and_args",
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
ident: "fourth",
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
],
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
],
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
],
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
]
PRINT-ATTR_ARGS INPUT (DISPLAY): third
PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [
Ident {
ident: "third",
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
]
PRINT-ATTR INPUT (DISPLAY): fn foo() { # ! [print_target_and_args(fourth)] }
PRINT-ATTR INPUT (DEBUG): TokenStream [
Ident {
ident: "fn",
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
Ident {
ident: "foo",
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [],
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
Group {
delimiter: Brace,
stream: TokenStream [
Punct {
ch: '#',
spacing: Joint,
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
Punct {
ch: '!',
spacing: Alone,
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
ident: "print_target_and_args",
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
ident: "fourth",
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
],
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
],
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
],
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
]
PRINT-ATTR_ARGS INPUT (DISPLAY): fourth
PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [
Ident {
ident: "fourth",
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
]
PRINT-ATTR INPUT (DISPLAY): fn foo() { }
PRINT-ATTR INPUT (DEBUG): TokenStream [
Ident {
ident: "fn",
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
Ident {
ident: "foo",
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [],
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
Group {
delimiter: Brace,
stream: TokenStream [],
span: $DIR/inner-attrs.rs:17:1: 20:2 (#0),
},
]
PRINT-ATTR_ARGS INPUT (DISPLAY): fifth
PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [
Ident {
ident: "fifth",
span: $DIR/inner-attrs.rs:27:31: 27:36 (#0),
},
]
PRINT-ATTR INPUT (DISPLAY): (1, 2) ;
PRINT-ATTR INPUT (DEBUG): TokenStream [
Group {
delimiter: Parenthesis,
stream: TokenStream [
Literal {
kind: Integer,
symbol: "1",
suffix: None,
span: $DIR/inner-attrs.rs:27:5: 27:45 (#0),
},
Punct {
ch: ',',
spacing: Alone,
span: $DIR/inner-attrs.rs:27:5: 27:45 (#0),
},
Literal {
kind: Integer,
symbol: "2",
suffix: None,
span: $DIR/inner-attrs.rs:27:5: 27:45 (#0),
},
],
span: $DIR/inner-attrs.rs:27:5: 27:45 (#0),
},
Punct {
ch: ';',
spacing: Alone,
span: $DIR/inner-attrs.rs:27:5: 27:45 (#0),
},
]
PRINT-ATTR_ARGS INPUT (DISPLAY): sixth
PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [
Ident {
ident: "sixth",
span: $DIR/inner-attrs.rs:29:31: 29:36 (#0),
},
]
PRINT-ATTR INPUT (DISPLAY): [1, 2] ;
PRINT-ATTR INPUT (DEBUG): TokenStream [
Group {
delimiter: Bracket,
stream: TokenStream [
Literal {
kind: Integer,
symbol: "1",
suffix: None,
span: $DIR/inner-attrs.rs:29:5: 29:46 (#0),
},
Punct {
ch: ',',
spacing: Alone,
span: $DIR/inner-attrs.rs:29:5: 29:46 (#0),
},
Literal {
kind: Integer,
symbol: "2",
suffix: None,
span: $DIR/inner-attrs.rs:29:5: 29:46 (#0),
},
],
span: $DIR/inner-attrs.rs:29:5: 29:46 (#0),
},
Punct {
ch: ';',
spacing: Alone,
span: $DIR/inner-attrs.rs:29:5: 29:46 (#0),
},
]
PRINT-ATTR_ARGS INPUT (DISPLAY): seventh
PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [
Ident {
ident: "seventh",
span: $DIR/inner-attrs.rs:30:31: 30:38 (#0),
},
]
PRINT-ATTR INPUT (DISPLAY): [true ; 5] ;
PRINT-ATTR INPUT (DEBUG): TokenStream [
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
ident: "true",
span: $DIR/inner-attrs.rs:30:5: 30:51 (#0),
},
Punct {
ch: ';',
spacing: Alone,
span: $DIR/inner-attrs.rs:30:5: 30:51 (#0),
},
Literal {
kind: Integer,
symbol: "5",
suffix: None,
span: $DIR/inner-attrs.rs:30:5: 30:51 (#0),
},
],
span: $DIR/inner-attrs.rs:30:5: 30:51 (#0),
},
Punct {
ch: ';',
spacing: Alone,
span: $DIR/inner-attrs.rs:30:5: 30:51 (#0),
},
]
PRINT-ATTR_ARGS INPUT (DISPLAY): eighth
PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [
Ident {
ident: "eighth",
span: $DIR/inner-attrs.rs:34:34: 34:40 (#0),
},
]
PRINT-ATTR INPUT (DISPLAY): match 0 { _ => { } }
PRINT-ATTR INPUT (DEBUG): TokenStream [
Ident {
ident: "match",
span: $DIR/inner-attrs.rs:33:5: 36:6 (#0),
},
Literal {
kind: Integer,
symbol: "0",
suffix: None,
span: $DIR/inner-attrs.rs:33:5: 36:6 (#0),
},
Group {
delimiter: Brace,
stream: TokenStream [
Ident {
ident: "_",
span: $DIR/inner-attrs.rs:33:5: 36:6 (#0),
},
Punct {
ch: '=',
spacing: Joint,
span: $DIR/inner-attrs.rs:33:5: 36:6 (#0),
},
Punct {
ch: '>',
spacing: Alone,
span: $DIR/inner-attrs.rs:33:5: 36:6 (#0),
},
Group {
delimiter: Brace,
stream: TokenStream [],
span: $DIR/inner-attrs.rs:33:5: 36:6 (#0),
},
],
span: $DIR/inner-attrs.rs:33:5: 36:6 (#0),
},
]
PRINT-ATTR_ARGS INPUT (DISPLAY): ninth
PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [
Ident {
ident: "ninth",
span: $DIR/inner-attrs.rs:38:41: 38:46 (#0),
},
]
PRINT-ATTR INPUT (DISPLAY): MyStruct { field : true, } ;
PRINT-ATTR INPUT (DEBUG): TokenStream [
Ident {
ident: "MyStruct",
span: $DIR/inner-attrs.rs:38:5: 38:63 (#0),
},
Group {
delimiter: Brace,
stream: TokenStream [
Ident {
ident: "field",
span: $DIR/inner-attrs.rs:38:5: 38:63 (#0),
},
Punct {
ch: ':',
spacing: Alone,
span: $DIR/inner-attrs.rs:38:5: 38:63 (#0),
},
Ident {
ident: "true",
span: $DIR/inner-attrs.rs:38:5: 38:63 (#0),
},
Punct {
ch: ',',
spacing: Alone,
span: $DIR/inner-attrs.rs:38:5: 38:63 (#0),
},
],
span: $DIR/inner-attrs.rs:38:5: 38:63 (#0),
},
Punct {
ch: ';',
spacing: Alone,
span: $DIR/inner-attrs.rs:38:5: 38:63 (#0),
},
]
PRINT-ATTR_ARGS INPUT (DISPLAY): tenth
PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [
Ident {
ident: "tenth",
span: $DIR/inner-attrs.rs:43:42: 43:47 (#0),
},
]
PRINT-ATTR INPUT (DISPLAY): fn weird_extern() { }
PRINT-ATTR INPUT (DEBUG): TokenStream [
Ident {
ident: "fn",
span: $DIR/inner-attrs.rs:42:5: 44:6 (#0),
},
Ident {
ident: "weird_extern",
span: $DIR/inner-attrs.rs:42:5: 44:6 (#0),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [],
span: $DIR/inner-attrs.rs:42:5: 44:6 (#0),
},
Group {
delimiter: Brace,
stream: TokenStream [],
span: $DIR/inner-attrs.rs:42:5: 44:6 (#0),
},
]

View File

@ -10,6 +10,9 @@
// (a pretty-printed struct may cause a line to start with '{' )
// FIXME: We currently lose spans here (see issue #43081)
#![no_std] // Don't load unnecessary hygiene information from std
extern crate std;
#[macro_use]
extern crate test_macros;
@ -58,6 +61,10 @@ struct Foo<#[cfg(FALSE)] A, B> {
u8
);
fn plain_removed_fn() {
#![cfg_attr(not(FALSE), cfg(FALSE))]
}
0
}],
#[print_helper(d)]

View File

@ -1,5 +1,5 @@
warning: derive helper attribute is used before it is introduced
--> $DIR/issue-75930-derive-cfg.rs:16:3
--> $DIR/issue-75930-derive-cfg.rs:19:3
|
LL | #[print_helper(a)]
| ^^^^^^^^^^^^

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,31 @@
// check-pass
// compile-flags: -Z span-debug --error-format human
// aux-build:test-macros.rs
#![feature(rustc_attrs)]
#![feature(stmt_expr_attributes)]
#![no_std] // Don't load unnecessary hygiene information from std
extern crate std;
#[macro_use]
extern crate test_macros;
macro_rules! produce_it {
($expr:expr) => {
#[derive(Print)]
struct Foo {
val: [bool; {
let a = #[cfg_attr(not(FALSE), rustc_dummy(first))] $expr;
0
}]
}
}
}
produce_it!(#[cfg_attr(not(FALSE), rustc_dummy(second))] {
#![cfg_attr(not(FALSE), allow(unused))]
30
});
fn main() {}

View File

@ -0,0 +1,176 @@
PRINT-DERIVE INPUT (DISPLAY): struct Foo
{
val :
[bool ;
{
let a = #[rustc_dummy(first)] #[rustc_dummy(second)]
{ # ! [allow(unused)] 30 } ; 0
}],
}
PRINT-DERIVE INPUT (DEBUG): TokenStream [
Ident {
ident: "struct",
span: $DIR/macro-rules-derive-cfg.rs:17:9: 22:10 (#4),
},
Ident {
ident: "Foo",
span: $DIR/macro-rules-derive-cfg.rs:17:9: 22:10 (#4),
},
Group {
delimiter: Brace,
stream: TokenStream [
Ident {
ident: "val",
span: $DIR/macro-rules-derive-cfg.rs:17:9: 22:10 (#4),
},
Punct {
ch: ':',
spacing: Alone,
span: $DIR/macro-rules-derive-cfg.rs:17:9: 22:10 (#4),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
ident: "bool",
span: $DIR/macro-rules-derive-cfg.rs:17:9: 22:10 (#4),
},
Punct {
ch: ';',
spacing: Alone,
span: $DIR/macro-rules-derive-cfg.rs:17:9: 22:10 (#4),
},
Group {
delimiter: Brace,
stream: TokenStream [
Ident {
ident: "let",
span: $DIR/macro-rules-derive-cfg.rs:17:9: 22:10 (#4),
},
Ident {
ident: "a",
span: $DIR/macro-rules-derive-cfg.rs:17:9: 22:10 (#4),
},
Punct {
ch: '=',
spacing: Alone,
span: $DIR/macro-rules-derive-cfg.rs:17:9: 22:10 (#4),
},
Punct {
ch: '#',
spacing: Alone,
span: $DIR/macro-rules-derive-cfg.rs:17:9: 22:10 (#4),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
ident: "rustc_dummy",
span: $DIR/macro-rules-derive-cfg.rs:17:9: 22:10 (#4),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
ident: "first",
span: $DIR/macro-rules-derive-cfg.rs:17:9: 22:10 (#4),
},
],
span: $DIR/macro-rules-derive-cfg.rs:17:9: 22:10 (#4),
},
],
span: $DIR/macro-rules-derive-cfg.rs:17:9: 22:10 (#4),
},
Punct {
ch: '#',
spacing: Alone,
span: $DIR/macro-rules-derive-cfg.rs:17:9: 22:10 (#4),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
ident: "rustc_dummy",
span: $DIR/macro-rules-derive-cfg.rs:17:9: 22:10 (#4),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
ident: "second",
span: $DIR/macro-rules-derive-cfg.rs:17:9: 22:10 (#4),
},
],
span: $DIR/macro-rules-derive-cfg.rs:17:9: 22:10 (#4),
},
],
span: $DIR/macro-rules-derive-cfg.rs:17:9: 22:10 (#4),
},
Group {
delimiter: Brace,
stream: TokenStream [
Punct {
ch: '#',
spacing: Joint,
span: $DIR/macro-rules-derive-cfg.rs:17:9: 22:10 (#4),
},
Punct {
ch: '!',
spacing: Alone,
span: $DIR/macro-rules-derive-cfg.rs:17:9: 22:10 (#4),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
ident: "allow",
span: $DIR/macro-rules-derive-cfg.rs:17:9: 22:10 (#4),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
ident: "unused",
span: $DIR/macro-rules-derive-cfg.rs:17:9: 22:10 (#4),
},
],
span: $DIR/macro-rules-derive-cfg.rs:17:9: 22:10 (#4),
},
],
span: $DIR/macro-rules-derive-cfg.rs:17:9: 22:10 (#4),
},
Literal {
kind: Integer,
symbol: "30",
suffix: None,
span: $DIR/macro-rules-derive-cfg.rs:17:9: 22:10 (#4),
},
],
span: $DIR/macro-rules-derive-cfg.rs:17:9: 22:10 (#4),
},
Punct {
ch: ';',
spacing: Alone,
span: $DIR/macro-rules-derive-cfg.rs:17:9: 22:10 (#4),
},
Literal {
kind: Integer,
symbol: "0",
suffix: None,
span: $DIR/macro-rules-derive-cfg.rs:17:9: 22:10 (#4),
},
],
span: $DIR/macro-rules-derive-cfg.rs:17:9: 22:10 (#4),
},
],
span: $DIR/macro-rules-derive-cfg.rs:17:9: 22:10 (#4),
},
Punct {
ch: ',',
spacing: Alone,
span: $DIR/macro-rules-derive-cfg.rs:17:9: 22:10 (#4),
},
],
span: $DIR/macro-rules-derive-cfg.rs:17:9: 22:10 (#4),
},
]

View File

@ -0,0 +1,23 @@
// compile-flags: -Z span-debug --error-format human
// aux-build:test-macros.rs
// check-pass
#![no_std] // Don't load unnecessary hygiene information from std
extern crate std;
#[macro_use]
extern crate test_macros;
#[derive(Print)]
struct Foo {
#[cfg(FALSE)] removed: bool,
my_array: [bool; {
struct Inner {
#[cfg(FALSE)] removed_inner_field: u8,
non_removed_inner_field: usize
}
0
}]
}
fn main() {}

View File

@ -0,0 +1,94 @@
PRINT-DERIVE INPUT (DISPLAY): struct Foo
{
my_array :
[bool ; { struct Inner { non_removed_inner_field : usize, } 0 }],
}
PRINT-DERIVE INPUT (DEBUG): TokenStream [
Ident {
ident: "struct",
span: $DIR/nested-derive-cfg.rs:12:1: 21:2 (#0),
},
Ident {
ident: "Foo",
span: $DIR/nested-derive-cfg.rs:12:1: 21:2 (#0),
},
Group {
delimiter: Brace,
stream: TokenStream [
Ident {
ident: "my_array",
span: $DIR/nested-derive-cfg.rs:12:1: 21:2 (#0),
},
Punct {
ch: ':',
spacing: Alone,
span: $DIR/nested-derive-cfg.rs:12:1: 21:2 (#0),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
ident: "bool",
span: $DIR/nested-derive-cfg.rs:12:1: 21:2 (#0),
},
Punct {
ch: ';',
spacing: Alone,
span: $DIR/nested-derive-cfg.rs:12:1: 21:2 (#0),
},
Group {
delimiter: Brace,
stream: TokenStream [
Ident {
ident: "struct",
span: $DIR/nested-derive-cfg.rs:12:1: 21:2 (#0),
},
Ident {
ident: "Inner",
span: $DIR/nested-derive-cfg.rs:12:1: 21:2 (#0),
},
Group {
delimiter: Brace,
stream: TokenStream [
Ident {
ident: "non_removed_inner_field",
span: $DIR/nested-derive-cfg.rs:12:1: 21:2 (#0),
},
Punct {
ch: ':',
spacing: Alone,
span: $DIR/nested-derive-cfg.rs:12:1: 21:2 (#0),
},
Ident {
ident: "usize",
span: $DIR/nested-derive-cfg.rs:12:1: 21:2 (#0),
},
Punct {
ch: ',',
spacing: Alone,
span: $DIR/nested-derive-cfg.rs:12:1: 21:2 (#0),
},
],
span: $DIR/nested-derive-cfg.rs:12:1: 21:2 (#0),
},
Literal {
kind: Integer,
symbol: "0",
suffix: None,
span: $DIR/nested-derive-cfg.rs:12:1: 21:2 (#0),
},
],
span: $DIR/nested-derive-cfg.rs:12:1: 21:2 (#0),
},
],
span: $DIR/nested-derive-cfg.rs:12:1: 21:2 (#0),
},
Punct {
ch: ',',
spacing: Alone,
span: $DIR/nested-derive-cfg.rs:12:1: 21:2 (#0),
},
],
span: $DIR/nested-derive-cfg.rs:12:1: 21:2 (#0),
},
]

View File

@ -0,0 +1,23 @@
// aux-build:test-macros.rs
// check-pass
// compile-flags: -Z span-debug
#![feature(custom_inner_attributes)]
#![no_std] // Don't load unnecessary hygiene information from std
extern crate std;
extern crate test_macros;
use test_macros::{print_target_and_args};
struct Foo<const V: bool>;
trait Bar<const V: bool> {}
#[print_target_and_args(first_outer)]
#[print_target_and_args(second_outer)]
impl Bar<{1 > 0}> for Foo<{true}> {
#![print_target_and_args(first_inner)]
#![print_target_and_args(second_inner)]
}
fn main() {}

View File

@ -0,0 +1,524 @@
PRINT-ATTR_ARGS INPUT (DISPLAY): first_outer
PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [
Ident {
ident: "first_outer",
span: $DIR/weird-braces.rs:16:25: 16:36 (#0),
},
]
PRINT-ATTR INPUT (DISPLAY): #[print_target_and_args(second_outer)] impl Bar < { 1 > 0 } > for Foo <
{ true } >
{
# ! [print_target_and_args(first_inner)] # !
[print_target_and_args(second_inner)]
}
PRINT-ATTR INPUT (DEBUG): TokenStream [
Punct {
ch: '#',
spacing: Alone,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
ident: "print_target_and_args",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
ident: "second_outer",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
],
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
],
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Ident {
ident: "impl",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Ident {
ident: "Bar",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Punct {
ch: '<',
spacing: Alone,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Group {
delimiter: Brace,
stream: TokenStream [
Literal {
kind: Integer,
symbol: "1",
suffix: None,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Punct {
ch: '>',
spacing: Alone,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Literal {
kind: Integer,
symbol: "0",
suffix: None,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
],
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Punct {
ch: '>',
spacing: Alone,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Ident {
ident: "for",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Ident {
ident: "Foo",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Punct {
ch: '<',
spacing: Alone,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Group {
delimiter: Brace,
stream: TokenStream [
Ident {
ident: "true",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
],
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Punct {
ch: '>',
spacing: Alone,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Group {
delimiter: Brace,
stream: TokenStream [
Punct {
ch: '#',
spacing: Joint,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Punct {
ch: '!',
spacing: Alone,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
ident: "print_target_and_args",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
ident: "first_inner",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
],
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
],
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Punct {
ch: '#',
spacing: Joint,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Punct {
ch: '!',
spacing: Alone,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
ident: "print_target_and_args",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
ident: "second_inner",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
],
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
],
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
],
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
]
PRINT-ATTR_ARGS INPUT (DISPLAY): second_outer
PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [
Ident {
ident: "second_outer",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
]
PRINT-ATTR INPUT (DISPLAY): impl Bar < { 1 > 0 } > for Foo < { true } >
{
# ! [print_target_and_args(first_inner)] # !
[print_target_and_args(second_inner)]
}
PRINT-ATTR INPUT (DEBUG): TokenStream [
Ident {
ident: "impl",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Ident {
ident: "Bar",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Punct {
ch: '<',
spacing: Alone,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Group {
delimiter: Brace,
stream: TokenStream [
Literal {
kind: Integer,
symbol: "1",
suffix: None,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Punct {
ch: '>',
spacing: Alone,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Literal {
kind: Integer,
symbol: "0",
suffix: None,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
],
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Punct {
ch: '>',
spacing: Alone,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Ident {
ident: "for",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Ident {
ident: "Foo",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Punct {
ch: '<',
spacing: Alone,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Group {
delimiter: Brace,
stream: TokenStream [
Ident {
ident: "true",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
],
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Punct {
ch: '>',
spacing: Alone,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Group {
delimiter: Brace,
stream: TokenStream [
Punct {
ch: '#',
spacing: Joint,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Punct {
ch: '!',
spacing: Alone,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
ident: "print_target_and_args",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
ident: "first_inner",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
],
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
],
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Punct {
ch: '#',
spacing: Joint,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Punct {
ch: '!',
spacing: Alone,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
ident: "print_target_and_args",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
ident: "second_inner",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
],
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
],
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
],
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
]
PRINT-ATTR_ARGS INPUT (DISPLAY): first_inner
PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [
Ident {
ident: "first_inner",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
]
PRINT-ATTR INPUT (DISPLAY): impl Bar < { 1 > 0 } > for Foo < { true } >
{ # ! [print_target_and_args(second_inner)] }
PRINT-ATTR INPUT (DEBUG): TokenStream [
Ident {
ident: "impl",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Ident {
ident: "Bar",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Punct {
ch: '<',
spacing: Alone,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Group {
delimiter: Brace,
stream: TokenStream [
Literal {
kind: Integer,
symbol: "1",
suffix: None,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Punct {
ch: '>',
spacing: Alone,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Literal {
kind: Integer,
symbol: "0",
suffix: None,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
],
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Punct {
ch: '>',
spacing: Alone,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Ident {
ident: "for",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Ident {
ident: "Foo",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Punct {
ch: '<',
spacing: Alone,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Group {
delimiter: Brace,
stream: TokenStream [
Ident {
ident: "true",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
],
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Punct {
ch: '>',
spacing: Alone,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Group {
delimiter: Brace,
stream: TokenStream [
Punct {
ch: '#',
spacing: Joint,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Punct {
ch: '!',
spacing: Alone,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
ident: "print_target_and_args",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
ident: "second_inner",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
],
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
],
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
],
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
]
PRINT-ATTR_ARGS INPUT (DISPLAY): second_inner
PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [
Ident {
ident: "second_inner",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
]
PRINT-ATTR INPUT (DISPLAY): impl Bar < { 1 > 0 } > for Foo < { true } > { }
PRINT-ATTR INPUT (DEBUG): TokenStream [
Ident {
ident: "impl",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Ident {
ident: "Bar",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Punct {
ch: '<',
spacing: Alone,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Group {
delimiter: Brace,
stream: TokenStream [
Literal {
kind: Integer,
symbol: "1",
suffix: None,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Punct {
ch: '>',
spacing: Alone,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Literal {
kind: Integer,
symbol: "0",
suffix: None,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
],
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Punct {
ch: '>',
spacing: Alone,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Ident {
ident: "for",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Ident {
ident: "Foo",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Punct {
ch: '<',
spacing: Alone,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Group {
delimiter: Brace,
stream: TokenStream [
Ident {
ident: "true",
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
],
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Punct {
ch: '>',
spacing: Alone,
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
Group {
delimiter: Brace,
stream: TokenStream [],
span: $DIR/weird-braces.rs:18:1: 21:2 (#0),
},
]

View File

@ -3,9 +3,14 @@ name = "tidy"
version = "0.1.0"
authors = ["Alex Crichton <alex@alexcrichton.com>"]
edition = "2018"
autobins = false
[dependencies]
cargo_metadata = "0.11"
regex = "1"
lazy_static = "1"
walkdir = "2"
[[bin]]
name = "rust-tidy"
path = "src/main.rs"