rust/src/test/ui/lint/function-references.stderr
Ayrton 511fe048b4 Changed lint to check for std::fmt::Pointer and transmute
The lint checks arguments in calls to `transmute` or functions that have
`Pointer` as a trait bound and displays a warning if the argument is a function
reference. Also checks for `std::fmt::Pointer::fmt` to handle formatting macros
although it doesn't depend on the exact expansion of the macro or formatting
internals. `std::fmt::Pointer` and `std::fmt::Pointer::fmt` were also added as
diagnostic items and symbols.
2020-10-27 11:04:04 -04:00

171 lines
5.3 KiB
Plaintext

warning: cast `foo` with `as fn() -> _` to use it as a pointer
--> $DIR/function-references.rs:58:22
|
LL | println!("{:p}", &foo);
| ^^^^
|
note: the lint level is defined here
--> $DIR/function-references.rs:3:9
|
LL | #![warn(function_item_references)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
warning: cast `foo` with `as fn() -> _` to use it as a pointer
--> $DIR/function-references.rs:60:20
|
LL | print!("{:p}", &foo);
| ^^^^
warning: cast `foo` with `as fn() -> _` to use it as a pointer
--> $DIR/function-references.rs:62:21
|
LL | format!("{:p}", &foo);
| ^^^^
warning: cast `foo` with `as fn() -> _` to use it as a pointer
--> $DIR/function-references.rs:65:22
|
LL | println!("{:p}", &foo as *const _);
| ^^^^^^^^^^^^^^^^
warning: cast `foo` with `as fn() -> _` to use it as a pointer
--> $DIR/function-references.rs:67:22
|
LL | println!("{:p}", zst_ref);
| ^^^^^^^
warning: cast `foo` with `as fn() -> _` to use it as a pointer
--> $DIR/function-references.rs:69:22
|
LL | println!("{:p}", cast_zst_ptr);
| ^^^^^^^^^^^^
warning: cast `foo` with `as fn() -> _` to use it as a pointer
--> $DIR/function-references.rs:71:22
|
LL | println!("{:p}", coerced_zst_ptr);
| ^^^^^^^^^^^^^^^
warning: cast `foo` with `as fn() -> _` to use it as a pointer
--> $DIR/function-references.rs:74:22
|
LL | println!("{:p}", &fn_item);
| ^^^^^^^^
warning: cast `foo` with `as fn() -> _` to use it as a pointer
--> $DIR/function-references.rs:76:22
|
LL | println!("{:p}", indirect_ref);
| ^^^^^^^^^^^^
warning: cast `nop` with `as fn()` to use it as a pointer
--> $DIR/function-references.rs:79:22
|
LL | println!("{:p}", &nop);
| ^^^^
warning: cast `bar` with `as fn(_) -> _` to use it as a pointer
--> $DIR/function-references.rs:81:22
|
LL | println!("{:p}", &bar);
| ^^^^
warning: cast `baz` with `as fn(_, _) -> _` to use it as a pointer
--> $DIR/function-references.rs:83:22
|
LL | println!("{:p}", &baz);
| ^^^^
warning: cast `unsafe_fn` with `as unsafe fn()` to use it as a pointer
--> $DIR/function-references.rs:85:22
|
LL | println!("{:p}", &unsafe_fn);
| ^^^^^^^^^^
warning: cast `c_fn` with `as extern "C" fn()` to use it as a pointer
--> $DIR/function-references.rs:87:22
|
LL | println!("{:p}", &c_fn);
| ^^^^^
warning: cast `unsafe_c_fn` with `as unsafe extern "C" fn()` to use it as a pointer
--> $DIR/function-references.rs:89:22
|
LL | println!("{:p}", &unsafe_c_fn);
| ^^^^^^^^^^^^
warning: cast `variadic_fn` with `as unsafe extern "C" fn(_, ...)` to use it as a pointer
--> $DIR/function-references.rs:91:22
|
LL | println!("{:p}", &variadic_fn);
| ^^^^^^^^^^^^
warning: cast `var` with `as fn(_) -> _` to use it as a pointer
--> $DIR/function-references.rs:93:22
|
LL | println!("{:p}", &std::env::var::<String>);
| ^^^^^^^^^^^^^^^^^^^^^^^^
warning: cast `nop` with `as fn()` to use it as a pointer
--> $DIR/function-references.rs:96:32
|
LL | println!("{:p} {:p} {:p}", &nop, &foo, &bar);
| ^^^^
warning: cast `foo` with `as fn() -> _` to use it as a pointer
--> $DIR/function-references.rs:96:38
|
LL | println!("{:p} {:p} {:p}", &nop, &foo, &bar);
| ^^^^
warning: cast `bar` with `as fn(_) -> _` to use it as a pointer
--> $DIR/function-references.rs:96:44
|
LL | println!("{:p} {:p} {:p}", &nop, &foo, &bar);
| ^^^^
warning: cast `foo` with `as fn() -> _` to use it as a pointer
--> $DIR/function-references.rs:111:41
|
LL | std::mem::transmute::<_, usize>(&foo);
| ^^^^
warning: cast `foo` with `as fn() -> _` to use it as a pointer
--> $DIR/function-references.rs:113:50
|
LL | std::mem::transmute::<_, (usize, usize)>((&foo, &bar));
| ^^^^^^^^^^^^
warning: cast `bar` with `as fn(_) -> _` to use it as a pointer
--> $DIR/function-references.rs:113:50
|
LL | std::mem::transmute::<_, (usize, usize)>((&foo, &bar));
| ^^^^^^^^^^^^
warning: cast `bar` with `as fn(_) -> _` to use it as a pointer
--> $DIR/function-references.rs:123:15
|
LL | print_ptr(&bar);
| ^^^^
warning: cast `bar` with `as fn(_) -> _` to use it as a pointer
--> $DIR/function-references.rs:125:24
|
LL | bound_by_ptr_trait(&bar);
| ^^^^
warning: cast `bar` with `as fn(_) -> _` to use it as a pointer
--> $DIR/function-references.rs:127:30
|
LL | bound_by_ptr_trait_tuple((&foo, &bar));
| ^^^^^^^^^^^^
warning: cast `foo` with `as fn() -> _` to use it as a pointer
--> $DIR/function-references.rs:127:30
|
LL | bound_by_ptr_trait_tuple((&foo, &bar));
| ^^^^^^^^^^^^
warning: 27 warnings emitted