@@ -6882,109 +6882,14 @@ pub fn foo() {}
6882
6882
6883
6883
#[ test]
6884
6884
fn hover_feature ( ) {
6885
- check (
6886
- r#"#![feature(intrinsics$0)]"# ,
6887
- expect ! [ [ r#"
6888
- *intrinsics*
6889
- ```
6890
- intrinsics
6891
- ```
6892
- ___
6893
-
6894
- # `intrinsics`
6895
-
6896
- The tracking issue for this feature is: None.
6897
-
6898
- Intrinsics are rarely intended to be stable directly, but are usually
6899
- exported in some sort of stable manner. Prefer using the stable interfaces to
6900
- the intrinsic directly when you can.
6901
-
6902
- ------------------------
6903
-
6904
-
6905
- ## Intrinsics with fallback logic
6906
-
6907
- Many intrinsics can be written in pure rust, albeit inefficiently or without supporting
6908
- some features that only exist on some backends. Backends can simply not implement those
6909
- intrinsics without causing any code miscompilations or failures to compile.
6910
- All intrinsic fallback bodies are automatically made cross-crate inlineable (like `#[inline]`)
6911
- by the codegen backend, but not the MIR inliner.
6912
-
6913
- ```rust
6914
- #![feature(intrinsics)]
6915
- #![allow(internal_features)]
6916
-
6917
- #[rustc_intrinsic]
6918
- const unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {}
6919
- ```
6920
-
6921
- Since these are just regular functions, it is perfectly ok to create the intrinsic twice:
6922
-
6923
- ```rust
6924
- #![feature(intrinsics)]
6925
- #![allow(internal_features)]
6926
-
6927
- #[rustc_intrinsic]
6928
- const unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {}
6929
-
6930
- mod foo {
6931
- #[rustc_intrinsic]
6932
- const unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {
6933
- panic!("noisy const dealloc")
6934
- }
6935
- }
6936
-
6937
- ```
6938
-
6939
- The behaviour on backends that override the intrinsic is exactly the same. On other
6940
- backends, the intrinsic behaviour depends on which implementation is called, just like
6941
- with any regular function.
6942
-
6943
- ## Intrinsics lowered to MIR instructions
6944
-
6945
- Various intrinsics have native MIR operations that they correspond to. Instead of requiring
6946
- backends to implement both the intrinsic and the MIR operation, the `lower_intrinsics` pass
6947
- will convert the calls to the MIR operation. Backends do not need to know about these intrinsics
6948
- at all. These intrinsics only make sense without a body, and can either be declared as a "rust-intrinsic"
6949
- or as a `#[rustc_intrinsic]`. The body is never used, as calls to the intrinsic do not exist
6950
- anymore after MIR analyses.
6951
-
6952
- ## Intrinsics without fallback logic
6953
-
6954
- These must be implemented by all backends.
6955
-
6956
- ### `#[rustc_intrinsic]` declarations
6957
-
6958
- These are written like intrinsics with fallback bodies, but the body is irrelevant.
6959
- Use `loop {}` for the body or call the intrinsic recursively and add
6960
- `#[rustc_intrinsic_must_be_overridden]` to the function to ensure that backends don't
6961
- invoke the body.
6962
-
6963
- ### Legacy extern ABI based intrinsics
6964
-
6965
- These are imported as if they were FFI functions, with the special
6966
- `rust-intrinsic` ABI. For example, if one was in a freestanding
6967
- context, but wished to be able to `transmute` between types, and
6968
- perform efficient pointer arithmetic, one would import those functions
6969
- via a declaration like
6970
-
6971
- ```rust
6972
- #![feature(intrinsics)]
6973
- #![allow(internal_features)]
6974
- # fn main() {}
6975
-
6976
- extern "rust-intrinsic" {
6977
- fn transmute<T, U>(x: T) -> U;
6978
-
6979
- fn arith_offset<T>(dst: *const T, offset: isize) -> *const T;
6980
- }
6981
- ```
6982
-
6983
- As with any other FFI functions, these are by default always `unsafe` to call.
6984
- You can add `#[rustc_safe_intrinsic]` to the intrinsic to make it safe to call.
6985
-
6986
- "# ] ] ,
6987
- )
6885
+ let ( analysis, position) = fixture:: position ( r#"#![feature(intrinsics$0)]"# ) ;
6886
+ analysis
6887
+ . hover (
6888
+ & HoverConfig { links_in_hover : true , ..HOVER_BASE_CONFIG } ,
6889
+ FileRange { file_id : position. file_id , range : TextRange :: empty ( position. offset ) } ,
6890
+ )
6891
+ . unwrap ( )
6892
+ . unwrap ( ) ;
6988
6893
}
6989
6894
6990
6895
#[ test]
0 commit comments