Auto merge of #7285 - camsteffen:mini-macro-move, r=flip1995

Move mini-macro to tests/ui/auxilary

changelog: none

Merges `/mini-macro` into `/tests/ui/auxilary/proc_macro_derive.rs`.

The mini-macro crate is an artifact of the distant past. A lot has changed (#2284) and it doesn't make sense as a top-level crate anymore. Especially since we can use the auxilary folder to accompolish the same thing.
This commit is contained in:
bors 2021-05-27 17:19:39 +00:00
commit 543a8a6aac
11 changed files with 45 additions and 77 deletions

View File

@ -33,7 +33,6 @@ tempfile = { version = "3.1.0", optional = true }
cargo_metadata = "0.12"
compiletest_rs = { version = "0.6.0", features = ["tmp"] }
tester = "0.9"
clippy-mini-macro-test = { version = "0.2", path = "mini-macro" }
serde = { version = "1.0", features = ["derive"] }
derive-new = "0.5"
regex = "1.4"

View File

@ -1,14 +0,0 @@
[package]
name = "clippy-mini-macro-test"
version = "0.2.0"
authors = ["The Rust Clippy Developers"]
license = "MIT OR Apache-2.0"
description = "A macro to test clippy's procedural macro checks"
repository = "https://github.com/rust-lang/rust-clippy"
edition = "2018"
[lib]
name = "clippy_mini_macro_test"
proc-macro = true
[dependencies]

View File

@ -1,29 +0,0 @@
#![feature(proc_macro_quote)]
#![deny(rust_2018_idioms)]
// FIXME: Remove this attribute once the weird failure is gone.
#![allow(unused_extern_crates)]
extern crate proc_macro;
use proc_macro::{quote, TokenStream};
#[proc_macro_derive(ClippyMiniMacroTest)]
/// # Panics
///
/// Panics if the macro derivation fails
pub fn mini_macro(_: TokenStream) -> TokenStream {
quote!(
#[allow(unused)]
fn needless_take_by_value(s: String) {
println!("{}", s.len());
}
#[allow(unused)]
fn needless_loop(items: &[u8]) {
for i in 0..items.len() {
println!("{}", items[i]);
}
}
fn line_wrapper() {
println!("{}", line!());
}
)
}

View File

@ -53,3 +53,22 @@ fn new() -> A {
}
}
}
#[proc_macro_derive(ClippyMiniMacroTest)]
pub fn mini_macro(_: TokenStream) -> TokenStream {
quote!(
#[allow(unused)]
fn needless_take_by_value(s: String) {
println!("{}", s.len());
}
#[allow(unused)]
fn needless_loop(items: &[u8]) {
for i in 0..items.len() {
println!("{}", items[i]);
}
}
fn line_wrapper() {
println!("{}", line!());
}
)
}

View File

@ -1,11 +0,0 @@
#[macro_use]
extern crate clippy_mini_macro_test;
#[deny(warnings)]
fn main() {
let x = Foo;
println!("{:?}", x);
}
#[derive(ClippyMiniMacroTest, Debug)]
struct Foo;

View File

@ -1,6 +1,7 @@
// compile-flags: --edition 2018
// aux-build:macro_rules.rs
// aux-build:macro_use_helper.rs
// aux-build:proc_macro_derive.rs
// run-rustfix
// ignore-32bit
@ -12,7 +13,7 @@
extern crate macro_use_helper as mac;
#[macro_use]
extern crate clippy_mini_macro_test as mini_mac;
extern crate proc_macro_derive as mini_mac;
mod a {
use mac::{pub_macro, inner_mod_macro, function_macro, ty_macro, pub_in_private_macro};

View File

@ -1,6 +1,7 @@
// compile-flags: --edition 2018
// aux-build:macro_rules.rs
// aux-build:macro_use_helper.rs
// aux-build:proc_macro_derive.rs
// run-rustfix
// ignore-32bit
@ -12,7 +13,7 @@
extern crate macro_use_helper as mac;
#[macro_use]
extern crate clippy_mini_macro_test as mini_mac;
extern crate proc_macro_derive as mini_mac;
mod a {
#[macro_use]

View File

@ -1,5 +1,5 @@
error: `macro_use` attributes are no longer needed in the Rust 2018 edition
--> $DIR/macro_use_imports.rs:18:5
--> $DIR/macro_use_imports.rs:19:5
|
LL | #[macro_use]
| ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::{pub_macro, inner_mod_macro, function_macro, ty_macro, pub_in_private_macro};`
@ -7,22 +7,22 @@ LL | #[macro_use]
= note: `-D clippy::macro-use-imports` implied by `-D warnings`
error: `macro_use` attributes are no longer needed in the Rust 2018 edition
--> $DIR/macro_use_imports.rs:20:5
--> $DIR/macro_use_imports.rs:25:5
|
LL | #[macro_use]
| ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::inner::nested::string_add;`
error: `macro_use` attributes are no longer needed in the Rust 2018 edition
--> $DIR/macro_use_imports.rs:21:5
|
LL | #[macro_use]
| ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mini_mac::ClippyMiniMacroTest;`
error: `macro_use` attributes are no longer needed in the Rust 2018 edition
--> $DIR/macro_use_imports.rs:22:5
--> $DIR/macro_use_imports.rs:23:5
|
LL | #[macro_use]
| ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::{inner::foofoo, inner::try_err};`
error: `macro_use` attributes are no longer needed in the Rust 2018 edition
--> $DIR/macro_use_imports.rs:24:5
|
LL | #[macro_use]
| ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::inner::nested::string_add;`
error: aborting due to 4 previous errors

View File

@ -1,10 +1,11 @@
// run-rustfix
// aux-build:proc_macro_derive.rs
#![warn(clippy::unseparated_literal_suffix)]
#![allow(dead_code)]
#[macro_use]
extern crate clippy_mini_macro_test;
extern crate proc_macro_derive;
// Test for proc-macro attribute
#[derive(ClippyMiniMacroTest)]

View File

@ -1,10 +1,11 @@
// run-rustfix
// aux-build:proc_macro_derive.rs
#![warn(clippy::unseparated_literal_suffix)]
#![allow(dead_code)]
#[macro_use]
extern crate clippy_mini_macro_test;
extern crate proc_macro_derive;
// Test for proc-macro attribute
#[derive(ClippyMiniMacroTest)]

View File

@ -1,5 +1,5 @@
error: integer type suffix should be separated by an underscore
--> $DIR/unseparated_prefix_literals.rs:23:18
--> $DIR/unseparated_prefix_literals.rs:24:18
|
LL | let _fail1 = 1234i32;
| ^^^^^^^ help: add an underscore: `1234_i32`
@ -7,43 +7,43 @@ LL | let _fail1 = 1234i32;
= note: `-D clippy::unseparated-literal-suffix` implied by `-D warnings`
error: integer type suffix should be separated by an underscore
--> $DIR/unseparated_prefix_literals.rs:24:18
--> $DIR/unseparated_prefix_literals.rs:25:18
|
LL | let _fail2 = 1234u32;
| ^^^^^^^ help: add an underscore: `1234_u32`
error: integer type suffix should be separated by an underscore
--> $DIR/unseparated_prefix_literals.rs:25:18
--> $DIR/unseparated_prefix_literals.rs:26:18
|
LL | let _fail3 = 1234isize;
| ^^^^^^^^^ help: add an underscore: `1234_isize`
error: integer type suffix should be separated by an underscore
--> $DIR/unseparated_prefix_literals.rs:26:18
--> $DIR/unseparated_prefix_literals.rs:27:18
|
LL | let _fail4 = 1234usize;
| ^^^^^^^^^ help: add an underscore: `1234_usize`
error: integer type suffix should be separated by an underscore
--> $DIR/unseparated_prefix_literals.rs:27:18
--> $DIR/unseparated_prefix_literals.rs:28:18
|
LL | let _fail5 = 0x123isize;
| ^^^^^^^^^^ help: add an underscore: `0x123_isize`
error: float type suffix should be separated by an underscore
--> $DIR/unseparated_prefix_literals.rs:31:19
--> $DIR/unseparated_prefix_literals.rs:32:19
|
LL | let _failf1 = 1.5f32;
| ^^^^^^ help: add an underscore: `1.5_f32`
error: float type suffix should be separated by an underscore
--> $DIR/unseparated_prefix_literals.rs:32:19
--> $DIR/unseparated_prefix_literals.rs:33:19
|
LL | let _failf2 = 1f32;
| ^^^^ help: add an underscore: `1_f32`
error: integer type suffix should be separated by an underscore
--> $DIR/unseparated_prefix_literals.rs:15:9
--> $DIR/unseparated_prefix_literals.rs:16:9
|
LL | 42usize
| ^^^^^^^ help: add an underscore: `42_usize`
@ -54,7 +54,7 @@ LL | let _ = lit_from_macro!();
= note: this error originates in the macro `lit_from_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
error: integer type suffix should be separated by an underscore
--> $DIR/unseparated_prefix_literals.rs:40:16
--> $DIR/unseparated_prefix_literals.rs:41:16
|
LL | assert_eq!(4897u32, 32223);
| ^^^^^^^ help: add an underscore: `4897_u32`