@@ -6704,109 +6704,14 @@ pub fn foo() {}
6704
6704
6705
6705
#[ test]
6706
6706
fn hover_feature ( ) {
6707
- check (
6708
- r#"#![feature(intrinsics$0)]"# ,
6709
- expect ! [ [ r#"
6710
- *intrinsics*
6711
- ```
6712
- intrinsics
6713
- ```
6714
- ___
6715
-
6716
- # `intrinsics`
6717
-
6718
- The tracking issue for this feature is: None.
6719
-
6720
- Intrinsics are rarely intended to be stable directly, but are usually
6721
- exported in some sort of stable manner. Prefer using the stable interfaces to
6722
- the intrinsic directly when you can.
6723
-
6724
- ------------------------
6725
-
6726
-
6727
- ## Intrinsics with fallback logic
6728
-
6729
- Many intrinsics can be written in pure rust, albeit inefficiently or without supporting
6730
- some features that only exist on some backends. Backends can simply not implement those
6731
- intrinsics without causing any code miscompilations or failures to compile.
6732
- All intrinsic fallback bodies are automatically made cross-crate inlineable (like `#[inline]`)
6733
- by the codegen backend, but not the MIR inliner.
6734
-
6735
- ```rust
6736
- #![feature(intrinsics)]
6737
- #![allow(internal_features)]
6738
-
6739
- #[rustc_intrinsic]
6740
- const unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {}
6741
- ```
6742
-
6743
- Since these are just regular functions, it is perfectly ok to create the intrinsic twice:
6744
-
6745
- ```rust
6746
- #![feature(intrinsics)]
6747
- #![allow(internal_features)]
6748
-
6749
- #[rustc_intrinsic]
6750
- const unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {}
6751
-
6752
- mod foo {
6753
- #[rustc_intrinsic]
6754
- const unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {
6755
- panic!("noisy const dealloc")
6756
- }
6757
- }
6758
-
6759
- ```
6760
-
6761
- The behaviour on backends that override the intrinsic is exactly the same. On other
6762
- backends, the intrinsic behaviour depends on which implementation is called, just like
6763
- with any regular function.
6764
-
6765
- ## Intrinsics lowered to MIR instructions
6766
-
6767
- Various intrinsics have native MIR operations that they correspond to. Instead of requiring
6768
- backends to implement both the intrinsic and the MIR operation, the `lower_intrinsics` pass
6769
- will convert the calls to the MIR operation. Backends do not need to know about these intrinsics
6770
- at all. These intrinsics only make sense without a body, and can either be declared as a "rust-intrinsic"
6771
- or as a `#[rustc_intrinsic]`. The body is never used, as calls to the intrinsic do not exist
6772
- anymore after MIR analyses.
6773
-
6774
- ## Intrinsics without fallback logic
6775
-
6776
- These must be implemented by all backends.
6777
-
6778
- ### `#[rustc_intrinsic]` declarations
6779
-
6780
- These are written like intrinsics with fallback bodies, but the body is irrelevant.
6781
- Use `loop {}` for the body or call the intrinsic recursively and add
6782
- `#[rustc_intrinsic_must_be_overridden]` to the function to ensure that backends don't
6783
- invoke the body.
6784
-
6785
- ### Legacy extern ABI based intrinsics
6786
-
6787
- These are imported as if they were FFI functions, with the special
6788
- `rust-intrinsic` ABI. For example, if one was in a freestanding
6789
- context, but wished to be able to `transmute` between types, and
6790
- perform efficient pointer arithmetic, one would import those functions
6791
- via a declaration like
6792
-
6793
- ```rust
6794
- #![feature(intrinsics)]
6795
- #![allow(internal_features)]
6796
- # fn main() {}
6797
-
6798
- extern "rust-intrinsic" {
6799
- fn transmute<T, U>(x: T) -> U;
6800
-
6801
- fn arith_offset<T>(dst: *const T, offset: isize) -> *const T;
6802
- }
6803
- ```
6804
-
6805
- As with any other FFI functions, these are by default always `unsafe` to call.
6806
- You can add `#[rustc_safe_intrinsic]` to the intrinsic to make it safe to call.
6807
-
6808
- "# ] ] ,
6809
- )
6707
+ let ( analysis, position) = fixture:: position ( r#"#![feature(intrinsics$0)]"# ) ;
6708
+ analysis
6709
+ . hover (
6710
+ & HoverConfig { links_in_hover : true , ..HOVER_BASE_CONFIG } ,
6711
+ FileRange { file_id : position. file_id , range : TextRange :: empty ( position. offset ) } ,
6712
+ )
6713
+ . unwrap ( )
6714
+ . unwrap ( ) ;
6810
6715
}
6811
6716
6812
6717
#[ test]
0 commit comments