Skip to content

Commit

Permalink
Correctly analyze sealed status of traits with multiple supertraits. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
obi1kenobi authored Aug 19, 2024
1 parent 127cd5d commit cea580b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/adapter/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ fn rustdoc_sealed_traits() {
name: "TransitivelyTraitSealed".into(),
sealed: true,
},
Output {
name: "SealedTraitWithStdSupertrait".into(),
sealed: true,
},
Output {
name: "Unsealed".into(),
sealed: false,
Expand Down
2 changes: 1 addition & 1 deletion src/sealed_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fn has_sealed_supertrait<'a>(indexed_crate: &IndexedCrate<'a>, inner: &'a Trait)
// TODO: Once we have the ability to do cross-crate analysis, consider
// whether this external trait is sealed. That can have
// some interesting SemVer implications as well.
return false;
continue;
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions test_crates/sealed_traits/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ pub trait DirectlyTraitSealed: private::Sealed {}
/// This trait is sealed since nobody can implement its supertrait.
pub trait TransitivelyTraitSealed: DirectlyTraitSealed {}

/// This trait is sealed, and happens to have more than one supertrait.
pub trait SealedTraitWithStdSupertrait: AsRef<()> + private::Sealed {}

pub trait Unsealed {}

/// This trait is sealed because its argument type is pub-in-priv,
Expand Down

0 comments on commit cea580b

Please sign in to comment.