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

ty_bare_fn consts have an environment pointer, but their type doesn't. #5210

Closed
jld opened this issue Mar 3, 2013 · 3 comments
Closed

ty_bare_fn consts have an environment pointer, but their type doesn't. #5210

jld opened this issue Mar 3, 2013 · 3 comments

Comments

@jld
Copy link
Contributor

jld commented Mar 3, 2013

fn f() { }
const fs: &[extern fn()] = &[f, f];
fn main() { for fs.each |&g| { g() } }

The type_of (and sizing_type_of) for that extern fn is just a pointer, but what's getting generated for the constant also has an environment pointer. Because we have to defeat LLVM's type checks to support enums (and we don't have sufficient assertions of our own), we don't catch the mismatch and the second call to f jumps through the first array element's null environment pointer instead.

@jld
Copy link
Contributor Author

jld commented Mar 3, 2013

This looks like febdb49 from #4808, or rather something that that change missed.

@nikomatsakis
Copy link
Contributor

Yeah, that's my fault. I forgot that constants have a different path.

jld added a commit to jld/rust that referenced this issue Mar 4, 2013
Otherwise we can add a null environment when we shouldn't.

Fixes rust-lang#5210.
bors added a commit that referenced this issue Mar 5, 2013
@jld
Copy link
Contributor Author

jld commented Mar 5, 2013

Fixed on incoming.

@jld jld closed this as completed Mar 5, 2013
flip1995 pushed a commit to flip1995/rust that referenced this issue Apr 22, 2021
…0, r=giraffate

Fix FP in `single_component_path_imports` lint

Fix FP in  `single_component_path_imports` lint when the import is reused with `self`, like in `use self::module`.

Fixes rust-lang#5210

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants