Static rustc_lint::builtin::TRIVIAL_BOUNDS
source · static TRIVIAL_BOUNDS: &'static Lint
Expand description
The trivial_bounds
lint detects trait bounds that don’t depend on
any type parameters.
Example
#![feature(trivial_bounds)]
pub struct A where i32: Copy;
{{produces}}
Explanation
Usually you would not write a trait bound that you know is always
true, or never true. However, when using macros, the macro may not
know whether or not the constraint would hold or not at the time when
generating the code. Currently, the compiler does not alert you if the
constraint is always true, and generates an error if it is never true.
The trivial_bounds
feature changes this to be a warning in both
cases, giving macros more freedom and flexibility to generate code,
while still providing a signal when writing non-macro code that
something is amiss.
See RFC 2056 for more details. This feature is currently only available on the nightly channel, see tracking issue #48214.