File tree 3 files changed +29
-2
lines changed
3 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ use ptr::P;
24
24
/// The specific types of unsupported syntax
25
25
#[ derive( Copy , PartialEq , Eq , Hash ) ]
26
26
pub enum ObsoleteSyntax {
27
+ ObsoleteForSized ,
27
28
ObsoleteOwnedType ,
28
29
ObsoleteOwnedExpr ,
29
30
ObsoleteOwnedPattern ,
@@ -55,6 +56,11 @@ impl<'a> ParserObsoleteMethods for parser::Parser<'a> {
55
56
/// Reports an obsolete syntax non-fatal error.
56
57
fn obsolete ( & mut self , sp : Span , kind : ObsoleteSyntax ) {
57
58
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
+ ) ,
58
64
ObsoleteProcType => (
59
65
"the `proc` type" ,
60
66
"use unboxed closures instead" ,
Original file line number Diff line number Diff line change @@ -5003,6 +5003,7 @@ impl<'a> Parser<'a> {
5003
5003
// re-jigged shortly in any case, so leaving the hacky version for now.
5004
5004
if self . eat_keyword ( keywords:: For ) {
5005
5005
let span = self . span ;
5006
+
5006
5007
let mut ate_question = false ;
5007
5008
if self . eat ( & token:: Question ) {
5008
5009
ate_question = true ;
@@ -5020,8 +5021,11 @@ impl<'a> Parser<'a> {
5020
5021
"expected `?Sized` after `for` in trait item" ) ;
5021
5022
return None ;
5022
5023
}
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
5025
5029
} else {
5026
5030
None
5027
5031
}
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