rust/compiler
bors 1b427b3bf7 Auto merge of #118879 - Nadrieril:lint-range-gap, r=estebank
Lint singleton gaps after exclusive ranges

In the discussion to stabilize exclusive range patterns (https://github.com/rust-lang/rust/issues/37854), it has often come up that they're likely to cause off-by-one mistakes. We already have the `overlapping_range_endpoints` lint, so I [proposed](https://github.com/rust-lang/rust/issues/37854#issuecomment-1845580712) a lint to catch the complementary mistake.

This PR adds a new `non_contiguous_range_endpoints` lint that catches likely off-by-one errors with exclusive range patterns. Here's the idea (see the test file for more examples):
```rust
match x {
    0..10 => ..., // WARN: this range doesn't match `10_u8` because `..` is an exclusive range
    11..20 => ..., // this could appear to continue range `0_u8..10_u8`, but `10_u8` isn't matched by either of them
    _ => ...,
}
// help: use an inclusive range instead: `0_u8..=10_u8`
```

More precisely: for any exclusive range `lo..hi`, if `hi+1` is matched by another range but `hi` isn't, we suggest writing an inclusive range `lo..=hi` instead. We also catch `lo..T::MAX`.
2024-03-09 03:49:01 +00:00
..
rustc
rustc_abi Rollup merge of #121382 - nnethercote:rework-untranslatable_diagnostic-lint, r=davidtwco 2024-03-06 22:02:46 +01:00
rustc_arena rename ptr::invalid -> ptr::without_provenance 2024-02-21 20:15:52 +01:00
rustc_ast Rollup merge of #119365 - nbdd0121:asm-goto, r=Amanieu 2024-03-08 08:19:17 +01:00
rustc_ast_ir Move visitor utils to rustc_ast_ir 2024-03-05 12:38:03 -05:00
rustc_ast_lowering Rollup merge of #121563 - Jarcho:use_cf, r=petrochenkov 2024-03-08 13:22:26 +01:00
rustc_ast_passes Rollup merge of #122004 - fmease:astvalidator-min-fix, r=compiler-errors 2024-03-07 18:32:47 +01:00
rustc_ast_pretty Rollup merge of #119365 - nbdd0121:asm-goto, r=Amanieu 2024-03-08 08:19:17 +01:00
rustc_attr Rewrite the untranslatable_diagnostic lint. 2024-03-06 14:19:01 +11:00
rustc_baked_icu_data
rustc_borrowck Rollup merge of #121563 - Jarcho:use_cf, r=petrochenkov 2024-03-08 13:22:26 +01:00
rustc_builtin_macros Rollup merge of #121563 - Jarcho:use_cf, r=petrochenkov 2024-03-08 13:22:26 +01:00
rustc_codegen_cranelift Merge commit '54cbb6e7531f95e086d5c3dd0d5e73bfbe3545ba' into sync_cg_clif-2024-03-08 2024-03-08 20:41:29 +00:00
rustc_codegen_gcc Rollup merge of #119365 - nbdd0121:asm-goto, r=Amanieu 2024-03-08 08:19:17 +01:00
rustc_codegen_llvm Rollup merge of #122198 - beetrees:no-llvm-14, r=cuviper 2024-03-08 21:02:04 +01:00
rustc_codegen_ssa Rollup merge of #122164 - beetrees:uefi-argv-align, r=workingjubilee 2024-03-08 21:02:01 +01:00
rustc_const_eval Rollup merge of #122076 - WaffleLapkin:mplace-args, r=RalfJung 2024-03-08 21:02:00 +01:00
rustc_data_structures Rollup merge of #120976 - matthiaskrgr:constify_TL_statics, r=lcnr 2024-03-04 22:16:30 +01:00
rustc_driver
rustc_driver_impl Rollup merge of #121194 - beetrees:rustc-raw-args, r=petrochenkov 2024-03-08 13:22:25 +01:00
rustc_error_codes Improve error message for opaque captures 2024-03-08 19:08:13 +00:00
rustc_error_messages Rename SubdiagnosticMessage as SubdiagMessage. 2024-03-05 12:14:49 +11:00
rustc_errors Rollup merge of #121382 - nnethercote:rework-untranslatable_diagnostic-lint, r=davidtwco 2024-03-06 22:02:46 +01:00
rustc_expand Rollup merge of #121382 - nnethercote:rework-untranslatable_diagnostic-lint, r=davidtwco 2024-03-06 22:02:46 +01:00
rustc_feature Rollup merge of #119365 - nbdd0121:asm-goto, r=Amanieu 2024-03-08 08:19:17 +01:00
rustc_fluent_macro Rename SubdiagnosticMessage as SubdiagMessage. 2024-03-05 12:14:49 +11:00
rustc_fs_util Invert diagnostic lints. 2024-02-06 13:12:33 +11:00
rustc_graphviz Invert diagnostic lints. 2024-02-06 13:12:33 +11:00
rustc_hir Rollup merge of #122103 - compiler-errors:taits-capture-everything, r=oli-obk 2024-03-08 08:19:20 +01:00
rustc_hir_analysis Rollup merge of #122172 - compiler-errors:rpitit-collect-ice, r=fmease 2024-03-08 21:02:03 +01:00
rustc_hir_pretty Add asm label support to AST and HIR 2024-02-24 18:49:39 +00:00
rustc_hir_typeck Auto merge of #122190 - matthiaskrgr:rollup-9ol4y30, r=matthiaskrgr 2024-03-08 17:31:00 +00:00
rustc_incremental Rename all ParseSess variables/fields/lifetimes as psess. 2024-03-05 08:11:45 +11:00
rustc_index doc: Add better explanation 2024-03-06 16:54:42 +01:00
rustc_index_macros Step all bootstrap cfgs forward 2024-02-08 07:44:34 -05:00
rustc_infer Rollup merge of #121563 - Jarcho:use_cf, r=petrochenkov 2024-03-08 13:22:26 +01:00
rustc_interface Rollup merge of #121089 - oli-obk:create_def_feed, r=petrochenkov 2024-03-07 18:32:47 +01:00
rustc_lexer Invert diagnostic lints. 2024-02-06 13:12:33 +11:00
rustc_lint Rollup merge of #122181 - chenyukang:yukang-fix-late-lint-crash, r=oli-obk 2024-03-08 13:22:28 +01:00
rustc_lint_defs Declare new lint 2024-03-09 01:13:42 +01:00
rustc_llvm Rollup merge of #122143 - durin42:llvm-19-compression-options, r=workingjubilee 2024-03-08 08:19:20 +01:00
rustc_log rustc_log: expose tracing-tree "wraparound" in an env var 2024-03-03 12:33:26 +01:00
rustc_macros Convert TypeVisitor and DefIdVisitor to use VisitorResult 2024-03-05 13:28:15 -05:00
rustc_metadata Auto merge of #122010 - oli-obk:intrinsics3.0, r=pnkfelix 2024-03-09 01:18:13 +00:00
rustc_middle Auto merge of #122010 - oli-obk:intrinsics3.0, r=pnkfelix 2024-03-09 01:18:13 +00:00
rustc_mir_build Rollup merge of #119365 - nbdd0121:asm-goto, r=Amanieu 2024-03-08 08:19:17 +01:00
rustc_mir_dataflow Rollup merge of #119365 - nbdd0121:asm-goto, r=Amanieu 2024-03-08 08:19:17 +01:00
rustc_mir_transform Auto merge of #122182 - matthiaskrgr:rollup-gzimi4c, r=matthiaskrgr 2024-03-08 09:34:05 +00:00
rustc_monomorphize Rollup merge of #119365 - nbdd0121:asm-goto, r=Amanieu 2024-03-08 08:19:17 +01:00
rustc_next_trait_solver Allow a way to add constructors for rustc_type_ir types 2024-03-04 15:39:59 +00:00
rustc_parse Rollup merge of #121563 - Jarcho:use_cf, r=petrochenkov 2024-03-08 13:22:26 +01:00
rustc_parse_format remove a couple of redundant clones 2024-02-17 12:46:18 +01:00
rustc_passes Rollup merge of #119365 - nbdd0121:asm-goto, r=Amanieu 2024-03-08 08:19:17 +01:00
rustc_pattern_analysis Lint small gaps between ranges 2024-03-09 01:14:22 +01:00
rustc_privacy Convert SpannedTypeVisitor to use VisitorResult 2024-03-05 13:30:46 -05:00
rustc_query_impl Avoid using unnecessary queries when printing the query stack in panics 2024-03-04 20:43:58 +01:00
rustc_query_system Don't panic when waiting on poisoned queries 2024-03-02 19:51:56 +01:00
rustc_resolve Rollup merge of #119365 - nbdd0121:asm-goto, r=Amanieu 2024-03-08 08:19:17 +01:00
rustc_serialize Replace NonZero::<_>::new with NonZero::new. 2024-02-15 08:09:42 +01:00
rustc_session Rollup merge of #121959 - sundeep-kokkonda:patch-2, r=davidtwco 2024-03-06 22:02:47 +01:00
rustc_smir Rollup merge of #119365 - nbdd0121:asm-goto, r=Amanieu 2024-03-08 08:19:17 +01:00
rustc_span Rollup merge of #119365 - nbdd0121:asm-goto, r=Amanieu 2024-03-08 08:19:17 +01:00
rustc_symbol_mangling Rollup merge of #121841 - tgross35:f16-f128-step2-intrinsics, r=compiler-errors 2024-03-02 20:13:24 +01:00
rustc_target Rollup merge of #122157 - dpaoliello:targetdesc, r=Nilstrieb 2024-03-08 21:02:01 +01:00
rustc_trait_selection Rollup merge of #121563 - Jarcho:use_cf, r=petrochenkov 2024-03-08 13:22:26 +01:00
rustc_traits Merge check_mod_impl_wf and check_mod_type_wf 2024-03-07 06:27:09 +00:00
rustc_transmute Convert TypeVisitor and DefIdVisitor to use VisitorResult 2024-03-05 13:28:15 -05:00
rustc_ty_utils Rename some functions to represent their generalized behavior 2024-03-08 02:10:11 +00:00
rustc_type_ir Convert TypeVisitor and DefIdVisitor to use VisitorResult 2024-03-05 13:28:15 -05:00
stable_mir Add support to new float types 2024-03-01 11:16:35 -08:00