about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorJakub Bukaj <jakub@jakub.cc>2014-11-18 00:24:07 +0100
committerJakub Bukaj <jakub@jakub.cc>2014-11-18 00:24:07 +0100
commitde05565ba31fb09b686d00f1b620ec1384136c42 (patch)
treeced0057bb2a8e6fb97cd782e9347b656a623281e /src
parentf3759dd2b66c155450f5fa618a22ae66ba4b5c7d (diff)
parent55200504f06956664cc6a9a998e7a14e05f09fdb (diff)
downloadrust-de05565ba31fb09b686d00f1b620ec1384136c42.tar.gz
rust-de05565ba31fb09b686d00f1b620ec1384136c42.zip
rollup merge of #19029: vberger/stability_function_body
Items defined in the body of a function has no visibility outside it, and thus have no reason to inherit its stability.

Closes #17488
Diffstat (limited to 'src')
-rw-r--r--src/librustc/middle/stability.rs7
-rw-r--r--src/test/compile-fail/lint-stability.rs14
2 files changed, 19 insertions, 2 deletions
diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs
index 49bbfd0be47..e3069f54e44 100644
--- a/src/librustc/middle/stability.rs
+++ b/src/librustc/middle/stability.rs
@@ -83,10 +83,13 @@ impl<'v> Visitor<'v> for Annotator {
                 b: &'v Block, s: Span, _: NodeId) {
         match fk {
             FkMethod(_, _, meth) => {
-                self.annotate(meth.id, &meth.attrs, |v| visit::walk_fn(v, fk, fd, b, s));
+                // Methods are not already annotated, so we annotate it
+                self.annotate(meth.id, &meth.attrs, |_| {});
             }
-            _ => visit::walk_fn(self, fk, fd, b, s)
+            _ => {}
         }
+        // Items defined in a function body have no reason to have
+        // a stability attribute, so we don't recurse.
     }
 
     fn visit_trait_item(&mut self, t: &TraitItem) {
diff --git a/src/test/compile-fail/lint-stability.rs b/src/test/compile-fail/lint-stability.rs
index 9e397ce9d8d..8e1723ddab2 100644
--- a/src/test/compile-fail/lint-stability.rs
+++ b/src/test/compile-fail/lint-stability.rs
@@ -460,6 +460,20 @@ mod this_crate {
     }
 
     #[deprecated]
+    fn test_fn_body() {
+        fn fn_in_body() {}
+        fn_in_body();
+    }
+
+    impl MethodTester {
+        #[deprecated]
+        fn test_method_body(&self) {
+            fn fn_in_body() {}
+            fn_in_body();
+        }
+    }
+
+    #[deprecated]
     pub trait DeprecatedTrait {}
 
     struct S;