-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added suggestion to
function_item_references
lint and fixed warning…
… message Also updated tests accordingly and tweaked some wording in the lint declaration.
- Loading branch information
Showing
4 changed files
with
102 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,176 +1,176 @@ | ||
warning: cast `foo` with `as fn() -> _` to obtain a function pointer | ||
warning: taking a reference to a function item does not give a function pointer | ||
--> $DIR/function-item-references.rs:40:18 | ||
| | ||
LL | Pointer::fmt(&zst_ref, f) | ||
| ^^^^^^^^ | ||
| ^^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/function-item-references.rs:3:9 | ||
| | ||
LL | #![warn(function_item_references)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
warning: cast `foo` with `as fn() -> _` to obtain a function pointer | ||
warning: taking a reference to a function item does not give a function pointer | ||
--> $DIR/function-item-references.rs:77:22 | ||
| | ||
LL | println!("{:p}", &foo); | ||
| ^^^^ | ||
| ^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` | ||
|
||
warning: cast `foo` with `as fn() -> _` to obtain a function pointer | ||
warning: taking a reference to a function item does not give a function pointer | ||
--> $DIR/function-item-references.rs:79:20 | ||
| | ||
LL | print!("{:p}", &foo); | ||
| ^^^^ | ||
| ^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` | ||
|
||
warning: cast `foo` with `as fn() -> _` to obtain a function pointer | ||
warning: taking a reference to a function item does not give a function pointer | ||
--> $DIR/function-item-references.rs:81:21 | ||
| | ||
LL | format!("{:p}", &foo); | ||
| ^^^^ | ||
| ^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` | ||
|
||
warning: cast `foo` with `as fn() -> _` to obtain a function pointer | ||
warning: taking a reference to a function item does not give a function pointer | ||
--> $DIR/function-item-references.rs:84:22 | ||
| | ||
LL | println!("{:p}", &foo as *const _); | ||
| ^^^^^^^^^^^^^^^^ | ||
| ^^^^^^^^^^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` | ||
|
||
warning: cast `foo` with `as fn() -> _` to obtain a function pointer | ||
warning: taking a reference to a function item does not give a function pointer | ||
--> $DIR/function-item-references.rs:86:22 | ||
| | ||
LL | println!("{:p}", zst_ref); | ||
| ^^^^^^^ | ||
| ^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` | ||
|
||
warning: cast `foo` with `as fn() -> _` to obtain a function pointer | ||
warning: taking a reference to a function item does not give a function pointer | ||
--> $DIR/function-item-references.rs:88:22 | ||
| | ||
LL | println!("{:p}", cast_zst_ptr); | ||
| ^^^^^^^^^^^^ | ||
| ^^^^^^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` | ||
|
||
warning: cast `foo` with `as fn() -> _` to obtain a function pointer | ||
warning: taking a reference to a function item does not give a function pointer | ||
--> $DIR/function-item-references.rs:90:22 | ||
| | ||
LL | println!("{:p}", coerced_zst_ptr); | ||
| ^^^^^^^^^^^^^^^ | ||
| ^^^^^^^^^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` | ||
|
||
warning: cast `foo` with `as fn() -> _` to obtain a function pointer | ||
warning: taking a reference to a function item does not give a function pointer | ||
--> $DIR/function-item-references.rs:93:22 | ||
| | ||
LL | println!("{:p}", &fn_item); | ||
| ^^^^^^^^ | ||
| ^^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` | ||
|
||
warning: cast `foo` with `as fn() -> _` to obtain a function pointer | ||
warning: taking a reference to a function item does not give a function pointer | ||
--> $DIR/function-item-references.rs:95:22 | ||
| | ||
LL | println!("{:p}", indirect_ref); | ||
| ^^^^^^^^^^^^ | ||
| ^^^^^^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` | ||
|
||
warning: cast `nop` with `as fn()` to obtain a function pointer | ||
warning: taking a reference to a function item does not give a function pointer | ||
--> $DIR/function-item-references.rs:98:22 | ||
| | ||
LL | println!("{:p}", &nop); | ||
| ^^^^ | ||
| ^^^^ help: cast `nop` to obtain a function pointer: `nop as fn()` | ||
|
||
warning: cast `bar` with `as fn(_) -> _` to obtain a function pointer | ||
warning: taking a reference to a function item does not give a function pointer | ||
--> $DIR/function-item-references.rs:100:22 | ||
| | ||
LL | println!("{:p}", &bar); | ||
| ^^^^ | ||
| ^^^^ help: cast `bar` to obtain a function pointer: `bar as fn(_) -> _` | ||
|
||
warning: cast `baz` with `as fn(_, _) -> _` to obtain a function pointer | ||
warning: taking a reference to a function item does not give a function pointer | ||
--> $DIR/function-item-references.rs:102:22 | ||
| | ||
LL | println!("{:p}", &baz); | ||
| ^^^^ | ||
| ^^^^ help: cast `baz` to obtain a function pointer: `baz as fn(_, _) -> _` | ||
|
||
warning: cast `unsafe_fn` with `as unsafe fn()` to obtain a function pointer | ||
warning: taking a reference to a function item does not give a function pointer | ||
--> $DIR/function-item-references.rs:104:22 | ||
| | ||
LL | println!("{:p}", &unsafe_fn); | ||
| ^^^^^^^^^^ | ||
| ^^^^^^^^^^ help: cast `unsafe_fn` to obtain a function pointer: `unsafe_fn as unsafe fn()` | ||
|
||
warning: cast `c_fn` with `as extern "C" fn()` to obtain a function pointer | ||
warning: taking a reference to a function item does not give a function pointer | ||
--> $DIR/function-item-references.rs:106:22 | ||
| | ||
LL | println!("{:p}", &c_fn); | ||
| ^^^^^ | ||
| ^^^^^ help: cast `c_fn` to obtain a function pointer: `c_fn as extern "C" fn()` | ||
|
||
warning: cast `unsafe_c_fn` with `as unsafe extern "C" fn()` to obtain a function pointer | ||
warning: taking a reference to a function item does not give a function pointer | ||
--> $DIR/function-item-references.rs:108:22 | ||
| | ||
LL | println!("{:p}", &unsafe_c_fn); | ||
| ^^^^^^^^^^^^ | ||
| ^^^^^^^^^^^^ help: cast `unsafe_c_fn` to obtain a function pointer: `unsafe_c_fn as unsafe extern "C" fn()` | ||
|
||
warning: cast `variadic` with `as unsafe extern "C" fn(_, ...)` to obtain a function pointer | ||
warning: taking a reference to a function item does not give a function pointer | ||
--> $DIR/function-item-references.rs:110:22 | ||
| | ||
LL | println!("{:p}", &variadic); | ||
| ^^^^^^^^^ | ||
| ^^^^^^^^^ help: cast `variadic` to obtain a function pointer: `variadic as unsafe extern "C" fn(_, ...)` | ||
|
||
warning: cast `var` with `as fn(_) -> _` to obtain a function pointer | ||
warning: taking a reference to a function item does not give a function pointer | ||
--> $DIR/function-item-references.rs:112:22 | ||
| | ||
LL | println!("{:p}", &std::env::var::<String>); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: cast `var` to obtain a function pointer: `var as fn(_) -> _` | ||
|
||
warning: cast `nop` with `as fn()` to obtain a function pointer | ||
warning: taking a reference to a function item does not give a function pointer | ||
--> $DIR/function-item-references.rs:115:32 | ||
| | ||
LL | println!("{:p} {:p} {:p}", &nop, &foo, &bar); | ||
| ^^^^ | ||
| ^^^^ help: cast `nop` to obtain a function pointer: `nop as fn()` | ||
|
||
warning: cast `foo` with `as fn() -> _` to obtain a function pointer | ||
warning: taking a reference to a function item does not give a function pointer | ||
--> $DIR/function-item-references.rs:115:38 | ||
| | ||
LL | println!("{:p} {:p} {:p}", &nop, &foo, &bar); | ||
| ^^^^ | ||
| ^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` | ||
|
||
warning: cast `bar` with `as fn(_) -> _` to obtain a function pointer | ||
warning: taking a reference to a function item does not give a function pointer | ||
--> $DIR/function-item-references.rs:115:44 | ||
| | ||
LL | println!("{:p} {:p} {:p}", &nop, &foo, &bar); | ||
| ^^^^ | ||
| ^^^^ help: cast `bar` to obtain a function pointer: `bar as fn(_) -> _` | ||
|
||
warning: cast `foo` with `as fn() -> _` to obtain a function pointer | ||
warning: taking a reference to a function item does not give a function pointer | ||
--> $DIR/function-item-references.rs:130:41 | ||
| | ||
LL | std::mem::transmute::<_, usize>(&foo); | ||
| ^^^^ | ||
| ^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` | ||
|
||
warning: cast `foo` with `as fn() -> _` to obtain a function pointer | ||
warning: taking a reference to a function item does not give a function pointer | ||
--> $DIR/function-item-references.rs:132:50 | ||
| | ||
LL | std::mem::transmute::<_, (usize, usize)>((&foo, &bar)); | ||
| ^^^^^^^^^^^^ | ||
| ^^^^^^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` | ||
|
||
warning: cast `bar` with `as fn(_) -> _` to obtain a function pointer | ||
warning: taking a reference to a function item does not give a function pointer | ||
--> $DIR/function-item-references.rs:132:50 | ||
| | ||
LL | std::mem::transmute::<_, (usize, usize)>((&foo, &bar)); | ||
| ^^^^^^^^^^^^ | ||
| ^^^^^^^^^^^^ help: cast `bar` to obtain a function pointer: `bar as fn(_) -> _` | ||
|
||
warning: cast `bar` with `as fn(_) -> _` to obtain a function pointer | ||
warning: taking a reference to a function item does not give a function pointer | ||
--> $DIR/function-item-references.rs:142:15 | ||
| | ||
LL | print_ptr(&bar); | ||
| ^^^^ | ||
| ^^^^ help: cast `bar` to obtain a function pointer: `bar as fn(_) -> _` | ||
|
||
warning: cast `bar` with `as fn(_) -> _` to obtain a function pointer | ||
warning: taking a reference to a function item does not give a function pointer | ||
--> $DIR/function-item-references.rs:144:24 | ||
| | ||
LL | bound_by_ptr_trait(&bar); | ||
| ^^^^ | ||
| ^^^^ help: cast `bar` to obtain a function pointer: `bar as fn(_) -> _` | ||
|
||
warning: cast `bar` with `as fn(_) -> _` to obtain a function pointer | ||
warning: taking a reference to a function item does not give a function pointer | ||
--> $DIR/function-item-references.rs:146:30 | ||
| | ||
LL | bound_by_ptr_trait_tuple((&foo, &bar)); | ||
| ^^^^^^^^^^^^ | ||
| ^^^^^^^^^^^^ help: cast `bar` to obtain a function pointer: `bar as fn(_) -> _` | ||
|
||
warning: cast `foo` with `as fn() -> _` to obtain a function pointer | ||
warning: taking a reference to a function item does not give a function pointer | ||
--> $DIR/function-item-references.rs:146:30 | ||
| | ||
LL | bound_by_ptr_trait_tuple((&foo, &bar)); | ||
| ^^^^^^^^^^^^ | ||
| ^^^^^^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` | ||
|
||
warning: 28 warnings emitted | ||
|