Skip to content

main can be a inner function? #4433

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

Closed
ILyoan opened this issue Jan 11, 2013 · 7 comments
Closed

main can be a inner function? #4433

ILyoan opened this issue Jan 11, 2013 · 7 comments
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR) E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@ILyoan
Copy link
Contributor

ILyoan commented Jan 11, 2013

main function can be a inner function.

for example

fn foo() {
    fn main() {
        io::println("i am the inner main");
        foo();
    }
    io::println("i am a outer function");
}

I wonder if it's intended.
If not, main should be always at the top crate level.

@brson
Copy link
Contributor

brson commented Jan 11, 2013

I would not mind forcing main to always be a crate-level function.

@nikomatsakis
Copy link
Contributor

I think my preference would be that main must be at the root of the crate. I hate when I download some C code and I have to grep around just to find main().

@brson
Copy link
Contributor

brson commented Apr 29, 2013

Removing from 0.7.

I-nominated (well-defined)

@brson
Copy link
Contributor

brson commented Apr 29, 2013

I think the main discovery logic needs to get its own pass. It's starting to get a bit complicated.

@brson
Copy link
Contributor

brson commented Apr 29, 2013

If we do this we'll need extra diagnostics to see if there's a 'main' function defined in the wrong place.

brson added a commit to brson/rust that referenced this issue Apr 29, 2013
It doesn't have anything to do with resolve and the logic will likely get
more involved in the future, after rust-lang#4433
@graydon
Copy link
Contributor

graydon commented May 2, 2013

accepted for backwards compat

@ILyoan
Copy link
Contributor Author

ILyoan commented May 9, 2013

Closing as #6119 landed

@ILyoan ILyoan closed this as completed May 9, 2013
Aatch pushed a commit to Aatch/rust that referenced this issue May 12, 2013
It doesn't have anything to do with resolve and the logic will likely get
more involved in the future, after rust-lang#4433
flip1995 pushed a commit to flip1995/rust that referenced this issue Mar 14, 2022
Fix some `unnecessary_filter_map` false positives

This is a proposed fix for rust-lang#4433.

It moves `clone_or_copy_needed` out of `unnecessary_iter_cloned.rs` and into `methods::utils`. It then adds a check of this function to `unnecessary_filter_map::check`.

Fixes rust-lang#4433

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR) E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

4 participants