rust icon indicating copy to clipboard operation
rust copied to clipboard

main can be a inner function?

Open ILyoan opened this issue 13 years ago • 7 comments

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.

ILyoan avatar Jan 11 '13 00:01 ILyoan

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

brson avatar Jan 11 '13 04:01 brson

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().

nikomatsakis avatar Jan 11 '13 15:01 nikomatsakis

Removing from 0.7.

I-nominated (well-defined)

brson avatar Apr 29 '13 19:04 brson

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

brson avatar Apr 29 '13 20:04 brson

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

brson avatar Apr 29 '13 21:04 brson

accepted for backwards compat

graydon avatar May 02 '13 18:05 graydon

Closing as #6119 landed

ILyoan avatar May 09 '13 06:05 ILyoan