diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index 446a7a135222..84a61641fe5b 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -192,7 +192,7 @@ declare_lint! { /// code generation units. Furthermore, different functions could have the /// same address after being merged together. UNPREDICTABLE_FUNCTION_POINTER_COMPARISONS, - Warn, + Deny, "detects unpredictable function pointer comparisons" } diff --git a/tests/ui/lint/fn-ptr-comparisons.rs b/tests/ui/lint/fn-ptr-comparisons.rs index 7e56a15383b1..e56bc74d90a1 100644 --- a/tests/ui/lint/fn-ptr-comparisons.rs +++ b/tests/ui/lint/fn-ptr-comparisons.rs @@ -1,4 +1,4 @@ -// check-pass +// check-fail extern "C" { fn test(); @@ -14,21 +14,21 @@ fn main() { let g: F = f; let _ = f == a; - //~^ WARN function pointer comparisons + //~^ ERROR function pointer comparisons let _ = f != a; - //~^ WARN function pointer comparisons + //~^ ERROR function pointer comparisons let _ = f == g; - //~^ WARN function pointer comparisons + //~^ ERROR function pointer comparisons let _ = f == f; - //~^ WARN function pointer comparisons + //~^ ERROR function pointer comparisons let _ = g == g; - //~^ WARN function pointer comparisons + //~^ ERROR function pointer comparisons let cfn: extern "C" fn() = c; let _ = cfn == c; - //~^ WARN function pointer comparisons + //~^ ERROR function pointer comparisons let t: unsafe extern "C" fn() = test; let _ = t == test; - //~^ WARN function pointer comparisons + //~^ ERROR function pointer comparisons } diff --git a/tests/ui/lint/fn-ptr-comparisons.stderr b/tests/ui/lint/fn-ptr-comparisons.stderr index 5b37511ae859..56c6ce7e526c 100644 --- a/tests/ui/lint/fn-ptr-comparisons.stderr +++ b/tests/ui/lint/fn-ptr-comparisons.stderr @@ -1,4 +1,4 @@ -warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique +error: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique --> $DIR/fn-ptr-comparisons.rs:16:13 | LL | let _ = f == a; @@ -6,9 +6,9 @@ LL | let _ = f == a; | = note: the address of the same function can very between different codegen units = note: furthermore, different functions could have the same address after being merged together - = note: `#[warn(unpredictable_function_pointer_comparisons)]` on by default + = note: `#[deny(unpredictable_function_pointer_comparisons)]` on by default -warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique +error: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique --> $DIR/fn-ptr-comparisons.rs:18:13 | LL | let _ = f != a; @@ -17,7 +17,7 @@ LL | let _ = f != a; = note: the address of the same function can very between different codegen units = note: furthermore, different functions could have the same address after being merged together -warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique +error: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique --> $DIR/fn-ptr-comparisons.rs:20:13 | LL | let _ = f == g; @@ -26,7 +26,7 @@ LL | let _ = f == g; = note: the address of the same function can very between different codegen units = note: furthermore, different functions could have the same address after being merged together -warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique +error: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique --> $DIR/fn-ptr-comparisons.rs:22:13 | LL | let _ = f == f; @@ -35,7 +35,7 @@ LL | let _ = f == f; = note: the address of the same function can very between different codegen units = note: furthermore, different functions could have the same address after being merged together -warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique +error: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique --> $DIR/fn-ptr-comparisons.rs:24:13 | LL | let _ = g == g; @@ -44,7 +44,7 @@ LL | let _ = g == g; = note: the address of the same function can very between different codegen units = note: furthermore, different functions could have the same address after being merged together -warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique +error: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique --> $DIR/fn-ptr-comparisons.rs:28:13 | LL | let _ = cfn == c; @@ -53,7 +53,7 @@ LL | let _ = cfn == c; = note: the address of the same function can very between different codegen units = note: furthermore, different functions could have the same address after being merged together -warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique +error: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique --> $DIR/fn-ptr-comparisons.rs:32:13 | LL | let _ = t == test; @@ -62,5 +62,5 @@ LL | let _ = t == test; = note: the address of the same function can very between different codegen units = note: furthermore, different functions could have the same address after being merged together -warning: 7 warnings emitted +error: aborting due to 7 previous errors