Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide/src/hover/tests.rs')
| -rw-r--r-- | crates/ide/src/hover/tests.rs | 122 |
1 files changed, 115 insertions, 7 deletions
diff --git a/crates/ide/src/hover/tests.rs b/crates/ide/src/hover/tests.rs index 20d07bf991..5036770fec 100644 --- a/crates/ide/src/hover/tests.rs +++ b/crates/ide/src/hover/tests.rs @@ -5310,6 +5310,71 @@ const FOO$0: f64 = expf64(1.2); ``` "#]], ); + // check `f32` isn't double rounded via `f64` + check( + r#" +/// This is a doc +const FOO$0: f32 = 1.9999999403953552_f32; +"#, + expect![[r#" + *FOO* + + ```rust + test + ``` + + ```rust + const FOO: f32 = 1.9999999 + ``` + + --- + + This is a doc + "#]], + ); + // Check `f16` and `f128` + check( + r#" +/// This is a doc +const FOO$0: f16 = -1.0f16; +"#, + expect![[r#" + *FOO* + + ```rust + test + ``` + + ```rust + const FOO: f16 = -1.0 + ``` + + --- + + This is a doc + "#]], + ); + check( + r#" +/// This is a doc +const FOO$0: f128 = -1.0f128; +"#, + expect![[r#" + *FOO* + + ```rust + test + ``` + + ```rust + const FOO: f128 = -1.0 + ``` + + --- + + This is a doc + "#]], + ); } #[test] @@ -6138,7 +6203,7 @@ fn hover_feature() { by the codegen backend, but not the MIR inliner. ```rust - #![feature(rustc_attrs, effects)] + #![feature(rustc_attrs)] #![allow(internal_features)] #[rustc_intrinsic] @@ -6148,7 +6213,7 @@ fn hover_feature() { Since these are just regular functions, it is perfectly ok to create the intrinsic twice: ```rust - #![feature(rustc_attrs, effects)] + #![feature(rustc_attrs)] #![allow(internal_features)] #[rustc_intrinsic] @@ -6172,12 +6237,23 @@ fn hover_feature() { Various intrinsics have native MIR operations that they correspond to. Instead of requiring backends to implement both the intrinsic and the MIR operation, the `lower_intrinsics` pass will convert the calls to the MIR operation. Backends do not need to know about these intrinsics - at all. + at all. These intrinsics only make sense without a body, and can either be declared as a "rust-intrinsic" + or as a `#[rustc_intrinsic]`. The body is never used, as calls to the intrinsic do not exist + anymore after MIR analyses. ## Intrinsics without fallback logic These must be implemented by all backends. + ### `#[rustc_intrinsic]` declarations + + These are written like intrinsics with fallback bodies, but the body is irrelevant. + Use `loop {}` for the body or call the intrinsic recursively and add + `#[rustc_intrinsic_must_be_overridden]` to the function to ensure that backends don't + invoke the body. + + ### Legacy extern ABI based intrinsics + These are imported as if they were FFI functions, with the special `rust-intrinsic` ABI. For example, if one was in a freestanding context, but wished to be able to `transmute` between types, and @@ -8013,6 +8089,22 @@ fn main() { check( r#" fn main() { + $01.0f16; +} +"#, + expect![[r#" + *1.0f16* + ```rust + f16 + ``` + ___ + + value of literal: 1 (bits: 0x3C00) + "#]], + ); + check( + r#" +fn main() { $01.0f32; } "#, @@ -8029,6 +8121,22 @@ fn main() { check( r#" fn main() { + $01.0f128; +} +"#, + expect![[r#" + *1.0f128* + ```rust + f128 + ``` + ___ + + value of literal: 1 (bits: 0x3FFF0000000000000000000000000000) + "#]], + ); + check( + r#" +fn main() { $0134e12; } "#, @@ -8357,8 +8465,8 @@ impl Iterator for S { file_id: FileId( 1, ), - full_range: 7791..7999, - focus_range: 7856..7862, + full_range: 7800..8008, + focus_range: 7865..7871, name: "Future", kind: Trait, container_name: "future", @@ -8371,8 +8479,8 @@ impl Iterator for S { file_id: FileId( 1, ), - full_range: 8629..9095, - focus_range: 8673..8681, + full_range: 8638..9104, + focus_range: 8682..8690, name: "Iterator", kind: Trait, container_name: "iterator", |