Rollup merge of #36995 - nrc:stable, r=@nikomatsakis

stabilise ?, attributes on stmts, deprecate Reflect

r? @nikomatsakis
This commit is contained in:
Alex Crichton 2016-10-12 10:15:26 -07:00
commit 9d70ff384f
55 changed files with 53 additions and 133 deletions

View file

@ -2472,8 +2472,7 @@ The currently implemented features of the reference compiler are:
* - `default_type_parameter_fallback` - Allows type parameter defaults to
influence type inference.
* - `stmt_expr_attributes` - Allows attributes on expressions and
non-item statements.
* - `stmt_expr_attributes` - Allows attributes on expressions.
* - `type_ascription` - Allows type ascription expressions `expr: Type`.

View file

@ -73,7 +73,6 @@
use fmt;
use intrinsics;
use marker::Reflect;
///////////////////////////////////////////////////////////////////////////////
// Any trait
@ -86,7 +85,7 @@ use marker::Reflect;
///
/// [mod]: index.html
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Any: Reflect + 'static {
pub trait Any: 'static {
/// Gets the `TypeId` of `self`.
///
/// # Examples
@ -112,7 +111,7 @@ pub trait Any: Reflect + 'static {
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Reflect + 'static + ?Sized > Any for T {
impl<T: 'static + ?Sized > Any for T {
fn get_type_id(&self) -> TypeId { TypeId::of::<T>() }
}
@ -366,7 +365,7 @@ impl TypeId {
/// }
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn of<T: ?Sized + Reflect + 'static>() -> TypeId {
pub fn of<T: ?Sized + 'static>() -> TypeId {
TypeId {
t: unsafe { intrinsics::type_id::<T>() },
}

View file

@ -89,7 +89,7 @@
#![feature(specialization)]
#![feature(staged_api)]
#![feature(unboxed_closures)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#![feature(never_type)]
#![feature(prelude_import)]

View file

@ -255,6 +255,9 @@ macro_rules! debug_assert_ne {
/// Helper macro for reducing boilerplate code for matching `Result` together
/// with converting downstream errors.
///
/// Prefer using `?` syntax to `try!`. `?` is built in to the language and is
/// more succinct than `try!`. It is the standard method for error propagation.
///
/// `try!` matches the given `Result`. In case of the `Ok` variant, the
/// expression has the value of the wrapped value.
///

View file

@ -587,6 +587,7 @@ mod impls {
#[unstable(feature = "reflect_marker",
reason = "requires RFC and more experience",
issue = "27749")]
#[rustc_deprecated(since = "1.14.0", reason = "Specialization makes parametricity impossible")]
#[rustc_on_unimplemented = "`{Self}` does not implement `Any`; \
ensure all type parameters are bounded by `Any`"]
pub trait Reflect {}
@ -594,4 +595,6 @@ pub trait Reflect {}
#[unstable(feature = "reflect_marker",
reason = "requires RFC and more experience",
issue = "27749")]
#[rustc_deprecated(since = "1.14.0", reason = "Specialization makes parametricity impossible")]
#[allow(deprecated)]
impl Reflect for .. { }

View file

@ -295,7 +295,7 @@
#![cfg_attr(not(stage0), deny(warnings))]
#![feature(str_escape)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
use self::LabelText::*;

View file

@ -1327,30 +1327,6 @@ let x: i32 = "I am not a number!";
// |
// type `i32` assigned to variable `x`
```
Another situation in which this occurs is when you attempt to use the `try!`
macro inside a function that does not return a `Result<T, E>`:
```compile_fail,E0308
use std::fs::File;
fn main() {
let mut f = try!(File::create("foo.txt"));
}
```
This code gives an error like this:
```text
<std macros>:5:8: 6:42 error: mismatched types:
expected `()`,
found `core::result::Result<_, _>`
(expected (),
found enum `core::result::Result`) [E0308]
```
`try!` returns a `Result<T, E>`, and so the function must. But `main()` has
`()` as its return type, hence the error.
"##,
E0309: r##"

View file

@ -40,7 +40,7 @@
#![feature(rustc_private)]
#![feature(slice_patterns)]
#![feature(staged_api)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#![cfg_attr(test, feature(test))]
extern crate arena;

View file

@ -37,7 +37,7 @@
#![feature(rustc_private)]
#![feature(staged_api)]
#![feature(step_by)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#![cfg_attr(test, feature(test, rand))]
extern crate syntax;

View file

@ -26,7 +26,7 @@
#![feature(staged_api)]
#![feature(associated_consts)]
#![feature(nonzero)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#[macro_use] extern crate log;
#[macro_use] extern crate syntax;
extern crate syntax_pos;

View file

@ -27,7 +27,7 @@
#![feature(staged_api)]
#![feature(rustc_diagnostic_macros)]
#![feature(slice_patterns)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#![feature(box_patterns)]
#![feature(box_syntax)]

View file

@ -25,7 +25,7 @@
#![feature(rustc_private)]
#![feature(staged_api)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#[macro_use] extern crate log;
#[macro_use] extern crate syntax;

View file

@ -31,7 +31,7 @@
#![feature(rustc_private)]
#![feature(set_stdio)]
#![feature(staged_api)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
extern crate arena;
extern crate flate;

View file

@ -21,7 +21,7 @@
#![allow(unused_attributes)]
#![feature(rustc_private)]
#![feature(staged_api)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#![feature(range_contains)]
#![feature(libc)]
#![feature(unicode)]

View file

@ -20,7 +20,7 @@
#![cfg_attr(not(stage0), deny(warnings))]
#![feature(dotdot_in_tuple_patterns)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#![feature(rustc_private)]
#![feature(staged_api)]
#![feature(rand)]

View file

@ -23,7 +23,7 @@
#![feature(dotdot_in_tuple_patterns)]
#![feature(proc_macro_internals)]
#![feature(proc_macro_lib)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]

View file

@ -26,7 +26,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]
#![feature(staged_api)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#[macro_use] extern crate log;
extern crate graphviz as dot;

View file

@ -36,7 +36,7 @@
#![feature(slice_patterns)]
#![feature(staged_api)]
#![feature(unicode)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
use rustc::dep_graph::WorkProduct;

View file

@ -82,7 +82,7 @@ This API is completely unstable and subject to change.
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]
#![feature(staged_api)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#[macro_use] extern crate log;
#[macro_use] extern crate syntax;

View file

@ -28,7 +28,7 @@
#![feature(staged_api)]
#![feature(test)]
#![feature(unicode)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
extern crate arena;
extern crate getopts;

View file

@ -35,7 +35,7 @@ Core encoding and decoding interfaces.
#![feature(specialization)]
#![feature(staged_api)]
#![feature(unicode)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#![cfg_attr(test, feature(test))]
// test harness access

View file

@ -55,7 +55,6 @@ use any::TypeId;
use cell;
use char;
use fmt::{self, Debug, Display};
use marker::Reflect;
use mem::transmute;
use num;
use str;
@ -63,7 +62,7 @@ use string;
/// Base functionality for all errors in Rust.
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Error: Debug + Display + Reflect {
pub trait Error: Debug + Display {
/// A short description of the error.
///
/// The description should not contain newlines or sentence-ending

View file

@ -12,7 +12,6 @@
use io::prelude::*;
use marker::Reflect;
use cmp;
use error;
use fmt;
@ -578,7 +577,7 @@ impl<W> From<IntoInnerError<W>> for Error {
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<W: Reflect + Send + fmt::Debug> error::Error for IntoInnerError<W> {
impl<W: Send + fmt::Debug> error::Error for IntoInnerError<W> {
fn description(&self) -> &str {
error::Error::description(self.error())
}

View file

@ -255,10 +255,9 @@
#![feature(panic_unwind)]
#![feature(placement_in_syntax)]
#![feature(prelude_import)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#![feature(rand)]
#![feature(raw)]
#![feature(reflect_marker)]
#![feature(repr_simd)]
#![feature(rustc_attrs)]
#![feature(shared)]

View file

@ -270,7 +270,6 @@ use error;
use fmt;
use mem;
use cell::UnsafeCell;
use marker::Reflect;
use time::{Duration, Instant};
#[unstable(feature = "mpsc_select", issue = "27800")]
@ -1163,7 +1162,7 @@ impl<T> fmt::Display for SendError<T> {
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Send + Reflect> error::Error for SendError<T> {
impl<T: Send> error::Error for SendError<T> {
fn description(&self) -> &str {
"sending on a closed channel"
}
@ -1198,7 +1197,7 @@ impl<T> fmt::Display for TrySendError<T> {
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Send + Reflect> error::Error for TrySendError<T> {
impl<T: Send> error::Error for TrySendError<T> {
fn description(&self) -> &str {
match *self {

View file

@ -10,7 +10,6 @@
use error::{Error};
use fmt;
use marker::Reflect;
use sync::atomic::{AtomicBool, Ordering};
use thread;
@ -117,7 +116,7 @@ impl<T> fmt::Display for PoisonError<T> {
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Reflect> Error for PoisonError<T> {
impl<T> Error for PoisonError<T> {
fn description(&self) -> &str {
"poisoned lock: another task failed inside"
}
@ -174,7 +173,7 @@ impl<T> fmt::Display for TryLockError<T> {
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Reflect> Error for TryLockError<T> {
impl<T> Error for TryLockError<T> {
fn description(&self) -> &str {
match *self {
TryLockError::Poisoned(ref p) => p.description(),

View file

@ -153,7 +153,7 @@ impl<'a> StripUnconfigured<'a> {
}
// Visit attributes on expression and statements (but not attributes on items in blocks).
fn visit_stmt_or_expr_attrs(&mut self, attrs: &[ast::Attribute]) {
fn visit_expr_attrs(&mut self, attrs: &[ast::Attribute]) {
// flag the offending attributes
for attr in attrs.iter() {
if !self.features.map(|features| features.stmt_expr_attributes).unwrap_or(true) {
@ -227,7 +227,7 @@ impl<'a> StripUnconfigured<'a> {
}
pub fn configure_expr(&mut self, expr: P<ast::Expr>) -> P<ast::Expr> {
self.visit_stmt_or_expr_attrs(expr.attrs());
self.visit_expr_attrs(expr.attrs());
// If an expr is valid to cfg away it will have been removed by the
// outer stmt or expression folder before descending in here.
@ -245,7 +245,6 @@ impl<'a> StripUnconfigured<'a> {
}
pub fn configure_stmt(&mut self, stmt: ast::Stmt) -> Option<ast::Stmt> {
self.visit_stmt_or_expr_attrs(stmt.attrs());
self.configure(stmt)
}
}

View file

@ -253,9 +253,6 @@ declare_features! (
// a...b and ...b
(active, inclusive_range_syntax, "1.7.0", Some(28237)),
// `expr?`
(active, question_mark, "1.9.0", Some(31436)),
// impl specialization (RFC 1210)
(active, specialization, "1.7.0", Some(31844)),
@ -348,6 +345,8 @@ declare_features! (
(accepted, while_let, "1.0.0", None),
// Allows `#[deprecated]` attribute
(accepted, deprecated, "1.9.0", Some(29935)),
// `expr?`
(accepted, question_mark, "1.14.0", Some(31436)),
);
// (changing above list without updating src/doc/reference.md makes @cmr sad)
@ -1072,9 +1071,6 @@ impl<'a> Visitor for PostExpansionVisitor<'a> {
e.span,
"inclusive range syntax is experimental");
}
ast::ExprKind::Try(..) => {
gate_feature_post!(&self, question_mark, e.span, "the `?` operator is not stable");
}
ast::ExprKind::InPlace(..) => {
gate_feature_post!(&self, placement_in_syntax, e.span, EXPLAIN_PLACEMENT_IN);
}

View file

@ -31,7 +31,7 @@
#![feature(staged_api)]
#![feature(str_escape)]
#![feature(unicode)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#![feature(rustc_diagnostic_macros)]
#![feature(specialization)]

View file

@ -27,7 +27,7 @@
#![allow(unused_attributes)]
#![feature(rustc_private)]
#![feature(staged_api)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#![feature(specialization)]
use std::cell::{Cell, RefCell};

View file

@ -59,7 +59,7 @@
#![cfg_attr(windows, feature(libc))]
// Handle rustfmt skips
#![feature(custom_attribute)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#![allow(unused_attributes)]
use std::io::prelude::*;

View file

@ -38,7 +38,7 @@
#![feature(rustc_private)]
#![feature(set_stdio)]
#![feature(staged_api)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#![feature(panic_unwind)]
extern crate getopts;

View file

@ -1,18 +0,0 @@
// Copyright 2016 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
macro_rules! id {
($e:expr) => { $e }
}
fn main() {
id!(x?); //~ error: the `?` operator is not stable (see issue #31436)
y?; //~ error: the `?` operator is not stable (see issue #31436)
}

View file

@ -8,12 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(question_mark)]
// Make sure that the span of try shorthand does not include the trailing
// semicolon;
fn a() -> Result<i32, ()> {
Err(5)?; //~ ERROR 16:5: 16:12
Err(5)?; //~ ERROR 14:5: 14:12
Ok(1)
}

View file

@ -8,9 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(reflect_marker)]
use std::marker::Reflect;
use std::any::Any;
struct Foo;

View file

@ -11,7 +11,6 @@
// General test of maybe_uninits state computed by MIR dataflow.
#![feature(rustc_attrs)]
#![feature(stmt_expr_attributes)]
use std::intrinsics::rustc_peek;
use std::mem::{drop, replace};

View file

@ -11,7 +11,6 @@
// General test of maybe_inits state computed by MIR dataflow.
#![feature(rustc_attrs)]
#![feature(stmt_expr_attributes)]
use std::intrinsics::rustc_peek;
use std::mem::{drop, replace};

View file

@ -11,7 +11,6 @@
// General test of maybe_uninits state computed by MIR dataflow.
#![feature(rustc_attrs)]
#![feature(stmt_expr_attributes)]
use std::intrinsics::rustc_peek;
use std::mem::{drop, replace};

View file

@ -11,7 +11,6 @@
// General test of maybe_uninits state computed by MIR dataflow.
#![feature(rustc_attrs)]
#![feature(stmt_expr_attributes)]
use std::intrinsics::rustc_peek;
use std::mem::{drop, replace};

View file

@ -21,15 +21,15 @@ fn main() {
#[attr]
fn a() {}
#[attr] //~ ERROR 15701
#[attr]
{
}
#[attr] //~ ERROR 15701
#[attr]
5;
#[attr] //~ ERROR 15701
#[attr]
stmt_mac!();
}
@ -43,7 +43,7 @@ fn c() {
#[cfg(not(unset))]
fn j() {
#[attr] //~ ERROR 15701
#[attr]
5;
}
@ -55,7 +55,7 @@ fn d() {
#[cfg_attr(not(unset), cfg(not(unset)))]
fn i() {
#[attr] //~ ERROR 15701
#[attr]
8;
}
@ -64,7 +64,7 @@ fn i() {
macro_rules! item_mac {
($e:ident) => {
fn $e() {
#[attr] //~ ERROR 15701
#[attr]
42;
#[cfg(unset)]
@ -75,7 +75,7 @@ macro_rules! item_mac {
#[cfg(not(unset))]
fn k() {
#[attr] //~ ERROR 15701
#[attr]
5;
}
@ -87,7 +87,7 @@ macro_rules! item_mac {
#[cfg_attr(not(unset), cfg(not(unset)))]
fn h() {
#[attr] //~ ERROR 15701
#[attr]
8;
}

View file

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(stmt_expr_attributes)]
#[deny(const_err)]
fn main() {

View file

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(stmt_expr_attributes)]
use std::mem::size_of;
enum Ei8 {

View file

@ -14,7 +14,6 @@
#![allow(unused_must_use)]
#![allow(unused_features)]
#![feature(box_syntax)]
#![feature(question_mark)]
use std::fmt::{self, Write};
use std::usize;

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(conservative_impl_trait, question_mark)]
#![feature(conservative_impl_trait)]
struct State;
type Error = ();

View file

@ -10,8 +10,6 @@
// pretty-expanded FIXME #23616
#![feature(question_mark)]
use std::fs::File;
use std::io::{self, BufReader, Read};

View file

@ -8,17 +8,14 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(reflect_marker)]
use std::any::TypeId;
use std::marker::Reflect;
use std::rc::Rc;
type Fp<T> = Rc<T>;
struct Engine;
trait Component: 'static + Reflect {}
trait Component: 'static {}
impl Component for Engine {}
trait Env {

View file

@ -10,8 +10,6 @@
// Regression test for #20797.
#![feature(question_mark)]
use std::default::Default;
use std::io;
use std::fs;

View file

@ -11,8 +11,6 @@
// Regression test for #21400 which itself was extracted from
// stackoverflow.com/questions/28031155/is-my-borrow-checker-drunk/28031580
#![feature(question_mark)]
fn main() {
let mut t = Test;
assert_eq!(t.method1("one"), Ok(1));

View file

@ -11,7 +11,7 @@
// ignore-emscripten no threads support
// ignore-pretty : (#23623) problems when ending with // comments
#![feature(rustc_attrs, stmt_expr_attributes, zero_one)]
#![feature(rustc_attrs, zero_one)]
use std::num::Zero;
use std::thread;

View file

@ -18,8 +18,6 @@
// This test verifies that the expansion is hygienic, i.e. it's not affected by other `val` and
// `err` bindings that may be in scope.
#![feature(question_mark)]
use std::num::ParseIntError;
fn main() {

View file

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(question_mark)]
use std::fs::File;
use std::io::{Read, self};
use std::num::ParseIntError;

View file

@ -13,7 +13,6 @@
#![feature(box_syntax)]
#![feature(rustc_private)]
#![feature(test)]
#![feature(question_mark)]
#![feature(libc)]
#![deny(warnings)]

View file

@ -9,7 +9,6 @@
// except according to those terms.
#![feature(rustc_private, rustdoc)]
#![feature(question_mark)]
extern crate syntax;
extern crate rustdoc;

View file

@ -24,8 +24,6 @@
//! A few whitelisted exceptions are allowed as there's known bugs in rustdoc,
//! but this should catch the majority of "broken link" cases.
#![feature(question_mark)]
extern crate url;
use std::env;

View file

@ -12,7 +12,6 @@
#![feature(rustc_private)]
#![feature(rustdoc)]
#![feature(question_mark)]
extern crate rustdoc;
extern crate rustc_back;