]> git.lizzy.rs Git - rust.git/blobdiff - src/utils.rs
Merge pull request #2138 from topecongiro/comments-around-trait-bounds
[rust.git] / src / utils.rs
index 3106df9ed8b2ff8f703085b491c5ed2fba7f4d0d..999ba9f67b9544f4a713e704ef10bd17f4f170b3 100644 (file)
 use std::borrow::Cow;
 
 use syntax::{abi, ptr};
-use syntax::ast::{self, Attribute, MetaItem, MetaItemKind, NestedMetaItem, NestedMetaItemKind,
-                  Path, Visibility};
+use syntax::ast::{self, Attribute, CrateSugar, MetaItem, MetaItemKind, NestedMetaItem,
+                  NestedMetaItemKind, Path, Visibility};
 use syntax::codemap::{BytePos, Span, NO_EXPANSION};
 
 use rewrite::RewriteContext;
 use shape::Shape;
 
 // When we get scoped annotations, we should have rustfmt::skip.
-const SKIP_ANNOTATION: &'static str = "rustfmt_skip";
+const SKIP_ANNOTATION: &str = "rustfmt_skip";
 
 // Computes the length of a string's last line, minus offset.
 pub fn extra_offset(text: &str, shape: Shape) -> usize {
@@ -37,7 +37,8 @@ pub fn format_visibility(vis: &Visibility) -> Cow<'static, str> {
     match *vis {
         Visibility::Public => Cow::from("pub "),
         Visibility::Inherited => Cow::from(""),
-        Visibility::Crate(_) => Cow::from("pub(crate) "),
+        Visibility::Crate(_, CrateSugar::PubCrate) => Cow::from("pub(crate) "),
+        Visibility::Crate(_, CrateSugar::JustCrate) => Cow::from("crate "),
         Visibility::Restricted { ref path, .. } => {
             let Path { ref segments, .. } = **path;
             let mut segments_iter = segments.iter().map(|seg| seg.identifier.name.to_string());
@@ -297,7 +298,6 @@ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
         impl<'de> ::serde::de::Deserialize<'de> for $e {
             fn deserialize<D>(d: D) -> Result<Self, D::Error>
                     where D: ::serde::Deserializer<'de> {
-                use std::ascii::AsciiExt;
                 use serde::de::{Error, Visitor};
                 use std::marker::PhantomData;
                 use std::fmt;
@@ -327,7 +327,6 @@ impl ::std::str::FromStr for $e {
             type Err = &'static str;
 
             fn from_str(s: &str) -> Result<Self, Self::Err> {
-                use std::ascii::AsciiExt;
                 $(
                     if stringify!($x).eq_ignore_ascii_case(s) {
                         return Ok($e::$x);