Skip to content

Commit fea8d0e

Browse files
More nits
1 parent 43ad19b commit fea8d0e

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

compiler/rustc_middle/src/ty/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -2506,6 +2506,10 @@ impl<'tcx> TyCtxt<'tcx> {
25062506
self.trait_def(trait_def_id).has_auto_impl
25072507
}
25082508

2509+
pub fn trait_is_coinductive(self, trait_def_id: DefId) -> bool {
2510+
self.trait_is_auto(trait_def_id) || self.lang_items().sized_trait() == Some(trait_def_id)
2511+
}
2512+
25092513
/// Returns layout of a generator. Layout might be unavailable if the
25102514
/// generator is tainted by errors.
25112515
pub fn generator_layout(self, def_id: DefId) -> Option<&'tcx GeneratorLayout<'tcx>> {

compiler/rustc_trait_selection/src/traits/select/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -959,10 +959,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
959959

960960
fn coinductive_predicate(&self, predicate: ty::Predicate<'tcx>) -> bool {
961961
let result = match predicate.kind().skip_binder() {
962-
ty::PredicateKind::Trait(ref data) => {
963-
self.tcx().trait_is_auto(data.def_id())
964-
|| self.tcx().lang_items().sized_trait() == Some(data.def_id())
965-
}
962+
ty::PredicateKind::Trait(ref data) => self.tcx().trait_is_coinductive(data.def_id()),
966963
ty::PredicateKind::WellFormed(_) => true,
967964
_ => false,
968965
};
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// check-pass
2+
struct Node<C: Trait>(C::Assoc::<Self>);
3+
4+
trait Trait {
5+
type Assoc<T>;
6+
}
7+
8+
impl Trait for Vec<()> {
9+
type Assoc<T> = Vec<T>;
10+
}
11+
12+
fn main() {
13+
let _ = Node::<Vec<()>>(Vec::new());
14+
}

0 commit comments

Comments
 (0)