Deny-by-default Lints
These lints are all set to the ‘deny’ level by default.
aarch64_softfloat_neonaligned_fields_in_packedambiguous_associated_itemsambiguous_glob_importsarithmetic_overflowbinary_asm_labelsbindings_with_variant_nameconflicting_repr_hintsdangerous_implicit_autorefsdefault_overrides_default_fieldsderef_nullptrduplicate_featuresduplicate_toolsenum_intrinsics_non_enumsexceeding_bitshiftsexplicit_builtin_cfgs_in_flagsill_formed_attribute_inputincomplete_includeineffective_unstable_reexportsineffective_unstable_trait_implinvalid_atomic_orderinginvalid_from_utf8_uncheckedinvalid_macro_export_argumentsinvalid_null_argumentsinvalid_reference_castinginvalid_runtime_symbol_definitionsinvalid_type_param_defaultlegacy_derive_helperslet_underscore_locklong_running_const_evalmacro_expanded_macro_exports_accessed_by_absolute_pathsmutable_transmutesnamed_asm_labelsnever_type_fallback_flowing_into_unsafeno_mangle_const_itemsout_of_scope_macro_callsoverflowing_literalspatterns_in_fns_without_bodyprivate_macro_useproc_macro_derive_resolution_fallbackpub_use_of_private_extern_cratesemicolon_in_expressions_from_macrostest_unstable_linttext_direction_codepoint_in_commenttext_direction_codepoint_in_literalunconditional_panicundropped_manually_dropsuninhabited_staticunknown_crate_typesunstable_importsuseless_deprecatedvarargs_without_patternx86_softfloat_sse
aarch64-softfloat-neon
The aarch64_softfloat_neon lint detects usage of #[target_feature(enable = "neon")] on
softfloat aarch64 targets. Enabling this target feature causes LLVM to alter the ABI of
function calls, making this attribute unsound to use.
Example
This will produce:
error: enabling the `neon` target feature on the current target is unsound due to ABI issues
--> $DIR/abi-incompatible-target-feature-attribute-fcw.rs:11:18
|
| #[target_feature(enable = "neon")]
| ^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #134375 <https://github.com/rust-lang/rust/issues/134375>
Explanation
If a function like with_neon above ends up containing calls to LLVM builtins, those will
not use the correct ABI. This is caused by a lack of support in LLVM for mixing code with
and without the neon target feature. The target feature should never have been stabilized
on this target due to this issue, but the problem was not known at the time of
stabilization.
aligned-fields-in-packed
The aligned_fields_in_packed lint detects fields with align representation hints
inside repr(C) types with packed representation hint.
Example
;
// error!
;
Explanation
The behavior of this combination of hints is inconsistent across C compilers. The layout computed for these types by Rust may thus not match the layout actually used by C. Specifically, Rust always follows the GCC convention, which makes it incompatible with MSVC for these types. This may change in the future for targets where GCC is not the default C compiler.
ambiguous-associated-items
The ambiguous_associated_items lint detects ambiguity between
associated items and enum variants.
Example
Explanation
Previous versions of Rust did not allow accessing enum variants through type aliases. When this ability was added (see RFC 2338), this introduced some situations where it can be ambiguous what a type was referring to.
To fix this ambiguity, you should use a qualified path to explicitly
state which type to use. For example, in the above example the
function can be written as fn f() -> <Self as Tr>::V { 0 } to
specifically refer to the associated type.
This is a future-incompatible lint to transition this to a hard error in the future. See issue #57644 for more details.
ambiguous-glob-imports
The ambiguous_glob_imports lint detects glob imports that should report ambiguity
errors, but previously didn’t do that due to rustc bugs.
Example
// library crate `my_library`
pub use *;
pub use *;
// another crate using `my_library`
let c = C; // `C` is ambiguous
Explanation
Previous versions of Rust compile it successfully because ambiguous glob imports weren’t preserved correctly over crate boundaries.
This is a future-incompatible lint to transition this to a hard error in the future.
arithmetic-overflow
The arithmetic_overflow lint detects that an arithmetic operation
will overflow.
Example
1_i32 << 32;
Explanation
It is very likely a mistake to perform an arithmetic operation that overflows its value. If the compiler is able to detect these kinds of overflows at compile-time, it will trigger this lint. Consider adjusting the expression to avoid overflow, or use a data type that will not overflow.
binary-asm-labels
The binary_asm_labels lint detects the use of numeric labels containing only binary
digits in the inline asm! macro.
Example
use asm;
This will produce:
error: avoid using labels containing only the digits `0` and `1` in inline assembly
--> <source>:7:15
|
7 | asm!("0: jmp 0b");
| ^ use a different label that doesn't start with `0` or `1`
|
= help: start numbering with `2` instead
= note: an LLVM bug makes these labels ambiguous with a binary literal number on x86
= note: see <https://github.com/llvm/llvm-project/issues/99547> for more information
= note: `#[deny(binary_asm_labels)]` on by default
Explanation
An LLVM bug causes this code to fail to compile because it interprets the 0b as a binary
literal instead of a reference to the previous local label 0. To work around this bug,
don’t use labels that could be confused with a binary literal.
This behavior is platform-specific to x86 and x86-64.
See the explanation in Rust By Example for more details.
bindings-with-variant-name
The bindings_with_variant_name lint detects pattern bindings with
the same name as one of the matched variants.
Example
Explanation
It is usually a mistake to specify an enum variant name as an
identifier pattern. In the example above, the match arms are
specifying a variable name to bind the value of x to. The second arm
is ignored because the first one matches all values. The likely
intent is that the arm was intended to match on the enum variant.
Two possible solutions are:
- Specify the enum variant using a path pattern, such as
Enum::Foo. - Bring the enum variants into local scope, such as adding
use Enum::*;to the beginning of thefoofunction in the example above.
conflicting-repr-hints
The conflicting_repr_hints lint detects repr attributes with
conflicting hints.
Example
Explanation
The compiler incorrectly accepted these conflicting representations in the past. This is a future-incompatible lint to transition this to a hard error in the future. See issue #68585 for more details.
To correct the issue, remove one of the conflicting hints.
dangerous-implicit-autorefs
The dangerous_implicit_autorefs lint checks for implicitly taken references
to dereferences of raw pointers.
Example
unsafe *mut
Explanation
When working with raw pointers it’s usually undesirable to create references, since they inflict additional safety requirements. Unfortunately, it’s possible to take a reference to the dereference of a raw pointer implicitly, which inflicts the usual reference requirements.
If you are sure that you can soundly take a reference, then you can take it explicitly:
unsafe *mut
Otherwise try to find an alternative way to achieve your goals using only raw pointers:
use ptr;
*mut
default-overrides-default-fields
The default_overrides_default_fields lint checks for manual impl blocks of the
Default trait of types with default field values.
Example
;
Explanation
Manually writing a Default implementation for a type that has
default field values runs the risk of diverging behavior between
Type { .. } and <Type as Default>::default(), which would be a
foot-gun for users of that type that would expect these to be
equivalent. If Default can’t be derived due to some fields not
having a Default implementation, we encourage the use of .. for
the fields that do have a default field value.
deref-nullptr
The deref_nullptr lint detects when a null pointer is dereferenced,
which causes undefined behavior.
Example
use ptr;
unsafe
Explanation
Dereferencing a null pointer causes undefined behavior if it is accessed (loaded from or stored to).
duplicate-features
The duplicate_features lint detects duplicate features found in
crate-level feature attributes.
Note: This lint used to be a hard error (E0636).
Example
Explanation
Enabling a feature more than once is a no-op.
To avoid this warning, remove the second feature() attribute.
duplicate-tools
The duplicate_tools lint detects duplicate tools found in crate-level
register_tool attributes (including register_attribute_tool or register_lint_tool).
Example
Explanation
Enabling a tool more than once is a no-op.
To avoid this warning, remove the second register_tool() attribute.
enum-intrinsics-non-enums
The enum_intrinsics_non_enums lint detects calls to
intrinsic functions that require an enum (core::mem::discriminant,
core::mem::variant_count), but are called with a non-enum type.
Example
;
Explanation
In order to accept any enum, the mem::discriminant and
mem::variant_count functions are generic over a type T.
This makes it technically possible for T to be a non-enum,
in which case the return value is unspecified.
This lint prevents such incorrect usage of these functions.
exceeding-bitshifts
The lint exceeding-bitshifts has been renamed to arithmetic-overflow.
explicit-builtin-cfgs-in-flags
The explicit_builtin_cfgs_in_flags lint detects builtin cfgs set via the --cfg flag.
Example
rustc --cfg unix
This will produce:
error: unexpected `--cfg unix` flag
|
= note: config `unix` is only supposed to be controlled by `--target`
= note: manually setting a built-in cfg can and does create incoherent behaviors
= note: `#[deny(explicit_builtin_cfgs_in_flags)]` on by default
Explanation
Setting builtin cfgs can and does produce incoherent behavior, it’s better to the use
the appropriate rustc flag that controls the config. For example setting the windows
cfg but on Linux based target.
ill-formed-attribute-input
The ill_formed_attribute_input lint detects ill-formed attribute
inputs that were previously accepted and used in practice.
Example
Explanation
Previously, inputs for many built-in attributes weren’t validated and nonsensical attribute inputs were accepted. After validation was added, it was determined that some existing projects made use of these invalid forms. This is a future-incompatible lint to transition this to a hard error in the future. See issue #57571 for more details.
Check the attribute reference for details on the valid inputs for attributes.
incomplete-include
The incomplete_include lint detects the use of the include!
macro with a file that contains more than one expression.
Example
where the file foo.txt contains:
println!("hi!");
produces:
error: include macro expected single expression in source
--> foo.txt:1:14
|
1 | println!("1");
| ^
|
= note: `#[deny(incomplete_include)]` on by default
Explanation
The include! macro is currently only intended to be used to
include a single expression or multiple items. Historically it
would ignore any contents after the first expression, but that can be
confusing. In the example above, the println! expression ends just
before the semicolon, making the semicolon “extra” information that is
ignored. Perhaps even more surprising, if the included file had
multiple print statements, the subsequent ones would be ignored!
One workaround is to place the contents in braces to create a block expression. Also consider alternatives, like using functions to encapsulate the expressions, or use proc-macros.
This is a lint instead of a hard error because existing projects were
found to hit this error. To be cautious, it is a lint for now. The
future semantics of the include! macro are also uncertain, see
issue #35560.
ineffective-unstable-reexports
The ineffective_unstable_reexports lint detects #[unstable]
attributes on re-exports where the attribute does not make the
re-exported path unstable.
Example
;
pub use S as T;
Explanation
#[unstable] on a re-export does not make a stable path unstable
re-exports inside unstable modules are already on an unstable path
ineffective-unstable-trait-impl
The ineffective_unstable_trait_impl lint detects #[unstable] attributes which are not used.
Example
Explanation
staged_api does not currently support using a stability attribute on impl blocks.
impls are always stable if both the type and trait are stable, and always unstable otherwise.
invalid-atomic-ordering
The invalid_atomic_ordering lint detects passing an Ordering
to an atomic operation that does not support that ordering.
Example
let atom = new;
let value = atom.load;
Explanation
Some atomic operations are only supported for a subset of the
atomic::Ordering variants. Passing an unsupported variant will cause
an unconditional panic at runtime, which is detected by this lint.
This lint will trigger in the following cases: (where AtomicType is an
atomic type from core::sync::atomic, such as AtomicBool,
AtomicPtr, AtomicUsize, or any of the other integer atomics).
-
Passing
Ordering::AcquireorOrdering::AcqReltoAtomicType::store. -
Passing
Ordering::ReleaseorOrdering::AcqReltoAtomicType::load. -
Passing
Ordering::Relaxedtocore::sync::atomic::fenceorcore::sync::atomic::compiler_fence. -
Passing
Ordering::ReleaseorOrdering::AcqRelas the failure ordering for any ofAtomicType::compare_exchange,AtomicType::compare_exchange_weak,AtomicType::update, orAtomicType::try_update.
invalid-from-utf8-unchecked
The invalid_from_utf8_unchecked lint checks for calls to
std::str::from_utf8_unchecked and std::str::from_utf8_unchecked_mut
with a known invalid UTF-8 value.
Example
unsafe
Explanation
Creating such a str would result in undefined behavior as per documentation
for std::str::from_utf8_unchecked and std::str::from_utf8_unchecked_mut.
invalid-macro-export-arguments
The invalid_macro_export_arguments lint detects cases where #[macro_export] is being used with invalid arguments.
Example
Explanation
The only valid argument is #[macro_export(local_inner_macros)] or no argument (#[macro_export]).
You can’t have multiple arguments in a #[macro_export(..)], or mention arguments other than local_inner_macros.
invalid-null-arguments
The invalid_null_arguments lint checks for invalid usage of null pointers in arguments.
Example
// Undefined behavior
unsafe ;
Explanation
Calling methods whos safety invariants requires non-null ptr with a null pointer is Undefined Behavior!
invalid-reference-casting
The invalid_reference_casting lint checks for casts of &T to &mut T
without using interior mutability.
Example
Explanation
Casting &T to &mut T without using interior mutability is undefined behavior,
as it’s a violation of Rust reference aliasing requirements.
UnsafeCell is the only way to obtain aliasable data that is considered
mutable.
invalid-runtime-symbol-definitions
The invalid_runtime_symbol_definitions lint checks the signature of items whose
symbol name is a runtime symbol expected by core or std differs significantly from the
expected signature (like mismatch ABI, mismatch C variadics, mismatch argument count,
missing return type, …).
Example
// invalid definition of the `strlen` function
Explanation
Up-most care is required when defining runtime symbols assumed and used by the standard library. They must follow the C specification, not use any standard-library facility or undefined behavior may occur.
The symbols currently checked are memcpy, memmove, memset, memcmp,
bcmp, strlen, as well as the following POSIX symbols: open, read, write
close, malloc, realloc, free and exit.
invalid-type-param-default
The invalid_type_param_default lint detects type parameter defaults
erroneously allowed in an invalid location.
Example
Explanation
Default type parameters were only intended to be allowed in certain situations, but historically the compiler allowed them everywhere. This is a future-incompatible lint to transition this to a hard error in the future. See issue #36887 for more details.
legacy-derive-helpers
The legacy_derive_helpers lint detects derive helper attributes
that are used before they are introduced.
Example
produces:
warning: derive helper attribute is used before it is introduced
--> $DIR/legacy-derive-helpers.rs:1:3
|
1 | #[serde(rename_all = "camelCase")]
| ^^^^^
...
2 | #[derive(Deserialize)]
| ----------- the attribute is introduced here
Explanation
Attributes like this work for historical reasons, but attribute expansion works in
left-to-right order in general, so, to resolve #[serde], compiler has to try to “look
into the future” at not yet expanded part of the item , but such attempts are not always
reliable.
To fix the warning place the helper attribute after its corresponding derive.
let-underscore-lock
The let_underscore_lock lint checks for statements which don’t bind
a mutex to anything, causing the lock to be released immediately instead
of at end of scope, which is typically incorrect.
Example
use ;
use thread;
let data = new;
spawn;
Explanation
Statements which assign an expression to an underscore causes the
expression to immediately drop instead of extending the expression’s
lifetime to the end of the scope. This is usually unintended,
especially for types like MutexGuard, which are typically used to
lock a mutex for the duration of an entire scope.
If you want to extend the expression’s lifetime to the end of the scope,
assign an underscore-prefixed name (such as _foo) to the expression.
If you do actually want to drop the expression immediately, then
calling std::mem::drop on the expression is clearer and helps convey
intent.
long-running-const-eval
The long_running_const_eval lint is emitted when const
eval is running for a long time to ensure rustc terminates
even if you accidentally wrote an infinite loop.
Example
const FOO: = loop ;
Explanation
Loops allow const evaluation to compute arbitrary code, but may also cause infinite loops or just very long running computations. Users can enable long running computations by allowing the lint on individual constants or for entire crates.
Unconditional warnings
Note that regardless of whether the lint is allowed or set to warn, the compiler will issue warnings if constant evaluation runs significantly longer than this lint’s limit. These warnings are also shown to downstream users from crates.io or similar registries. If you are above the lint’s limit, both you and downstream users might be exposed to these warnings. They might also appear on compiler updates, as the compiler makes minor changes about how complexity is measured: staying below the limit ensures that there is enough room, and given that the lint is disabled for people who use your dependency it means you will be the only one to get the warning and can put out an update in your own time.
macro-expanded-macro-exports-accessed-by-absolute-paths
The macro_expanded_macro_exports_accessed_by_absolute_paths lint
detects macro-expanded macro_export macros from the current crate
that cannot be referred to by absolute paths.
Example
define_exported!;
Explanation
The intent is that all macros marked with the #[macro_export]
attribute are made available in the root of the crate. However, when a
macro_rules! definition is generated by another macro, the macro
expansion is unable to uphold this rule. This is a
future-incompatible lint to transition this to a hard error in the
future. See issue #53495 for more details.
mutable-transmutes
The mutable_transmutes lint catches transmuting from &T to &mut T because it is undefined behavior.
Example
unsafe
Explanation
Certain assumptions are made about aliasing of data, and this transmute
violates those assumptions. Consider using UnsafeCell instead.
named-asm-labels
The named_asm_labels lint detects the use of named labels in the
inline asm! macro.
Example
use asm;
Explanation
LLVM is allowed to duplicate inline assembly blocks for any reason, for example when it is in a function that gets inlined. Because of this, GNU assembler local labels must be used instead of labels with a name. Using named labels might cause assembler or linker errors.
See the explanation in Rust By Example for more details.
never-type-fallback-flowing-into-unsafe
The never_type_fallback_flowing_into_unsafe lint detects cases where never type fallback
affects unsafe function calls.
Never type fallback
When the compiler sees a value of type ! it implicitly inserts a coercion (if possible),
to allow type check to infer any type:
// this
let x: u8 = panic!;
// is (essentially) turned by the compiler into
let x: u8 = absurd;
// where absurd is a function with the following signature
// (it's sound, because `!` always marks unreachable code):
While it’s convenient to be able to use non-diverging code in one of the branches (like
if a { b } else { return }) this could lead to compilation errors:
// this
;
// gets turned into this
; // error: can't infer the type of `absurd`
To prevent such errors, compiler remembers where it inserted absurd calls, and if it
can’t infer their type, it sets the type to fallback. { absurd::<Fallback>(panic!()) };.
This is what is known as “never type fallback”.
Example
Explanation
The never type fallback used to be (), meaning that ! got spontaneously coerced to ().
Since then the never type fallback has been changed to !, making the above code undefined
behavior. Instead of depending on the fallback, you should specify the type explicitly:
if true {
return
} else {
// type is explicitly specified, fallback can't hurt us no more
unsafe { std::mem::zeroed::<()>() }
};
See Tracking Issue for making ! fall back to !.
no-mangle-const-items
The no_mangle_const_items lint detects any const items with the
no_mangle attribute.
Example
const FOO: i32 = 5;
Explanation
Constants do not have their symbols exported, and therefore, this
probably means you meant to use a static, not a const.
out-of-scope-macro-calls
The out_of_scope_macro_calls lint detects macro_rules called when they are not in scope,
above their definition, which may happen in key-value attributes.
Example
Explanation
The scope in which a macro_rules item is visible starts at that item and continues
below it. This is more similar to let than to other items, which are in scope both above
and below their definition.
Due to a bug macro_rules were accidentally in scope inside some key-value attributes
above their definition. The lint catches such cases.
To address the issue turn the macro_rules into a regularly scoped item by importing it
with use.
This is a future-incompatible lint to transition this to a hard error in the future.
overflowing-literals
The overflowing_literals lint detects literals out of range for their type.
Example
let x: u8 = 1000;
Explanation
It is usually a mistake to use a literal that overflows its type Change either the literal or its type such that the literal is within the range of its type.
patterns-in-fns-without-body
The patterns_in_fns_without_body lint detects mut identifier
patterns as a parameter in functions without a body.
Example
Explanation
To fix this, remove mut from the parameter in the trait definition;
it can be used in the implementation. That is, the following is OK:
Trait definitions can define functions without a body to specify a
function that implementors must define. The parameter names in the
body-less functions are only allowed to be _ or an identifier for
documentation purposes (only the type is relevant). Previous versions
of the compiler erroneously allowed identifier patterns with the
mut keyword, but this was not intended to be allowed. This is a
future-incompatible lint to transition this to a hard error in the
future. See issue #35203 for more details.
private-macro-use
The private_macro_use lint detects private macros that are imported
with #[macro_use].
Example
// extern_macro.rs
use foo_ as foo;
// code.rs
extern crate extern_macro;
This will produce:
error: cannot find macro `foo` in this scope
Explanation
This lint arises from overlooking visibility checks for macros in an external crate.
This is a future-incompatible lint to transition this to a hard error in the future.
proc-macro-derive-resolution-fallback
The proc_macro_derive_resolution_fallback lint detects proc macro
derives using inaccessible names from parent modules.
Example
// foo.rs
extern crate proc_macro;
use *;
// bar.rs
extern crate foo;
;
;
This will produce:
warning: cannot find type `Something` in this scope
--> src/main.rs:8:10
|
8 | #[derive(Foo)]
| ^^^ names from parent modules are not accessible without an explicit import
|
= note: `#[warn(proc_macro_derive_resolution_fallback)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #50504 <https://github.com/rust-lang/rust/issues/50504>
Explanation
If a proc-macro generates a module, the compiler unintentionally allowed items in that module to refer to items in the crate root without importing them. This is a future-incompatible lint to transition this to a hard error in the future. See issue #50504 for more details.
pub-use-of-private-extern-crate
The pub_use_of_private_extern_crate lint detects a specific
situation of re-exporting a private extern crate.
Example
extern crate core;
pub use core as reexported_core;
Explanation
A public use declaration should not be used to publically re-export a
private extern crate. pub extern crate should be used instead.
This was historically allowed, but is not the intended behavior according to the visibility rules. This is a future-incompatible lint to transition this to a hard error in the future. See issue #127909 for more details.
semicolon-in-expressions-from-macros
The semicolon_in_expressions_from_macros lint detects trailing semicolons
in macro bodies when the macro is invoked in expression position.
This was previous accepted, but is being phased out.
Example
Explanation
Previous, Rust ignored trailing semicolon in a macro body when a macro was invoked in expression position. However, this makes the treatment of semicolons in the language inconsistent, and could lead to unexpected runtime behavior in some circumstances (e.g. if the macro author expects a value to be dropped).
This is a future-incompatible lint to transition this to a hard error in the future. See issue #79813 for more details.
test-unstable-lint
The test_unstable_lint lint tests unstable lints and is perma-unstable.
Example
// This lint is intentionally used to test the compiler's behavior
// when an unstable lint is enabled without the corresponding feature gate.
Explanation
In order to test the behavior of unstable lints, a permanently-unstable lint is required. This lint can be used to trigger warnings and errors from the compiler related to unstable lints.
text-direction-codepoint-in-comment
The text_direction_codepoint_in_comment lint detects Unicode codepoints in comments that
change the visual representation of text on screen in a way that does not correspond to
their on memory representation.
Example
Explanation
Unicode allows changing the visual flow of text on screen in order to support scripts that are written right-to-left, but a specially crafted comment can make code that will be compiled appear to be part of a comment, depending on the software used to read the code. To avoid potential problems or confusion, such as in CVE-2021-42574, by default we deny their use.
text-direction-codepoint-in-literal
The text_direction_codepoint_in_literal lint detects Unicode codepoints that change the
visual representation of text on screen in a way that does not correspond to their on
memory representation.
Explanation
The unicode characters \u{202A}, \u{202B}, \u{202D}, \u{202E}, \u{2066},
\u{2067}, \u{2068}, \u{202C} and \u{2069} make the flow of text on screen change
its direction on software that supports these codepoints. This makes the text “abc” display
as “cba” on screen. By leveraging software that supports these, people can write specially
crafted literals that make the surrounding code seem like it’s performing one action, when
in reality it is performing another. Because of this, we proactively lint against their
presence to avoid surprises.
Example
unconditional-panic
The unconditional_panic lint detects an operation that will cause a
panic at runtime.
Example
let x = 1 / 0;
Explanation
This lint detects code that is very likely incorrect because it will
always panic, such as division by zero and out-of-bounds array
accesses. Consider adjusting your code if this is a bug, or using the
panic! or unreachable! macro instead in case the panic is intended.
undropped-manually-drops
The undropped_manually_drops lint check for calls to std::mem::drop
and std::ptr::drop_in_place where the dropped value is std::mem::ManuallyDrop
which doesn’t drop.
Example
;
drop;
Explanation
ManuallyDrop does not drop it’s inner value so calling std::mem::drop will
not drop the inner value of the ManuallyDrop either.
uninhabited-static
The uninhabited_static lint detects uninhabited statics.
Example
unsafe extern
Explanation
Statics with an uninhabited type can never be initialized, so they are impossible to define.
However, this can be side-stepped with an extern static, leading to problems later in the
compiler which assumes that there are no initialized uninhabited places (such as locals or
statics). This was accidentally allowed, but is being phased out.
unknown-crate-types
The unknown_crate_types lint detects an unknown crate type found in
a crate_type attribute.
Example
Explanation
An unknown value give to the crate_type attribute is almost
certainly a mistake.
unstable-imports
The unstable_imports lints detects imports that go through unstable modules.
Example
use transmute;
Explanation
Previous versions of Rust accidentally allowed certain imports through unstable modules because stability information of modules was not correctly accounted for if the imported item was stable itself.
useless-deprecated
The useless_deprecated lint detects deprecation attributes with no effect.
Example
;
Explanation
Deprecation attributes have no effect on trait implementations.
varargs-without-pattern
The varargs_without_pattern lint detects when ... is used as an argument to a
non-foreign function without any pattern being specified.
Example
// Using `...` in non-foreign function definitions is unstable, however stability is
// currently only checked after attributes are expanded, so using `#[cfg(false)]` here will
// allow this to compile on stable Rust.
Explanation
Patterns are currently required for all non-... arguments in function definitions (with
some exceptions in the 2015 edition). Requiring ... arguments to have patterns in
non-foreign function definitions makes the language more consistent, and removes a source of
confusion for the unstable C variadic feature. ... arguments without a pattern are already
stable and widely used in foreign function definitions; this lint only affects non-foreign
function definitions.
Using ... (C varargs) in a non-foreign function definition is currently unstable. However,
stability checking for the ... syntax in non-foreign function definitions is currently
implemented after attributes have been expanded, meaning that if the attribute removes the
use of the unstable syntax (e.g. #[cfg(false)], or a procedural macro), the code will
compile on stable Rust; this is the only situation where this lint affects code that
compiles on stable Rust.
This is a future-incompatible lint to transition this to a hard error in the future.
x86-softfloat-sse
The x86_softfloat_sse lint detects usage of #[target_feature(enable = "sse")] or target
features that imply SSE on softfloat x86 and x86-64 targets. Enabling this target feature
in a soft-float configuration is not supported by LLVM and can lead to crashes.
Example
This will produce:
error: enabling the `sse` target feature on the current target is unsupported due to LLVM backend issues
--> $DIR/abi-incompatible-target-feature-attribute-fcw.rs:11:18
|
| #[target_feature(enable = "avx")]
| ^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #117938 <https://github.com/rust-lang/rust/issues/117938>
Explanation
LLVM does not support combining the soft-float target feature (which is implicitly enabled
on these targets) with sse. This can lead to crashes of the backend. To prevent that,
Rust is turning that combination into an error.