Skip to content

Commit d46451c

Browse files
Rollup merge of rust-lang#100431 - compiler-errors:enum-ctor-variant-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
2 parents e248c7f + 6925f41 commit d46451c

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

compiler/rustc_passes/src/stability.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
460460
AnnotationKind::Required,
461461
InheritDeprecation::Yes,
462462
InheritConstStability::No,
463-
InheritStability::No,
463+
InheritStability::Yes,
464464
|_| {},
465465
);
466466
}
@@ -600,6 +600,9 @@ impl<'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'tcx> {
600600

601601
fn visit_variant(&mut self, var: &'tcx Variant<'tcx>) {
602602
self.check_missing_stability(self.tcx.hir().local_def_id(var.id), var.span);
603+
if let Some(ctor_hir_id) = var.data.ctor_hir_id() {
604+
self.check_missing_stability(self.tcx.hir().local_def_id(ctor_hir_id), var.span);
605+
}
603606
intravisit::walk_variant(self, var);
604607
}
605608

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![crate_type = "lib"]
2+
#![feature(staged_api)]
3+
#![stable(feature = "none", since = "1.0")]
4+
5+
#[stable(feature = "none", since = "1.0")]
6+
pub enum Foo {
7+
A,
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// aux-build:ctor-stability.rs
2+
// check-pass
3+
4+
extern crate ctor_stability;
5+
6+
fn main() {
7+
let _ = ctor_stability::Foo::A;
8+
}

0 commit comments

Comments
 (0)