diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-09-02 17:28:37 -0400 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-09-02 17:28:37 -0400 |
| commit | dd323f8a72327aba0b4771ea08a8b007bba995ca (patch) | |
| tree | 958d649c9a0998c9eff757b70953c0acf4df9b22 /src/librustc | |
| parent | 9af17757be1cc3f672928ecf06c40a662c5ec26d (diff) | |
| download | rust-dd323f8a72327aba0b4771ea08a8b007bba995ca.tar.gz rust-dd323f8a72327aba0b4771ea08a8b007bba995ca.zip | |
Emit error on intrinsic to fn ptr casts
Diffstat (limited to 'src/librustc')
| -rw-r--r-- | src/librustc/infer/error_reporting/mod.rs | 3 | ||||
| -rw-r--r-- | src/librustc/ty/error.rs | 5 | ||||
| -rw-r--r-- | src/librustc/ty/structural_impls.rs | 2 |
3 files changed, 10 insertions, 0 deletions
diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index 9be73cf3c6d..e684ccfeeb7 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -1636,6 +1636,9 @@ impl<'tcx> ObligationCause<'tcx> { TypeError::CyclicTy(ty) if ty.is_closure() || ty.is_generator() => { Error0644("closure/generator type that references itself") } + TypeError::IntrinsicCast => { + Error0308("cannot coerce intrinsics to function pointers") + } _ => Error0308("mismatched types"), }, } diff --git a/src/librustc/ty/error.rs b/src/librustc/ty/error.rs index c70006b68d6..fe8f94ab1d3 100644 --- a/src/librustc/ty/error.rs +++ b/src/librustc/ty/error.rs @@ -46,6 +46,8 @@ pub enum TypeError<'tcx> { ExistentialMismatch(ExpectedFound<&'tcx ty::List<ty::ExistentialPredicate<'tcx>>>), ConstMismatch(ExpectedFound<&'tcx ty::Const<'tcx>>), + + IntrinsicCast, } #[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Hash, Debug, Copy)] @@ -179,6 +181,9 @@ impl<'tcx> fmt::Display for TypeError<'tcx> { ConstMismatch(ref values) => { write!(f, "expected `{}`, found `{}`", values.expected, values.found) } + IntrinsicCast => { + write!(f, "cannot coerce intrinsics to function pointers") + } } } } diff --git a/src/librustc/ty/structural_impls.rs b/src/librustc/ty/structural_impls.rs index 649a5244728..ec7cf1a13c5 100644 --- a/src/librustc/ty/structural_impls.rs +++ b/src/librustc/ty/structural_impls.rs @@ -748,6 +748,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::error::TypeError<'a> { Sorts(ref x) => return tcx.lift(x).map(Sorts), ExistentialMismatch(ref x) => return tcx.lift(x).map(ExistentialMismatch), ConstMismatch(ref x) => return tcx.lift(x).map(ConstMismatch), + IntrinsicCast => IntrinsicCast, }) } } @@ -1338,6 +1339,7 @@ EnumTypeFoldableImpl! { (ty::error::TypeError::Sorts)(x), (ty::error::TypeError::ExistentialMismatch)(x), (ty::error::TypeError::ConstMismatch)(x), + (ty::error::TypeError::IntrinsicCast), } } |
