From 465ada623a32ba1fa99921ed5c4ef8ab503df827 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sun, 16 Jul 2017 22:11:46 +0300 Subject: [PATCH] Fix checking for missing stability annotations Remove couple of unnecessary `#![feature(staged_api)]`. --- src/liballoc/lib.rs | 4 ++-- src/librustc/middle/stability.rs | 4 ++-- src/libterm/lib.rs | 1 - .../explore-issue-38412.rs | 1 - src/test/compile-fail/lint-forbid-cmdline.rs | 1 - .../stability-attribute-issue-43027.rs | 20 +++++++++++++++++++ 6 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 src/test/compile-fail/stability-attribute-issue-43027.rs diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index b419aeb5ab593..80532bbdda157 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -244,10 +244,10 @@ mod std { pub enum Bound { /// 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, diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index 668a8693d3a84..68c01db544a66 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -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 @@ impl<'a, 'tcx> 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 { diff --git a/src/libterm/lib.rs b/src/libterm/lib.rs index 753dfbe4cee01..4864e4581faab 100644 --- a/src/libterm/lib.rs +++ b/src/libterm/lib.rs @@ -51,7 +51,6 @@ #![deny(missing_docs)] #![deny(warnings)] -#![feature(staged_api)] #![cfg_attr(windows, feature(libc))] // Handle rustfmt skips #![feature(custom_attribute)] diff --git a/src/test/compile-fail-fulldeps/explore-issue-38412.rs b/src/test/compile-fail-fulldeps/explore-issue-38412.rs index b9839edea2dc4..4b9a5b716182c 100644 --- a/src/test/compile-fail-fulldeps/explore-issue-38412.rs +++ b/src/test/compile-fail-fulldeps/explore-issue-38412.rs @@ -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`, diff --git a/src/test/compile-fail/lint-forbid-cmdline.rs b/src/test/compile-fail/lint-forbid-cmdline.rs index dfa6866f66e36..6a4d17b33de73 100644 --- a/src/test/compile-fail/lint-forbid-cmdline.rs +++ b/src/test/compile-fail/lint-forbid-cmdline.rs @@ -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 index 0000000000000..dac50db3fd9b2 --- /dev/null +++ b/src/test/compile-fail/stability-attribute-issue-43027.rs @@ -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 or the MIT license +// , 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(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; +}