fix tests
This commit is contained in:
parent
758a77d46c
commit
142c52f4a3
@ -7,7 +7,7 @@ depending on how you've configured things.
|
|||||||
|
|
||||||
Here's a small example:
|
Here's a small example:
|
||||||
|
|
||||||
```rust
|
```bash
|
||||||
$ cat main.rs
|
$ cat main.rs
|
||||||
fn main() {
|
fn main() {
|
||||||
let x = 5;
|
let x = 5;
|
||||||
@ -25,4 +25,4 @@ warning: unused variable: `x`
|
|||||||
|
|
||||||
This is the `unused_variables` lint, and it tells you that you've introduced
|
This is the `unused_variables` lint, and it tells you that you've introduced
|
||||||
a variable that you don't use in your code. That's not *wrong*, so it's not
|
a variable that you don't use in your code. That's not *wrong*, so it's not
|
||||||
an error, but it might be a bug, so you get a warning.
|
an error, but it might be a bug, so you get a warning.
|
||||||
|
@ -22,7 +22,7 @@ pub fn foo() {}
|
|||||||
|
|
||||||
Compiling this file produces no warnings:
|
Compiling this file produces no warnings:
|
||||||
|
|
||||||
```rust
|
```bash
|
||||||
$ rustc lib.rs --crate-type=lib
|
$ rustc lib.rs --crate-type=lib
|
||||||
$
|
$
|
||||||
```
|
```
|
||||||
@ -62,7 +62,7 @@ warning: unused variable: `x`
|
|||||||
A 'deny' lint produces an error if you violate it. For example, this code
|
A 'deny' lint produces an error if you violate it. For example, this code
|
||||||
runs into the `exceeding_bitshifts` lint.
|
runs into the `exceeding_bitshifts` lint.
|
||||||
|
|
||||||
```rust
|
```rust,ignore
|
||||||
fn main() {
|
fn main() {
|
||||||
100u8 << 10;
|
100u8 << 10;
|
||||||
}
|
}
|
||||||
@ -215,7 +215,7 @@ pub fn foo() {}
|
|||||||
This is the maximum level for all lints. So for example, if we take our
|
This is the maximum level for all lints. So for example, if we take our
|
||||||
code sample from the "deny" lint level above:
|
code sample from the "deny" lint level above:
|
||||||
|
|
||||||
```rust
|
```rust,ignore
|
||||||
fn main() {
|
fn main() {
|
||||||
100u8 << 10;
|
100u8 << 10;
|
||||||
}
|
}
|
||||||
@ -249,4 +249,4 @@ $
|
|||||||
|
|
||||||
This feature is used heavily by Cargo; it will pass `--cap-lints allow` when
|
This feature is used heavily by Cargo; it will pass `--cap-lints allow` when
|
||||||
compiling your dependencies, so that if they have any warnings, they do not
|
compiling your dependencies, so that if they have any warnings, they do not
|
||||||
pollute the output of your build.
|
pollute the output of your build.
|
||||||
|
@ -336,7 +336,7 @@ This lint is deprecated and no longer used.
|
|||||||
This lint guards against `extern crate` items that are never used. Some
|
This lint guards against `extern crate` items that are never used. Some
|
||||||
example code that triggers this lint:
|
example code that triggers this lint:
|
||||||
|
|
||||||
```rust
|
```rust,ignore
|
||||||
extern crate semver;
|
extern crate semver;
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -359,9 +359,10 @@ code that triggers this lint:
|
|||||||
```rust
|
```rust
|
||||||
use test::{A};
|
use test::{A};
|
||||||
|
|
||||||
mod test {
|
pub mod test {
|
||||||
struct A;
|
pub struct A;
|
||||||
}
|
}
|
||||||
|
# fn main() {}
|
||||||
```
|
```
|
||||||
|
|
||||||
When set to 'deny', this will produce:
|
When set to 'deny', this will produce:
|
||||||
@ -410,7 +411,7 @@ You can call `bar()` directly, without the `foo::`.
|
|||||||
This lint checks for the unused result of an expression in a statement. Some
|
This lint checks for the unused result of an expression in a statement. Some
|
||||||
example code that triggers this lint:
|
example code that triggers this lint:
|
||||||
|
|
||||||
```rust
|
```rust,no_run
|
||||||
fn foo<T>() -> T { panic!() }
|
fn foo<T>() -> T { panic!() }
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
@ -449,4 +450,4 @@ error: enum variant is more than three times larger (1024 bytes) than the next l
|
|||||||
5 | VBig([u8; 1024]), //~ ERROR variant is more than three times larger
|
5 | VBig([u8; 1024]), //~ ERROR variant is more than three times larger
|
||||||
| ^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
```
|
```
|
||||||
|
@ -7,7 +7,7 @@ These lints are all set to the 'deny' level by default.
|
|||||||
This lint detects that a shift exceeds the type's number of bits. Some
|
This lint detects that a shift exceeds the type's number of bits. Some
|
||||||
example code that triggers this lint:
|
example code that triggers this lint:
|
||||||
|
|
||||||
```rust
|
```rust,ignore
|
||||||
1_i32 << 32;
|
1_i32 << 32;
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ error: bitshift exceeds the type's number of bits
|
|||||||
This lint detects type parameter default erroneously allowed in invalid location. Some
|
This lint detects type parameter default erroneously allowed in invalid location. Some
|
||||||
example code that triggers this lint:
|
example code that triggers this lint:
|
||||||
|
|
||||||
```rust
|
```rust,ignore
|
||||||
fn foo<T=i32>(t: T) {}
|
fn foo<T=i32>(t: T) {}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ error: defaults for type parameters are only allowed in `struct`, `enum`, `type`
|
|||||||
visibility rules, and changed the visibility of struct constructors. Some
|
visibility rules, and changed the visibility of struct constructors. Some
|
||||||
example code that triggers this lint:
|
example code that triggers this lint:
|
||||||
|
|
||||||
```rust
|
```rust,ignore
|
||||||
mod m {
|
mod m {
|
||||||
pub struct S(u8);
|
pub struct S(u8);
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ it into its own directory if appropriate.
|
|||||||
This lint detects names that resolve to ambiguous glob imports. Some example
|
This lint detects names that resolve to ambiguous glob imports. Some example
|
||||||
code that triggers this lint:
|
code that triggers this lint:
|
||||||
|
|
||||||
```rust
|
```rust,ignore
|
||||||
pub struct Foo;
|
pub struct Foo;
|
||||||
|
|
||||||
mod bar {
|
mod bar {
|
||||||
@ -143,7 +143,7 @@ This warning can always be fixed by removing the unused pattern in the
|
|||||||
This lint catches transmuting from `&T` to `&mut T` becuase it is undefined
|
This lint catches transmuting from `&T` to `&mut T` becuase it is undefined
|
||||||
behavior. Some example code that triggers this lint:
|
behavior. Some example code that triggers this lint:
|
||||||
|
|
||||||
```rust
|
```rust,ignore
|
||||||
unsafe {
|
unsafe {
|
||||||
let y = std::mem::transmute::<&i32, &mut i32>(&5);
|
let y = std::mem::transmute::<&i32, &mut i32>(&5);
|
||||||
}
|
}
|
||||||
@ -168,7 +168,7 @@ Constants do not have their symbols exported, and therefore, this probably
|
|||||||
means you meant to use a `static`, not a `const. Some example code that
|
means you meant to use a `static`, not a `const. Some example code that
|
||||||
triggers this lint:
|
triggers this lint:
|
||||||
|
|
||||||
```rust
|
```rust,ignore
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
const FOO: i32 = 5;
|
const FOO: i32 = 5;
|
||||||
```
|
```
|
||||||
@ -191,7 +191,7 @@ error: const items should never be #[no_mangle]
|
|||||||
This lint detects incorrect parentheses. Some example code that triggers this
|
This lint detects incorrect parentheses. Some example code that triggers this
|
||||||
lint:
|
lint:
|
||||||
|
|
||||||
```rust
|
```rust,ignore
|
||||||
let x = 5 as usize();
|
let x = 5 as usize();
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -225,7 +225,7 @@ to be accessed in safe code. This lint now catches and denies this kind of code.
|
|||||||
This lint detects an unknown crate type found in a `#[crate_type]` directive. Some
|
This lint detects an unknown crate type found in a `#[crate_type]` directive. Some
|
||||||
example code that triggers this lint:
|
example code that triggers this lint:
|
||||||
|
|
||||||
```rust
|
```rust,ignore
|
||||||
#![crate_type="lol"]
|
#![crate_type="lol"]
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -238,4 +238,4 @@ error: invalid `crate_type` value
|
|||||||
1 | #![crate_type="lol"]
|
1 | #![crate_type="lol"]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
```
|
```
|
||||||
|
@ -7,7 +7,7 @@ These lints are all set to the 'warn' level by default.
|
|||||||
This lint detects an erroneous expression while doing constant evaluation. Some
|
This lint detects an erroneous expression while doing constant evaluation. Some
|
||||||
example code that triggers this lint:
|
example code that triggers this lint:
|
||||||
|
|
||||||
```rust
|
```rust,ignore
|
||||||
let b = 200u8 + 200u8;
|
let b = 200u8 + 200u8;
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -413,7 +413,7 @@ impl Trait for i32 {
|
|||||||
This lint detects when compiler plugins are used as ordinary library in
|
This lint detects when compiler plugins are used as ordinary library in
|
||||||
non-plugin crate. Some example code that triggers this lint:
|
non-plugin crate. Some example code that triggers this lint:
|
||||||
|
|
||||||
```rust
|
```rust,ignore
|
||||||
#![feature(plugin)]
|
#![feature(plugin)]
|
||||||
#![plugin(macro_crate_test)]
|
#![plugin(macro_crate_test)]
|
||||||
|
|
||||||
@ -425,7 +425,7 @@ extern crate macro_crate_test;
|
|||||||
This lint detects detect private items in public interfaces not caught by the old implementation. Some
|
This lint detects detect private items in public interfaces not caught by the old implementation. Some
|
||||||
example code that triggers this lint:
|
example code that triggers this lint:
|
||||||
|
|
||||||
```rust
|
```rust,ignore
|
||||||
pub trait Trait {
|
pub trait Trait {
|
||||||
type A;
|
type A;
|
||||||
}
|
}
|
||||||
@ -439,6 +439,7 @@ mod foo {
|
|||||||
type A = Z;
|
type A = Z;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
# fn main() {}
|
||||||
```
|
```
|
||||||
|
|
||||||
This will produce:
|
This will produce:
|
||||||
@ -682,7 +683,7 @@ warning: union contains a field with possibly non-trivial drop code, drop code o
|
|||||||
This lint detects unrecognized lint attribute. Some
|
This lint detects unrecognized lint attribute. Some
|
||||||
example code that triggers this lint:
|
example code that triggers this lint:
|
||||||
|
|
||||||
```rust
|
```rust,ignore
|
||||||
#[allow(not_a_real_lint)]
|
#[allow(not_a_real_lint)]
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -702,7 +703,7 @@ warning: unknown lint: `not_a_real_lint`
|
|||||||
This lint detects detects unreachable code paths. Some example code that
|
This lint detects detects unreachable code paths. Some example code that
|
||||||
triggers this lint:
|
triggers this lint:
|
||||||
|
|
||||||
```rust
|
```rust,no_run
|
||||||
panic!("we never go past here!");
|
panic!("we never go past here!");
|
||||||
|
|
||||||
let x = 5;
|
let x = 5;
|
||||||
@ -1020,7 +1021,7 @@ As such, you won't ever trigger this lint in your code directly.
|
|||||||
This lint detects `while true { }`. Some example code that triggers this
|
This lint detects `while true { }`. Some example code that triggers this
|
||||||
lint:
|
lint:
|
||||||
|
|
||||||
```rust
|
```rust,no_run
|
||||||
while true {
|
while true {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1035,4 +1036,4 @@ warning: denote infinite loops with `loop { ... }`
|
|||||||
2 | while true {
|
2 | while true {
|
||||||
| ^^^^^^^^^^ help: use `loop`
|
| ^^^^^^^^^^ help: use `loop`
|
||||||
|
|
|
|
||||||
```
|
```
|
||||||
|
Loading…
x
Reference in New Issue
Block a user