mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-03 12:13:43 +00:00
Merge pull request #1041 from oli-obk/procedural
don't depend on regex_macros anymore
This commit is contained in:
commit
60cc87baba
@ -26,13 +26,6 @@ script:
|
||||
- cd clippy_lints && PATH=$PATH:~/rust/cargo/bin cargo clippy -- -D clippy && cd ..
|
||||
|
||||
after_success:
|
||||
# only test regex_macros if it compiles
|
||||
- |
|
||||
#!/bin/bash
|
||||
cargo test --no-run --features 'debugging test-regex_macros'
|
||||
if [ "$?" != 101 ]; then
|
||||
cargo test --features 'debugging test-regex_macros' compile_test
|
||||
fi
|
||||
# trigger rebuild of the clippy-service, to keep it up to date with clippy itself
|
||||
- |
|
||||
#!/bin/bash
|
||||
|
@ -24,7 +24,6 @@ name = "cargo-clippy"
|
||||
test = false
|
||||
|
||||
[dependencies]
|
||||
regex_macros = { version = "0.1.33", optional = true }
|
||||
# begin automatic update
|
||||
clippy_lints = { version = "0.0.77", path = "clippy_lints" }
|
||||
# end automatic update
|
||||
@ -32,9 +31,10 @@ clippy_lints = { version = "0.0.77", path = "clippy_lints" }
|
||||
[dev-dependencies]
|
||||
compiletest_rs = "0.2.0"
|
||||
lazy_static = "0.1.15"
|
||||
regex = "0.1.56"
|
||||
regex = "0.1.71"
|
||||
rustc-serialize = "0.3"
|
||||
clippy-mini-macro-test = { version = "0.1", path = "mini-macro" }
|
||||
|
||||
|
||||
[features]
|
||||
debugging = []
|
||||
test-regex_macros = ["regex_macros"]
|
||||
|
19
mini-macro/Cargo.toml
Normal file
19
mini-macro/Cargo.toml
Normal file
@ -0,0 +1,19 @@
|
||||
[package]
|
||||
name = "clippy-mini-macro-test"
|
||||
version = "0.1.0"
|
||||
authors = [
|
||||
"Manish Goregaokar <manishsmail@gmail.com>",
|
||||
"Andre Bogus <bogusandre@gmail.com>",
|
||||
"Georg Brandl <georg@python.org>",
|
||||
"Martin Carton <cartonmartin@gmail.com>",
|
||||
"Oliver Schneider <clippy-iethah7aipeen8neex1a@oli-obk.de>"
|
||||
]
|
||||
license = "MPL-2.0"
|
||||
description = "A macro to test clippy's procedural macro checks"
|
||||
repository = "https://github.com/Manishearth/rust-clippy"
|
||||
|
||||
[lib]
|
||||
name = "clippy_mini_macro_test"
|
||||
plugin = true
|
||||
|
||||
[dependencies]
|
22
mini-macro/src/lib.rs
Normal file
22
mini-macro/src/lib.rs
Normal file
@ -0,0 +1,22 @@
|
||||
#![feature(plugin_registrar, rustc_private)]
|
||||
|
||||
extern crate syntax;
|
||||
extern crate rustc;
|
||||
extern crate rustc_plugin;
|
||||
|
||||
use syntax::codemap::Span;
|
||||
use syntax::ast::TokenTree;
|
||||
use syntax::ext::base::{ExtCtxt, MacResult, MacEager};
|
||||
use syntax::ext::build::AstBuilder; // trait for expr_usize
|
||||
use rustc_plugin::Registry;
|
||||
|
||||
fn expand_macro(cx: &mut ExtCtxt, sp: Span, _: &[TokenTree]) -> Box<MacResult + 'static> {
|
||||
let e = cx.expr_usize(sp, 42);
|
||||
let e = cx.expr_mut_addr_of(sp, e);
|
||||
MacEager::expr(cx.expr_mut_addr_of(sp, e))
|
||||
}
|
||||
|
||||
#[plugin_registrar]
|
||||
pub fn plugin_registrar(reg: &mut Registry) {
|
||||
reg.register_macro("mini_macro", expand_macro);
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
#![feature(plugin)]
|
||||
#![plugin(clippy, regex_macros)]
|
||||
|
||||
#![allow(unused)]
|
||||
#![deny(invalid_regex, trivial_regex, regex_macro)]
|
||||
|
||||
extern crate regex;
|
||||
|
||||
fn main() {
|
||||
let some_regex = regex!("for real!"); //~ERROR `regex!(_)`
|
||||
let other_regex = regex!("[a-z]_[A-Z]"); //~ERROR `regex!(_)`
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
extern crate compiletest_rs as compiletest;
|
||||
|
||||
use std::path::PathBuf;
|
||||
use std::env::{set_var, var, temp_dir};
|
||||
use std::env::{set_var, var};
|
||||
|
||||
fn run_mode(dir: &'static str, mode: &'static str) {
|
||||
let mut config = compiletest::default_config();
|
||||
@ -14,10 +14,6 @@ fn run_mode(dir: &'static str, mode: &'static str) {
|
||||
}
|
||||
|
||||
config.mode = cfg_mode;
|
||||
if cfg!(windows) {
|
||||
// work around https://github.com/laumann/compiletest-rs/issues/35 on msvc windows
|
||||
config.build_base = temp_dir();
|
||||
}
|
||||
config.src_base = PathBuf::from(format!("tests/{}", dir));
|
||||
|
||||
compiletest::run_tests(&config);
|
||||
@ -28,17 +24,8 @@ fn prepare_env() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(feature = "test-regex_macros"))]
|
||||
fn compile_test() {
|
||||
prepare_env();
|
||||
run_mode("run-pass", "run-pass");
|
||||
run_mode("compile-fail", "compile-fail");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "test-regex_macros")]
|
||||
fn compile_test() {
|
||||
prepare_env();
|
||||
run_mode("run-pass-regex_macros", "run-pass");
|
||||
run_mode("compile-fail-regex_macros", "compile-fail");
|
||||
}
|
||||
|
@ -1,12 +0,0 @@
|
||||
#![feature(plugin)]
|
||||
#![plugin(clippy, regex_macros)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate regex;
|
||||
|
||||
#[deny(mut_mut)]
|
||||
#[allow(regex_macro)]
|
||||
fn main() {
|
||||
let pattern = regex!(r"^(?P<level>[#]+)\s(?P<title>.+)$");
|
||||
assert!(pattern.is_match("# headline"));
|
||||
}
|
7
tests/run-pass/procedural_macro.rs
Normal file
7
tests/run-pass/procedural_macro.rs
Normal file
@ -0,0 +1,7 @@
|
||||
#![feature(plugin)]
|
||||
#![plugin(clippy, clippy_mini_macro_test)]
|
||||
|
||||
#[deny(warnings)]
|
||||
fn main() {
|
||||
let _ = mini_macro!();
|
||||
}
|
Loading…
Reference in New Issue
Block a user