Skip to content

Commit 378914c

Browse files
committed
Add test
1 parent e4d3b8f commit 378914c

2 files changed

Lines changed: 46 additions & 0 deletions

File tree

crates/ide-completion/src/render.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3647,6 +3647,25 @@ fn f() {
36473647
);
36483648
}
36493649

3650+
#[test]
3651+
/// Issue: https://github.com/rust-lang/rust-analyzer/issues/18554
3652+
fn float_consts_relevance() {
3653+
check_relevance(
3654+
r#"
3655+
//- minicore: float_consts
3656+
fn main() {
3657+
let x = f32::INF$0
3658+
}
3659+
"#,
3660+
expect![[r#"
3661+
ct INFINITY f32 [type_could_unify+requires_import]
3662+
ct NEG_INFINITY f32 [type_could_unify+requires_import]
3663+
ct INFINITY pub const INFINITY: f32 []
3664+
ct NEG_INFINITY pub const NEG_INFINITY: f32 []
3665+
"#]],
3666+
);
3667+
}
3668+
36503669
#[test]
36513670
fn completes_struct_with_raw_identifier() {
36523671
check_edit(

crates/test-utils/src/minicore.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
//! env: option
3434
//! eq: sized
3535
//! error: fmt
36+
//! float_consts:
3637
//! fmt: option, result, transmute, coerce_unsized, copy, clone, derive
3738
//! fmt_before_1_93_0: fmt
3839
//! fmt_before_1_89_0: fmt_before_1_93_0
@@ -2173,6 +2174,32 @@ pub mod error {
21732174
}
21742175
// endregion:error
21752176

2177+
// region:float_consts
2178+
impl f32 {
2179+
pub const INFINITY: f32 = 0.0;
2180+
pub const NEG_INFINITY: f32 = -0.0;
2181+
}
2182+
2183+
impl f64 {
2184+
pub const INFINITY: f64 = 0.0;
2185+
pub const NEG_INFINITY: f64 = -0.0;
2186+
}
2187+
2188+
pub mod f32 {
2189+
#[deprecated]
2190+
pub const INFINITY: f32 = 0.0;
2191+
#[deprecated]
2192+
pub const NEG_INFINITY: f32 = -0.0;
2193+
}
2194+
2195+
pub mod f64 {
2196+
#[deprecated]
2197+
pub const INFINITY: f64 = 0.0;
2198+
#[deprecated]
2199+
pub const NEG_INFINITY: f64 = -0.0;
2200+
}
2201+
// endregion:float_consts
2202+
21762203
// region:column
21772204
#[rustc_builtin_macro]
21782205
#[macro_export]

0 commit comments

Comments
 (0)