File tree 7 files changed +67
-7
lines changed
7 files changed +67
-7
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,10 @@ script:
15
15
travis-cargo --only nightly build -- --features spin_no_std &&
16
16
travis-cargo --only nightly test -- --features spin_no_std &&
17
17
travis-cargo --only nightly bench -- --features spin_no_std &&
18
+ travis-cargo --only nightly clean &&
19
+ travis-cargo --only nightly build -- --features compiletest &&
20
+ travis-cargo --only nightly test -- --features compiletest &&
21
+ travis-cargo --only nightly clean &&
18
22
travis-cargo --only stable doc
19
23
after_success :
20
24
- travis-cargo --only stable doc-upload
Original file line number Diff line number Diff line change @@ -17,9 +17,14 @@ categories = [ "no-std", "rust-patterns" ]
17
17
version = " 0.4"
18
18
optional = true
19
19
20
+ [dependencies .compiletest_rs ]
21
+ version = " 0.3"
22
+ optional = true
23
+
20
24
[features ]
21
25
nightly = []
22
26
spin_no_std = [" nightly" , " spin" ]
27
+ compiletest = [" compiletest_rs" ]
23
28
24
29
[badges ]
25
30
appveyor = { repository = " rust-lang-nursery/lazy-static.rs" }
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ environment:
40
40
# (Based on from https://github.com/rust-lang/libc/blob/master/appveyor.yml)
41
41
install :
42
42
- appveyor-retry appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
43
- - rustup-init.exe -y --default-host %TARGET%
43
+ - rustup-init.exe -y --default-toolchain %CHANNEL% --default- host %TARGET%
44
44
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
45
45
- if "%TARGET%" == "i686-pc-windows-gnu" set PATH=%PATH%;C:\msys64\mingw32\bin
46
46
- if "%TARGET%" == "x86_64-pc-windows-gnu" set PATH=%PATH%;C:\msys64\mingw64\bin
@@ -50,5 +50,10 @@ install:
50
50
build : false
51
51
52
52
test_script :
53
- - cargo build --verbose --target %TARGET%
54
- - cargo test --target %TARGET%
53
+ - cargo build --verbose
54
+ - cargo test
55
+ - if [%CHANNEL%]==[nightly] (
56
+ cargo clean &&
57
+ cargo build --verbose --features "compiletest" &&
58
+ cargo test --features "compiletest"
59
+ )
Original file line number Diff line number Diff line change
1
+ This directory contains snippets of code that should yield a
2
+ warning/note/help/error at compilation. Syntax of annotations is described in
3
+ [ rust documentation] ( https://github.com/rust-lang/rust/blob/master/src/test/COMPILER_TESTS.md ) .
4
+ For more information check out [ ` compiletest ` crate] ( https://github.com/laumann/compiletest-rs ) .
5
+
6
+ To run compile tests issue ` cargo +nightly --test --features compiletest ` .
7
+
8
+ ## Notes on working with ` compiletest ` crate
9
+
10
+ * Currently code that is inside macro should not be annotated, as ` compiletest `
11
+ crate cannot deal with the fact that macro invocations effectively changes
12
+ line numbering. To prevent this add a ` // error-pattern:<your error message here> `
13
+ on the top of the file and make sure that you set ` deny ` lint level
14
+ if you want to test compiler message different than error.
15
+ * ` compiletest ` crate by default sets ` allow(dead_code) ` lint level so make sure
16
+ that you change it to something suiting your needs even if the warning is
17
+ issued prior to any macro invocation.
18
+ * If you get a message ` error: 0 unexpected errors found, 1 expected errors not found `
19
+ despite the fact that some error was bound to occur don't worry - it's a known
20
+ issue in the ` compiletest ` crate and your error was probably not registered -
21
+ make sure that your annotations are correct and that you are setting correct
22
+ lint levels.
Original file line number Diff line number Diff line change
1
+ // error-pattern:static item is never used: `UNUSED`
2
+ #![ deny( dead_code) ]
3
+ #[ macro_use]
4
+ extern crate lazy_static;
5
+
6
+ lazy_static ! {
7
+ static ref UNUSED : ( ) = ( ) ;
8
+ }
9
+
10
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ #![ cfg( feature="compiletest" ) ]
2
+ extern crate compiletest_rs as compiletest;
3
+
4
+ fn run_mode ( mode : & ' static str ) {
5
+ let mut config = compiletest:: Config :: default ( ) ;
6
+ config. mode = mode. parse ( ) . expect ( "Invalid mode" ) ;
7
+ config. src_base = [ "tests" , mode] . iter ( ) . collect ( ) ;
8
+ config. target_rustcflags = Some ( "-L target/debug/ -L target/debug/deps/" . to_owned ( ) ) ;
9
+
10
+ config. verbose = true ;
11
+
12
+ compiletest:: run_tests ( & config) ;
13
+ }
14
+
15
+ #[ test]
16
+ fn compile_test ( ) {
17
+ run_mode ( "compile-fail" ) ;
18
+ }
Original file line number Diff line number Diff line change @@ -27,10 +27,6 @@ lazy_static! {
27
27
static ref UNSAFE : u32 = unsafe {
28
28
std:: mem:: transmute:: <i32 , u32 >( -1 )
29
29
} ;
30
-
31
- // This *should* triggger warn(dead_code) by design.
32
- static ref UNUSED : ( ) = ( ) ;
33
-
34
30
}
35
31
36
32
lazy_static ! {
You can’t perform that action at this time.
0 commit comments