File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
branches/try2/src/rustc/middle Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
5
5
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be
6
6
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
7
7
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8
- refs/heads/try2: 1c2843c8adb670570c6a18a06a5d1473b17afffb
8
+ refs/heads/try2: db8d9ddcbb9741570a2724c227c824f5eda13ad1
9
9
refs/heads/incoming: 05543fd04dfb3f63b453a331e239ceb1a9a219f9
10
10
refs/heads/dist-snap: 2f32a1581f522e524009138b33b1c7049ced668d
11
11
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
Original file line number Diff line number Diff line change @@ -380,6 +380,17 @@ class Module {
380
380
}
381
381
}
382
382
383
+ pure fn is_crate_root ( module : @Module ) -> bool {
384
+ alt module. def_id {
385
+ none => {
386
+ ret false ;
387
+ }
388
+ some ( def_id) => {
389
+ ret def_id. crate == 0 && def_id. node == 0 ;
390
+ }
391
+ }
392
+ }
393
+
383
394
// XXX: This is a workaround due to is_none in the standard library mistakenly
384
395
// requiring a T:copy.
385
396
@@ -2802,6 +2813,20 @@ class Resolver {
2802
2813
}
2803
2814
2804
2815
item_fn ( fn_decl, ty_params, block) {
2816
+ // If this is the main function, we must record it in the
2817
+ // session.
2818
+ //
2819
+ // For speed, we put the string comparison last in this chain
2820
+ // of conditionals.
2821
+
2822
+ if !self . session . building_library &&
2823
+ is_none ( self . session . main_fn ) &&
2824
+ is_crate_root ( self . current_module ) &&
2825
+ str:: eq ( * item. ident , "main" ) {
2826
+
2827
+ self . session . main_fn = some ( ( item. id , item. span ) ) ;
2828
+ }
2829
+
2805
2830
self . resolve_function ( NormalRibKind ,
2806
2831
some ( @fn_decl) ,
2807
2832
HasTypeParameters ( & ty_params,
You can’t perform that action at this time.
0 commit comments