Skip to content

Commit

Permalink
Rollup merge of rust-lang#100431 - compiler-errors:enum-ctor-variant-…
Browse files Browse the repository at this point in the history
…stab, r=estebank

Enum variant ctor inherits the stability of the enum variant

Fixes rust-lang#100399
Fixes rust-lang#100420

Context rust-lang#71481 for why enum variants don't need stability
  • Loading branch information
compiler-errors authored Aug 14, 2022
2 parents e248c7f + 6925f41 commit d46451c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
5 changes: 4 additions & 1 deletion compiler/rustc_passes/src/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
AnnotationKind::Required,
InheritDeprecation::Yes,
InheritConstStability::No,
InheritStability::No,
InheritStability::Yes,
|_| {},
);
}
Expand Down Expand Up @@ -600,6 +600,9 @@ impl<'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'tcx> {

fn visit_variant(&mut self, var: &'tcx Variant<'tcx>) {
self.check_missing_stability(self.tcx.hir().local_def_id(var.id), var.span);
if let Some(ctor_hir_id) = var.data.ctor_hir_id() {
self.check_missing_stability(self.tcx.hir().local_def_id(ctor_hir_id), var.span);
}
intravisit::walk_variant(self, var);
}

Expand Down
8 changes: 8 additions & 0 deletions src/test/ui/stability-attribute/auxiliary/ctor-stability.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#![crate_type = "lib"]
#![feature(staged_api)]
#![stable(feature = "none", since = "1.0")]

#[stable(feature = "none", since = "1.0")]
pub enum Foo {
A,
}
8 changes: 8 additions & 0 deletions src/test/ui/stability-attribute/ctor-stability.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// aux-build:ctor-stability.rs
// check-pass

extern crate ctor_stability;

fn main() {
let _ = ctor_stability::Foo::A;
}

0 comments on commit d46451c

Please sign in to comment.