Unnamed repository; edit this file 'description' to name the repository.
Add test
| -rw-r--r-- | crates/ide-completion/src/render.rs | 19 | ||||
| -rw-r--r-- | crates/test-utils/src/minicore.rs | 27 |
2 files changed, 46 insertions, 0 deletions
diff --git a/crates/ide-completion/src/render.rs b/crates/ide-completion/src/render.rs index 7e6e76541e..607ca6ff54 100644 --- a/crates/ide-completion/src/render.rs +++ b/crates/ide-completion/src/render.rs @@ -3648,6 +3648,25 @@ fn f() { } #[test] + /// Issue: https://github.com/rust-lang/rust-analyzer/issues/18554 + fn float_consts_relevance() { + check_relevance( + r#" +//- minicore: float_consts +fn main() { + let x = f32::INF$0 +} +"#, + expect![[r#" + ct INFINITY f32 [type_could_unify+requires_import] + ct NEG_INFINITY f32 [type_could_unify+requires_import] + ct INFINITY pub const INFINITY: f32 [] + ct NEG_INFINITY pub const NEG_INFINITY: f32 [] + "#]], + ); + } + + #[test] fn completes_struct_with_raw_identifier() { check_edit( "type", diff --git a/crates/test-utils/src/minicore.rs b/crates/test-utils/src/minicore.rs index 86fb080732..85bd821ebb 100644 --- a/crates/test-utils/src/minicore.rs +++ b/crates/test-utils/src/minicore.rs @@ -33,6 +33,7 @@ //! env: option //! eq: sized //! error: fmt +//! float_consts: //! fmt: option, result, transmute, coerce_unsized, copy, clone, derive //! fmt_before_1_93_0: fmt //! fmt_before_1_89_0: fmt_before_1_93_0 @@ -2173,6 +2174,32 @@ pub mod error { } // endregion:error +// region:float_consts +impl f32 { + pub const INFINITY: f32 = 0.0; + pub const NEG_INFINITY: f32 = -0.0; +} + +impl f64 { + pub const INFINITY: f64 = 0.0; + pub const NEG_INFINITY: f64 = -0.0; +} + +pub mod f32 { + #[deprecated] + pub const INFINITY: f32 = 0.0; + #[deprecated] + pub const NEG_INFINITY: f32 = -0.0; +} + +pub mod f64 { + #[deprecated] + pub const INFINITY: f64 = 0.0; + #[deprecated] + pub const NEG_INFINITY: f64 = -0.0; +} +// endregion:float_consts + // region:column #[rustc_builtin_macro] #[macro_export] |