From 774588fd9def900a467ba2b4ec3620f89832a799 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Sun, 4 Jan 2015 21:39:02 -0500 Subject: sed -i -s 's/ for Sized?//g' **/*.rs --- src/libsyntax/ext/quote.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index e46bd7ac4bc..f1b52fa33c3 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -85,14 +85,14 @@ pub mod rt { */ // FIXME: Move this trait to pprust and get rid of *_to_str? - pub trait ToSource for Sized? { + pub trait ToSource { // Takes a thing and generates a string containing rust code for it. fn to_source(&self) -> String; } // FIXME (Issue #16472): This should go away after ToToken impls // are revised to go directly to token-trees. - trait ToSourceWithHygiene for Sized? : ToSource { + trait ToSourceWithHygiene : ToSource { // Takes a thing and generates a string containing rust code // for it, encoding Idents as special byte sequences to // maintain hygiene across serialization and deserialization. -- cgit 1.4.1-3-g733a5 From 4ed2800701fa0634c2aa73e7b090e84be665166a Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Mon, 5 Jan 2015 13:51:29 -0500 Subject: syntax: obsolete the `for Sized?` syntax --- src/libsyntax/parse/obsolete.rs | 6 ++++++ src/libsyntax/parse/parser.rs | 8 ++++++-- src/test/compile-fail/obsolete-for-sized.rs | 17 +++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 src/test/compile-fail/obsolete-for-sized.rs (limited to 'src/libsyntax') diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index e1e456f880e..d63f432589d 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -24,6 +24,7 @@ use ptr::P; /// The specific types of unsupported syntax #[derive(Copy, PartialEq, Eq, Hash)] pub enum ObsoleteSyntax { + ObsoleteForSized, ObsoleteOwnedType, ObsoleteOwnedExpr, ObsoleteOwnedPattern, @@ -55,6 +56,11 @@ impl<'a> ParserObsoleteMethods for parser::Parser<'a> { /// Reports an obsolete syntax non-fatal error. fn obsolete(&mut self, sp: Span, kind: ObsoleteSyntax) { let (kind_str, desc) = match kind { + ObsoleteForSized => ( + "for Sized?", + "no longer required, traits apply to sized and unsized types by default, use \ + `: Sized` to opt-out of unsized types", + ), ObsoleteProcType => ( "the `proc` type", "use unboxed closures instead", diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index cc67079e538..aedfaac59c5 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -5003,6 +5003,7 @@ impl<'a> Parser<'a> { // re-jigged shortly in any case, so leaving the hacky version for now. if self.eat_keyword(keywords::For) { let span = self.span; + let mut ate_question = false; if self.eat(&token::Question) { ate_question = true; @@ -5020,8 +5021,11 @@ impl<'a> Parser<'a> { "expected `?Sized` after `for` in trait item"); return None; } - let tref = Parser::trait_ref_from_ident(ident, span); - Some(tref) + let _tref = Parser::trait_ref_from_ident(ident, span); + + self.obsolete(span, ObsoleteForSized); + + None } else { None } diff --git a/src/test/compile-fail/obsolete-for-sized.rs b/src/test/compile-fail/obsolete-for-sized.rs new file mode 100644 index 00000000000..1b86d08a50d --- /dev/null +++ b/src/test/compile-fail/obsolete-for-sized.rs @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , 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 `for Sized?` + +trait Foo for Sized? {} //~ ERROR obsolete syntax: for Sized? + +trait Bar for ?Sized {} //~ ERROR obsolete syntax: for Sized? + +fn main() { } -- cgit 1.4.1-3-g733a5 From cd4205a970b07a9f4e8a2a6363ebe535df530386 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Mon, 5 Jan 2015 15:19:38 -0500 Subject: tweak the obsolete syntax message --- src/libsyntax/parse/obsolete.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index d63f432589d..cb8b82b2041 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -58,8 +58,8 @@ impl<'a> ParserObsoleteMethods for parser::Parser<'a> { let (kind_str, desc) = match kind { ObsoleteForSized => ( "for Sized?", - "no longer required, traits apply to sized and unsized types by default, use \ - `: Sized` to opt-out of unsized types", + "no longer required. Traits (and their `Self` type) do not have the `Sized` bound \ + by default", ), ObsoleteProcType => ( "the `proc` type", -- cgit 1.4.1-3-g733a5