diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2021-04-22 18:14:42 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-22 18:14:42 +0200 |
| commit | f180c1e05de9729bd34716418e6adce6e9f649f1 (patch) | |
| tree | 4febc65e428e9413ff0586054e3205391276d6e1 /compiler | |
| parent | aac5125da4c8f06de57ab89985a5fc204c122483 (diff) | |
| parent | 75732dd00e845ed27e6a482db965e673805d85a9 (diff) | |
| download | rust-f180c1e05de9729bd34716418e6adce6e9f649f1.tar.gz rust-f180c1e05de9729bd34716418e6adce6e9f649f1.zip | |
Rollup merge of #84404 - tmiasko:intrinsics-in-coercion-lub, r=Mark-Simulacrum
Check for intrinsics before coercing to a function pointer Return an error if coercing function items / non-capturing closures to a common function pointer type would require reifying an intrinsic. Turns ICE reported in #84297 into a proper error.
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_typeck/src/check/coercion.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_typeck/src/check/coercion.rs b/compiler/rustc_typeck/src/check/coercion.rs index fd7c50e9788..427f967a9b6 100644 --- a/compiler/rustc_typeck/src/check/coercion.rs +++ b/compiler/rustc_typeck/src/check/coercion.rs @@ -973,6 +973,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } }; if let (Some(a_sig), Some(b_sig)) = (a_sig, b_sig) { + // Intrinsics are not coercible to function pointers. + if a_sig.abi() == Abi::RustIntrinsic + || a_sig.abi() == Abi::PlatformIntrinsic + || b_sig.abi() == Abi::RustIntrinsic + || b_sig.abi() == Abi::PlatformIntrinsic + { + return Err(TypeError::IntrinsicCast); + } // The signature must match. let a_sig = self.normalize_associated_types_in(new.span, a_sig); let b_sig = self.normalize_associated_types_in(new.span, b_sig); |
