Empowering everyone to build reliable and efficient software.
Go to file
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
.github Promote OpenHarmony targets to tier 2 2024-03-02 18:11:25 +00:00
.reuse update license reference 2024-02-16 12:10:49 +01:00
compiler Auto merge of #118879 - Nadrieril:lint-range-gap, r=estebank 2024-03-09 03:49:01 +00:00
library Rollup merge of #121201 - RalfJung:align_offset_contract, r=cuviper 2024-03-08 21:01:59 +01:00
LICENSES Add missing CC-BY-SA-4.0. 2023-11-27 11:03:53 +00:00
src Auto merge of #118879 - Nadrieril:lint-range-gap, r=estebank 2024-03-09 03:49:01 +00:00
tests Auto merge of #118879 - Nadrieril:lint-range-gap, r=estebank 2024-03-09 03:49:01 +00:00
.editorconfig
.git-blame-ignore-revs Ignore compiletest test directive migration commits 2024-02-22 18:55:02 +00:00
.gitattributes
.gitignore
.gitmodules Update to LLVM 18 2024-02-13 10:33:40 +01:00
.mailmap
Cargo.lock Add arm64ec-pc-windows-msvc target 2024-03-06 17:49:37 -08:00
Cargo.toml Add supporting infrastructure for run-make V2 tests 2024-02-29 16:30:38 +00:00
CODE_OF_CONDUCT.md
config.example.toml Rollup merge of #121976 - lu-zero:bootstrap-cache, r=onur-ozkan 2024-03-06 22:41:53 +01:00
configure Ensure ./configure works when configure.py path contains spaces 2024-02-16 18:57:22 +00:00
CONTRIBUTING.md
COPYRIGHT
INSTALL.md Update INSTALL.md instructions for MinGW 2024-02-16 11:19:39 +00:00
LICENSE-APACHE
LICENSE-MIT
README.md
RELEASES.md Remove duplicate release note 2024-02-09 12:31:32 -05:00
rust-bors.toml
rustfmt.toml Remove exception for deleted file from rustfmt.toml 2024-03-08 20:46:33 +00:00
triagebot.toml Restore the standard library review rotation to its former glory 2024-02-29 08:58:58 +00:00
x
x.ps1
x.py

The Rust Programming Language

Rust Community

This is the main source code repository for Rust. It contains the compiler, standard library, and documentation.

Note: this README is for users rather than contributors. If you wish to contribute to the compiler, you should read CONTRIBUTING.md instead.

Table of Contents

Quick Start

Read "Installation" from The Book.

Installing from Source

If you really want to install from source (though this is not recommended), see INSTALL.md.

Getting Help

See https://www.rust-lang.org/community for a list of chat platforms and forums.

Contributing

See CONTRIBUTING.md.

License

Rust is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses.

See LICENSE-APACHE, LICENSE-MIT, and COPYRIGHT for details.

Trademark

The Rust Foundation owns and protects the Rust and Cargo trademarks and logos (the "Rust Trademarks").

If you want to use these names or brands, please read the media guide.

Third-party logos may be subject to third-party copyrights and trademarks. See Licenses for details.