1
Fork 0

Obsolete Sized? T

[breaking-change]

Use `T: ?Sized`
This commit is contained in:
Nick Cameron 2015-01-06 09:44:33 +13:00
parent 595a082587
commit 48f50e1e98
2 changed files with 9 additions and 3 deletions

View file

@ -22,6 +22,7 @@ use ptr::P;
/// The specific types of unsupported syntax /// The specific types of unsupported syntax
#[derive(Copy, PartialEq, Eq, Hash)] #[derive(Copy, PartialEq, Eq, Hash)]
pub enum ObsoleteSyntax { pub enum ObsoleteSyntax {
Sized,
OwnedType, OwnedType,
OwnedExpr, OwnedExpr,
OwnedPattern, OwnedPattern,
@ -92,7 +93,11 @@ impl<'a> ParserObsoleteMethods for parser::Parser<'a> {
ObsoleteSyntax::ExternCrateRenaming => ( ObsoleteSyntax::ExternCrateRenaming => (
"`extern crate foo = bar` syntax", "`extern crate foo = bar` syntax",
"write `extern crate bar as foo` instead" "write `extern crate bar as foo` instead"
) ),
ObsoleteSyntax::Sized => (
"`Sized? T` syntax for removing the `Sized` bound",
"write `T: ?Sized` instead"
),
}; };
self.report(sp, kind, kind_str, desc); self.report(sp, kind, kind_str, desc);

View file

@ -4092,8 +4092,8 @@ impl<'a> Parser<'a> {
// unbound, and it may only be `Sized`. To avoid backtracking and other // unbound, and it may only be `Sized`. To avoid backtracking and other
// complications, we parse an ident, then check for `?`. If we find it, // complications, we parse an ident, then check for `?`. If we find it,
// we use the ident as the unbound, otherwise, we use it as the name of // we use the ident as the unbound, otherwise, we use it as the name of
// type param. Even worse, for now, we need to check for `?` before or // type param. Even worse, we need to check for `?` before or after the
// after the bound. // bound.
let mut span = self.span; let mut span = self.span;
let mut ident = self.parse_ident(); let mut ident = self.parse_ident();
let mut unbound = None; let mut unbound = None;
@ -4102,6 +4102,7 @@ impl<'a> Parser<'a> {
unbound = Some(tref); unbound = Some(tref);
span = self.span; span = self.span;
ident = self.parse_ident(); ident = self.parse_ident();
self.obsolete(span, ObsoleteSyntax::Sized);
} }
let mut bounds = self.parse_colon_then_ty_param_bounds(BoundParsingMode::Modified); let mut bounds = self.parse_colon_then_ty_param_bounds(BoundParsingMode::Modified);