diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2022-06-24 16:43:44 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-24 16:43:44 +0900 |
| commit | 6580d7e784d0046ab2f8d43dac36ea0de0139978 (patch) | |
| tree | fa078fb0231faca95d7a5503914e7d41ace6543c /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | |
| parent | 0af99c99c4a662fb5a3fe2cd399de7761a1cc235 (diff) | |
| parent | 774e814b9523ee4b7cc96bac0735f185358449e5 (diff) | |
| download | rust-6580d7e784d0046ab2f8d43dac36ea0de0139978.tar.gz rust-6580d7e784d0046ab2f8d43dac36ea0de0139978.zip | |
Rollup merge of #98039 - tnballo:master, r=thomcc
Fix `panic` message for `BTreeSet`'s `range` API and document `panic` cases
Currently, the `panic` cases for [`BTreeSet`'s `range` API](https://doc.rust-lang.org/std/collections/struct.BTreeSet.html#method.range) are undocumented and produce a slightly wrong `panic` message (says `BTreeMap` instead of `BTreeSet`).
Panic case 1 code:
```rust
use std::collections::BTreeSet;
use std::ops::Bound::Excluded;
fn main() {
let mut set = BTreeSet::new();
set.insert(3);
set.insert(5);
set.insert(8);
for &elem in set.range((Excluded(&3), Excluded(&3))) {
println!("{elem}");
}
}
```
Panic case 1 message:
```
thread 'main' panicked at 'range start and end are equal and excluded in BTreeMap', /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/alloc/src/collections/btree/search.rs:105:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
Panic case 2 code:
```rust
use std::collections::BTreeSet;
use std::ops::Bound::Included;
fn main() {
let mut set = BTreeSet::new();
set.insert(3);
set.insert(5);
set.insert(8);
for &elem in set.range((Included(&8), Included(&3))) {
println!("{elem}");
}
}
```
Panic case 2:
```
thread 'main' panicked at 'range start is greater than range end in BTreeMap', /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/alloc/src/collections/btree/search.rs:110:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
This PR fixes the output messages to say `BTreeSet`, adds the relevant unit tests, and updates the documentation for the API.
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
