1 # Deny-by-default lints
3 These lints are all set to the 'deny' level by default.
7 This lint detects that a shift exceeds the type's number of bits. Some
8 example code that triggers this lint:
17 error: bitshift exceeds the type's number of bits
25 ## invalid-type-param-default
27 This lint detects type parameter default erroneously allowed in invalid location. Some
28 example code that triggers this lint:
31 fn foo<T=i32>(t: T) {}
37 error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions.
40 4 | fn foo<T=i32>(t: T) {}
43 = note: #[deny(invalid_type_param_default)] on by default
44 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
45 = note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
48 ## legacy-constructor-visibility
50 [RFC 1506](https://github.com/rust-lang/rfcs/blob/master/text/1506-adt-kinds.md) modified some
51 visibility rules, and changed the visibility of struct constructors. Some
52 example code that triggers this lint:
59 // this is trying to use S from the 'use' line, but becuase the `u8` is
60 // not pub, it is private
71 error: private struct constructors are not usable through re-exports in outer modules
77 = note: #[deny(legacy_constructor_visibility)] on by default
78 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
79 = note: for more information, see issue #39207 <https://github.com/rust-lang/rust/issues/39207>
83 ## legacy-directory-ownership
85 The legacy_directory_ownership warning is issued when
87 * There is a non-inline module with a #[path] attribute (e.g. #[path = "foo.rs"] mod bar;),
88 * The module's file ("foo.rs" in the above example) is not named "mod.rs", and
89 * The module's file contains a non-inline child module without a #[path] attribute.
91 The warning can be fixed by renaming the parent module to "mod.rs" and moving
92 it into its own directory if appropriate.
96 This lint detects names that resolve to ambiguous glob imports. Some example
97 code that triggers this lint:
116 error: `Foo` is ambiguous
120 | - `Foo` could refer to the name imported here
122 | ------ `Foo` could also refer to the name imported here
126 = note: #[deny(legacy_imports)] on by default
127 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
128 = note: for more information, see issue #38260 <https://github.com/rust-lang/rust/issues/38260>
132 ## missing-fragment-specifier
134 The missing_fragment_specifier warning is issued when an unused pattern in a
135 `macro_rules!` macro definition has a meta-variable (e.g. `$e`) that is not
136 followed by a fragment specifier (e.g. `:expr`).
138 This warning can always be fixed by removing the unused pattern in the
139 `macro_rules!` macro definition.
141 ## mutable-transmutes
143 This lint catches transmuting from `&T` to `&mut T` becuase it is undefined
144 behavior. Some example code that triggers this lint:
148 let y = std::mem::transmute::<&i32, &mut i32>(&5);
155 error: mutating transmuted &mut T from &T may cause undefined behavior, consider instead using an UnsafeCell
158 3 | let y = std::mem::transmute::<&i32, &mut i32>(&5);
159 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
164 ## no-mangle-const-items
166 This lint detects any `const` items with the `#[no_mangle]` attribute.
167 Constants do not have their symbols exported, and therefore, this probably
168 means you meant to use a `static`, not a `const`. Some example code that
179 error: const items should never be #[no_mangle]
182 3 | const FOO: i32 = 5;
183 | -----^^^^^^^^^^^^^^
185 | help: try a static value: `pub static`
189 ## parenthesized-params-in-types-and-modules
191 This lint detects incorrect parentheses. Some example code that triggers this
195 let x = 5 as usize();
201 error: parenthesized parameters may only be used with a trait
204 2 | let x = 5 as usize();
207 = note: #[deny(parenthesized_params_in_types_and_modules)] on by default
208 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
209 = note: for more information, see issue #42238 <https://github.com/rust-lang/rust/issues/42238>
212 To fix it, remove the `()`s.
214 ## pub-use-of-private-extern-crate
216 This lint detects a specific situation of re-exporting a private `extern crate`;
218 ## safe-extern-statics
220 In older versions of Rust, there was a soundness issue where `extern static`s were allowed
221 to be accessed in safe code. This lint now catches and denies this kind of code.
223 ## unknown-crate-types
225 This lint detects an unknown crate type found in a `#[crate_type]` directive. Some
226 example code that triggers this lint:
235 error: invalid `crate_type` value
238 1 | #![crate_type="lol"]
239 | ^^^^^^^^^^^^^^^^^^^^