[breaking-change] don't glob export ast::StrStyle variants

This commit is contained in:
Oliver 'ker' Schneider 2016-02-09 18:01:08 +01:00 committed by Oliver Schneider
parent d844bfb196
commit 8b3856b1bc
8 changed files with 28 additions and 28 deletions

View File

@ -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));
}
@ -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));
@ -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());
@ -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(())
}));
@ -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(())
}));
}

View File

@ -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::*;
@ -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

View File

@ -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)
}
@ -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,

View File

@ -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> {

View File

@ -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)
}
}

View File

@ -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()))),
@ -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
};

View File

@ -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))
@ -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));
}
@ -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));
@ -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());
@ -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(())
}));
@ -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(())
}));
}

View File

@ -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());
@ -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());