Closed
Description
Code
const _: Range = 0..1;
Current output
error[E0412]: cannot find type `Range` in this scope
--> <anon>:1:10
|
1 | const _: Range = 0..1;
| ^^^^^ not found in this scope
|
help: consider importing one of these structs
|
1 + use std::collections::btree_map::Range;
|
1 + use std::collections::btree_set::Range;
|
1 + use std::range::Range;
|
1 + use std::range::legacy::Range;
|
error: aborting due to 1 previous error
Desired output
error[E0412]: cannot find type `Range` in this scope
--> <anon>:1:10
|
1 | const _: Range = 0..1;
| ^^^^^ not found in this scope
|
help: consider importing one of these structs
|
1 + use std::ops::Range;
|
1 + use std::collections::btree_map::Range;
|
1 + use std::collections::btree_set::Range;
|
1 + use std::range::Range;
|
error: aborting due to 1 previous error
Rationale and extra context
It should suggests importing the stable ops::Range
; and ideally should points that range::Range
is unstable, and not suggest legacy::Range
(a unstable pub reexport of a stable type) as the reexported type is available.
I.e. importing one of those types will yield an error:
error[E0658]: use of unstable library feature `new_range_api`
--> <anon>:1:5
|
1 | use std::range::Range;
| ^^^^^^^^^^^^^^^^^
|
= note: see issue #125687 <https://github.com/rust-lang/rust/issues/125687> for more information
error[E0658]: use of unstable library feature `new_range_api`
--> <anon>:2:5
|
2 | use std::range::legacy::Range;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #125687 <https://github.com/rust-lang/rust/issues/125687> for more information
Rust Version
$ rustc -Vv
rustc 1.86.0 (05f9846f8 2025-03-31)
binary: rustc
commit-hash: 05f9846f893b09a1be1fc8560e33fc3c815cfecb
commit-date: 2025-03-31
host: x86_64-unknown-linux-gnu
release: 1.86.0
LLVM version: 19.1.7