]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #43270 - petrochenkov:fixstab, r=alexcrichton
authorbors <bors@rust-lang.org>
Thu, 20 Jul 2017 09:01:58 +0000 (09:01 +0000)
committerbors <bors@rust-lang.org>
Thu, 20 Jul 2017 09:01:58 +0000 (09:01 +0000)
Fix checking for missing stability annotations

This was a regression from https://github.com/rust-lang/rust/pull/37676 causing "unmarked API" ICEs like https://github.com/rust-lang/rust/issues/43027.

r? @alexcrichton

src/liballoc/lib.rs
src/librustc/middle/stability.rs
src/libterm/lib.rs
src/test/compile-fail-fulldeps/explore-issue-38412.rs
src/test/compile-fail/lint-forbid-cmdline.rs
src/test/compile-fail/stability-attribute-issue-43027.rs [new file with mode: 0644]

index b419aeb5ab5931e56eac4c565dfaeb670d9426b3..80532bbdda15708ce08e2956e46c14ecb705b6ab 100644 (file)
@@ -244,10 +244,10 @@ mod std {
 pub enum Bound<T> {
     /// An inclusive bound.
     #[stable(feature = "collections_bound", since = "1.17.0")]
-    Included(T),
+    Included(#[stable(feature = "collections_bound", since = "1.17.0")] T),
     /// An exclusive bound.
     #[stable(feature = "collections_bound", since = "1.17.0")]
-    Excluded(T),
+    Excluded(#[stable(feature = "collections_bound", since = "1.17.0")] T),
     /// An infinite endpoint. Indicates that there is no bound in this direction.
     #[stable(feature = "collections_bound", since = "1.17.0")]
     Unbounded,
index 668a8693d3a84ff5a3ebc6e641aede232b8d10f2..68c01db544a66bab857e147f0a3bdabc131c1f08 100644 (file)
@@ -313,8 +313,9 @@ struct MissingStabilityAnnotations<'a, 'tcx: 'a> {
 impl<'a, 'tcx: 'a> MissingStabilityAnnotations<'a, 'tcx> {
     fn check_missing_stability(&self, id: NodeId, span: Span) {
         let def_id = self.tcx.hir.local_def_id(id);
+        let stab = self.tcx.stability.borrow().stab_map.get(&def_id).cloned();
         let is_error = !self.tcx.sess.opts.test &&
-                        !self.tcx.stability.borrow().stab_map.contains_key(&def_id) &&
+                        (stab == None || stab == Some(None)) &&
                         self.access_levels.is_reachable(id);
         if is_error {
             self.tcx.sess.span_err(span, "This node does not have a stability attribute");
@@ -420,7 +421,6 @@ pub fn new(sess: &Session) -> Index<'tcx> {
         let is_staged_api =
             sess.opts.debugging_opts.force_unstable_if_unmarked ||
             sess.features.borrow().staged_api;
-
         let mut staged_api = FxHashMap();
         staged_api.insert(LOCAL_CRATE, is_staged_api);
         Index {
index 753dfbe4cee013f791b5aa6722eaa7c5d128bcea..4864e4581faab87c033a023409d8958f6c015ff1 100644 (file)
@@ -51,7 +51,6 @@
 #![deny(missing_docs)]
 #![deny(warnings)]
 
-#![feature(staged_api)]
 #![cfg_attr(windows, feature(libc))]
 // Handle rustfmt skips
 #![feature(custom_attribute)]
index b9839edea2dc4e5b4e39e6423e53525341c60b61..4b9a5b716182c18cd3264ab893fdb18b0b107c0f 100644 (file)
@@ -10,7 +10,6 @@
 
 // aux-build:pub_and_stability.rs
 
-#![feature(staged_api)]
 #![feature(unused_feature)]
 
 // A big point of this test is that we *declare* `unstable_declared`,
index dfa6866f66e36d707c042c18b0c0ba036086bf7d..6a4d17b33de7306419ad4c2fe71ca41cb795b0f7 100644 (file)
@@ -10,7 +10,6 @@
 
 // compile-flags: -F deprecated
 
-#![feature(staged_api)]
 #[allow(deprecated)] //~ ERROR allow(deprecated) overruled by outer forbid(deprecated)
 fn main() {
 }
diff --git a/src/test/compile-fail/stability-attribute-issue-43027.rs b/src/test/compile-fail/stability-attribute-issue-43027.rs
new file mode 100644 (file)
index 0000000..dac50db
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright 2017 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(staged_api)]
+#![stable(feature = "test", since = "0")]
+
+#[stable(feature = "test", since = "0")]
+pub struct Reverse<T>(pub T); //~ ERROR This node does not have a stability attribute
+
+fn main() {
+    // Make sure the field is used to fill the stability cache
+    Reverse(0).0;
+}