Skip to content

Commit 4504648

Browse files
committed
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>
1 parent 5c86348 commit 4504648

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/librustc_lint/types.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -878,9 +878,15 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
878878

879879
// `extern "C" fn` functions can have type parameters, which may or may not be FFI-safe,
880880
// so they are currently ignored for the purposes of this lint.
881-
ty::Param(..) | ty::Projection(..) => FfiSafe,
881+
ty::Param(..) | ty::Projection(..)
882+
if matches!(self.mode, ImproperCTypesMode::Definitions) =>
883+
{
884+
FfiSafe
885+
}
882886

883-
ty::Infer(..)
887+
ty::Param(..)
888+
| ty::Projection(..)
889+
| ty::Infer(..)
884890
| ty::Bound(..)
885891
| ty::Error(_)
886892
| ty::Closure(..)

0 commit comments

Comments
 (0)