Don't inherit stability to items in a function body.

Items defined in the body of a function has no visibility
outside it, and thus have no reason to be marked with
stability attributes.

Closes #17488
This commit is contained in:
Victor Berger 2014-11-17 11:37:07 +01:00
parent 803aacd5ae
commit 55200504f0
2 changed files with 19 additions and 2 deletions

View File

@ -83,10 +83,13 @@ impl<'v> Visitor<'v> for Annotator {
b: &'v Block, s: Span, _: NodeId) { b: &'v Block, s: Span, _: NodeId) {
match fk { match fk {
FkMethod(_, _, meth) => { 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) { fn visit_trait_item(&mut self, t: &TraitItem) {

View File

@ -459,6 +459,20 @@ mod this_crate {
foo.trait_stable(); foo.trait_stable();
} }
#[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] #[deprecated]
pub trait DeprecatedTrait {} pub trait DeprecatedTrait {}