add generator_clone feature gate
This commit is contained in:
parent
2c0bc9444e
commit
0228c073e0
3 changed files with 35 additions and 24 deletions
|
@ -396,6 +396,8 @@ declare_features! (
|
|||
(active, fn_align, "1.53.0", Some(82232), None),
|
||||
/// Allows defining generators.
|
||||
(active, generators, "1.21.0", Some(43122), None),
|
||||
/// Allows generators to be cloned.
|
||||
(active, generator_clone, "1.60.0", None, None),
|
||||
/// Infer generic args for both consts and types.
|
||||
(active, generic_arg_infer, "1.55.0", Some(85077), None),
|
||||
/// Allows associated types to be generic, e.g., `type Foo<T>;` (RFC 1598).
|
||||
|
|
|
@ -763,6 +763,7 @@ symbols! {
|
|||
gen_future,
|
||||
gen_kill,
|
||||
generator,
|
||||
generator_clone,
|
||||
generator_state,
|
||||
generators,
|
||||
generic_arg_infer,
|
||||
|
|
|
@ -1938,6 +1938,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
}
|
||||
|
||||
ty::Generator(_, substs, hir::Movability::Movable) => {
|
||||
if self.tcx().features().generator_clone {
|
||||
let resolved_upvars = self.infcx.shallow_resolve(substs.as_generator().tupled_upvars_ty());
|
||||
let resolved_witness = self.infcx.shallow_resolve(substs.as_generator().witness());
|
||||
if {
|
||||
|
@ -1951,10 +1952,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
all.push(substs.as_generator().witness());
|
||||
Where(obligation.predicate.rebind(all))
|
||||
}
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
ty::GeneratorWitness(binder) => {
|
||||
let tys = binder.no_bound_vars().unwrap();
|
||||
match binder.no_bound_vars() {
|
||||
Some(tys) => {
|
||||
let mut iter = tys.iter();
|
||||
loop {
|
||||
let ty = match iter.next() {
|
||||
|
@ -1968,6 +1973,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
break Ambiguous;
|
||||
}
|
||||
}
|
||||
},
|
||||
Option::None => None,
|
||||
}
|
||||
}
|
||||
|
||||
ty::Closure(_, substs) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue