@@ -635,7 +635,12 @@ fn adjustment_hints(
635
635
expr : & ast:: Expr ,
636
636
) -> Option < ( ) > {
637
637
if config. adjustment_hints == AdjustmentHints :: Never {
638
- // return None;
638
+ return None ;
639
+ }
640
+
641
+ if let ast:: Expr :: ParenExpr ( _) = expr {
642
+ // These inherit from the inner expression which would result in duplicate hints
643
+ return None ;
639
644
}
640
645
641
646
let parent = expr. syntax ( ) . parent ( ) . and_then ( ast:: Expr :: cast) ;
@@ -2909,48 +2914,6 @@ impl () {
2909
2914
) ;
2910
2915
}
2911
2916
2912
- #[ test]
2913
- fn hints_implicit_reborrow ( ) {
2914
- check_with_config (
2915
- InlayHintsConfig {
2916
- adjustment_hints : AdjustmentHints :: Always ,
2917
- parameter_hints : true ,
2918
- ..DISABLED_CONFIG
2919
- } ,
2920
- r#"
2921
- fn __() {
2922
- let unique = &mut ();
2923
- let r_mov = unique;
2924
- let foo: &mut _ = unique;
2925
- //^^^^^^ &mut *
2926
- ref_mut_id(unique);
2927
- //^^^^^^ mut_ref
2928
- //^^^^^^ &mut *
2929
- let shared = ref_id(unique);
2930
- //^^^^^^ shared_ref
2931
- //^^^^^^ &*
2932
- let mov = shared;
2933
- let r_mov: &_ = shared;
2934
- ref_id(shared);
2935
- //^^^^^^ shared_ref
2936
-
2937
- identity(unique);
2938
- identity(shared);
2939
- }
2940
- fn identity<T>(t: T) -> T {
2941
- t
2942
- }
2943
- fn ref_mut_id(mut_ref: &mut ()) -> &mut () {
2944
- mut_ref
2945
- //^^^^^^^ &mut *
2946
- }
2947
- fn ref_id(shared_ref: &()) -> &() {
2948
- shared_ref
2949
- }
2950
- "# ,
2951
- ) ;
2952
- }
2953
-
2954
2917
#[ test]
2955
2918
fn hints_binding_modes ( ) {
2956
2919
check_with_config (
@@ -3058,4 +3021,76 @@ fn f() {
3058
3021
"# ,
3059
3022
) ;
3060
3023
}
3024
+
3025
+ #[ test]
3026
+ fn adjustment_hints ( ) {
3027
+ check_with_config (
3028
+ InlayHintsConfig { adjustment_hints : AdjustmentHints :: Always , ..DISABLED_CONFIG } ,
3029
+ r#"
3030
+ //- minicore: coerce_unsized
3031
+ fn main() {
3032
+ let _: u32 = loop {};
3033
+ //^^^^^^^<never-to-any>
3034
+ let _: &u32 = &mut 0;
3035
+ //^^^^^^&
3036
+ //^^^^^^*
3037
+ let _: &mut u32 = &mut 0;
3038
+ //^^^^^^&mut $
3039
+ //^^^^^^*
3040
+ let _: *const u32 = &mut 0;
3041
+ //^^^^^^&raw const $
3042
+ //^^^^^^*
3043
+ let _: *mut u32 = &mut 0;
3044
+ //^^^^^^&raw mut $
3045
+ //^^^^^^*
3046
+ let _: fn() = main;
3047
+ //^^^^<fn-item-to-fn-pointer>
3048
+ let _: unsafe fn() = main;
3049
+ //^^^^<safe-fn-pointer-to-unsafe-fn-pointer>
3050
+ //^^^^<fn-item-to-fn-pointer>
3051
+ let _: unsafe fn() = main as fn();
3052
+ //^^^^^^^^^^^^<safe-fn-pointer-to-unsafe-fn-pointer>
3053
+ let _: fn() = || {};
3054
+ //^^^^^<closure-to-fn-pointer>
3055
+ let _: unsafe fn() = || {};
3056
+ //^^^^^<closure-to-unsafe-fn-pointer>
3057
+ let _: *const u32 = &mut 0u32 as *mut u32;
3058
+ //^^^^^^^^^^^^^^^^^^^^^<mut-ptr-to-const-ptr>
3059
+ let _: &mut [_] = &mut [0; 0];
3060
+ //^^^^^^^^^^^<unsize>
3061
+ //^^^^^^^^^^^&mut $
3062
+ //^^^^^^^^^^^*
3063
+
3064
+ Struct.consume();
3065
+ Struct.by_ref();
3066
+ //^^^^^^(
3067
+ //^^^^^^&
3068
+ //^^^^^^)
3069
+ Struct.by_ref_mut();
3070
+ //^^^^^^(
3071
+ //^^^^^^&mut $
3072
+ //^^^^^^)
3073
+
3074
+ (&Struct).consume();
3075
+ //^^^^^^^*
3076
+ (&Struct).by_ref();
3077
+
3078
+ (&mut Struct).consume();
3079
+ //^^^^^^^^^^^*
3080
+ (&mut Struct).by_ref();
3081
+ //^^^^^^^^^^^&
3082
+ //^^^^^^^^^^^*
3083
+ (&mut Struct).by_ref_mut();
3084
+ }
3085
+
3086
+ #[derive(Copy, Clone)]
3087
+ struct Struct;
3088
+ impl Struct {
3089
+ fn consume(self) {}
3090
+ fn by_ref(&self) {}
3091
+ fn by_ref_mut(&mut self) {}
3092
+ }
3093
+ "# ,
3094
+ )
3095
+ }
3061
3096
}
0 commit comments