Change:
The following ICE's in nightly: <details<summaryBacktrace:</summary</detailsBeta just errors normally, complaining that takes two parameters.
this seems the one to blame. tested the snippet above with , rustc complained: <details<summaryRUSTCLOG=rustctypeck::check=debug </summaryerror[E0107]: wrong number of type arguments: expected 2, found 1 --t.rs:3:19 | 3 | async fn foo() -std::result::Result<(){ | ^^^^^^^^^^^^^^^^^^^^^^^ expected 2 type arguments [DEBUG rustctypeck::check] checkfn(sig=([]; cvariadic: false)-impl std::future::Future, fnid=HirId { owner: DefIndex(13), localid: 0 }, paramenv=ParamEnv { callerbounds: [], reveal: UserFacing, defid: None }) [DEBUG rustctypeck::check] instantiateopaquetypesfromvalue(parentdefid=DefId(0:13 ~ t[317d]::foo[0]), value=impl std::future::Future) [DEBUG rustctypeck::check] checkfn: declaredretty: impl std::future::Future, revealedretty: [DEBUG rustctypeck::check::expr] type-checking: expr=expr(HirId { owner: DefIndex(13), localid: 16 }: ::std::future::fromgenerator(move )) expected=ExpectHasType() [DEBUG rustctypeck::check::expr] checkexprkind(expr=expr(HirId { owner: DefIndex(13), localid: 16 }: ::std::future::fromgenerator(move )), expected=ExpectHasType(), needs=None) [DEBUG rustctypeck::check::expr] type-checking: expr=expr(HirId { owner: DefIndex(13), localid: 15 }: ::std::future::fromgenerator) expected=NoExpectation [DEBUG rustctypeck::check::expr] checkexprkind(expr=expr(HirId { owner: DefIndex(13), localid: 15 }: ::std::future::fromgenerator), expected=NoExpectation, needs=None) [DEBUG rustctypeck::check] resolvetyandresufcs: qpath=Resolved(None, path(::std::future::fromgenerator)) hirid=HirId { owner: DefIndex(13), localid: 15 } 5:2 [DEBUG rustctypeck::check] instantiatevaluepath(segments=[PathSegment { ident: {{root}}, hirid: Some(HirId { owner: DefIndex(13), localid: 11 }), res: Some(Err), args: None, inferargs: true }, PathSegment { ident: std, hirid: Some(HirId { owner: DefIndex(13), localid: 12 }), res: Some(Def(Mod, DefId(1:0 ~ std[5025]))), args: None, inferargs: true }, PathSegment { ident: future, hirid: Some(HirId { owner: DefIndex(13), localid: 13 }), res: Some(Def(Mod, DefId(1:5334 ~ std[5025]::future[0]))), args: None, inferargs: true }, PathSegment { ident: fromgenerator, hirid: Some(HirId { owner: DefIndex(13), localid: 14 }), res: Some(Err), args: None, inferargs: true }], selfty=None, res=Def(Fn, DefId(1:5348 ~ std[5025]::future[0]::fromgenerator[0])), hirid=HirId { owner: DefIndex(13), localid: 15 }) [DEBUG rustctypeck::check] writeusertypeannotationfromsubsts: hirid=HirId { owner: DefIndex(13), localid: 15 } defid=DefId(1:5348 ~ std[5025]::future[0]::fromgenerator[0]) substs=[] userselfty=None in fcx 0x70000faed8d0 [DEBUG rustctypeck::check] writeusertypeannotationfromsubsts: canonicalized=Canonical { maxuniverse: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: TypeOf(DefId(1:5348 ~ std[5025]::future[0]::fromgenerator[0]), UserSubsts { substs: [^0], userselfty: None }) } [DEBUG rustctypeck::check] writeusertypeannotation: hirid=HirId { owner: DefIndex(13), localid: 15 } canonicalusertypeannotation=Canonical { maxuniverse: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: TypeOf(DefId(1:5348 ~ std[5025]::future[0]::fromgenerator[0]), UserSubsts { substs: [^0], userselfty: None }) } tag=0x70000faed8d0 [DEBUG rustctypeck::check] writeusertypeannotation: skipping identity substs [DEBUG rustctypeck::check] instantiatebounds(bounds=GenericPredicates { parent: None, predicates: [(Binder(TraitPredicate(<T as std::marker::Sized)), 21:24), (Binder(TraitPredicate(<T as std::ops::Generator)), 21:47), (Binder(ProjectionPredicate(ProjectionTy { substs: [T], itemdefid: DefId(2:1765 ~ core[6f86]::ops[0]::generator[0]::Generator[0]::Yield[0]) }, ())), 21:46)] }, substs=[]) = InstantiatedPredicates { predicates: [Binder(TraitPredicate(< as std::marker::Sized)), Binder(TraitPredicate(< as std::ops::Generator)), Binder(ProjectionPredicate(ProjectionTy { substs: [], itemdefid: DefId(2:1765 ~ core[6f86]::ops[0]::generator[0]::Generator[0]::Yield[0]) }, ()))] }, [ 21:24, 21:47, 21:46] [DEBUG rustctypeck::check] registerpredicate(Obligation(predicate=Binder(TraitPredicate(< as std::marker::Sized)), depth=0)) [DEBUG rustctypeck::check] registerpredicate(Obligation(predicate=Binder(TraitPredicate(< as std::ops::Generator)), depth=0)) [DEBUG rustctypeck::check] registerpredicate(Obligation(predicate=Binder(ProjectionPredicate(ProjectionTy { substs: [], itemdefid: DefId(2:1765 ~ core[6f86]::ops[0]::generator[0]::Generator[0]::Yield[0]) }, ())), depth=0)) [DEBUG rustctypeck::check] instantiatetypescheme(value=fn() -impl std::future::Future {std::future::fromgenerator::<}, substs=[]) = fn() -impl std::future::Future {std::future::fromgenerator::<} [DEBUG rustctypeck::check] instantiatevaluepath: type of HirId { owner: DefIndex(13), localid: 15 } is fn() -impl std::future::Future {std::future::fromgenerator::<} [DEBUG rustctypeck::check] writesubsts(HirId { owner: DefIndex(13), localid: 15 }, []) in fcx 0x70000faed8d0 [DEBUG rustctypeck::check] registerpredicate(Obligation(predicate=WellFormed(), depth=0)) [DEBUG rustctypeck::check] writety(HirId { owner: DefIndex(13), localid: 15 }, fn() -impl std::future::Future {std::future::fromgenerator::<}) in fcx 0x70000faed8d0 [DEBUG rustctypeck::check::expr] type of expr ::std::future::fromgenerator (hirid=HirId { owner: DefIndex(13), localid: 15 }) is... [DEBUG rustctypeck::check::expr] ... fn() -impl std::future::Future {std::future::fromgenerator::<}, expected is NoExpectation [DEBUG rustctypeck::check] resolvetypevarswithobligations(ty=fn() -impl std::future::Future {std::future::fromgenerator::<}) [DEBUG rustctypeck::check] resolvetypevarswithobligations: ty=fn() -impl std::future::Future {std::future::fromgenerator::<} [DEBUG rustctypeck::check::autoderef] autoderef: steps=[], curty=fn() -impl std::future::Future {std::future::fromgenerator::<} [DEBUG rustctypeck::check::autoderef] autoderef stage is fn() -impl std::future::Future {std::future::fromgenerator::<} [DEBUG rustctypeck::check] resolvetypevarswithobligations(ty=fn() -impl std::future::Future {std::future::fromgenerator::<}) [DEBUG rustctypeck::check] resolvetypevarswithobligations: ty=fn() -impl std::future::Future {std::future::fromgenerator::<} [DEBUG rustctypeck::check::callee] tryoverloadedcallstep(callexpr=expr(HirId { owner: DefIndex(13), localid: 16 }: ::std::future::fromgenerator(move )), adjustedty=fn() -impl std::future::Future {std::future::fromgenerator::<}) [DEBUG rustctypeck::check] applyadjustments(expr=expr(HirId { owner: DefIndex(13), localid: 15 }: ::std::future::fromgenerator), adj=[]) [DEBUG rustctypeck::check] resolvetypevarswithobligations(ty=impl std::future::Future) [DEBUG rustctypeck::check] resolvetypevarswithobligations: ty=impl std::future::Future [DEBUG rustctypeck::check] expectedinputsforexpectedoutput(formal=[] -impl std::future::Future, expected=[] -ExpectHasType()) [DEBUG rustctypeck::check] registerpredicate(Obligation(predicate=WellFormed(), depth=0)) [DEBUG rustctypeck::check] checkargumenttypes: formaltys=[""] [DEBUG rustctypeck::check] checkclosures=false [DEBUG rustctypeck::check] checkclosures=true [DEBUG rustctypeck::check] checking the argument [DEBUG rustctypeck::check::expr] type-checking: expr=expr(HirId { owner: DefIndex(13), localid: 10 }: move ) expected=ExpectHasType() [DEBUG rustctypeck::check::expr] checkexprkind(expr=expr(HirId { owner: DefIndex(13), localid: 10 }: move ), expected=ExpectHasType(), needs=None) [DEBUG rustctypeck::check::closure] checkexprclosure(expr=expr(HirId { owner: DefIndex(13), localid: 10 }: move ),expected=ExpectHasType()) [DEBUG rustctypeck::check::closure] deduceexpectationsfromexpectedtype(expectedty=) [DEBUG rustctypeck::check] obligationsforselfty: selfty=t tyvarroot=t pendingobligations=[Obligation(predicate=Binder(TraitPredicate(< as std::marker::Sized)), depth=0), Obligation(predicate=Binder(TraitPredicate(< as std::ops::Generator)), depth=0), Obligation(predicate=Binder(ProjectionPredicate(ProjectionTy { substs: [], itemdefid: DefId(2:1765 ~ core[6f86]::ops[0]::generator[0]::Generator[0]::Yield[0]) }, ())), depth=0), Obligation(predicate=WellFormed(), depth=0)] [DEBUG rustctypeck::check] selftypematchesexpectedvid(traitref=Binder(< as std::marker::Sized), selfty=, expectedvid=t) [DEBUG rustctypeck::check] selftypematchesexpectedvid - foundvid=t [DEBUG rustctypeck::check::closure] deduceexpectationsfromobligations: obligation.predicate=Binder(TraitPredicate(< as std::marker::Sized)) [DEBUG rustctypeck::check] selftypematchesexpectedvid(traitref=Binder(< as std::ops::Generator), selfty=, expectedvid=t) [DEBUG rustctypeck::check] selftypematchesexpectedvid - foundvid=t [DEBUG rustctypeck::check::closure] deduceexpectationsfromobligations: obligation.predicate=Binder(TraitPredicate(< as std::ops::Generator)) [DEBUG rustctypeck::check] selftypematchesexpectedvid(traitref=Binder(< as std::ops::Generator), selfty=, expectedvid=t) [DEBUG rustctypeck::check] selftypematchesexpectedvid - foundvid=t [DEBUG rustctypeck::check::closure] deduceexpectationsfromobligations: obligation.predicate=Binder(ProjectionPredicate(ProjectionTy { substs: [], itemdefid: DefId(2:1765 ~ core[6f86]::ops[0]::generator[0]::Generator[0]::Yield[0]) }, ())) [DEBUG rustctypeck::check::closure] deducesigfromprojection(Binder(ProjectionPredicate(ProjectionTy { substs: [], itemdefid: DefId(2:1765 ~ core[6f86]::ops[0]::generator[0]::Generator[0]::Yield[0]) }, ()))) [DEBUG rustctypeck::check::closure] deducesigfromprojection: not return assoc item of generator [DEBUG rustctypeck::check] obligationsforselfty: selfty=t tyvarroot=t pendingobligations=[Obligation(predicate=Binder(TraitPredicate(< as std::marker::Sized)), depth=0), Obligation(predicate=Binder(TraitPredicate(< as std::ops::Generator)), depth=0), Obligation(predicate=Binder(ProjectionPredicate(ProjectionTy { substs: [], itemdefid: DefId(2:1765 ~ core[6f86]::ops[0]::generator[0]::Generator[0]::Yield[0]) }, ())), depth=0), Obligation(predicate=WellFormed(), depth=0)] [DEBUG rustctypeck::check] selftypematchesexpectedvid(traitref=Binder(< as std::marker::Sized), selfty=, expectedvid=t) [DEBUG rustctypeck::check] selftypematchesexpectedvid - foundvid=t [DEBUG rustctypeck::check] selftypematchesexpectedvid(traitref=Binder(< as std::ops::Generator), selfty=, expectedvid=t) [DEBUG rustctypeck::check] selftypematchesexpectedvid - foundvid=t [DEBUG rustctypeck::check] selftypematchesexpectedvid(traitref=Binder(< as std::ops::Generator), selfty=, expectedvid=t) [DEBUG rustctypeck::check] selftypematchesexpectedvid - foundvid=t [DEBUG rustctypeck::check::closure] checkclosure(optkind=None, expectedsig=None) [DEBUG rustctypeck::check::closure] sigofclosurenoexpectation() [DEBUG rustctypeck::check::closure] suppliedsigofclosure(decl=FnDecl { inputs: [], output: DefaultReturn(t.rs:3:43: 5:2), cvariadic: false, implicitself: None }, body.generatorkind=Some(Async(Fn))) [DEBUG rustctypeck::check::closure] suppliedsigofclosure: closure is async fn body [DEBUG rustctypeck::check::closure] deducefutureoutputfromobligations(exprdefid=DefId(0:15 ~ t[317d]::foo[0]::{{closure}}[0])) [DEBUG rustctypeck::check] obligationsforselfty: selfty=t tyvarroot=t pendingobligations=[Obligation(predicate=Binder(TraitPredicate(< as std::marker::Sized)), depth=0), Obligation(predicate=Binder(TraitPredicate(< as std::ops::Generator)), depth=0), Obligation(predicate=Binder(ProjectionPredicate(ProjectionTy { substs: [], itemdefid: DefId(2:1765 ~ core[6f86]::ops[0]::generator[0]::Generator[0]::Yield[0]) }, ())), depth=0), Obligation(predicate=WellFormed(), depth=0)] [DEBUG rustctypeck::check] selftypematchesexpectedvid(traitref=Binder(< as std::marker::Sized), selfty=, expectedvid=t) [DEBUG rustctypeck::check] selftypematchesexpectedvid - foundvid=t [DEBUG rustctypeck::check] selftypematchesexpectedvid(traitref=Binder(< as std::ops::Generator), selfty=, expectedvid=t) [DEBUG rustctypeck::check] selftypematchesexpectedvid - foundvid=t [DEBUG rustctypeck::check] selftypematchesexpectedvid(traitref=Binder(< as std::ops::Generator), selfty=, expectedvid=t) [DEBUG rustctypeck::check] selftypematchesexpectedvid - foundvid=t thread 'rustc' panicked at 'called on a value', </details
I'll investigate tomorrow.
Pending fix in

Discussion:
Some(hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Fn)) => { debug!("supplied_sig_of_closure: closure is async fn body"); self.deduce_future_output_from_obligations(expr_def_id) <ins> .unwrap_or_else(|| { // AFAIK, deducing the future output // always succeeds *except* in error cases // like #65159. I'd like to return Error // here, but I can't because I can't // easily (and locally) prove that we // *have* reported an // error. --nikomatsakis astconv.ty_infer(None, decl.output.span()) }) </ins> } _ => astconv.ty_infer(None, decl.output.span()),

fn deduce_future_output_from_obligations( &self, expr_def_id: DefId, <del> ) -> Ty<'tcx> { </del> <ins> ) -> Option<Ty<'tcx>> { </ins> debug!("deduce_future_output_from_obligations(expr_def_id={:?})", expr_def_id); let ret_coercion =

} else { None } <del> }) .unwrap(); </del> <ins> }); </ins> debug!("deduce_future_output_from_obligations: output_ty={:?}", output_ty); output_ty

<ins> // Regression test for #65159. We used to ICE. // // edition:2018 async fn copy() -> Result<()> //~ ERROR wrong number of type arguments { Ok(()) } fn main() { } </ins>

<ins> error[E0107]: wrong number of type arguments: expected 2, found 1 --> $DIR/issue-65159.rs:5:20 | LL | async fn copy() -> Result<()> |                    ^^^^^^^^^^ expected 2 type arguments error: aborting due to previous error For more information about this error, try `rustc --explain E0107`. </ins>