@@ -25,19 +25,19 @@ declare_lint! {
2525 /// since they inflict a lot of safety requirement. Unfortunately, it's possible
2626 /// to take a reference to a dereference of a raw pointer implicitly, which inflicts
2727 /// the usual reference requirements without you even knowing that.
28- ///
28+ ///
2929 /// If you are sure, you can soundly take a reference, then you can take it explicitly:
3030 /// ```rust
3131 /// unsafe fn fun(ptr: *mut [u8]) -> *mut [u8] {
3232 /// addr_of_mut!((&mut *ptr)[..16])
3333 /// }
3434 /// ```
35- ///
35+ ///
3636 /// Otherwise try to find an alternative way to achive your goals that work only with
3737 /// raw pointers:
3838 /// ```rust
3939 /// #![feature(slice_ptr_get)]
40- ///
40+ ///
4141 /// unsafe fn fun(ptr: *mut [u8]) -> *mut [u8] {
4242 /// ptr.get_unchecked_mut(..16)
4343 /// }
@@ -54,7 +54,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitUnsafeAutorefs {
5454 let typeck = cx. typeck_results ( ) ;
5555 let adjustments_table = typeck. adjustments ( ) ;
5656
57- if let Some ( adjustments) = adjustments_table. get ( expr. hir_id )
57+ if let Some ( adjustments) = adjustments_table. get ( expr. hir_id )
5858 && let [ adjustment] = & * * adjustments
5959 // An auto-borrow
6060 && let Adjust :: Borrow ( AutoBorrow :: Ref ( _, mutbl) ) = adjustment. kind
@@ -64,17 +64,17 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitUnsafeAutorefs {
6464 && typeck. expr_ty ( dereferenced) . is_unsafe_ptr ( )
6565 {
6666 let mutbl = hir:: Mutability :: prefix_str ( & mutbl. into ( ) ) ;
67-
67+
6868 let msg = "implicit auto-ref creates a reference to a dereference of a raw pointer" ;
6969 cx. struct_span_lint ( IMPLICIT_UNSAFE_AUTOREFS , expr. span , msg, |lint| {
7070 lint
7171 . note ( "creating a reference requires the pointer to be valid and imposes aliasing requirements" )
7272 . 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" ,
7474 vec ! [
7575 ( expr. span. shrink_to_lo( ) , format!( "(&{mutbl}" ) ) ,
7676 ( expr. span. shrink_to_hi( ) , ")" . to_owned( ) )
77- ] ,
77+ ] ,
7878 Applicability :: MaybeIncorrect
7979 )
8080 } )
0 commit comments