Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coercing bare fn to &fn is inconsistent in statics. #5216

Closed
jld opened this issue Mar 4, 2013 · 8 comments
Closed

Coercing bare fn to &fn is inconsistent in statics. #5216

jld opened this issue Mar 4, 2013 · 8 comments
Labels
A-typesystem Area: The type system

Comments

@jld
Copy link
Contributor

jld commented Mar 4, 2013

This types:

fn f() { }
struct S(&fn());
pub static C: S = S(f);

This doesn't:

fn f() { }
type T = &fn();
pub static C: T = f;

This seems wrong.

@catamorphism
Copy link
Contributor

Doesn't seem critical for 0.7. Nominating for milestone 2.

@graydon
Copy link
Contributor

graydon commented May 2, 2013

Seems like just-a-bug; if fixed, would only admit more code. Declined milestone.

@graydon
Copy link
Contributor

graydon commented May 2, 2013

related to #5551

@emberian
Copy link
Member

emberian commented Aug 5, 2013

@jld neither typecheck now. Same error:

foo.rs:2:9: 2:14 error: Illegal anonymous lifetime: anonymous lifetimes are not permitted here
foo.rs:2 struct S(&fn());
                  ^~~~~
foo.rs:3:14: 3:16 error: Illegal anonymous lifetime: only 'static is allowed here
foo.rs:3 pub static C: S = S(f);
                       ^~

@jdm
Copy link
Contributor

jdm commented Aug 5, 2013

These are well-typed:

fn f() {}
type T = &'static extern "Rust" fn();
pub static C: T = &f;
 fn f() {}
struct S(&'static extern "Rust" fn());
pub static C: S = S(&f);

I guess this bypasses the coercion, though.

@catamorphism
Copy link
Contributor

I'm about to check in the test case.

@catamorphism
Copy link
Contributor

#10027 will close this.

@pnkfelix
Copy link
Member

closed by SHA: 5de50a3

bors added a commit to rust-lang-ci/rust that referenced this issue May 2, 2020
…-fn, r=flip1995

Prevent `missing_const_for_fn` on functions with const generic params

`const` functions cannot have const generic parameters so prevent the
`missing_const_for_fn` lint from firing in that case.

changelog: Fix false positive in `missing_const_for_fn`

Fixes rust-lang#5192
calebcartwright pushed a commit to calebcartwright/rust that referenced this issue Mar 30, 2022
)

* chore(rustfmt): remove executable path from usage string

* add unit test for usage string

* rename test and check usage text in a single assert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-typesystem Area: The type system
Projects
None yet
Development

No branches or pull requests

6 participants