improper_ctypes: only allow params in defns mode

This commit adjusts the behaviour introduced in a previous commit so
that generic parameters and projections are only allowed in the
definitions mode - and are otherwise a bug. Generic parameters in
declarations are prohibited earlier in the compiler, so if that branch
were reached, it would be a bug.

Signed-off-by: David Wood <david@davidtw.co>
This commit is contained in:
David Wood 2020-06-21 20:30:41 +01:00
parent 5c8634805c
commit 4504648090
No known key found for this signature in database
GPG Key ID: 2592E76C87381FD9

@ -878,9 +878,15 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
// `extern "C" fn` functions can have type parameters, which may or may not be FFI-safe,
// so they are currently ignored for the purposes of this lint.
ty::Param(..) | ty::Projection(..) => FfiSafe,
ty::Param(..) | ty::Projection(..)
if matches!(self.mode, ImproperCTypesMode::Definitions) =>
{
FfiSafe
}
ty::Infer(..)
ty::Param(..)
| ty::Projection(..)
| ty::Infer(..)
| ty::Bound(..)
| ty::Error(_)
| ty::Closure(..)