Remove the MacroVisitor pass.
This pass was supposed to check use of gated features before `#[cfg]`-stripping but this was not the case since it in fact happens after. Checks that are actually important and must be done before macro expansion are now made where the features are actually used. Close #32648. Also ensure that attributes on macro-generated macro invocations are checked as well. Close #32782 and #32655.
This commit is contained in:
parent
11f1eb0c4e
commit
03ab057f97
11 changed files with 208 additions and 200 deletions
|
|
@ -11,8 +11,8 @@
|
|||
macro_rules! bar {
|
||||
() => {
|
||||
// more layers don't help:
|
||||
#[allow_internal_unstable]
|
||||
macro_rules! baz { //~ ERROR allow_internal_unstable side-steps
|
||||
#[allow_internal_unstable] //~ ERROR allow_internal_unstable side-steps
|
||||
macro_rules! baz {
|
||||
() => {}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
|
|
@ -8,13 +8,10 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// Test that the trace_macros feature gate is on.
|
||||
// checks that this attribute is caught on non-macro items.
|
||||
// this needs a different test since this is done after expansion
|
||||
|
||||
fn main() {
|
||||
// (Infrastructure does not attempt to detect uses in macro definitions.)
|
||||
macro_rules! expando {
|
||||
($x: ident) => { trace_macros!($x) }
|
||||
}
|
||||
#[allow_internal_unstable] //~ ERROR allow_internal_unstable side-steps
|
||||
struct S;
|
||||
|
||||
expando!(true); //~ ERROR `trace_macros` is not stable
|
||||
}
|
||||
fn main() {}
|
||||
33
src/test/compile-fail/issue-32655.rs
Normal file
33
src/test/compile-fail/issue-32655.rs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright 2016 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.
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
macro_rules! foo (
|
||||
() => (
|
||||
#[derive_Clone] //~ WARN attributes of the form
|
||||
struct T;
|
||||
);
|
||||
);
|
||||
|
||||
macro_rules! bar (
|
||||
($e:item) => ($e)
|
||||
);
|
||||
|
||||
foo!();
|
||||
|
||||
bar!(
|
||||
#[derive_Clone] //~ WARN attributes of the form
|
||||
struct S;
|
||||
);
|
||||
|
||||
#[rustc_error]
|
||||
fn main() {} //~ ERROR compilation successful
|
||||
23
src/test/compile-fail/issue-32782.rs
Normal file
23
src/test/compile-fail/issue-32782.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright 2016 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.
|
||||
|
||||
macro_rules! bar (
|
||||
() => ()
|
||||
);
|
||||
|
||||
macro_rules! foo (
|
||||
() => (
|
||||
#[allow_internal_unstable] //~ ERROR allow_internal_unstable side-steps
|
||||
bar!();
|
||||
);
|
||||
);
|
||||
|
||||
foo!();
|
||||
fn main() {}
|
||||
|
|
@ -26,5 +26,5 @@ fn main() {
|
|||
($x: ident) => { trace_macros!($x) }
|
||||
}
|
||||
|
||||
expando!(true);
|
||||
expando!(true); //~ ERROR `trace_macros` is not stable
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,20 +0,0 @@
|
|||
// Copyright 2015 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.
|
||||
|
||||
// Test that the trace_macros feature gate is on.
|
||||
|
||||
pub fn main() {
|
||||
println!("arg: {}", trace_macros!()); //~ ERROR `trace_macros` is not stable
|
||||
println!("arg: {}", trace_macros!(1)); //~ ERROR `trace_macros` is not stable
|
||||
println!("arg: {}", trace_macros!(ident)); //~ ERROR `trace_macros` is not stable
|
||||
println!("arg: {}", trace_macros!(for)); //~ ERROR `trace_macros` is not stable
|
||||
println!("arg: {}", trace_macros!(true,)); //~ ERROR `trace_macros` is not stable
|
||||
println!("arg: {}", trace_macros!(false 1)); //~ ERROR `trace_macros` is not stable
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue