From 8b3856b1bc1c23969e5d8983f25cf85698a5c2b1 Mon Sep 17 00:00:00 2001 From: Oliver 'ker' Schneider <git-spam-no-reply9815368754983@oli-obk.de> Date: Tue, 9 Feb 2016 18:01:08 +0100 Subject: [PATCH] [breaking-change] don't glob export ast::StrStyle variants --- src/librustc_front/print/pprust.rs | 12 ++++++------ src/libsyntax/ast.rs | 5 ++--- src/libsyntax/attr.rs | 4 ++-- src/libsyntax/ext/build.rs | 2 +- src/libsyntax/ext/quote.rs | 2 +- src/libsyntax/parse/parser.rs | 10 ++++++---- src/libsyntax/print/pprust.rs | 16 ++++++++-------- src/libsyntax_ext/deriving/debug.rs | 5 ++--- 8 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/librustc_front/print/pprust.rs b/src/librustc_front/print/pprust.rs index 091352bb8f8..cc43e3ae56e 100644 --- a/src/librustc_front/print/pprust.rs +++ b/src/librustc_front/print/pprust.rs @@ -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(()) })); } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 79b465a02b8..713f5c9a7be 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -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 diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 53ab4e1b6d5..cc5f30e2184 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -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, diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 0f1f92f3fb8..161443c6eb0 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -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> { diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index d8099ff004b..57db1347021 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -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) } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index a13c79bdda1..afab3a0711b 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -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 }; diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 78a4bbd962f..bb3bc2d78e3 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -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(()) })); } diff --git a/src/libsyntax_ext/deriving/debug.rs b/src/libsyntax_ext/deriving/debug.rs index 6e769cd3810..858066cb626 100644 --- a/src/libsyntax_ext/deriving/debug.rs +++ b/src/libsyntax_ext/deriving/debug.rs @@ -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());