From 935fc3642a61e1545e1b98bf4716acbb7bf12e91 Mon Sep 17 00:00:00 2001 From: Ayrton Date: Wed, 21 Oct 2020 17:19:21 -0400 Subject: Added documentation for `function_item_references` lint Added documentation for `function_item_references` lint to the rustc book and fixed comments in the lint checker itself. --- src/test/ui/lint/function-item-references.rs | 155 ++++++++++++++++++++ src/test/ui/lint/function-item-references.stderr | 176 +++++++++++++++++++++++ src/test/ui/lint/function-references.rs | 155 -------------------- src/test/ui/lint/function-references.stderr | 176 ----------------------- 4 files changed, 331 insertions(+), 331 deletions(-) create mode 100644 src/test/ui/lint/function-item-references.rs create mode 100644 src/test/ui/lint/function-item-references.stderr delete mode 100644 src/test/ui/lint/function-references.rs delete mode 100644 src/test/ui/lint/function-references.stderr (limited to 'src') diff --git a/src/test/ui/lint/function-item-references.rs b/src/test/ui/lint/function-item-references.rs new file mode 100644 index 00000000000..28c66a31322 --- /dev/null +++ b/src/test/ui/lint/function-item-references.rs @@ -0,0 +1,155 @@ +// check-pass +#![feature(c_variadic)] +#![warn(function_item_references)] +use std::fmt::Pointer; +use std::fmt::Formatter; + +fn nop() { } +fn foo() -> u32 { 42 } +fn bar(x: u32) -> u32 { x } +fn baz(x: u32, y: u32) -> u32 { x + y } +unsafe fn unsafe_fn() { } +extern "C" fn c_fn() { } +unsafe extern "C" fn unsafe_c_fn() { } +unsafe extern fn variadic(_x: u32, _args: ...) { } + +//function references passed to these functions should never lint +fn call_fn(f: &dyn Fn(u32) -> u32, x: u32) { f(x); } +fn parameterized_call_fn u32>(f: &F, x: u32) { f(x); } + +//function references passed to these functions should lint +fn print_ptr(f: F) { println!("{:p}", f); } +fn bound_by_ptr_trait(_f: F) { } +fn bound_by_ptr_trait_tuple(_t: (F, G)) { } +fn implicit_ptr_trait(f: &F) { println!("{:p}", f); } + +//case found in tinyvec that triggered a compiler error in an earlier version of the lint checker +trait HasItem { + type Item; + fn assoc_item(&self) -> Self::Item; +} +fn _format_assoc_item(data: T, f: &mut Formatter) -> std::fmt::Result + where T::Item: Pointer { + //when the arg type bound by `Pointer` is an associated type, we shouldn't attempt to normalize + Pointer::fmt(&data.assoc_item(), f) +} + +//simple test to make sure that calls to `Pointer::fmt` aren't double counted +fn _call_pointer_fmt(f: &mut Formatter) -> std::fmt::Result { + let zst_ref = &foo; + Pointer::fmt(&zst_ref, f) + //~^ WARNING cast `foo` with `as fn() -> _` to obtain a function pointer +} + +fn main() { + //`let` bindings with function references shouldn't lint + let _ = &foo; + let _ = &mut foo; + + let zst_ref = &foo; + let fn_item = foo; + let indirect_ref = &fn_item; + + let _mut_zst_ref = &mut foo; + let mut mut_fn_item = foo; + let _mut_indirect_ref = &mut mut_fn_item; + + let cast_zst_ptr = &foo as *const _; + let coerced_zst_ptr: *const _ = &foo; + + let _mut_cast_zst_ptr = &mut foo as *mut _; + let _mut_coerced_zst_ptr: *mut _ = &mut foo; + + let _cast_zst_ref = &foo as &dyn Fn() -> u32; + let _coerced_zst_ref: &dyn Fn() -> u32 = &foo; + + let _mut_cast_zst_ref = &mut foo as &mut dyn Fn() -> u32; + let _mut_coerced_zst_ref: &mut dyn Fn() -> u32 = &mut foo; + + //the suggested way to cast to a function pointer + let fn_ptr = foo as fn() -> u32; + + //correct ways to print function pointers + println!("{:p}", foo as fn() -> u32); + println!("{:p}", fn_ptr); + + //potential ways to incorrectly try printing function pointers + println!("{:p}", &foo); + //~^ WARNING cast `foo` with `as fn() -> _` to obtain a function pointer + print!("{:p}", &foo); + //~^ WARNING cast `foo` with `as fn() -> _` to obtain a function pointer + format!("{:p}", &foo); + //~^ WARNING cast `foo` with `as fn() -> _` to obtain a function pointer + + println!("{:p}", &foo as *const _); + //~^ WARNING cast `foo` with `as fn() -> _` to obtain a function pointer + println!("{:p}", zst_ref); + //~^ WARNING cast `foo` with `as fn() -> _` to obtain a function pointer + println!("{:p}", cast_zst_ptr); + //~^ WARNING cast `foo` with `as fn() -> _` to obtain a function pointer + println!("{:p}", coerced_zst_ptr); + //~^ WARNING cast `foo` with `as fn() -> _` to obtain a function pointer + + println!("{:p}", &fn_item); + //~^ WARNING cast `foo` with `as fn() -> _` to obtain a function pointer + println!("{:p}", indirect_ref); + //~^ WARNING cast `foo` with `as fn() -> _` to obtain a function pointer + + println!("{:p}", &nop); + //~^ WARNING cast `nop` with `as fn()` to obtain a function pointer + println!("{:p}", &bar); + //~^ WARNING cast `bar` with `as fn(_) -> _` to obtain a function pointer + println!("{:p}", &baz); + //~^ WARNING cast `baz` with `as fn(_, _) -> _` to obtain a function pointer + println!("{:p}", &unsafe_fn); + //~^ WARNING cast `unsafe_fn` with `as unsafe fn()` to obtain a function pointer + println!("{:p}", &c_fn); + //~^ WARNING cast `c_fn` with `as extern "C" fn()` to obtain a function pointer + println!("{:p}", &unsafe_c_fn); + //~^ WARNING cast `unsafe_c_fn` with `as unsafe extern "C" fn()` to obtain a function pointer + println!("{:p}", &variadic); + //~^ WARNING cast `variadic` with `as unsafe extern "C" fn(_, ...)` to obtain a function pointer + println!("{:p}", &std::env::var::); + //~^ WARNING cast `var` with `as fn(_) -> _` to obtain a function pointer + + println!("{:p} {:p} {:p}", &nop, &foo, &bar); + //~^ WARNING cast `nop` with `as fn()` to obtain a function pointer + //~^^ WARNING cast `foo` with `as fn() -> _` to obtain a function pointer + //~^^^ WARNING cast `bar` with `as fn(_) -> _` to obtain a function pointer + + //using a function reference to call a function shouldn't lint + (&bar)(1); + + //passing a function reference to an arbitrary function shouldn't lint + call_fn(&bar, 1); + parameterized_call_fn(&bar, 1); + std::mem::size_of_val(&foo); + + unsafe { + //potential ways to incorrectly try transmuting function pointers + std::mem::transmute::<_, usize>(&foo); + //~^ WARNING cast `foo` with `as fn() -> _` to obtain a function pointer + std::mem::transmute::<_, (usize, usize)>((&foo, &bar)); + //~^ WARNING cast `foo` with `as fn() -> _` to obtain a function pointer + //~^^ WARNING cast `bar` with `as fn(_) -> _` to obtain a function pointer + + //the correct way to transmute function pointers + std::mem::transmute::<_, usize>(foo as fn() -> u32); + std::mem::transmute::<_, (usize, usize)>((foo as fn() -> u32, bar as fn(u32) -> u32)); + } + + //function references as arguments required to be bound by std::fmt::Pointer should lint + print_ptr(&bar); + //~^ WARNING cast `bar` with `as fn(_) -> _` to obtain a function pointer + bound_by_ptr_trait(&bar); + //~^ WARNING cast `bar` with `as fn(_) -> _` to obtain a function pointer + bound_by_ptr_trait_tuple((&foo, &bar)); + //~^ WARNING cast `foo` with `as fn() -> _` to obtain a function pointer + //~^^ WARNING cast `bar` with `as fn(_) -> _` to obtain a function pointer + implicit_ptr_trait(&bar); // ignore + + //correct ways to pass function pointers as arguments bound by std::fmt::Pointer + print_ptr(bar as fn(u32) -> u32); + bound_by_ptr_trait(bar as fn(u32) -> u32); + bound_by_ptr_trait_tuple((foo as fn() -> u32, bar as fn(u32) -> u32)); +} diff --git a/src/test/ui/lint/function-item-references.stderr b/src/test/ui/lint/function-item-references.stderr new file mode 100644 index 00000000000..a96b134ed58 --- /dev/null +++ b/src/test/ui/lint/function-item-references.stderr @@ -0,0 +1,176 @@ +warning: cast `foo` with `as fn() -> _` to obtain a function pointer + --> $DIR/function-item-references.rs:40:18 + | +LL | Pointer::fmt(&zst_ref, f) + | ^^^^^^^^ + | +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 + --> $DIR/function-item-references.rs:77:22 + | +LL | println!("{:p}", &foo); + | ^^^^ + +warning: cast `foo` with `as fn() -> _` to obtain a function pointer + --> $DIR/function-item-references.rs:79:20 + | +LL | print!("{:p}", &foo); + | ^^^^ + +warning: cast `foo` with `as fn() -> _` to obtain a function pointer + --> $DIR/function-item-references.rs:81:21 + | +LL | format!("{:p}", &foo); + | ^^^^ + +warning: cast `foo` with `as fn() -> _` to obtain a function pointer + --> $DIR/function-item-references.rs:84:22 + | +LL | println!("{:p}", &foo as *const _); + | ^^^^^^^^^^^^^^^^ + +warning: cast `foo` with `as fn() -> _` to obtain a function pointer + --> $DIR/function-item-references.rs:86:22 + | +LL | println!("{:p}", zst_ref); + | ^^^^^^^ + +warning: cast `foo` with `as fn() -> _` to obtain a function pointer + --> $DIR/function-item-references.rs:88:22 + | +LL | println!("{:p}", cast_zst_ptr); + | ^^^^^^^^^^^^ + +warning: cast `foo` with `as fn() -> _` to obtain a function pointer + --> $DIR/function-item-references.rs:90:22 + | +LL | println!("{:p}", coerced_zst_ptr); + | ^^^^^^^^^^^^^^^ + +warning: cast `foo` with `as fn() -> _` to obtain a function pointer + --> $DIR/function-item-references.rs:93:22 + | +LL | println!("{:p}", &fn_item); + | ^^^^^^^^ + +warning: cast `foo` with `as fn() -> _` to obtain a function pointer + --> $DIR/function-item-references.rs:95:22 + | +LL | println!("{:p}", indirect_ref); + | ^^^^^^^^^^^^ + +warning: cast `nop` with `as fn()` to obtain a function pointer + --> $DIR/function-item-references.rs:98:22 + | +LL | println!("{:p}", &nop); + | ^^^^ + +warning: cast `bar` with `as fn(_) -> _` to obtain a function pointer + --> $DIR/function-item-references.rs:100:22 + | +LL | println!("{:p}", &bar); + | ^^^^ + +warning: cast `baz` with `as fn(_, _) -> _` to obtain a function pointer + --> $DIR/function-item-references.rs:102:22 + | +LL | println!("{:p}", &baz); + | ^^^^ + +warning: cast `unsafe_fn` with `as unsafe fn()` to obtain a function pointer + --> $DIR/function-item-references.rs:104:22 + | +LL | println!("{:p}", &unsafe_fn); + | ^^^^^^^^^^ + +warning: cast `c_fn` with `as extern "C" fn()` to obtain a function pointer + --> $DIR/function-item-references.rs:106:22 + | +LL | println!("{:p}", &c_fn); + | ^^^^^ + +warning: cast `unsafe_c_fn` with `as unsafe extern "C" fn()` to obtain a function pointer + --> $DIR/function-item-references.rs:108:22 + | +LL | println!("{:p}", &unsafe_c_fn); + | ^^^^^^^^^^^^ + +warning: cast `variadic` with `as unsafe extern "C" fn(_, ...)` to obtain a function pointer + --> $DIR/function-item-references.rs:110:22 + | +LL | println!("{:p}", &variadic); + | ^^^^^^^^^ + +warning: cast `var` with `as fn(_) -> _` to obtain a function pointer + --> $DIR/function-item-references.rs:112:22 + | +LL | println!("{:p}", &std::env::var::); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: cast `nop` with `as fn()` to obtain a function pointer + --> $DIR/function-item-references.rs:115:32 + | +LL | println!("{:p} {:p} {:p}", &nop, &foo, &bar); + | ^^^^ + +warning: cast `foo` with `as fn() -> _` to obtain a function pointer + --> $DIR/function-item-references.rs:115:38 + | +LL | println!("{:p} {:p} {:p}", &nop, &foo, &bar); + | ^^^^ + +warning: cast `bar` with `as fn(_) -> _` to obtain a function pointer + --> $DIR/function-item-references.rs:115:44 + | +LL | println!("{:p} {:p} {:p}", &nop, &foo, &bar); + | ^^^^ + +warning: cast `foo` with `as fn() -> _` to obtain a function pointer + --> $DIR/function-item-references.rs:130:41 + | +LL | std::mem::transmute::<_, usize>(&foo); + | ^^^^ + +warning: cast `foo` with `as fn() -> _` to obtain a function pointer + --> $DIR/function-item-references.rs:132:50 + | +LL | std::mem::transmute::<_, (usize, usize)>((&foo, &bar)); + | ^^^^^^^^^^^^ + +warning: cast `bar` with `as fn(_) -> _` to obtain a function pointer + --> $DIR/function-item-references.rs:132:50 + | +LL | std::mem::transmute::<_, (usize, usize)>((&foo, &bar)); + | ^^^^^^^^^^^^ + +warning: cast `bar` with `as fn(_) -> _` to obtain a function pointer + --> $DIR/function-item-references.rs:142:15 + | +LL | print_ptr(&bar); + | ^^^^ + +warning: cast `bar` with `as fn(_) -> _` to obtain a function pointer + --> $DIR/function-item-references.rs:144:24 + | +LL | bound_by_ptr_trait(&bar); + | ^^^^ + +warning: cast `bar` with `as fn(_) -> _` to obtain a function pointer + --> $DIR/function-item-references.rs:146:30 + | +LL | bound_by_ptr_trait_tuple((&foo, &bar)); + | ^^^^^^^^^^^^ + +warning: cast `foo` with `as fn() -> _` to obtain a function pointer + --> $DIR/function-item-references.rs:146:30 + | +LL | bound_by_ptr_trait_tuple((&foo, &bar)); + | ^^^^^^^^^^^^ + +warning: 28 warnings emitted + diff --git a/src/test/ui/lint/function-references.rs b/src/test/ui/lint/function-references.rs deleted file mode 100644 index 28c66a31322..00000000000 --- a/src/test/ui/lint/function-references.rs +++ /dev/null @@ -1,155 +0,0 @@ -// check-pass -#![feature(c_variadic)] -#![warn(function_item_references)] -use std::fmt::Pointer; -use std::fmt::Formatter; - -fn nop() { } -fn foo() -> u32 { 42 } -fn bar(x: u32) -> u32 { x } -fn baz(x: u32, y: u32) -> u32 { x + y } -unsafe fn unsafe_fn() { } -extern "C" fn c_fn() { } -unsafe extern "C" fn unsafe_c_fn() { } -unsafe extern fn variadic(_x: u32, _args: ...) { } - -//function references passed to these functions should never lint -fn call_fn(f: &dyn Fn(u32) -> u32, x: u32) { f(x); } -fn parameterized_call_fn u32>(f: &F, x: u32) { f(x); } - -//function references passed to these functions should lint -fn print_ptr(f: F) { println!("{:p}", f); } -fn bound_by_ptr_trait(_f: F) { } -fn bound_by_ptr_trait_tuple(_t: (F, G)) { } -fn implicit_ptr_trait(f: &F) { println!("{:p}", f); } - -//case found in tinyvec that triggered a compiler error in an earlier version of the lint checker -trait HasItem { - type Item; - fn assoc_item(&self) -> Self::Item; -} -fn _format_assoc_item(data: T, f: &mut Formatter) -> std::fmt::Result - where T::Item: Pointer { - //when the arg type bound by `Pointer` is an associated type, we shouldn't attempt to normalize - Pointer::fmt(&data.assoc_item(), f) -} - -//simple test to make sure that calls to `Pointer::fmt` aren't double counted -fn _call_pointer_fmt(f: &mut Formatter) -> std::fmt::Result { - let zst_ref = &foo; - Pointer::fmt(&zst_ref, f) - //~^ WARNING cast `foo` with `as fn() -> _` to obtain a function pointer -} - -fn main() { - //`let` bindings with function references shouldn't lint - let _ = &foo; - let _ = &mut foo; - - let zst_ref = &foo; - let fn_item = foo; - let indirect_ref = &fn_item; - - let _mut_zst_ref = &mut foo; - let mut mut_fn_item = foo; - let _mut_indirect_ref = &mut mut_fn_item; - - let cast_zst_ptr = &foo as *const _; - let coerced_zst_ptr: *const _ = &foo; - - let _mut_cast_zst_ptr = &mut foo as *mut _; - let _mut_coerced_zst_ptr: *mut _ = &mut foo; - - let _cast_zst_ref = &foo as &dyn Fn() -> u32; - let _coerced_zst_ref: &dyn Fn() -> u32 = &foo; - - let _mut_cast_zst_ref = &mut foo as &mut dyn Fn() -> u32; - let _mut_coerced_zst_ref: &mut dyn Fn() -> u32 = &mut foo; - - //the suggested way to cast to a function pointer - let fn_ptr = foo as fn() -> u32; - - //correct ways to print function pointers - println!("{:p}", foo as fn() -> u32); - println!("{:p}", fn_ptr); - - //potential ways to incorrectly try printing function pointers - println!("{:p}", &foo); - //~^ WARNING cast `foo` with `as fn() -> _` to obtain a function pointer - print!("{:p}", &foo); - //~^ WARNING cast `foo` with `as fn() -> _` to obtain a function pointer - format!("{:p}", &foo); - //~^ WARNING cast `foo` with `as fn() -> _` to obtain a function pointer - - println!("{:p}", &foo as *const _); - //~^ WARNING cast `foo` with `as fn() -> _` to obtain a function pointer - println!("{:p}", zst_ref); - //~^ WARNING cast `foo` with `as fn() -> _` to obtain a function pointer - println!("{:p}", cast_zst_ptr); - //~^ WARNING cast `foo` with `as fn() -> _` to obtain a function pointer - println!("{:p}", coerced_zst_ptr); - //~^ WARNING cast `foo` with `as fn() -> _` to obtain a function pointer - - println!("{:p}", &fn_item); - //~^ WARNING cast `foo` with `as fn() -> _` to obtain a function pointer - println!("{:p}", indirect_ref); - //~^ WARNING cast `foo` with `as fn() -> _` to obtain a function pointer - - println!("{:p}", &nop); - //~^ WARNING cast `nop` with `as fn()` to obtain a function pointer - println!("{:p}", &bar); - //~^ WARNING cast `bar` with `as fn(_) -> _` to obtain a function pointer - println!("{:p}", &baz); - //~^ WARNING cast `baz` with `as fn(_, _) -> _` to obtain a function pointer - println!("{:p}", &unsafe_fn); - //~^ WARNING cast `unsafe_fn` with `as unsafe fn()` to obtain a function pointer - println!("{:p}", &c_fn); - //~^ WARNING cast `c_fn` with `as extern "C" fn()` to obtain a function pointer - println!("{:p}", &unsafe_c_fn); - //~^ WARNING cast `unsafe_c_fn` with `as unsafe extern "C" fn()` to obtain a function pointer - println!("{:p}", &variadic); - //~^ WARNING cast `variadic` with `as unsafe extern "C" fn(_, ...)` to obtain a function pointer - println!("{:p}", &std::env::var::); - //~^ WARNING cast `var` with `as fn(_) -> _` to obtain a function pointer - - println!("{:p} {:p} {:p}", &nop, &foo, &bar); - //~^ WARNING cast `nop` with `as fn()` to obtain a function pointer - //~^^ WARNING cast `foo` with `as fn() -> _` to obtain a function pointer - //~^^^ WARNING cast `bar` with `as fn(_) -> _` to obtain a function pointer - - //using a function reference to call a function shouldn't lint - (&bar)(1); - - //passing a function reference to an arbitrary function shouldn't lint - call_fn(&bar, 1); - parameterized_call_fn(&bar, 1); - std::mem::size_of_val(&foo); - - unsafe { - //potential ways to incorrectly try transmuting function pointers - std::mem::transmute::<_, usize>(&foo); - //~^ WARNING cast `foo` with `as fn() -> _` to obtain a function pointer - std::mem::transmute::<_, (usize, usize)>((&foo, &bar)); - //~^ WARNING cast `foo` with `as fn() -> _` to obtain a function pointer - //~^^ WARNING cast `bar` with `as fn(_) -> _` to obtain a function pointer - - //the correct way to transmute function pointers - std::mem::transmute::<_, usize>(foo as fn() -> u32); - std::mem::transmute::<_, (usize, usize)>((foo as fn() -> u32, bar as fn(u32) -> u32)); - } - - //function references as arguments required to be bound by std::fmt::Pointer should lint - print_ptr(&bar); - //~^ WARNING cast `bar` with `as fn(_) -> _` to obtain a function pointer - bound_by_ptr_trait(&bar); - //~^ WARNING cast `bar` with `as fn(_) -> _` to obtain a function pointer - bound_by_ptr_trait_tuple((&foo, &bar)); - //~^ WARNING cast `foo` with `as fn() -> _` to obtain a function pointer - //~^^ WARNING cast `bar` with `as fn(_) -> _` to obtain a function pointer - implicit_ptr_trait(&bar); // ignore - - //correct ways to pass function pointers as arguments bound by std::fmt::Pointer - print_ptr(bar as fn(u32) -> u32); - bound_by_ptr_trait(bar as fn(u32) -> u32); - bound_by_ptr_trait_tuple((foo as fn() -> u32, bar as fn(u32) -> u32)); -} diff --git a/src/test/ui/lint/function-references.stderr b/src/test/ui/lint/function-references.stderr deleted file mode 100644 index 5e399c16305..00000000000 --- a/src/test/ui/lint/function-references.stderr +++ /dev/null @@ -1,176 +0,0 @@ -warning: cast `foo` with `as fn() -> _` to obtain a function pointer - --> $DIR/function-references.rs:40:18 - | -LL | Pointer::fmt(&zst_ref, f) - | ^^^^^^^^ - | -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 obtain a function pointer - --> $DIR/function-references.rs:77:22 - | -LL | println!("{:p}", &foo); - | ^^^^ - -warning: cast `foo` with `as fn() -> _` to obtain a function pointer - --> $DIR/function-references.rs:79:20 - | -LL | print!("{:p}", &foo); - | ^^^^ - -warning: cast `foo` with `as fn() -> _` to obtain a function pointer - --> $DIR/function-references.rs:81:21 - | -LL | format!("{:p}", &foo); - | ^^^^ - -warning: cast `foo` with `as fn() -> _` to obtain a function pointer - --> $DIR/function-references.rs:84:22 - | -LL | println!("{:p}", &foo as *const _); - | ^^^^^^^^^^^^^^^^ - -warning: cast `foo` with `as fn() -> _` to obtain a function pointer - --> $DIR/function-references.rs:86:22 - | -LL | println!("{:p}", zst_ref); - | ^^^^^^^ - -warning: cast `foo` with `as fn() -> _` to obtain a function pointer - --> $DIR/function-references.rs:88:22 - | -LL | println!("{:p}", cast_zst_ptr); - | ^^^^^^^^^^^^ - -warning: cast `foo` with `as fn() -> _` to obtain a function pointer - --> $DIR/function-references.rs:90:22 - | -LL | println!("{:p}", coerced_zst_ptr); - | ^^^^^^^^^^^^^^^ - -warning: cast `foo` with `as fn() -> _` to obtain a function pointer - --> $DIR/function-references.rs:93:22 - | -LL | println!("{:p}", &fn_item); - | ^^^^^^^^ - -warning: cast `foo` with `as fn() -> _` to obtain a function pointer - --> $DIR/function-references.rs:95:22 - | -LL | println!("{:p}", indirect_ref); - | ^^^^^^^^^^^^ - -warning: cast `nop` with `as fn()` to obtain a function pointer - --> $DIR/function-references.rs:98:22 - | -LL | println!("{:p}", &nop); - | ^^^^ - -warning: cast `bar` with `as fn(_) -> _` to obtain a function pointer - --> $DIR/function-references.rs:100:22 - | -LL | println!("{:p}", &bar); - | ^^^^ - -warning: cast `baz` with `as fn(_, _) -> _` to obtain a function pointer - --> $DIR/function-references.rs:102:22 - | -LL | println!("{:p}", &baz); - | ^^^^ - -warning: cast `unsafe_fn` with `as unsafe fn()` to obtain a function pointer - --> $DIR/function-references.rs:104:22 - | -LL | println!("{:p}", &unsafe_fn); - | ^^^^^^^^^^ - -warning: cast `c_fn` with `as extern "C" fn()` to obtain a function pointer - --> $DIR/function-references.rs:106:22 - | -LL | println!("{:p}", &c_fn); - | ^^^^^ - -warning: cast `unsafe_c_fn` with `as unsafe extern "C" fn()` to obtain a function pointer - --> $DIR/function-references.rs:108:22 - | -LL | println!("{:p}", &unsafe_c_fn); - | ^^^^^^^^^^^^ - -warning: cast `variadic` with `as unsafe extern "C" fn(_, ...)` to obtain a function pointer - --> $DIR/function-references.rs:110:22 - | -LL | println!("{:p}", &variadic); - | ^^^^^^^^^ - -warning: cast `var` with `as fn(_) -> _` to obtain a function pointer - --> $DIR/function-references.rs:112:22 - | -LL | println!("{:p}", &std::env::var::); - | ^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: cast `nop` with `as fn()` to obtain a function pointer - --> $DIR/function-references.rs:115:32 - | -LL | println!("{:p} {:p} {:p}", &nop, &foo, &bar); - | ^^^^ - -warning: cast `foo` with `as fn() -> _` to obtain a function pointer - --> $DIR/function-references.rs:115:38 - | -LL | println!("{:p} {:p} {:p}", &nop, &foo, &bar); - | ^^^^ - -warning: cast `bar` with `as fn(_) -> _` to obtain a function pointer - --> $DIR/function-references.rs:115:44 - | -LL | println!("{:p} {:p} {:p}", &nop, &foo, &bar); - | ^^^^ - -warning: cast `foo` with `as fn() -> _` to obtain a function pointer - --> $DIR/function-references.rs:130:41 - | -LL | std::mem::transmute::<_, usize>(&foo); - | ^^^^ - -warning: cast `foo` with `as fn() -> _` to obtain a function pointer - --> $DIR/function-references.rs:132:50 - | -LL | std::mem::transmute::<_, (usize, usize)>((&foo, &bar)); - | ^^^^^^^^^^^^ - -warning: cast `bar` with `as fn(_) -> _` to obtain a function pointer - --> $DIR/function-references.rs:132:50 - | -LL | std::mem::transmute::<_, (usize, usize)>((&foo, &bar)); - | ^^^^^^^^^^^^ - -warning: cast `bar` with `as fn(_) -> _` to obtain a function pointer - --> $DIR/function-references.rs:142:15 - | -LL | print_ptr(&bar); - | ^^^^ - -warning: cast `bar` with `as fn(_) -> _` to obtain a function pointer - --> $DIR/function-references.rs:144:24 - | -LL | bound_by_ptr_trait(&bar); - | ^^^^ - -warning: cast `bar` with `as fn(_) -> _` to obtain a function pointer - --> $DIR/function-references.rs:146:30 - | -LL | bound_by_ptr_trait_tuple((&foo, &bar)); - | ^^^^^^^^^^^^ - -warning: cast `foo` with `as fn() -> _` to obtain a function pointer - --> $DIR/function-references.rs:146:30 - | -LL | bound_by_ptr_trait_tuple((&foo, &bar)); - | ^^^^^^^^^^^^ - -warning: 28 warnings emitted - -- cgit 1.4.1-3-g733a5