mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
More nits
This commit is contained in:
parent
43ad19b250
commit
fea8d0eb99
@ -2506,6 +2506,10 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
self.trait_def(trait_def_id).has_auto_impl
|
||||
}
|
||||
|
||||
pub fn trait_is_coinductive(self, trait_def_id: DefId) -> bool {
|
||||
self.trait_is_auto(trait_def_id) || self.lang_items().sized_trait() == Some(trait_def_id)
|
||||
}
|
||||
|
||||
/// Returns layout of a generator. Layout might be unavailable if the
|
||||
/// generator is tainted by errors.
|
||||
pub fn generator_layout(self, def_id: DefId) -> Option<&'tcx GeneratorLayout<'tcx>> {
|
||||
|
@ -959,10 +959,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
|
||||
fn coinductive_predicate(&self, predicate: ty::Predicate<'tcx>) -> bool {
|
||||
let result = match predicate.kind().skip_binder() {
|
||||
ty::PredicateKind::Trait(ref data) => {
|
||||
self.tcx().trait_is_auto(data.def_id())
|
||||
|| self.tcx().lang_items().sized_trait() == Some(data.def_id())
|
||||
}
|
||||
ty::PredicateKind::Trait(ref data) => self.tcx().trait_is_coinductive(data.def_id()),
|
||||
ty::PredicateKind::WellFormed(_) => true,
|
||||
_ => false,
|
||||
};
|
||||
|
14
src/test/ui/sized/coinductive-1-gat.rs
Normal file
14
src/test/ui/sized/coinductive-1-gat.rs
Normal file
@ -0,0 +1,14 @@
|
||||
// check-pass
|
||||
struct Node<C: Trait>(C::Assoc::<Self>);
|
||||
|
||||
trait Trait {
|
||||
type Assoc<T>;
|
||||
}
|
||||
|
||||
impl Trait for Vec<()> {
|
||||
type Assoc<T> = Vec<T>;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _ = Node::<Vec<()>>(Vec::new());
|
||||
}
|
Loading…
Reference in New Issue
Block a user