File tree Expand file tree Collapse file tree 3 files changed +32
-5
lines changed
compiler/rustc_middle/src Expand file tree Collapse file tree 3 files changed +32
-5
lines changed Original file line number Diff line number Diff line change @@ -32,13 +32,23 @@ impl<'tcx> Value<TyCtxt<'tcx>> for ty::SymbolName<'_> {
3232}
3333
3434impl < ' tcx > Value < TyCtxt < ' tcx > > for ty:: Binder < ' _ , ty:: FnSig < ' _ > > {
35- fn from_cycle_error ( tcx : TyCtxt < ' tcx > , _ : & [ QueryInfo ] ) -> Self {
35+ fn from_cycle_error ( tcx : TyCtxt < ' tcx > , stack : & [ QueryInfo ] ) -> Self {
3636 let err = tcx. ty_error ( ) ;
37- // FIXME(compiler-errors): It would be nice if we could get the
38- // query key, so we could at least generate a fn signature that
39- // has the right arity.
37+
38+ let arity = if let Some ( frame) = stack. get ( 0 )
39+ && frame. query . name == "fn_sig"
40+ && let Some ( def_id) = frame. query . def_id
41+ && let Some ( node) = tcx. hir ( ) . get_if_local ( def_id)
42+ && let Some ( sig) = node. fn_sig ( )
43+ {
44+ sig. decl . inputs . len ( ) + sig. decl . implicit_self . has_implicit_self ( ) as usize
45+ } else {
46+ tcx. sess . abort_if_errors ( ) ;
47+ unreachable ! ( )
48+ } ;
49+
4050 let fn_sig = ty:: Binder :: dummy ( tcx. mk_fn_sig (
41- [ ] . into_iter ( ) ,
51+ std :: iter :: repeat ( err ) . take ( arity ) ,
4252 err,
4353 false ,
4454 rustc_hir:: Unsafety :: Normal ,
Original file line number Diff line number Diff line change 1+ trait Dancer {
2+ fn dance ( & self ) -> _ {
3+ //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types
4+ self . dance ( )
5+ }
6+ }
7+
8+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types
2+ --> $DIR/fn-sig-cycle-arity.rs:2:24
3+ |
4+ LL | fn dance(&self) -> _ {
5+ | ^ not allowed in type signatures
6+
7+ error: aborting due to previous error
8+
9+ For more information about this error, try `rustc --explain E0121`.
You can’t perform that action at this time.
0 commit comments