@@ -25,19 +25,19 @@ declare_lint! {
25
25
/// since they inflict a lot of safety requirement. Unfortunately, it's possible
26
26
/// to take a reference to a dereference of a raw pointer implicitly, which inflicts
27
27
/// the usual reference requirements without you even knowing that.
28
- ///
28
+ ///
29
29
/// If you are sure, you can soundly take a reference, then you can take it explicitly:
30
30
/// ```rust
31
31
/// unsafe fn fun(ptr: *mut [u8]) -> *mut [u8] {
32
32
/// addr_of_mut!((&mut *ptr)[..16])
33
33
/// }
34
34
/// ```
35
- ///
35
+ ///
36
36
/// Otherwise try to find an alternative way to achive your goals that work only with
37
37
/// raw pointers:
38
38
/// ```rust
39
39
/// #![feature(slice_ptr_get)]
40
- ///
40
+ ///
41
41
/// unsafe fn fun(ptr: *mut [u8]) -> *mut [u8] {
42
42
/// ptr.get_unchecked_mut(..16)
43
43
/// }
@@ -54,7 +54,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitUnsafeAutorefs {
54
54
let typeck = cx. typeck_results ( ) ;
55
55
let adjustments_table = typeck. adjustments ( ) ;
56
56
57
- if let Some ( adjustments) = adjustments_table. get ( expr. hir_id )
57
+ if let Some ( adjustments) = adjustments_table. get ( expr. hir_id )
58
58
&& let [ adjustment] = & * * adjustments
59
59
// An auto-borrow
60
60
&& let Adjust :: Borrow ( AutoBorrow :: Ref ( _, mutbl) ) = adjustment. kind
@@ -64,17 +64,17 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitUnsafeAutorefs {
64
64
&& typeck. expr_ty ( dereferenced) . is_unsafe_ptr ( )
65
65
{
66
66
let mutbl = hir:: Mutability :: prefix_str ( & mutbl. into ( ) ) ;
67
-
67
+
68
68
let msg = "implicit auto-ref creates a reference to a dereference of a raw pointer" ;
69
69
cx. struct_span_lint ( IMPLICIT_UNSAFE_AUTOREFS , expr. span , msg, |lint| {
70
70
lint
71
71
. note ( "creating a reference requires the pointer to be valid and imposes aliasing requirements" )
72
72
. multipart_suggestion (
73
- "try using a raw pointer method instead; or if this reference is intentional, make it explicit" ,
73
+ "try using a raw pointer method instead; or if this reference is intentional, make it explicit" ,
74
74
vec ! [
75
75
( expr. span. shrink_to_lo( ) , format!( "(&{mutbl}" ) ) ,
76
76
( expr. span. shrink_to_hi( ) , ")" . to_owned( ) )
77
- ] ,
77
+ ] ,
78
78
Applicability :: MaybeIncorrect
79
79
)
80
80
} )
0 commit comments