Skip to content

Commit 35040b6

Browse files
author
Jorge Aparicio
committed
---
yaml --- r: 171958 b: refs/heads/beta c: 4ed2800 h: refs/heads/master v: v3
1 parent 6f05bef commit 35040b6

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ refs/heads/automation-fail: 1bf06495443584539b958873e04cc2f864ab10e4
3131
refs/heads/issue-18208-method-dispatch-3-quick-reject: 2009f85b9f99dedcec4404418eda9ddba90258a2
3232
refs/heads/batch: b5571ed71a5879c0495a982506258d5d267744ed
3333
refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
34-
refs/heads/beta: bbf7e4e58a9b565342b5990cb3e750932a90a1b6
34+
refs/heads/beta: 4ed2800701fa0634c2aa73e7b090e84be665166a
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928

branches/beta/src/libsyntax/parse/obsolete.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use ptr::P;
2424
/// The specific types of unsupported syntax
2525
#[derive(Copy, PartialEq, Eq, Hash)]
2626
pub 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",

branches/beta/src/libsyntax/parse/parser.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff 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
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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() { }

0 commit comments

Comments
 (0)