]> git.lizzy.rs Git - rust.git/blobdiff - src/utils.rs
Use trim_tries to extract post comment over simple trim_matches
[rust.git] / src / utils.rs
index 3dbffd6d175be3d24dcde675134b0452aa157dcd..63b238a781761d8e73f7684b445ef9df6e3a3f7b 100644 (file)
     self, Attribute, CrateSugar, MetaItem, MetaItemKind, NestedMetaItem, NestedMetaItemKind, Path,
     Visibility, VisibilityKind,
 };
-use syntax::codemap::{BytePos, Span, NO_EXPANSION};
 use syntax::ptr;
+use syntax::source_map::{BytePos, Span, NO_EXPANSION};
 
+use comment::filter_normal_code;
 use rewrite::RewriteContext;
 use shape::Shape;
 
@@ -82,8 +83,8 @@ pub fn format_visibility(context: &RewriteContext, vis: &Visibility) -> Cow<'sta
 }
 
 #[inline]
-pub fn format_asyncness(asyncness: ast::IsAsync) -> &'static str {
-    match asyncness {
+pub fn format_async(is_async: ast::IsAsync) -> &'static str {
+    match is_async {
         ast::IsAsync::Async { .. } => "async ",
         ast::IsAsync::NotAsync => "",
     }
@@ -326,7 +327,7 @@ macro_rules! out_of_file_lines_range {
         !$self.config.file_lines().is_all() && !$self
             .config
             .file_lines()
-            .intersects(&$self.codemap.lookup_line_range($span))
+            .intersects(&$self.source_map.lookup_line_range($span))
     };
 }
 
@@ -350,7 +351,7 @@ macro_rules! skip_out_of_file_lines_range_visitor {
 // Wraps String in an Option. Returns Some when the string adheres to the
 // Rewrite constraints defined for the Rewrite trait and None otherwise.
 pub fn wrap_str(s: String, max_width: usize, shape: Shape) -> Option<String> {
-    if is_valid_str(&s, max_width, shape) {
+    if is_valid_str(&filter_normal_code(&s), max_width, shape) {
         Some(s)
     } else {
         None