Skip to content

Commit

Permalink
[breaking-change] don't glob export ast::StrStyle variants
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Feb 11, 2016
1 parent d844bfb commit 8b3856b
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 28 deletions.
12 changes: 6 additions & 6 deletions src/librustc_front/print/pprust.rs
Expand Up @@ -652,7 +652,7 @@ impl<'a> State<'a> {
if let Some(p) = *optional_path {
let val = p.as_str();
if val.contains("-") {
try!(self.print_string(&val, ast::CookedStr));
try!(self.print_string(&val, ast::StrStyle::Cooked));
} else {
try!(self.print_name(p));
}
Expand Down Expand Up @@ -1510,9 +1510,9 @@ impl<'a> State<'a> {
try!(self.commasep(Inconsistent, &a.outputs, |s, out| {
match out.constraint.slice_shift_char() {
Some(('=', operand)) if out.is_rw => {
try!(s.print_string(&format!("+{}", operand), ast::CookedStr))
try!(s.print_string(&format!("+{}", operand), ast::StrStyle::Cooked))
}
_ => try!(s.print_string(&out.constraint, ast::CookedStr)),
_ => try!(s.print_string(&out.constraint, ast::StrStyle::Cooked)),
}
try!(s.popen());
try!(s.print_expr(&*out.expr));
Expand All @@ -1523,7 +1523,7 @@ impl<'a> State<'a> {
try!(self.word_space(":"));

try!(self.commasep(Inconsistent, &a.inputs, |s, &(ref co, ref o)| {
try!(s.print_string(&co, ast::CookedStr));
try!(s.print_string(&co, ast::StrStyle::Cooked));
try!(s.popen());
try!(s.print_expr(&**o));
try!(s.pclose());
Expand All @@ -1533,7 +1533,7 @@ impl<'a> State<'a> {
try!(self.word_space(":"));

try!(self.commasep(Inconsistent, &a.clobbers, |s, co| {
try!(s.print_string(&co, ast::CookedStr));
try!(s.print_string(&co, ast::StrStyle::Cooked));
Ok(())
}));

Expand All @@ -1552,7 +1552,7 @@ impl<'a> State<'a> {
try!(space(&mut self.s));
try!(self.word_space(":"));
try!(self.commasep(Inconsistent, &*options, |s, &co| {
try!(s.print_string(co, ast::CookedStr));
try!(s.print_string(co, ast::StrStyle::Cooked));
Ok(())
}));
}
Expand Down
5 changes: 2 additions & 3 deletions src/libsyntax/ast.rs
Expand Up @@ -12,7 +12,6 @@

pub use self::Pat_::*;
pub use self::PathListItem_::*;
pub use self::StrStyle::*;
pub use self::StructFieldKind::*;
pub use self::TyParamBound::*;
pub use self::UnsafeSource::*;
Expand Down Expand Up @@ -1246,11 +1245,11 @@ pub struct Mac_ {
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
pub enum StrStyle {
/// A regular string, like `"foo"`
CookedStr,
Cooked,
/// A raw string, like `r##"foo"##`
///
/// The uint is the number of `#` symbols used
RawStr(usize)
Raw(usize)
}

/// A literal
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/attr.rs
Expand Up @@ -173,7 +173,7 @@ impl AttributeMethods for Attribute {

pub fn mk_name_value_item_str(name: InternedString, value: InternedString)
-> P<MetaItem> {
let value_lit = dummy_spanned(ast::LitKind::Str(value, ast::CookedStr));
let value_lit = dummy_spanned(ast::LitKind::Str(value, ast::StrStyle::Cooked));
mk_name_value_item(name, value_lit)
}

Expand Down Expand Up @@ -225,7 +225,7 @@ pub fn mk_sugared_doc_attr(id: AttrId, text: InternedString, lo: BytePos,
hi: BytePos)
-> Attribute {
let style = doc_comment_style(&text);
let lit = spanned(lo, hi, ast::LitKind::Str(text, ast::CookedStr));
let lit = spanned(lo, hi, ast::LitKind::Str(text, ast::StrStyle::Cooked));
let attr = Attribute_ {
id: id,
style: style,
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/ext/build.rs
Expand Up @@ -715,7 +715,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
self.expr_addr_of(sp, self.expr_vec(sp, exprs))
}
fn expr_str(&self, sp: Span, s: InternedString) -> P<ast::Expr> {
self.expr_lit(sp, ast::LitKind::Str(s, ast::CookedStr))
self.expr_lit(sp, ast::LitKind::Str(s, ast::StrStyle::Cooked))
}

fn expr_cast(&self, sp: Span, expr: P<ast::Expr>, ty: P<ast::Ty>) -> P<ast::Expr> {
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/ext/quote.rs
Expand Up @@ -219,7 +219,7 @@ pub mod rt {
impl ToTokens for str {
fn to_tokens(&self, cx: &ExtCtxt) -> Vec<TokenTree> {
let lit = ast::LitKind::Str(
token::intern_and_get_ident(self), ast::CookedStr);
token::intern_and_get_ident(self), ast::StrStyle::Cooked);
dummy_spanned(lit).to_tokens(cx)
}
}
Expand Down
10 changes: 6 additions & 4 deletions src/libsyntax/parse/parser.rs
Expand Up @@ -1544,13 +1544,13 @@ impl<'a> Parser<'a> {
token::Str_(s) => {
(true,
LitKind::Str(token::intern_and_get_ident(&parse::str_lit(&s.as_str())),
ast::CookedStr))
ast::StrStyle::Cooked))
}
token::StrRaw(s, n) => {
(true,
LitKind::Str(
token::intern_and_get_ident(&parse::raw_str_lit(&s.as_str())),
ast::RawStr(n)))
ast::StrStyle::Raw(n)))
}
token::ByteStr(i) =>
(true, LitKind::ByteStr(parse::byte_str_lit(&i.as_str()))),
Expand Down Expand Up @@ -5966,10 +5966,12 @@ impl<'a> Parser<'a> {
Option<ast::Name>)> {
let ret = match self.token {
token::Literal(token::Str_(s), suf) => {
(self.id_to_interned_str(ast::Ident::with_empty_ctxt(s)), ast::CookedStr, suf)
let s = self.id_to_interned_str(ast::Ident::with_empty_ctxt(s));
(s, ast::StrStyle::Cooked, suf)
}
token::Literal(token::StrRaw(s, n), suf) => {
(self.id_to_interned_str(ast::Ident::with_empty_ctxt(s)), ast::RawStr(n), suf)
let s = self.id_to_interned_str(ast::Ident::with_empty_ctxt(s));
(s, ast::StrStyle::Raw(n), suf)
}
_ => return None
};
Expand Down
16 changes: 8 additions & 8 deletions src/libsyntax/print/pprust.rs
Expand Up @@ -682,10 +682,10 @@ pub trait PrintState<'a> {
fn print_string(&mut self, st: &str,
style: ast::StrStyle) -> io::Result<()> {
let st = match style {
ast::CookedStr => {
ast::StrStyle::Cooked => {
(format!("\"{}\"", st.escape_default()))
}
ast::RawStr(n) => {
ast::StrStyle::Raw(n) => {
(format!("r{delim}\"{string}\"{delim}",
delim=repeat("#", n),
string=st))
Expand Down Expand Up @@ -1123,7 +1123,7 @@ impl<'a> State<'a> {
if let Some(p) = *optional_path {
let val = p.as_str();
if val.contains("-") {
try!(self.print_string(&val, ast::CookedStr));
try!(self.print_string(&val, ast::StrStyle::Cooked));
} else {
try!(self.print_name(p));
}
Expand Down Expand Up @@ -2215,9 +2215,9 @@ impl<'a> State<'a> {
match out.constraint.slice_shift_char() {
Some(('=', operand)) if out.is_rw => {
try!(s.print_string(&format!("+{}", operand),
ast::CookedStr))
ast::StrStyle::Cooked))
}
_ => try!(s.print_string(&out.constraint, ast::CookedStr))
_ => try!(s.print_string(&out.constraint, ast::StrStyle::Cooked))
}
try!(s.popen());
try!(s.print_expr(&*out.expr));
Expand All @@ -2229,7 +2229,7 @@ impl<'a> State<'a> {

try!(self.commasep(Inconsistent, &a.inputs,
|s, &(ref co, ref o)| {
try!(s.print_string(&co, ast::CookedStr));
try!(s.print_string(&co, ast::StrStyle::Cooked));
try!(s.popen());
try!(s.print_expr(&**o));
try!(s.pclose());
Expand All @@ -2240,7 +2240,7 @@ impl<'a> State<'a> {

try!(self.commasep(Inconsistent, &a.clobbers,
|s, co| {
try!(s.print_string(&co, ast::CookedStr));
try!(s.print_string(&co, ast::StrStyle::Cooked));
Ok(())
}));

Expand All @@ -2260,7 +2260,7 @@ impl<'a> State<'a> {
try!(self.word_space(":"));
try!(self.commasep(Inconsistent, &*options,
|s, &co| {
try!(s.print_string(co, ast::CookedStr));
try!(s.print_string(co, ast::StrStyle::Cooked));
Ok(())
}));
}
Expand Down
5 changes: 2 additions & 3 deletions src/libsyntax_ext/deriving/debug.rs
Expand Up @@ -71,8 +71,7 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span,

// We want to make sure we have the expn_id set so that we can use unstable methods
let span = Span { expn_id: cx.backtrace(), .. span };
let name = cx.expr_lit(span, ast::LitKind::Str(ident.name.as_str(),
ast::StrStyle::CookedStr));
let name = cx.expr_lit(span, ast::LitKind::Str(ident.name.as_str(), ast::StrStyle::Cooked));
let builder = token::str_to_ident("builder");
let builder_expr = cx.expr_ident(span, builder.clone());

Expand Down Expand Up @@ -114,7 +113,7 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span,
for field in fields {
let name = cx.expr_lit(field.span, ast::LitKind::Str(
field.name.unwrap().name.as_str(),
ast::StrStyle::CookedStr));
ast::StrStyle::Cooked));

// Use double indirection to make sure this works for unsized types
let field = cx.expr_addr_of(field.span, field.self_.clone());
Expand Down

0 comments on commit 8b3856b

Please sign in to comment.