File tree Expand file tree Collapse file tree 3 files changed +29
-2
lines changed Expand file tree Collapse file tree 3 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ use ptr::P;
2424/// The specific types of unsupported syntax
2525#[ derive( Copy , PartialEq , Eq , Hash ) ]
2626pub enum ObsoleteSyntax {
27+ ObsoleteForSized ,
2728 ObsoleteOwnedType ,
2829 ObsoleteOwnedExpr ,
2930 ObsoleteOwnedPattern ,
@@ -55,6 +56,11 @@ impl<'a> ParserObsoleteMethods for parser::Parser<'a> {
5556 /// Reports an obsolete syntax non-fatal error.
5657 fn obsolete ( & mut self , sp : Span , kind : ObsoleteSyntax ) {
5758 let ( kind_str, desc) = match kind {
59+ ObsoleteForSized => (
60+ "for Sized?" ,
61+ "no longer required, traits apply to sized and unsized types by default, use \
62+ `: Sized` to opt-out of unsized types",
63+ ) ,
5864 ObsoleteProcType => (
5965 "the `proc` type" ,
6066 "use unboxed closures instead" ,
Original file line number Diff line number Diff line change @@ -5003,6 +5003,7 @@ impl<'a> Parser<'a> {
50035003 // re-jigged shortly in any case, so leaving the hacky version for now.
50045004 if self . eat_keyword ( keywords:: For ) {
50055005 let span = self . span ;
5006+
50065007 let mut ate_question = false ;
50075008 if self . eat ( & token:: Question ) {
50085009 ate_question = true ;
@@ -5020,8 +5021,11 @@ impl<'a> Parser<'a> {
50205021 "expected `?Sized` after `for` in trait item" ) ;
50215022 return None ;
50225023 }
5023- let tref = Parser :: trait_ref_from_ident ( ident, span) ;
5024- Some ( tref)
5024+ let _tref = Parser :: trait_ref_from_ident ( ident, span) ;
5025+
5026+ self . obsolete ( span, ObsoleteForSized ) ;
5027+
5028+ None
50255029 } else {
50265030 None
50275031 }
Original file line number Diff line number Diff line change 1+ // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ // Test that we generate obsolete syntax errors around usages of `for Sized?`
12+
13+ trait Foo for Sized ? { } //~ ERROR obsolete syntax: for Sized?
14+
15+ trait Bar for ?Sized { } //~ ERROR obsolete syntax: for Sized?
16+
17+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments