Skip to content

Commit a81c513

Browse files
committed
Bail out on inference variables in function arguments
1 parent 643a708 commit a81c513

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/librustc_typeck/check/never_compat.rs

+22
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use rustc::ty::fold::TypeFolder;
77
use rustc::ty::{Ty, TyCtxt, TyVid};
88
use rustc_data_structures::fx::FxHashMap;
99
use rustc_hir::HirId;
10+
use std::borrow::Cow;
1011

1112
/// Code to detect cases where using `!` (never-type) fallback instead of `()` fallback
1213
/// may result in the introduction of undefined behavior;
@@ -302,6 +303,27 @@ impl<'tcx> NeverCompatHandler<'tcx> {
302303
}
303304
};
304305

306+
let args_infer = match path.args.as_ref().unwrap() {
307+
Cow::Borrowed(b) => b.iter().any(|ty| {
308+
fcx.infcx
309+
.unresolved_type_vars(&fcx.infcx.resolve_vars_if_possible(ty))
310+
.is_some()
311+
}),
312+
Cow::Owned(o) => fcx
313+
.infcx
314+
.unresolved_type_vars(&fcx.infcx.resolve_vars_if_possible(o))
315+
.is_some(),
316+
};
317+
318+
if args_infer {
319+
debug!(
320+
"pre_fallback: skipping due to inference vars in fn {:?} args {:?}",
321+
ty_resolved,
322+
path.args.unwrap()
323+
);
324+
return None;
325+
}
326+
305327
// Any method call with inference variables in its substs
306328
// could potentially be affected by fallback.
307329
if fcx.infcx.unresolved_type_vars(fn_substs).is_some() {

0 commit comments

Comments
 (0)