Skip to content

Commit 8b3856b

Browse files
committed
[breaking-change] don't glob export ast::StrStyle variants
1 parent d844bfb commit 8b3856b

File tree

8 files changed

+28
-28
lines changed

8 files changed

+28
-28
lines changed

src/librustc_front/print/pprust.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ impl<'a> State<'a> {
652652
if let Some(p) = *optional_path {
653653
let val = p.as_str();
654654
if val.contains("-") {
655-
try!(self.print_string(&val, ast::CookedStr));
655+
try!(self.print_string(&val, ast::StrStyle::Cooked));
656656
} else {
657657
try!(self.print_name(p));
658658
}
@@ -1510,9 +1510,9 @@ impl<'a> State<'a> {
15101510
try!(self.commasep(Inconsistent, &a.outputs, |s, out| {
15111511
match out.constraint.slice_shift_char() {
15121512
Some(('=', operand)) if out.is_rw => {
1513-
try!(s.print_string(&format!("+{}", operand), ast::CookedStr))
1513+
try!(s.print_string(&format!("+{}", operand), ast::StrStyle::Cooked))
15141514
}
1515-
_ => try!(s.print_string(&out.constraint, ast::CookedStr)),
1515+
_ => try!(s.print_string(&out.constraint, ast::StrStyle::Cooked)),
15161516
}
15171517
try!(s.popen());
15181518
try!(s.print_expr(&*out.expr));
@@ -1523,7 +1523,7 @@ impl<'a> State<'a> {
15231523
try!(self.word_space(":"));
15241524

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

15351535
try!(self.commasep(Inconsistent, &a.clobbers, |s, co| {
1536-
try!(s.print_string(&co, ast::CookedStr));
1536+
try!(s.print_string(&co, ast::StrStyle::Cooked));
15371537
Ok(())
15381538
}));
15391539

@@ -1552,7 +1552,7 @@ impl<'a> State<'a> {
15521552
try!(space(&mut self.s));
15531553
try!(self.word_space(":"));
15541554
try!(self.commasep(Inconsistent, &*options, |s, &co| {
1555-
try!(s.print_string(co, ast::CookedStr));
1555+
try!(s.print_string(co, ast::StrStyle::Cooked));
15561556
Ok(())
15571557
}));
15581558
}

src/libsyntax/ast.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
pub use self::Pat_::*;
1414
pub use self::PathListItem_::*;
15-
pub use self::StrStyle::*;
1615
pub use self::StructFieldKind::*;
1716
pub use self::TyParamBound::*;
1817
pub use self::UnsafeSource::*;
@@ -1246,11 +1245,11 @@ pub struct Mac_ {
12461245
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
12471246
pub enum StrStyle {
12481247
/// A regular string, like `"foo"`
1249-
CookedStr,
1248+
Cooked,
12501249
/// A raw string, like `r##"foo"##`
12511250
///
12521251
/// The uint is the number of `#` symbols used
1253-
RawStr(usize)
1252+
Raw(usize)
12541253
}
12551254

12561255
/// A literal

src/libsyntax/attr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ impl AttributeMethods for Attribute {
173173

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

@@ -225,7 +225,7 @@ pub fn mk_sugared_doc_attr(id: AttrId, text: InternedString, lo: BytePos,
225225
hi: BytePos)
226226
-> Attribute {
227227
let style = doc_comment_style(&text);
228-
let lit = spanned(lo, hi, ast::LitKind::Str(text, ast::CookedStr));
228+
let lit = spanned(lo, hi, ast::LitKind::Str(text, ast::StrStyle::Cooked));
229229
let attr = Attribute_ {
230230
id: id,
231231
style: style,

src/libsyntax/ext/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
715715
self.expr_addr_of(sp, self.expr_vec(sp, exprs))
716716
}
717717
fn expr_str(&self, sp: Span, s: InternedString) -> P<ast::Expr> {
718-
self.expr_lit(sp, ast::LitKind::Str(s, ast::CookedStr))
718+
self.expr_lit(sp, ast::LitKind::Str(s, ast::StrStyle::Cooked))
719719
}
720720

721721
fn expr_cast(&self, sp: Span, expr: P<ast::Expr>, ty: P<ast::Ty>) -> P<ast::Expr> {

src/libsyntax/ext/quote.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ pub mod rt {
219219
impl ToTokens for str {
220220
fn to_tokens(&self, cx: &ExtCtxt) -> Vec<TokenTree> {
221221
let lit = ast::LitKind::Str(
222-
token::intern_and_get_ident(self), ast::CookedStr);
222+
token::intern_and_get_ident(self), ast::StrStyle::Cooked);
223223
dummy_spanned(lit).to_tokens(cx)
224224
}
225225
}

src/libsyntax/parse/parser.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,13 +1544,13 @@ impl<'a> Parser<'a> {
15441544
token::Str_(s) => {
15451545
(true,
15461546
LitKind::Str(token::intern_and_get_ident(&parse::str_lit(&s.as_str())),
1547-
ast::CookedStr))
1547+
ast::StrStyle::Cooked))
15481548
}
15491549
token::StrRaw(s, n) => {
15501550
(true,
15511551
LitKind::Str(
15521552
token::intern_and_get_ident(&parse::raw_str_lit(&s.as_str())),
1553-
ast::RawStr(n)))
1553+
ast::StrStyle::Raw(n)))
15541554
}
15551555
token::ByteStr(i) =>
15561556
(true, LitKind::ByteStr(parse::byte_str_lit(&i.as_str()))),
@@ -5966,10 +5966,12 @@ impl<'a> Parser<'a> {
59665966
Option<ast::Name>)> {
59675967
let ret = match self.token {
59685968
token::Literal(token::Str_(s), suf) => {
5969-
(self.id_to_interned_str(ast::Ident::with_empty_ctxt(s)), ast::CookedStr, suf)
5969+
let s = self.id_to_interned_str(ast::Ident::with_empty_ctxt(s));
5970+
(s, ast::StrStyle::Cooked, suf)
59705971
}
59715972
token::Literal(token::StrRaw(s, n), suf) => {
5972-
(self.id_to_interned_str(ast::Ident::with_empty_ctxt(s)), ast::RawStr(n), suf)
5973+
let s = self.id_to_interned_str(ast::Ident::with_empty_ctxt(s));
5974+
(s, ast::StrStyle::Raw(n), suf)
59735975
}
59745976
_ => return None
59755977
};

src/libsyntax/print/pprust.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -682,10 +682,10 @@ pub trait PrintState<'a> {
682682
fn print_string(&mut self, st: &str,
683683
style: ast::StrStyle) -> io::Result<()> {
684684
let st = match style {
685-
ast::CookedStr => {
685+
ast::StrStyle::Cooked => {
686686
(format!("\"{}\"", st.escape_default()))
687687
}
688-
ast::RawStr(n) => {
688+
ast::StrStyle::Raw(n) => {
689689
(format!("r{delim}\"{string}\"{delim}",
690690
delim=repeat("#", n),
691691
string=st))
@@ -1123,7 +1123,7 @@ impl<'a> State<'a> {
11231123
if let Some(p) = *optional_path {
11241124
let val = p.as_str();
11251125
if val.contains("-") {
1126-
try!(self.print_string(&val, ast::CookedStr));
1126+
try!(self.print_string(&val, ast::StrStyle::Cooked));
11271127
} else {
11281128
try!(self.print_name(p));
11291129
}
@@ -2215,9 +2215,9 @@ impl<'a> State<'a> {
22152215
match out.constraint.slice_shift_char() {
22162216
Some(('=', operand)) if out.is_rw => {
22172217
try!(s.print_string(&format!("+{}", operand),
2218-
ast::CookedStr))
2218+
ast::StrStyle::Cooked))
22192219
}
2220-
_ => try!(s.print_string(&out.constraint, ast::CookedStr))
2220+
_ => try!(s.print_string(&out.constraint, ast::StrStyle::Cooked))
22212221
}
22222222
try!(s.popen());
22232223
try!(s.print_expr(&*out.expr));
@@ -2229,7 +2229,7 @@ impl<'a> State<'a> {
22292229

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

22412241
try!(self.commasep(Inconsistent, &a.clobbers,
22422242
|s, co| {
2243-
try!(s.print_string(&co, ast::CookedStr));
2243+
try!(s.print_string(&co, ast::StrStyle::Cooked));
22442244
Ok(())
22452245
}));
22462246

@@ -2260,7 +2260,7 @@ impl<'a> State<'a> {
22602260
try!(self.word_space(":"));
22612261
try!(self.commasep(Inconsistent, &*options,
22622262
|s, &co| {
2263-
try!(s.print_string(co, ast::CookedStr));
2263+
try!(s.print_string(co, ast::StrStyle::Cooked));
22642264
Ok(())
22652265
}));
22662266
}

src/libsyntax_ext/deriving/debug.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span,
7171

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

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

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

0 commit comments

Comments
 (0)