fn suggest_mut_for_immutable(&self, pty: &hir::Ty) -> Option<String> {
        // Check wether the argument is an immutable reference
        if let hir::TyRptr(opt_lifetime, hir::MutTy {
            mutbl: hir::Mutability::MutImmutable,
            ref ty
        }) = pty.node {
            // Account for existing lifetimes when generating the message
            if let Some(lifetime) = opt_lifetime {
                if let Ok(snippet) = self.tcx.sess.codemap().span_to_snippet(ty.span) {
                    if let Ok(lifetime_snippet) = self.tcx.sess.codemap()
                        .span_to_snippet(lifetime.span) {
                            return Some(format!("use `&{} mut {}` here to make mutable",
                                                lifetime_snippet,
                                                snippet));
                    }
                }
            } else if let Ok(snippet) = self.tcx.sess.codemap().span_to_snippet(pty.span) {
                if snippet.starts_with("&") {
                    return Some(format!("use `{}` here to make mutable",
                                        snippet.replace("&", "&mut ")));
                }
            } else {
                bug!("couldn't find a snippet for span: {:?}", pty.span);
            }
        }
        None
    }
/// Given a type, if it is an immutable reference, return a suggestion to make it mutable
Given a type, if it is an immutable reference, return a suggestion to make it mutable
Given a type if it is an immutable reference return a suggestion to make it mutable
fn suggest_mut_for_immutable(&self, pty: &hir::Ty) -> Option<String> {
        // Check wether the argument is an immutable reference
        if let hir::TyRptr(opt_lifetime, hir::MutTy {
            mutbl: hir::Mutability::MutImmutable,
            ref ty
        }) = pty.node {
            // Account for existing lifetimes when generating the message
            if let Some(lifetime) = opt_lifetime {
                if let Ok(snippet) = self.tcx.sess.codemap().span_to_snippet(ty.span) {
                    if let Ok(lifetime_snippet) = self.tcx.sess.codemap()
                        .span_to_snippet(lifetime.span) {
                            return Some(format!("use `&{} mut {}` here to make mutable",
                                                lifetime_snippet,
                                                snippet));
                    }
                }
            } else if let Ok(snippet) = self.tcx.sess.codemap().span_to_snippet(pty.span) {
                if snippet.starts_with("&") {
                    return Some(format!("use `{}` here to make mutable",
                                        snippet.replace("&", "&mut ")));
                }
            } else {
                bug!("couldn't find a snippet for span: {:?}", pty.span);
            }
        }
        None
    }
fn suggest_mut_for_immutable ( & self , pty : & hir :: Ty ) -> Option < String > { // Check wether the argument is an immutable reference if let hir :: TyRptr ( opt_lifetime , hir :: MutTy { mutbl : hir :: Mutability :: MutImmutable , ref ty } ) = pty . node { // Account for existing lifetimes when generating the message if let Some ( lifetime ) = opt_lifetime { if let Ok ( snippet ) = self . tcx . sess . codemap ( ) . span_to_snippet ( ty . span ) { if let Ok ( lifetime_snippet ) = self . tcx . sess . codemap ( ) . span_to_snippet ( lifetime . span ) { return Some ( format ! ( " " lifetime_snippet snippet ) ) ; } } } else if let Ok ( snippet ) = self . tcx . sess . codemap ( ) . span_to_snippet ( pty . span ) { if snippet . starts_with ( " " ) { return Some ( format ! ( " " snippet replace ( " " " " ) ) ) ; } } else { bug ! ( " " pty span ) ; } } None }
Given a type, if it is an immutable reference, return a suggestion to make it mutable
Given a type if it is an immutable reference return a suggestion to make it mutable
&self
pty
&hir::Ty