-
Notifications
You must be signed in to change notification settings - Fork 192
Open
Description
I tried this code:
fn f() {}
fn g() {}
fn main() {
let mut x = f;
x = g;
}I expected to see this happen: This should type error, as f and g have different types:
error[E0308]: mismatched types
--> <source>:6:9
|
6 | x = g;
| ^ expected fn item, found a different fn item
|
= note: expected fn item `fn() {f}`
found fn item `fn() {g}`
= note: different `fn` items always have unique types, even if their signatures are the same
= help: change the expected type to be function pointer `fn()`
= help: if the expected type is due to type inference, cast the expected `fn` to a function pointer: `f as fn()`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.
Compiler returned: 1
Instead, this happened: Compiles without error.
Godbolt link: https://godbolt.org/z/4bz9Pdjxr
Meta
- What version of Rust GCC were you using, git sha if possible. be27571
gccrs (Compiler-Explorer-Build-gcc-be27571c110d99fe55324a9c2b6622787b08fb52-binutils-2.38) 13.0.1 20230221 (experimental)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Todo