]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #39309 - eddyb:map-shmap, r=nikomatsakis
authorbors <bors@rust-lang.org>
Thu, 26 Jan 2017 15:02:23 +0000 (15:02 +0000)
committerbors <bors@rust-lang.org>
Thu, 26 Jan 2017 15:02:23 +0000 (15:02 +0000)
Rename tcx.map to the far more descriptive tcx.hir.

Also a bit more renaming because `ast_map` and `'ast` were still used with HIR.
Main motivation is to "free up" `tcx.map`, or rather, `tcx.maps`, to consolidate `ty::maps` there.

r? @nikomatsakis

16 files changed:
src/libcore/lib.rs
src/libcore/marker.rs
src/librustc/diagnostics.rs
src/librustc/infer/error_reporting.rs
src/librustc/traits/select.rs
src/libsyntax/feature_gate.rs
src/test/compile-fail/E0308-3.rs [deleted file]
src/test/compile-fail/E0580.rs [new file with mode: 0644]
src/test/compile-fail/bad-main.rs
src/test/compile-fail/extern-main-fn.rs
src/test/compile-fail/main-wrong-type-2.rs
src/test/compile-fail/main-wrong-type.rs
src/test/compile-fail/reflect-assoc.rs [deleted file]
src/test/compile-fail/reflect-object-param.rs [deleted file]
src/test/compile-fail/reflect.rs [deleted file]
src/tools/tidy/src/features.rs

index 35324f7b5968ff6e14bd78e0367e75e6b88571f3..98871bd084e3ca8f609f5aed1ed8e96df24b2145 100644 (file)
@@ -82,7 +82,6 @@
 #![feature(no_core)]
 #![feature(on_unimplemented)]
 #![feature(optin_builtin_traits)]
-#![feature(reflect)]
 #![feature(unwind_attributes)]
 #![feature(repr_simd, platform_intrinsics)]
 #![feature(rustc_attrs)]
index 798f1e6cbeb844b842b798568bf585261cc75d22..ede22ccddc62fee14b5781f3cd250c9df7618170 100644 (file)
@@ -553,59 +553,3 @@ unsafe impl<'a, T: Sync + ?Sized> Send for &'a T {}
     #[stable(feature = "rust1", since = "1.0.0")]
     unsafe impl<'a, T: Send + ?Sized> Send for &'a mut T {}
 }
-
-/// Types that can be reflected over.
-///
-/// By "reflection" we mean use of the [`Any`][any] trait, or related
-/// machinery such as [`TypeId`][typeid].
-///
-/// `Reflect` is implemented for all types. Its purpose is to ensure
-/// that when you write a generic function that will employ reflection,
-/// that must be reflected (no pun intended) in the generic bounds of
-/// that function.
-///
-/// ```
-/// #![feature(reflect_marker)]
-/// use std::marker::Reflect;
-/// use std::any::Any;
-///
-/// # #[allow(dead_code)]
-/// fn foo<T: Reflect + 'static>(x: &T) {
-///     let any: &Any = x;
-///     if any.is::<u32>() { println!("u32"); }
-/// }
-/// ```
-///
-/// Without the bound `T: Reflect`, `foo` would not typecheck. (As
-/// a matter of style, it would be preferable to write `T: Any`,
-/// because `T: Any` implies `T: Reflect` and `T: 'static`, but we
-/// use `Reflect` here for illustrative purposes.)
-///
-/// The `Reflect` bound serves to alert `foo`'s caller to the
-/// fact that `foo` may behave differently depending on whether
-/// `T` is `u32` or not. The ability for a caller to reason about what
-/// a function may do based solely on what generic bounds are declared
-/// is often called the "[parametricity property][param]". Despite the
-/// use of `Reflect`, Rust lacks true parametricity because a generic
-/// function can, at the very least, call [`mem::size_of`][size_of]
-/// without employing any trait bounds whatsoever.
-///
-/// [any]: ../any/trait.Any.html
-/// [typeid]: ../any/struct.TypeId.html
-/// [param]: http://en.wikipedia.org/wiki/Parametricity
-/// [size_of]: ../mem/fn.size_of.html
-#[rustc_reflect_like]
-#[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 {}
-
-#[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 .. { }
index 0d180e6ad76fda1be666cb41e66e7c0f53bd3083..2878ff5e2846e4f9ad8a776d7758d1a927925e2a 100644 (file)
@@ -1694,6 +1694,30 @@ fn main() {
 https://doc.rust-lang.org/book/closures.html
 "##,
 
+E0580: r##"
+The `main` function was incorrectly declared.
+
+Erroneous code example:
+
+```compile_fail,E0580
+fn main() -> i32 { // error: main function has wrong type
+    0
+}
+```
+
+The `main` function prototype should never take arguments or return type.
+Example:
+
+```
+fn main() {
+    // your code
+}
+```
+
+If you want to get command-line arguments, use `std::env::args`. To exit with a
+specified exit code, use `std::process::exit`.
+"##,
+
 }
 
 
index 73b5fda275819dee9c931f360b17c8ad68fa920f..23106d2bdc7d36f8373f77ec5651a46562cb7dd9 100644 (file)
@@ -629,10 +629,13 @@ pub fn report_and_explain_type_error(&self,
         let mut diag = match trace.cause.code {
             ObligationCauseCode::IfExpressionWithNoElse => {
                 struct_span_err!(self.tcx.sess, span, E0317, "{}", failure_str)
-            },
+            }
+            ObligationCauseCode::MainFunctionType => {
+                struct_span_err!(self.tcx.sess, span, E0580, "{}", failure_str)
+            }
             _ => {
                 struct_span_err!(self.tcx.sess, span, E0308, "{}", failure_str)
-            },
+            }
         };
         self.note_type_err(&mut diag, &trace.cause, None, Some(trace.values), terr);
         diag
index 23cfc2517590c1845b7a7f260dbc7a4a5a19d8c8..4990bb9f521d3490025094b3179462202e15458e 100644 (file)
@@ -204,7 +204,6 @@ enum SelectionCandidate<'tcx> {
     ParamCandidate(ty::PolyTraitRef<'tcx>),
     ImplCandidate(DefId),
     DefaultImplCandidate(DefId),
-    DefaultImplObjectCandidate(DefId),
 
     /// This is a trait matching with a projected type as `Self`, and
     /// we found an applicable bound in the trait definition.
@@ -237,9 +236,6 @@ fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lif
             }
             ImplCandidate(def_id) => ImplCandidate(def_id),
             DefaultImplCandidate(def_id) => DefaultImplCandidate(def_id),
-            DefaultImplObjectCandidate(def_id) => {
-                DefaultImplObjectCandidate(def_id)
-            }
             ProjectionCandidate => ProjectionCandidate,
             FnPointerCandidate => FnPointerCandidate,
             ObjectCandidate => ObjectCandidate,
@@ -1431,17 +1427,9 @@ fn assemble_candidates_from_default_impls(&mut self,
             match self_ty.sty {
                 ty::TyDynamic(..) => {
                     // For object types, we don't know what the closed
-                    // over types are. For most traits, this means we
-                    // conservatively say nothing; a candidate may be
-                    // added by `assemble_candidates_from_object_ty`.
-                    // However, for the kind of magic reflect trait,
-                    // we consider it to be implemented even for
-                    // object types, because it just lets you reflect
-                    // onto the object type, not into the object's
-                    // interior.
-                    if self.tcx().has_attr(def_id, "rustc_reflect_like") {
-                        candidates.vec.push(DefaultImplObjectCandidate(def_id));
-                    }
+                    // over types are. This means we conservatively
+                    // say nothing; a candidate may be added by
+                    // `assemble_candidates_from_object_ty`.
                 }
                 ty::TyParam(..) |
                 ty::TyProjection(..) |
@@ -1671,7 +1659,6 @@ fn candidate_should_be_dropped_in_favor_of<'o>(
                 FnPointerCandidate |
                 BuiltinObjectCandidate |
                 BuiltinUnsizeCandidate |
-                DefaultImplObjectCandidate(..) |
                 BuiltinCandidate { .. } => {
                     // We have a where-clause so don't go around looking
                     // for impls.
@@ -1998,11 +1985,6 @@ fn confirm_candidate(&mut self,
                 Ok(VtableDefaultImpl(data))
             }
 
-            DefaultImplObjectCandidate(trait_def_id) => {
-                let data = self.confirm_default_impl_object_candidate(obligation, trait_def_id);
-                Ok(VtableDefaultImpl(data))
-            }
-
             ImplCandidate(impl_def_id) => {
                 Ok(VtableImpl(self.confirm_impl_candidate(obligation, impl_def_id)))
             }
@@ -2138,42 +2120,6 @@ fn confirm_default_impl_candidate(&mut self,
         self.vtable_default_impl(obligation, trait_def_id, ty::Binder(types))
     }
 
-    fn confirm_default_impl_object_candidate(&mut self,
-                                             obligation: &TraitObligation<'tcx>,
-                                             trait_def_id: DefId)
-                                             -> VtableDefaultImplData<PredicateObligation<'tcx>>
-    {
-        debug!("confirm_default_impl_object_candidate({:?}, {:?})",
-               obligation,
-               trait_def_id);
-
-        assert!(self.tcx().has_attr(trait_def_id, "rustc_reflect_like"));
-
-        // OK to skip binder, it is reintroduced below
-        let self_ty = self.infcx.shallow_resolve(obligation.predicate.skip_binder().self_ty());
-        match self_ty.sty {
-            ty::TyDynamic(ref data, ..) => {
-                // OK to skip the binder, it is reintroduced below
-                let principal = data.principal().unwrap();
-                let input_types = principal.input_types();
-                let assoc_types = data.projection_bounds()
-                                      .map(|pb| pb.skip_binder().ty);
-                let all_types: Vec<_> = input_types.chain(assoc_types)
-                                                   .collect();
-
-                // reintroduce the two binding levels we skipped, then flatten into one
-                let all_types = ty::Binder(ty::Binder(all_types));
-                let all_types = self.tcx().flatten_late_bound_regions(&all_types);
-
-                self.vtable_default_impl(obligation, trait_def_id, all_types)
-            }
-            _ => {
-                bug!("asked to confirm default object implementation for non-object type: {:?}",
-                     self_ty);
-            }
-        }
-    }
-
     /// See `confirm_default_impl_candidate`
     fn vtable_default_impl(&mut self,
                            obligation: &TraitObligation<'tcx>,
index 3ce3e36d3c2522ffca03fcf8e4fcbecd1691e99d..d4448da932eaed8acd3df105bc563afe87bfb39c 100644 (file)
@@ -124,7 +124,6 @@ pub fn new() -> Features {
     (active, advanced_slice_patterns, "1.0.0", Some(23121)),
     (active, box_syntax, "1.0.0", Some(27779)),
     (active, placement_in_syntax, "1.0.0", Some(27779)),
-    (active, reflect, "1.0.0", Some(27749)),
     (active, unboxed_closures, "1.0.0", Some(29625)),
 
     (active, allocator, "1.0.0", Some(27389)),
@@ -337,6 +336,7 @@ pub fn new() -> Features {
     (removed, managed_boxes, "1.0.0", None),
     // Allows use of unary negate on unsigned integers, e.g. -e for e: u8
     (removed, negate_unsigned, "1.0.0", Some(29645)),
+    (removed, reflect, "1.0.0", Some(27749)),
     // A way to temporarily opt out of opt in copy. This will *never* be accepted.
     (removed, opt_out_copy, "1.0.0", None),
     (removed, quad_precision_float, "1.0.0", None),
@@ -734,10 +734,6 @@ pub fn is_builtin_attr(attr: &ast::Attribute) -> bool {
                                         "unboxed_closures",
                                         "unboxed_closures are still evolving",
                                         cfg_fn!(unboxed_closures))),
-    ("rustc_reflect_like", Whitelisted, Gated(Stability::Unstable,
-                                              "reflect",
-                                              "defining reflective traits is still evolving",
-                                              cfg_fn!(reflect))),
 
     ("windows_subsystem", Whitelisted, Gated(Stability::Unstable,
                                              "windows_subsystem",
diff --git a/src/test/compile-fail/E0308-3.rs b/src/test/compile-fail/E0308-3.rs
deleted file mode 100644 (file)
index d7dca05..0000000
+++ /dev/null
@@ -1,11 +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.
-
-fn main() -> i32 { 0 } //~ ERROR E0308
diff --git a/src/test/compile-fail/E0580.rs b/src/test/compile-fail/E0580.rs
new file mode 100644 (file)
index 0000000..a2ef7da
--- /dev/null
@@ -0,0 +1,11 @@
+// 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.
+
+fn main() -> i32 { 0 } //~ ERROR E0580
index 1253f7569e7e8e48ec2f9e315838d05b5c6940fa..b73b4a6af6e89e8fdcd3e29012ab6000c85ac2bb 100644 (file)
@@ -8,4 +8,4 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn main(x: isize) { } //~ ERROR: main function has wrong type
+fn main(x: isize) { } //~ ERROR: main function has wrong type [E0580]
index 11f299acefa874e55b5efa49b81eb345fd9350be..d9bdb4ecd04777a7384fc3b08c274130a5368f57 100644 (file)
@@ -8,4 +8,4 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern fn main() {} //~ ERROR: main function has wrong type
+extern fn main() {} //~ ERROR: main function has wrong type [E0580]
index 2878cbc7fc15488d6fcfb865390be929d419f7c9..9d74d1a90493bd8c8f08532c63685824df467c5d 100644 (file)
@@ -9,6 +9,6 @@
 // except according to those terms.
 
 fn main() -> char {
-//~^ ERROR: main function has wrong type
+//~^ ERROR: main function has wrong type [E0580]
     ' '
 }
index 431b855d5177373cfcabd13a747e6f90dbe86e48..402cd3a2d31b6f2dbeeab22336c924a7361a3d60 100644 (file)
@@ -14,5 +14,5 @@ struct S {
 }
 
 fn main(foo: S) {
-//~^ ERROR: main function has wrong type
+//~^ ERROR: main function has wrong type [E0580]
 }
diff --git a/src/test/compile-fail/reflect-assoc.rs b/src/test/compile-fail/reflect-assoc.rs
deleted file mode 100644 (file)
index 47da97d..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-// 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 <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.
-
-#![feature(reflect_marker)]
-
-// Test that types that appear in assoc bindings in an object
-// type are subject to the reflect check.
-
-use std::marker::Reflect;
-use std::io::Write;
-
-trait Get {
-    type Output;
-    fn get(self) -> Self::Output;
-}
-
-struct Struct<T>(T);
-
-fn is_reflect<T:Reflect>() { }
-
-fn a<T>() {
-    is_reflect::<Box<Get<Output=T>>>(); //~ ERROR E0277
-}
-
-fn ok_a<T: Reflect>() {
-    is_reflect::<Box<Get<Output=T>>>(); // OK
-}
-
-fn main() {
-}
diff --git a/src/test/compile-fail/reflect-object-param.rs b/src/test/compile-fail/reflect-object-param.rs
deleted file mode 100644 (file)
index be0dbd8..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-// 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 <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.
-
-#![feature(reflect_marker)]
-
-// Test that types that appear in input types in an object type are
-// subject to the reflect check.
-
-use std::marker::Reflect;
-use std::io::Write;
-
-trait Get<T> {
-    fn get(self) -> T;
-}
-
-struct Struct<T>(T);
-
-fn is_reflect<T:Reflect>() { }
-
-fn a<T>() {
-    is_reflect::<T>(); //~ ERROR E0277
-}
-
-fn ok_a<T: Reflect>() {
-    is_reflect::<T>(); // OK
-}
-
-fn b<T>() {
-    is_reflect::<Box<Get<T>>>(); //~ ERROR E0277
-}
-
-fn ok_b<T: Reflect>() {
-    is_reflect::<Box<Get<T>>>(); // OK
-}
-
-fn c<T>() {
-    is_reflect::<Box<Get<Struct<T>>>>(); //~ ERROR E0277
-}
-
-fn main() {
-    is_reflect::<Box<Get<Struct<()>>>>(); // OK
-}
diff --git a/src/test/compile-fail/reflect.rs b/src/test/compile-fail/reflect.rs
deleted file mode 100644 (file)
index 28ff7c8..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-// 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 <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.
-
-#![feature(reflect_marker)]
-
-// Test that there is no way to get a generic type `T` to be
-// considered as `Reflect` (or accessible via something that is
-// considered `Reflect`) without a reflect bound, but that any
-// concrete type works fine. Note that object types are tested
-// separately.
-
-use std::marker::Reflect;
-use std::io::Write;
-
-struct Struct<T>(T);
-
-fn is_reflect<T:Reflect>() { }
-
-fn c<T>() {
-    is_reflect::<Struct<T>>(); //~ ERROR E0277
-}
-
-fn ok_c<T: Reflect>() {
-    is_reflect::<Struct<T>>(); // OK
-}
-
-fn d<T>() {
-    is_reflect::<(i32, T)>(); //~ ERROR E0277
-}
-
-fn main() {
-    is_reflect::<&i32>(); // OK
-    is_reflect::<Box<Write>>(); // OK
-}
index ee8113e80e5752dd5284ac10a85cb0d32a07aed5..154ebd3649bcd0ec1aaa6df7c38505ee9584d922 100644 (file)
@@ -167,7 +167,7 @@ pub fn check(path: &Path, bad: &mut bool) {
     // FIXME get this whitelist empty.
     let whitelist = vec![
         "abi_ptx", "simd", "macro_reexport",
-        "static_recursion", "reflect", "quote",
+        "static_recursion", "quote",
         "cfg_target_has_atomic", "staged_api", "const_indexing",
         "unboxed_closures", "stmt_expr_attributes",
         "cfg_target_thread_local", "unwind_attributes",