Skip to content

Commit

Permalink
[DO NOT MERGE] Temporarily make the lint deny-by-default from crater
Browse files Browse the repository at this point in the history
  • Loading branch information
Urgau committed Dec 13, 2023
1 parent 23214cb commit 6c5c546
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down
16 changes: 8 additions & 8 deletions tests/ui/lint/fn-ptr-comparisons.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// check-pass
// check-fail

extern "C" {
fn test();
Expand All @@ -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
}
18 changes: 9 additions & 9 deletions tests/ui/lint/fn-ptr-comparisons.stderr
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
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;
| ^^^^^^
|
= 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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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

0 comments on commit 6c5c546

Please sign in to comment.