Auto merge of #41729 - ubsan:master, r=nrc
Delete features which are easily removed, in libsyntax
This commit is contained in:
commit
9956e81c19
6 changed files with 30 additions and 31 deletions
2
src/Cargo.lock
generated
2
src/Cargo.lock
generated
|
@ -860,8 +860,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
name = "syntax"
|
name = "syntax"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc_bitflags 0.0.0",
|
|
||||||
"rustc_data_structures 0.0.0",
|
"rustc_data_structures 0.0.0",
|
||||||
"rustc_errors 0.0.0",
|
"rustc_errors 0.0.0",
|
||||||
"serialize 0.0.0",
|
"serialize 0.0.0",
|
||||||
|
|
|
@ -11,7 +11,7 @@ crate-type = ["dylib"]
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serialize = { path = "../libserialize" }
|
serialize = { path = "../libserialize" }
|
||||||
log = "0.3"
|
log = "0.3"
|
||||||
rustc_bitflags = { path = "../librustc_bitflags" }
|
bitflags = "0.8"
|
||||||
syntax_pos = { path = "../libsyntax_pos" }
|
syntax_pos = { path = "../libsyntax_pos" }
|
||||||
rustc_errors = { path = "../librustc_errors" }
|
rustc_errors = { path = "../librustc_errors" }
|
||||||
rustc_data_structures = { path = "../librustc_data_structures" }
|
rustc_data_structures = { path = "../librustc_data_structures" }
|
||||||
|
|
|
@ -24,20 +24,15 @@
|
||||||
test(attr(deny(warnings))))]
|
test(attr(deny(warnings))))]
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
|
|
||||||
#![feature(associated_consts)]
|
|
||||||
#![feature(const_fn)]
|
|
||||||
#![feature(optin_builtin_traits)]
|
|
||||||
#![feature(rustc_private)]
|
#![feature(rustc_private)]
|
||||||
#![feature(staged_api)]
|
#![feature(staged_api)]
|
||||||
#![feature(str_escape)]
|
|
||||||
#![feature(unicode)]
|
#![feature(unicode)]
|
||||||
#![feature(rustc_diagnostic_macros)]
|
#![feature(rustc_diagnostic_macros)]
|
||||||
#![feature(specialization)]
|
|
||||||
#![feature(i128_type)]
|
#![feature(i128_type)]
|
||||||
|
|
||||||
extern crate serialize;
|
extern crate serialize;
|
||||||
#[macro_use] extern crate log;
|
#[macro_use] extern crate log;
|
||||||
#[macro_use] #[no_link] extern crate rustc_bitflags;
|
#[macro_use] extern crate bitflags;
|
||||||
extern crate std_unicode;
|
extern crate std_unicode;
|
||||||
pub extern crate rustc_errors as errors;
|
pub extern crate rustc_errors as errors;
|
||||||
extern crate syntax_pos;
|
extern crate syntax_pos;
|
||||||
|
|
|
@ -261,10 +261,14 @@ pub fn char_lit(lit: &str) -> (char, isize) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn escape_default(s: &str) -> String {
|
||||||
|
s.chars().map(char::escape_default).flat_map(|x| x).collect()
|
||||||
|
}
|
||||||
|
|
||||||
/// Parse a string representing a string literal into its final form. Does
|
/// Parse a string representing a string literal into its final form. Does
|
||||||
/// unescaping.
|
/// unescaping.
|
||||||
pub fn str_lit(lit: &str) -> String {
|
pub fn str_lit(lit: &str) -> String {
|
||||||
debug!("parse_str_lit: given {}", lit.escape_default());
|
debug!("parse_str_lit: given {}", escape_default(lit));
|
||||||
let mut res = String::with_capacity(lit.len());
|
let mut res = String::with_capacity(lit.len());
|
||||||
|
|
||||||
// FIXME #8372: This could be a for-loop if it didn't borrow the iterator
|
// FIXME #8372: This could be a for-loop if it didn't borrow the iterator
|
||||||
|
@ -339,7 +343,7 @@ pub fn str_lit(lit: &str) -> String {
|
||||||
/// Parse a string representing a raw string literal into its final form. The
|
/// Parse a string representing a raw string literal into its final form. The
|
||||||
/// only operation this does is convert embedded CRLF into a single LF.
|
/// only operation this does is convert embedded CRLF into a single LF.
|
||||||
pub fn raw_str_lit(lit: &str) -> String {
|
pub fn raw_str_lit(lit: &str) -> String {
|
||||||
debug!("raw_str_lit: given {}", lit.escape_default());
|
debug!("raw_str_lit: given {}", escape_default(lit));
|
||||||
let mut res = String::with_capacity(lit.len());
|
let mut res = String::with_capacity(lit.len());
|
||||||
|
|
||||||
// FIXME #8372: This could be a for-loop if it didn't borrow the iterator
|
// FIXME #8372: This could be a for-loop if it didn't borrow the iterator
|
||||||
|
|
|
@ -64,7 +64,7 @@ use std::path::{self, Path, PathBuf};
|
||||||
use std::slice;
|
use std::slice;
|
||||||
|
|
||||||
bitflags! {
|
bitflags! {
|
||||||
flags Restrictions: u8 {
|
pub flags Restrictions: u8 {
|
||||||
const RESTRICTION_STMT_EXPR = 1 << 0,
|
const RESTRICTION_STMT_EXPR = 1 << 0,
|
||||||
const RESTRICTION_NO_STRUCT_LITERAL = 1 << 1,
|
const RESTRICTION_NO_STRUCT_LITERAL = 1 << 1,
|
||||||
}
|
}
|
||||||
|
@ -2291,7 +2291,7 @@ impl<'a> Parser<'a> {
|
||||||
let e = if self.token.can_begin_expr()
|
let e = if self.token.can_begin_expr()
|
||||||
&& !(self.token == token::OpenDelim(token::Brace)
|
&& !(self.token == token::OpenDelim(token::Brace)
|
||||||
&& self.restrictions.contains(
|
&& self.restrictions.contains(
|
||||||
Restrictions::RESTRICTION_NO_STRUCT_LITERAL)) {
|
RESTRICTION_NO_STRUCT_LITERAL)) {
|
||||||
Some(self.parse_expr()?)
|
Some(self.parse_expr()?)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -2318,7 +2318,7 @@ impl<'a> Parser<'a> {
|
||||||
// This is a struct literal, unless we're prohibited
|
// This is a struct literal, unless we're prohibited
|
||||||
// from parsing struct literals here.
|
// from parsing struct literals here.
|
||||||
let prohibited = self.restrictions.contains(
|
let prohibited = self.restrictions.contains(
|
||||||
Restrictions::RESTRICTION_NO_STRUCT_LITERAL
|
RESTRICTION_NO_STRUCT_LITERAL
|
||||||
);
|
);
|
||||||
if !prohibited {
|
if !prohibited {
|
||||||
return self.parse_struct_expr(lo, pth, attrs);
|
return self.parse_struct_expr(lo, pth, attrs);
|
||||||
|
@ -2735,7 +2735,7 @@ impl<'a> Parser<'a> {
|
||||||
token::Ident(..) if self.token.is_keyword(keywords::In) => {
|
token::Ident(..) if self.token.is_keyword(keywords::In) => {
|
||||||
self.bump();
|
self.bump();
|
||||||
let place = self.parse_expr_res(
|
let place = self.parse_expr_res(
|
||||||
Restrictions::RESTRICTION_NO_STRUCT_LITERAL,
|
RESTRICTION_NO_STRUCT_LITERAL,
|
||||||
None,
|
None,
|
||||||
)?;
|
)?;
|
||||||
let blk = self.parse_block()?;
|
let blk = self.parse_block()?;
|
||||||
|
@ -2798,7 +2798,7 @@ impl<'a> Parser<'a> {
|
||||||
|
|
||||||
let cur_op_span = self.span;
|
let cur_op_span = self.span;
|
||||||
let restrictions = if op.is_assign_like() {
|
let restrictions = if op.is_assign_like() {
|
||||||
self.restrictions & Restrictions::RESTRICTION_NO_STRUCT_LITERAL
|
self.restrictions & RESTRICTION_NO_STRUCT_LITERAL
|
||||||
} else {
|
} else {
|
||||||
self.restrictions
|
self.restrictions
|
||||||
};
|
};
|
||||||
|
@ -2848,13 +2848,13 @@ impl<'a> Parser<'a> {
|
||||||
|
|
||||||
let rhs = match op.fixity() {
|
let rhs = match op.fixity() {
|
||||||
Fixity::Right => self.with_res(
|
Fixity::Right => self.with_res(
|
||||||
restrictions - Restrictions::RESTRICTION_STMT_EXPR,
|
restrictions - RESTRICTION_STMT_EXPR,
|
||||||
|this| {
|
|this| {
|
||||||
this.parse_assoc_expr_with(op.precedence(),
|
this.parse_assoc_expr_with(op.precedence(),
|
||||||
LhsExpr::NotYetParsed)
|
LhsExpr::NotYetParsed)
|
||||||
}),
|
}),
|
||||||
Fixity::Left => self.with_res(
|
Fixity::Left => self.with_res(
|
||||||
restrictions - Restrictions::RESTRICTION_STMT_EXPR,
|
restrictions - RESTRICTION_STMT_EXPR,
|
||||||
|this| {
|
|this| {
|
||||||
this.parse_assoc_expr_with(op.precedence() + 1,
|
this.parse_assoc_expr_with(op.precedence() + 1,
|
||||||
LhsExpr::NotYetParsed)
|
LhsExpr::NotYetParsed)
|
||||||
|
@ -2862,7 +2862,7 @@ impl<'a> Parser<'a> {
|
||||||
// We currently have no non-associative operators that are not handled above by
|
// We currently have no non-associative operators that are not handled above by
|
||||||
// the special cases. The code is here only for future convenience.
|
// the special cases. The code is here only for future convenience.
|
||||||
Fixity::None => self.with_res(
|
Fixity::None => self.with_res(
|
||||||
restrictions - Restrictions::RESTRICTION_STMT_EXPR,
|
restrictions - RESTRICTION_STMT_EXPR,
|
||||||
|this| {
|
|this| {
|
||||||
this.parse_assoc_expr_with(op.precedence() + 1,
|
this.parse_assoc_expr_with(op.precedence() + 1,
|
||||||
LhsExpr::NotYetParsed)
|
LhsExpr::NotYetParsed)
|
||||||
|
@ -2972,7 +2972,7 @@ impl<'a> Parser<'a> {
|
||||||
if self.token.can_begin_expr() {
|
if self.token.can_begin_expr() {
|
||||||
// parse `for i in 1.. { }` as infinite loop, not as `for i in (1..{})`.
|
// parse `for i in 1.. { }` as infinite loop, not as `for i in (1..{})`.
|
||||||
if self.token == token::OpenDelim(token::Brace) {
|
if self.token == token::OpenDelim(token::Brace) {
|
||||||
return !self.restrictions.contains(Restrictions::RESTRICTION_NO_STRUCT_LITERAL);
|
return !self.restrictions.contains(RESTRICTION_NO_STRUCT_LITERAL);
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
|
@ -2986,7 +2986,7 @@ impl<'a> Parser<'a> {
|
||||||
return self.parse_if_let_expr(attrs);
|
return self.parse_if_let_expr(attrs);
|
||||||
}
|
}
|
||||||
let lo = self.prev_span;
|
let lo = self.prev_span;
|
||||||
let cond = self.parse_expr_res(Restrictions::RESTRICTION_NO_STRUCT_LITERAL, None)?;
|
let cond = self.parse_expr_res(RESTRICTION_NO_STRUCT_LITERAL, None)?;
|
||||||
let thn = self.parse_block()?;
|
let thn = self.parse_block()?;
|
||||||
let mut els: Option<P<Expr>> = None;
|
let mut els: Option<P<Expr>> = None;
|
||||||
let mut hi = thn.span;
|
let mut hi = thn.span;
|
||||||
|
@ -3005,7 +3005,7 @@ impl<'a> Parser<'a> {
|
||||||
self.expect_keyword(keywords::Let)?;
|
self.expect_keyword(keywords::Let)?;
|
||||||
let pat = self.parse_pat()?;
|
let pat = self.parse_pat()?;
|
||||||
self.expect(&token::Eq)?;
|
self.expect(&token::Eq)?;
|
||||||
let expr = self.parse_expr_res(Restrictions::RESTRICTION_NO_STRUCT_LITERAL, None)?;
|
let expr = self.parse_expr_res(RESTRICTION_NO_STRUCT_LITERAL, None)?;
|
||||||
let thn = self.parse_block()?;
|
let thn = self.parse_block()?;
|
||||||
let (hi, els) = if self.eat_keyword(keywords::Else) {
|
let (hi, els) = if self.eat_keyword(keywords::Else) {
|
||||||
let expr = self.parse_else_expr()?;
|
let expr = self.parse_else_expr()?;
|
||||||
|
@ -3059,7 +3059,7 @@ impl<'a> Parser<'a> {
|
||||||
|
|
||||||
let pat = self.parse_pat()?;
|
let pat = self.parse_pat()?;
|
||||||
self.expect_keyword(keywords::In)?;
|
self.expect_keyword(keywords::In)?;
|
||||||
let expr = self.parse_expr_res(Restrictions::RESTRICTION_NO_STRUCT_LITERAL, None)?;
|
let expr = self.parse_expr_res(RESTRICTION_NO_STRUCT_LITERAL, None)?;
|
||||||
let (iattrs, loop_block) = self.parse_inner_attrs_and_block()?;
|
let (iattrs, loop_block) = self.parse_inner_attrs_and_block()?;
|
||||||
attrs.extend(iattrs);
|
attrs.extend(iattrs);
|
||||||
|
|
||||||
|
@ -3074,7 +3074,7 @@ impl<'a> Parser<'a> {
|
||||||
if self.token.is_keyword(keywords::Let) {
|
if self.token.is_keyword(keywords::Let) {
|
||||||
return self.parse_while_let_expr(opt_ident, span_lo, attrs);
|
return self.parse_while_let_expr(opt_ident, span_lo, attrs);
|
||||||
}
|
}
|
||||||
let cond = self.parse_expr_res(Restrictions::RESTRICTION_NO_STRUCT_LITERAL, None)?;
|
let cond = self.parse_expr_res(RESTRICTION_NO_STRUCT_LITERAL, None)?;
|
||||||
let (iattrs, body) = self.parse_inner_attrs_and_block()?;
|
let (iattrs, body) = self.parse_inner_attrs_and_block()?;
|
||||||
attrs.extend(iattrs);
|
attrs.extend(iattrs);
|
||||||
let span = span_lo.to(body.span);
|
let span = span_lo.to(body.span);
|
||||||
|
@ -3088,7 +3088,7 @@ impl<'a> Parser<'a> {
|
||||||
self.expect_keyword(keywords::Let)?;
|
self.expect_keyword(keywords::Let)?;
|
||||||
let pat = self.parse_pat()?;
|
let pat = self.parse_pat()?;
|
||||||
self.expect(&token::Eq)?;
|
self.expect(&token::Eq)?;
|
||||||
let expr = self.parse_expr_res(Restrictions::RESTRICTION_NO_STRUCT_LITERAL, None)?;
|
let expr = self.parse_expr_res(RESTRICTION_NO_STRUCT_LITERAL, None)?;
|
||||||
let (iattrs, body) = self.parse_inner_attrs_and_block()?;
|
let (iattrs, body) = self.parse_inner_attrs_and_block()?;
|
||||||
attrs.extend(iattrs);
|
attrs.extend(iattrs);
|
||||||
let span = span_lo.to(body.span);
|
let span = span_lo.to(body.span);
|
||||||
|
@ -3118,7 +3118,7 @@ impl<'a> Parser<'a> {
|
||||||
fn parse_match_expr(&mut self, mut attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> {
|
fn parse_match_expr(&mut self, mut attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> {
|
||||||
let match_span = self.prev_span;
|
let match_span = self.prev_span;
|
||||||
let lo = self.prev_span;
|
let lo = self.prev_span;
|
||||||
let discriminant = self.parse_expr_res(Restrictions::RESTRICTION_NO_STRUCT_LITERAL,
|
let discriminant = self.parse_expr_res(RESTRICTION_NO_STRUCT_LITERAL,
|
||||||
None)?;
|
None)?;
|
||||||
if let Err(mut e) = self.expect(&token::OpenDelim(token::Brace)) {
|
if let Err(mut e) = self.expect(&token::OpenDelim(token::Brace)) {
|
||||||
if self.token == token::Token::Semi {
|
if self.token == token::Token::Semi {
|
||||||
|
@ -3159,7 +3159,7 @@ impl<'a> Parser<'a> {
|
||||||
guard = Some(self.parse_expr()?);
|
guard = Some(self.parse_expr()?);
|
||||||
}
|
}
|
||||||
self.expect(&token::FatArrow)?;
|
self.expect(&token::FatArrow)?;
|
||||||
let expr = self.parse_expr_res(Restrictions::RESTRICTION_STMT_EXPR, None)?;
|
let expr = self.parse_expr_res(RESTRICTION_STMT_EXPR, None)?;
|
||||||
|
|
||||||
let require_comma =
|
let require_comma =
|
||||||
!classify::expr_is_simple_block(&expr)
|
!classify::expr_is_simple_block(&expr)
|
||||||
|
@ -3740,7 +3740,7 @@ impl<'a> Parser<'a> {
|
||||||
self.look_ahead(2, |t| *t == token::OpenDelim(token::Brace)) &&
|
self.look_ahead(2, |t| *t == token::OpenDelim(token::Brace)) &&
|
||||||
|
|
||||||
// prevent `while catch {} {}`, `if catch {} {} else {}`, etc.
|
// prevent `while catch {} {}`, `if catch {} {} else {}`, etc.
|
||||||
!self.restrictions.contains(Restrictions::RESTRICTION_NO_STRUCT_LITERAL)
|
!self.restrictions.contains(RESTRICTION_NO_STRUCT_LITERAL)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_union_item(&self) -> bool {
|
fn is_union_item(&self) -> bool {
|
||||||
|
@ -3812,7 +3812,7 @@ impl<'a> Parser<'a> {
|
||||||
self.mk_expr(lo.to(hi), ExprKind::Path(None, pth), ThinVec::new())
|
self.mk_expr(lo.to(hi), ExprKind::Path(None, pth), ThinVec::new())
|
||||||
};
|
};
|
||||||
|
|
||||||
let expr = self.with_res(Restrictions::RESTRICTION_STMT_EXPR, |this| {
|
let expr = self.with_res(RESTRICTION_STMT_EXPR, |this| {
|
||||||
let expr = this.parse_dot_or_call_expr_with(expr, lo, attrs.into())?;
|
let expr = this.parse_dot_or_call_expr_with(expr, lo, attrs.into())?;
|
||||||
this.parse_assoc_expr_with(0, LhsExpr::AlreadyParsed(expr))
|
this.parse_assoc_expr_with(0, LhsExpr::AlreadyParsed(expr))
|
||||||
})?;
|
})?;
|
||||||
|
@ -3952,7 +3952,7 @@ impl<'a> Parser<'a> {
|
||||||
|
|
||||||
// Remainder are line-expr stmts.
|
// Remainder are line-expr stmts.
|
||||||
let e = self.parse_expr_res(
|
let e = self.parse_expr_res(
|
||||||
Restrictions::RESTRICTION_STMT_EXPR, Some(attrs.into()))?;
|
RESTRICTION_STMT_EXPR, Some(attrs.into()))?;
|
||||||
Stmt {
|
Stmt {
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
span: lo.to(e.span),
|
span: lo.to(e.span),
|
||||||
|
@ -3965,7 +3965,7 @@ impl<'a> Parser<'a> {
|
||||||
|
|
||||||
/// Is this expression a successfully-parsed statement?
|
/// Is this expression a successfully-parsed statement?
|
||||||
fn expr_is_complete(&mut self, e: &Expr) -> bool {
|
fn expr_is_complete(&mut self, e: &Expr) -> bool {
|
||||||
self.restrictions.contains(Restrictions::RESTRICTION_STMT_EXPR) &&
|
self.restrictions.contains(RESTRICTION_STMT_EXPR) &&
|
||||||
!classify::expr_requires_semi_to_be_stmt(e)
|
!classify::expr_requires_semi_to_be_stmt(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -677,7 +677,7 @@ pub trait PrintState<'a> {
|
||||||
style: ast::StrStyle) -> io::Result<()> {
|
style: ast::StrStyle) -> io::Result<()> {
|
||||||
let st = match style {
|
let st = match style {
|
||||||
ast::StrStyle::Cooked => {
|
ast::StrStyle::Cooked => {
|
||||||
(format!("\"{}\"", st.escape_default()))
|
(format!("\"{}\"", parse::escape_default(st)))
|
||||||
}
|
}
|
||||||
ast::StrStyle::Raw(n) => {
|
ast::StrStyle::Raw(n) => {
|
||||||
(format!("r{delim}\"{string}\"{delim}",
|
(format!("r{delim}\"{string}\"{delim}",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue