mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Declare new lint
This commit is contained in:
parent
a047284b5a
commit
77f679430c
@ -67,6 +67,7 @@ declare_lint_pass! {
|
|||||||
MISSING_FRAGMENT_SPECIFIER,
|
MISSING_FRAGMENT_SPECIFIER,
|
||||||
MUST_NOT_SUSPEND,
|
MUST_NOT_SUSPEND,
|
||||||
NAMED_ARGUMENTS_USED_POSITIONALLY,
|
NAMED_ARGUMENTS_USED_POSITIONALLY,
|
||||||
|
NON_CONTIGUOUS_RANGE_ENDPOINTS,
|
||||||
NON_EXHAUSTIVE_OMITTED_PATTERNS,
|
NON_EXHAUSTIVE_OMITTED_PATTERNS,
|
||||||
ORDER_DEPENDENT_TRAIT_OBJECTS,
|
ORDER_DEPENDENT_TRAIT_OBJECTS,
|
||||||
OVERLAPPING_RANGE_ENDPOINTS,
|
OVERLAPPING_RANGE_ENDPOINTS,
|
||||||
@ -812,6 +813,36 @@ declare_lint! {
|
|||||||
"detects range patterns with overlapping endpoints"
|
"detects range patterns with overlapping endpoints"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare_lint! {
|
||||||
|
/// The `non_contiguous_range_endpoints` lint detects likely off-by-one errors when using
|
||||||
|
/// exclusive [range patterns].
|
||||||
|
///
|
||||||
|
/// [range patterns]: https://doc.rust-lang.org/nightly/reference/patterns.html#range-patterns
|
||||||
|
///
|
||||||
|
/// ### Example
|
||||||
|
///
|
||||||
|
/// ```rust
|
||||||
|
/// # #![feature(exclusive_range_pattern)]
|
||||||
|
/// let x = 123u32;
|
||||||
|
/// match x {
|
||||||
|
/// 0..100 => { println!("small"); }
|
||||||
|
/// 101..1000 => { println!("large"); }
|
||||||
|
/// _ => { println!("larger"); }
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// {{produces}}
|
||||||
|
///
|
||||||
|
/// ### Explanation
|
||||||
|
///
|
||||||
|
/// It is likely a mistake to have range patterns in a match expression that miss out a single
|
||||||
|
/// number. Check that the beginning and end values are what you expect, and keep in mind that
|
||||||
|
/// with `..=` the right bound is inclusive, and with `..` it is exclusive.
|
||||||
|
pub NON_CONTIGUOUS_RANGE_ENDPOINTS,
|
||||||
|
Warn,
|
||||||
|
"detects off-by-one errors with exclusive range patterns"
|
||||||
|
}
|
||||||
|
|
||||||
declare_lint! {
|
declare_lint! {
|
||||||
/// The `bindings_with_variant_name` lint detects pattern bindings with
|
/// The `bindings_with_variant_name` lint detects pattern bindings with
|
||||||
/// the same name as one of the matched variants.
|
/// the same name as one of the matched variants.
|
||||||
|
Loading…
Reference in New Issue
Block a user