Auto merge of #36393 - petrochenkov:ancient, r=eddyb
Remove some obsolete code from the compiler
This commit is contained in:
commit
1265cbf4e0
10 changed files with 40 additions and 196 deletions
|
@ -67,7 +67,6 @@ pub use self::ElementKind::*;
|
||||||
pub use self::MutabilityCategory::*;
|
pub use self::MutabilityCategory::*;
|
||||||
pub use self::AliasableReason::*;
|
pub use self::AliasableReason::*;
|
||||||
pub use self::Note::*;
|
pub use self::Note::*;
|
||||||
pub use self::deref_kind::*;
|
|
||||||
|
|
||||||
use self::Aliasability::*;
|
use self::Aliasability::*;
|
||||||
|
|
||||||
|
@ -195,51 +194,6 @@ pub struct cmt_<'tcx> {
|
||||||
|
|
||||||
pub type cmt<'tcx> = Rc<cmt_<'tcx>>;
|
pub type cmt<'tcx> = Rc<cmt_<'tcx>>;
|
||||||
|
|
||||||
// We pun on *T to mean both actual deref of a ptr as well
|
|
||||||
// as accessing of components:
|
|
||||||
#[derive(Copy, Clone)]
|
|
||||||
pub enum deref_kind<'tcx> {
|
|
||||||
deref_ptr(PointerKind<'tcx>),
|
|
||||||
deref_interior(InteriorKind),
|
|
||||||
}
|
|
||||||
|
|
||||||
type DerefKindContext = Option<InteriorOffsetKind>;
|
|
||||||
|
|
||||||
// Categorizes a derefable type. Note that we include vectors and strings as
|
|
||||||
// derefable (we model an index as the combination of a deref and then a
|
|
||||||
// pointer adjustment).
|
|
||||||
fn deref_kind(t: Ty, context: DerefKindContext) -> McResult<deref_kind> {
|
|
||||||
match t.sty {
|
|
||||||
ty::TyBox(_) => {
|
|
||||||
Ok(deref_ptr(Unique))
|
|
||||||
}
|
|
||||||
|
|
||||||
ty::TyRef(r, mt) => {
|
|
||||||
let kind = ty::BorrowKind::from_mutbl(mt.mutbl);
|
|
||||||
Ok(deref_ptr(BorrowedPtr(kind, r)))
|
|
||||||
}
|
|
||||||
|
|
||||||
ty::TyRawPtr(ref mt) => {
|
|
||||||
Ok(deref_ptr(UnsafePtr(mt.mutbl)))
|
|
||||||
}
|
|
||||||
|
|
||||||
ty::TyAdt(..) => { // newtype
|
|
||||||
Ok(deref_interior(InteriorField(PositionalField(0))))
|
|
||||||
}
|
|
||||||
|
|
||||||
ty::TyArray(..) | ty::TySlice(_) => {
|
|
||||||
// no deref of indexed content without supplying InteriorOffsetKind
|
|
||||||
if let Some(context) = context {
|
|
||||||
Ok(deref_interior(InteriorElement(context, ElementKind::VecElement)))
|
|
||||||
} else {
|
|
||||||
Err(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_ => Err(()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait ast_node {
|
pub trait ast_node {
|
||||||
fn id(&self) -> ast::NodeId;
|
fn id(&self) -> ast::NodeId;
|
||||||
fn span(&self) -> Span;
|
fn span(&self) -> Span;
|
||||||
|
@ -476,7 +430,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
||||||
autoderefs,
|
autoderefs,
|
||||||
cmt);
|
cmt);
|
||||||
for deref in 1..autoderefs + 1 {
|
for deref in 1..autoderefs + 1 {
|
||||||
cmt = self.cat_deref(expr, cmt, deref, None)?;
|
cmt = self.cat_deref(expr, cmt, deref)?;
|
||||||
}
|
}
|
||||||
return Ok(cmt);
|
return Ok(cmt);
|
||||||
}
|
}
|
||||||
|
@ -488,7 +442,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
||||||
match expr.node {
|
match expr.node {
|
||||||
hir::ExprUnary(hir::UnDeref, ref e_base) => {
|
hir::ExprUnary(hir::UnDeref, ref e_base) => {
|
||||||
let base_cmt = self.cat_expr(&e_base)?;
|
let base_cmt = self.cat_expr(&e_base)?;
|
||||||
self.cat_deref(expr, base_cmt, 0, None)
|
self.cat_deref(expr, base_cmt, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
hir::ExprField(ref base, f_name) => {
|
hir::ExprField(ref base, f_name) => {
|
||||||
|
@ -507,7 +461,6 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
||||||
|
|
||||||
hir::ExprIndex(ref base, _) => {
|
hir::ExprIndex(ref base, _) => {
|
||||||
let method_call = ty::MethodCall::expr(expr.id());
|
let method_call = ty::MethodCall::expr(expr.id());
|
||||||
let context = InteriorOffsetKind::Index;
|
|
||||||
match self.infcx.node_method_ty(method_call) {
|
match self.infcx.node_method_ty(method_call) {
|
||||||
Some(method_ty) => {
|
Some(method_ty) => {
|
||||||
// If this is an index implemented by a method call, then it
|
// If this is an index implemented by a method call, then it
|
||||||
|
@ -529,10 +482,10 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
||||||
// is an rvalue. That is what we will be
|
// is an rvalue. That is what we will be
|
||||||
// dereferencing.
|
// dereferencing.
|
||||||
let base_cmt = self.cat_rvalue_node(expr.id(), expr.span(), ret_ty);
|
let base_cmt = self.cat_rvalue_node(expr.id(), expr.span(), ret_ty);
|
||||||
self.cat_deref_common(expr, base_cmt, 1, elem_ty, Some(context), true)
|
Ok(self.cat_deref_common(expr, base_cmt, 1, elem_ty, true))
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
self.cat_index(expr, self.cat_expr(&base)?, context)
|
self.cat_index(expr, self.cat_expr(&base)?, InteriorOffsetKind::Index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -907,8 +860,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
||||||
fn cat_deref<N:ast_node>(&self,
|
fn cat_deref<N:ast_node>(&self,
|
||||||
node: &N,
|
node: &N,
|
||||||
base_cmt: cmt<'tcx>,
|
base_cmt: cmt<'tcx>,
|
||||||
deref_cnt: usize,
|
deref_cnt: usize)
|
||||||
deref_context: DerefKindContext)
|
|
||||||
-> McResult<cmt<'tcx>> {
|
-> McResult<cmt<'tcx>> {
|
||||||
let method_call = ty::MethodCall {
|
let method_call = ty::MethodCall {
|
||||||
expr_id: node.id(),
|
expr_id: node.id(),
|
||||||
|
@ -930,12 +882,9 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
||||||
let base_cmt_ty = base_cmt.ty;
|
let base_cmt_ty = base_cmt.ty;
|
||||||
match base_cmt_ty.builtin_deref(true, ty::NoPreference) {
|
match base_cmt_ty.builtin_deref(true, ty::NoPreference) {
|
||||||
Some(mt) => {
|
Some(mt) => {
|
||||||
let ret = self.cat_deref_common(node, base_cmt, deref_cnt,
|
let ret = self.cat_deref_common(node, base_cmt, deref_cnt, mt.ty, false);
|
||||||
mt.ty,
|
|
||||||
deref_context,
|
|
||||||
/* implicit: */ false);
|
|
||||||
debug!("cat_deref ret {:?}", ret);
|
debug!("cat_deref ret {:?}", ret);
|
||||||
ret
|
Ok(ret)
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
debug!("Explicit deref of non-derefable type: {:?}",
|
debug!("Explicit deref of non-derefable type: {:?}",
|
||||||
|
@ -950,40 +899,29 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
||||||
base_cmt: cmt<'tcx>,
|
base_cmt: cmt<'tcx>,
|
||||||
deref_cnt: usize,
|
deref_cnt: usize,
|
||||||
deref_ty: Ty<'tcx>,
|
deref_ty: Ty<'tcx>,
|
||||||
deref_context: DerefKindContext,
|
|
||||||
implicit: bool)
|
implicit: bool)
|
||||||
-> McResult<cmt<'tcx>>
|
-> cmt<'tcx>
|
||||||
{
|
{
|
||||||
let (m, cat) = match deref_kind(base_cmt.ty, deref_context)? {
|
let ptr = match base_cmt.ty.sty {
|
||||||
deref_ptr(ptr) => {
|
ty::TyBox(..) => Unique,
|
||||||
let ptr = if implicit {
|
ty::TyRawPtr(ref mt) => UnsafePtr(mt.mutbl),
|
||||||
match ptr {
|
ty::TyRef(r, mt) => {
|
||||||
BorrowedPtr(bk, r) => Implicit(bk, r),
|
let bk = ty::BorrowKind::from_mutbl(mt.mutbl);
|
||||||
_ => span_bug!(node.span(),
|
if implicit { Implicit(bk, r) } else { BorrowedPtr(bk, r) }
|
||||||
"Implicit deref of non-borrowed pointer")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ptr
|
|
||||||
};
|
|
||||||
// for unique ptrs, we inherit mutability from the
|
|
||||||
// owning reference.
|
|
||||||
(MutabilityCategory::from_pointer_kind(base_cmt.mutbl, ptr),
|
|
||||||
Categorization::Deref(base_cmt, deref_cnt, ptr))
|
|
||||||
}
|
|
||||||
deref_interior(interior) => {
|
|
||||||
(base_cmt.mutbl.inherit(), Categorization::Interior(base_cmt, interior))
|
|
||||||
}
|
}
|
||||||
|
ref ty => bug!("unexpected type in cat_deref_common: {:?}", ty)
|
||||||
};
|
};
|
||||||
let ret = Rc::new(cmt_ {
|
let ret = Rc::new(cmt_ {
|
||||||
id: node.id(),
|
id: node.id(),
|
||||||
span: node.span(),
|
span: node.span(),
|
||||||
cat: cat,
|
// For unique ptrs, we inherit mutability from the owning reference.
|
||||||
mutbl: m,
|
mutbl: MutabilityCategory::from_pointer_kind(base_cmt.mutbl, ptr),
|
||||||
|
cat: Categorization::Deref(base_cmt, deref_cnt, ptr),
|
||||||
ty: deref_ty,
|
ty: deref_ty,
|
||||||
note: NoteNone
|
note: NoteNone
|
||||||
});
|
});
|
||||||
debug!("cat_deref_common ret {:?}", ret);
|
debug!("cat_deref_common ret {:?}", ret);
|
||||||
Ok(ret)
|
ret
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cat_index<N:ast_node>(&self,
|
pub fn cat_index<N:ast_node>(&self,
|
||||||
|
@ -1206,7 +1144,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
||||||
// box p1, &p1, &mut p1. we can ignore the mutability of
|
// box p1, &p1, &mut p1. we can ignore the mutability of
|
||||||
// PatKind::Ref since that information is already contained
|
// PatKind::Ref since that information is already contained
|
||||||
// in the type.
|
// in the type.
|
||||||
let subcmt = self.cat_deref(pat, cmt, 0, None)?;
|
let subcmt = self.cat_deref(pat, cmt, 0)?;
|
||||||
self.cat_pattern_(subcmt, &subpat, op)?;
|
self.cat_pattern_(subcmt, &subpat, op)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -252,27 +252,6 @@ impl<'a, 'tcx, 'encoder> ItemContentBuilder<'a, 'tcx, 'encoder> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Iterates through "auxiliary node IDs", which are node IDs that describe
|
|
||||||
/// top-level items that are sub-items of the given item. Specifically:
|
|
||||||
///
|
|
||||||
/// * For newtype structs, iterates through the node ID of the constructor.
|
|
||||||
fn each_auxiliary_node_id<F>(item: &hir::Item, callback: F) -> bool where
|
|
||||||
F: FnOnce(NodeId) -> bool,
|
|
||||||
{
|
|
||||||
let mut continue_ = true;
|
|
||||||
match item.node {
|
|
||||||
hir::ItemStruct(ref struct_def, _) => {
|
|
||||||
// If this is a newtype struct, return the constructor.
|
|
||||||
if struct_def.is_tuple() {
|
|
||||||
continue_ = callback(struct_def.id());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
|
|
||||||
continue_
|
|
||||||
}
|
|
||||||
|
|
||||||
fn encode_reexports(ecx: &EncodeContext,
|
fn encode_reexports(ecx: &EncodeContext,
|
||||||
rbml_w: &mut Encoder,
|
rbml_w: &mut Encoder,
|
||||||
id: NodeId) {
|
id: NodeId) {
|
||||||
|
@ -313,13 +292,6 @@ impl<'a, 'tcx, 'encoder> ItemContentBuilder<'a, 'tcx, 'encoder> {
|
||||||
for item_id in &md.item_ids {
|
for item_id in &md.item_ids {
|
||||||
self.rbml_w.wr_tagged_u64(tag_mod_child,
|
self.rbml_w.wr_tagged_u64(tag_mod_child,
|
||||||
def_to_u64(ecx.tcx.map.local_def_id(item_id.id)));
|
def_to_u64(ecx.tcx.map.local_def_id(item_id.id)));
|
||||||
|
|
||||||
let item = ecx.tcx.map.expect_item(item_id.id);
|
|
||||||
each_auxiliary_node_id(item, |auxiliary_node_id| {
|
|
||||||
self.rbml_w.wr_tagged_u64(tag_mod_child,
|
|
||||||
def_to_u64(ecx.tcx.map.local_def_id(auxiliary_node_id)));
|
|
||||||
true
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.encode_visibility(vis);
|
self.encode_visibility(vis);
|
||||||
|
|
|
@ -261,8 +261,8 @@ impl<'b> Resolver<'b> {
|
||||||
let def = Def::Struct(self.definitions.local_def_id(item.id));
|
let def = Def::Struct(self.definitions.local_def_id(item.id));
|
||||||
self.define(parent, name, TypeNS, (def, sp, vis));
|
self.define(parent, name, TypeNS, (def, sp, vis));
|
||||||
|
|
||||||
// If this is a newtype or unit-like struct, define a name
|
// If this is a tuple or unit struct, define a name
|
||||||
// in the value namespace as well
|
// in the value namespace as well.
|
||||||
if !struct_def.is_struct() {
|
if !struct_def.is_struct() {
|
||||||
let def = Def::Struct(self.definitions.local_def_id(struct_def.id()));
|
let def = Def::Struct(self.definitions.local_def_id(struct_def.id()));
|
||||||
self.define(parent, name, ValueNS, (def, sp, vis));
|
self.define(parent, name, ValueNS, (def, sp, vis));
|
||||||
|
|
|
@ -231,7 +231,7 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
if cases.len() == 1 && hint == attr::ReprAny {
|
if cases.len() == 1 && hint == attr::ReprAny {
|
||||||
// Equivalent to a struct/tuple/newtype.
|
// Equivalent to a struct or tuple.
|
||||||
return Univariant(mk_struct(cx, &cases[0].tys, false, t));
|
return Univariant(mk_struct(cx, &cases[0].tys, false, t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ use rustc::middle::cstore;
|
||||||
use rustc::hir::def::Def;
|
use rustc::hir::def::Def;
|
||||||
use rustc::hir::def_id::DefId;
|
use rustc::hir::def_id::DefId;
|
||||||
use rustc::hir::print as pprust;
|
use rustc::hir::print as pprust;
|
||||||
use rustc::ty::{self, TyCtxt};
|
use rustc::ty::{self, TyCtxt, VariantKind};
|
||||||
use rustc::util::nodemap::FnvHashSet;
|
use rustc::util::nodemap::FnvHashSet;
|
||||||
|
|
||||||
use rustc_const_eval::lookup_const_by_id;
|
use rustc_const_eval::lookup_const_by_id;
|
||||||
|
@ -207,11 +207,10 @@ fn build_struct<'a, 'tcx>(cx: &DocContext, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
let variant = tcx.lookup_adt_def(did).struct_variant();
|
let variant = tcx.lookup_adt_def(did).struct_variant();
|
||||||
|
|
||||||
clean::Struct {
|
clean::Struct {
|
||||||
struct_type: match &variant.fields[..] {
|
struct_type: match variant.kind {
|
||||||
&[] => doctree::Unit,
|
VariantKind::Struct => doctree::Plain,
|
||||||
&[_] if variant.kind == ty::VariantKind::Tuple => doctree::Newtype,
|
VariantKind::Tuple => doctree::Tuple,
|
||||||
&[..] if variant.kind == ty::VariantKind::Tuple => doctree::Tuple,
|
VariantKind::Unit => doctree::Unit,
|
||||||
_ => doctree::Plain,
|
|
||||||
},
|
},
|
||||||
generics: (t.generics, &predicates).clean(cx),
|
generics: (t.generics, &predicates).clean(cx),
|
||||||
fields: variant.fields.clean(cx),
|
fields: variant.fields.clean(cx),
|
||||||
|
|
|
@ -82,14 +82,12 @@ impl Module {
|
||||||
|
|
||||||
#[derive(Debug, Clone, RustcEncodable, RustcDecodable, Copy)]
|
#[derive(Debug, Clone, RustcEncodable, RustcDecodable, Copy)]
|
||||||
pub enum StructType {
|
pub enum StructType {
|
||||||
/// A normal struct
|
/// A braced struct
|
||||||
Plain,
|
Plain,
|
||||||
/// A tuple struct
|
/// A tuple struct
|
||||||
Tuple,
|
Tuple,
|
||||||
/// A newtype struct (tuple struct with one element)
|
|
||||||
Newtype,
|
|
||||||
/// A unit struct
|
/// A unit struct
|
||||||
Unit
|
Unit,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum TypeBound {
|
pub enum TypeBound {
|
||||||
|
@ -262,15 +260,10 @@ pub struct Import {
|
||||||
pub whence: Span,
|
pub whence: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn struct_type_from_def(sd: &hir::VariantData) -> StructType {
|
pub fn struct_type_from_def(vdata: &hir::VariantData) -> StructType {
|
||||||
if !sd.is_struct() {
|
match *vdata {
|
||||||
// We are in a tuple-struct
|
hir::VariantData::Struct(..) => Plain,
|
||||||
match sd.fields().len() {
|
hir::VariantData::Tuple(..) => Tuple,
|
||||||
0 => Unit,
|
hir::VariantData::Unit(..) => Unit,
|
||||||
1 => Newtype,
|
|
||||||
_ => Tuple
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Plain
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2546,7 +2546,7 @@ fn render_struct(w: &mut fmt::Formatter, it: &clean::Item,
|
||||||
}
|
}
|
||||||
write!(w, "}}")?;
|
write!(w, "}}")?;
|
||||||
}
|
}
|
||||||
doctree::Tuple | doctree::Newtype => {
|
doctree::Tuple => {
|
||||||
write!(w, "(")?;
|
write!(w, "(")?;
|
||||||
for (i, field) in fields.iter().enumerate() {
|
for (i, field) in fields.iter().enumerate() {
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
|
|
|
@ -19,8 +19,7 @@ use parse::parser;
|
||||||
/// The specific types of unsupported syntax
|
/// The specific types of unsupported syntax
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
|
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
|
||||||
pub enum ObsoleteSyntax {
|
pub enum ObsoleteSyntax {
|
||||||
ClosureKind,
|
// Nothing here at the moment
|
||||||
ExternCrateString,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ParserObsoleteMethods {
|
pub trait ParserObsoleteMethods {
|
||||||
|
@ -36,18 +35,10 @@ pub trait ParserObsoleteMethods {
|
||||||
|
|
||||||
impl<'a> ParserObsoleteMethods for parser::Parser<'a> {
|
impl<'a> ParserObsoleteMethods for parser::Parser<'a> {
|
||||||
/// Reports an obsolete syntax non-fatal error.
|
/// Reports an obsolete syntax non-fatal error.
|
||||||
|
#[allow(unused_variables)]
|
||||||
fn obsolete(&mut self, sp: Span, kind: ObsoleteSyntax) {
|
fn obsolete(&mut self, sp: Span, kind: ObsoleteSyntax) {
|
||||||
let (kind_str, desc, error) = match kind {
|
let (kind_str, desc, error) = match kind {
|
||||||
ObsoleteSyntax::ClosureKind => (
|
// Nothing here at the moment
|
||||||
"`:`, `&mut:`, or `&:`",
|
|
||||||
"rely on inference instead",
|
|
||||||
true,
|
|
||||||
),
|
|
||||||
ObsoleteSyntax::ExternCrateString => (
|
|
||||||
"\"crate-name\"",
|
|
||||||
"use an identifier not in quotes instead",
|
|
||||||
false, // warning for now
|
|
||||||
),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
self.report(sp, kind, kind_str, desc, error);
|
self.report(sp, kind, kind_str, desc, error);
|
||||||
|
|
|
@ -47,7 +47,7 @@ use parse;
|
||||||
use parse::classify;
|
use parse::classify;
|
||||||
use parse::common::SeqSep;
|
use parse::common::SeqSep;
|
||||||
use parse::lexer::{Reader, TokenAndSpan};
|
use parse::lexer::{Reader, TokenAndSpan};
|
||||||
use parse::obsolete::{ParserObsoleteMethods, ObsoleteSyntax};
|
use parse::obsolete::ObsoleteSyntax;
|
||||||
use parse::token::{self, intern, MatchNt, SubstNt, SpecialVarNt, InternedString};
|
use parse::token::{self, intern, MatchNt, SubstNt, SpecialVarNt, InternedString};
|
||||||
use parse::token::{keywords, SpecialMacroVar};
|
use parse::token::{keywords, SpecialMacroVar};
|
||||||
use parse::{new_sub_parser_from_file, ParseSess};
|
use parse::{new_sub_parser_from_file, ParseSess};
|
||||||
|
@ -1165,36 +1165,6 @@ impl<'a> Parser<'a> {
|
||||||
})))
|
})))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parses an obsolete closure kind (`&:`, `&mut:`, or `:`).
|
|
||||||
pub fn parse_obsolete_closure_kind(&mut self) -> PResult<'a, ()> {
|
|
||||||
let lo = self.span.lo;
|
|
||||||
if
|
|
||||||
self.check(&token::BinOp(token::And)) &&
|
|
||||||
self.look_ahead(1, |t| t.is_keyword(keywords::Mut)) &&
|
|
||||||
self.look_ahead(2, |t| *t == token::Colon)
|
|
||||||
{
|
|
||||||
self.bump();
|
|
||||||
self.bump();
|
|
||||||
self.bump();
|
|
||||||
} else if
|
|
||||||
self.token == token::BinOp(token::And) &&
|
|
||||||
self.look_ahead(1, |t| *t == token::Colon)
|
|
||||||
{
|
|
||||||
self.bump();
|
|
||||||
self.bump();
|
|
||||||
} else if
|
|
||||||
self.eat(&token::Colon)
|
|
||||||
{
|
|
||||||
/* nothing */
|
|
||||||
} else {
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
|
|
||||||
let span = mk_sp(lo, self.span.hi);
|
|
||||||
self.obsolete(span, ObsoleteSyntax::ClosureKind);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn parse_unsafety(&mut self) -> PResult<'a, Unsafety> {
|
pub fn parse_unsafety(&mut self) -> PResult<'a, Unsafety> {
|
||||||
if self.eat_keyword(keywords::Unsafe) {
|
if self.eat_keyword(keywords::Unsafe) {
|
||||||
return Ok(Unsafety::Unsafe);
|
return Ok(Unsafety::Unsafe);
|
||||||
|
@ -4728,7 +4698,6 @@ impl<'a> Parser<'a> {
|
||||||
Vec::new()
|
Vec::new()
|
||||||
} else {
|
} else {
|
||||||
self.expect(&token::BinOp(token::Or))?;
|
self.expect(&token::BinOp(token::Or))?;
|
||||||
self.parse_obsolete_closure_kind()?;
|
|
||||||
let args = self.parse_seq_to_before_end(
|
let args = self.parse_seq_to_before_end(
|
||||||
&token::BinOp(token::Or),
|
&token::BinOp(token::Or),
|
||||||
SeqSep::trailing_allowed(token::Comma),
|
SeqSep::trailing_allowed(token::Comma),
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// Test that we generate obsolete syntax errors around usages of closure kinds: `|:|`, `|&:|` and
|
|
||||||
// `|&mut:|`.
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let a = |:| {}; //~ ERROR obsolete syntax: `:`, `&mut:`, or `&:`
|
|
||||||
let a = |&:| {}; //~ ERROR obsolete syntax: `:`, `&mut:`, or `&:`
|
|
||||||
let a = |&mut:| {}; //~ ERROR obsolete syntax: `:`, `&mut:`, or `&:`
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue