1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 use core::unicode::property::Pattern_White_Space;
15 pub mod borrowck_errors;
16 pub mod elaborate_drops;
22 pub(crate) mod pretty;
24 pub mod collect_writes;
26 pub use self::alignment::is_disaligned;
27 pub use self::pretty::{dump_enabled, dump_mir, write_mir_pretty, PassWhere};
28 pub use self::graphviz::{write_mir_graphviz};
29 pub use self::graphviz::write_node_label as write_graphviz_node_label;
31 /// If possible, suggest replacing `ref` with `ref mut`.
32 pub fn suggest_ref_mut<'cx, 'gcx, 'tcx>(
33 tcx: ty::TyCtxt<'cx, 'gcx, 'tcx>,
35 ) -> Option<(String)> {
36 let hi_src = tcx.sess.codemap().span_to_snippet(binding_span).unwrap();
37 if hi_src.starts_with("ref")
38 && hi_src["ref".len()..].starts_with(Pattern_White_Space)
40 let replacement = format!("ref mut{}", &hi_src["ref".len()..]);