Skip to content

Commit 4bf03e6

Browse files
committed
---
yaml --- r: 24523 b: refs/heads/try2 c: db8d9dd h: refs/heads/master i: 24521: 4e6c160 24519: 48786d8 v: v3
1 parent 15417ba commit 4bf03e6

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 1c2843c8adb670570c6a18a06a5d1473b17afffb
8+
refs/heads/try2: db8d9ddcbb9741570a2724c227c824f5eda13ad1
99
refs/heads/incoming: 05543fd04dfb3f63b453a331e239ceb1a9a219f9
1010
refs/heads/dist-snap: 2f32a1581f522e524009138b33b1c7049ced668d
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try2/src/rustc/middle/resolve3.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,17 @@ class Module {
380380
}
381381
}
382382

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+
383394
// XXX: This is a workaround due to is_none in the standard library mistakenly
384395
// requiring a T:copy.
385396

@@ -2802,6 +2813,20 @@ class Resolver {
28022813
}
28032814

28042815
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+
28052830
self.resolve_function(NormalRibKind,
28062831
some(@fn_decl),
28072832
HasTypeParameters(&ty_params,

0 commit comments

Comments
 (0)