Skip to content

Commit 998bed4

Browse files
committed
---
yaml --- r: 42362 b: refs/heads/master c: 2bc9655 h: refs/heads/master v: v3
1 parent 568f8b0 commit 998bed4

File tree

7 files changed

+166
-114
lines changed

7 files changed

+166
-114
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: b8943474dc4313c432ed791cebe9b76f89b0ad84
2+
refs/heads/master: 2bc9655bc1a5486a2fa4cbcd7543fe094cfc4616
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2f46b763da2c098913884f101b6d71d69af41b49
55
refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650

trunk/src/librustc/driver/driver.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,9 @@ pub fn build_session_options(+binary: ~str,
521521
} else {
522522
session::unknown_crate
523523
};
524+
let static = opt_present(matches, ~"static");
525+
let gc = opt_present(matches, ~"gc");
526+
524527
let parse_only = opt_present(matches, ~"parse-only");
525528
let no_trans = opt_present(matches, ~"no-trans");
526529
@@ -567,6 +570,7 @@ pub fn build_session_options(+binary: ~str,
567570
}
568571
}
569572
573+
let jit = opt_present(matches, ~"jit");
570574
let output_type =
571575
if parse_only || no_trans {
572576
link::output_type_none
@@ -580,6 +584,8 @@ pub fn build_session_options(+binary: ~str,
580584
} else if opt_present(matches, ~"emit-llvm") {
581585
link::output_type_bitcode
582586
} else { link::output_type_exe };
587+
let extra_debuginfo = opt_present(matches, ~"xg");
588+
let debuginfo = opt_present(matches, ~"g") || extra_debuginfo;
583589
let sysroot_opt = getopts::opt_maybe_str(matches, ~"sysroot");
584590
let sysroot_opt = sysroot_opt.map(|m| Path(*m));
585591
let target_opt = getopts::opt_maybe_str(matches, ~"target");
@@ -610,12 +616,6 @@ pub fn build_session_options(+binary: ~str,
610616
}
611617
} else { No }
612618
};
613-
let gc = debugging_opts & session::gc != 0;
614-
let jit = debugging_opts & session::jit != 0;
615-
let extra_debuginfo = debugging_opts & session::extra_debug_info != 0;
616-
let debuginfo = debugging_opts & session::debug_info != 0 ||
617-
extra_debuginfo;
618-
let static = debugging_opts & session::static != 0;
619619
let target =
620620
match target_opt {
621621
None => host_triple(),
@@ -712,11 +712,14 @@ pub fn optgroups() -> ~[getopts::groups::OptGroup] {
712712
environment", ~"SPEC"),
713713
optflag(~"", ~"emit-llvm",
714714
~"Produce an LLVM bitcode file"),
715+
optflag(~"g", ~"", ~"Produce debug info (experimental)"),
716+
optflag(~"", ~"gc", ~"Garbage collect shared data (experimental)"),
715717
optflag(~"h", ~"help",~"Display this message"),
716718
optmulti(~"L", ~"", ~"Add a directory to the library search path",
717719
~"PATH"),
718720
optflag(~"", ~"lib", ~"Compile a library crate"),
719721
optflag(~"", ~"ls", ~"List the symbols defined by a library crate"),
722+
optflag(~"", ~"jit", ~"Execute using JIT (experimental)"),
720723
optflag(~"", ~"no-trans",
721724
~"Run all passes except translation; no output"),
722725
optflag(~"O", ~"", ~"Equivalent to --opt-level=2"),
@@ -736,9 +739,13 @@ pub fn optgroups() -> ~[getopts::groups::OptGroup] {
736739
or identified (fully parenthesized,
737740
AST nodes and blocks with IDs)", ~"TYPE"),
738741
optflag(~"S", ~"", ~"Compile only; do not assemble or link"),
742+
optflag(~"", ~"xg", ~"Extra debugging info (experimental)"),
739743
optflag(~"", ~"save-temps",
740744
~"Write intermediate files (.bc, .opt.bc, .o)
741745
in addition to normal output"),
746+
optflag(~"", ~"static",
747+
~"Use or produce static libraries or binaries
748+
(experimental)"),
742749
optopt(~"", ~"sysroot",
743750
~"Override the system root", ~"PATH"),
744751
optflag(~"", ~"test", ~"Build a test harness"),

trunk/src/librustc/driver/session.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,6 @@ pub const count_type_sizes: uint = 1 << 14;
7575
pub const meta_stats: uint = 1 << 15;
7676
pub const no_opt: uint = 1 << 16;
7777
pub const no_monomorphic_collapse: uint = 1 << 17;
78-
const gc: uint = 1 << 18;
79-
const jit: uint = 1 << 19;
80-
const debug_info: uint = 1 << 20;
81-
const extra_debug_info: uint = 1 << 21;
82-
const static: uint = 1 << 22;
8378

8479
pub fn debugging_opts_map() -> ~[(~str, ~str, uint)] {
8580
~[(~"verbose", ~"in general, enable more debug printouts", verbose),
@@ -107,13 +102,6 @@ pub fn debugging_opts_map() -> ~[(~str, ~str, uint)] {
107102
(~"no-opt", ~"do not optimize, even if -O is passed", no_opt),
108103
(~"no-monomorphic-collapse", ~"do not collapse template instantiations",
109104
no_monomorphic_collapse),
110-
(~"gc", ~"Garbage collect shared data (experimental)", gc),
111-
(~"jit", ~"Execute using JIT (experimental)", jit),
112-
(~"extra-debug-info", ~"Extra debugging info (experimental)",
113-
extra_debug_info),
114-
(~"debug-info", ~"Produce debug info (experimental)", debug_info),
115-
(~"static", ~"Use or produce static libraries or binaries " +
116-
"(experimental)", static)
117105
]
118106
}
119107

trunk/src/librustc/middle/resolve.rs

Lines changed: 58 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -392,17 +392,19 @@ pub struct ImportResolution {
392392
/// The type that this `use` directive names, if there is one.
393393
mut type_target: Option<Target>,
394394
395-
mut used: bool,
395+
/// There exists one state per import statement
396+
state: @mut ImportState,
396397
}
397398
398-
pub fn ImportResolution(privacy: Privacy, span: span) -> ImportResolution {
399+
pub fn ImportResolution(privacy: Privacy, span: span,
400+
state: @mut ImportState) -> ImportResolution {
399401
ImportResolution {
400402
privacy: privacy,
401403
span: span,
402404
outstanding_references: 0,
403405
value_target: None,
404406
type_target: None,
405-
used: false
407+
state: state,
406408
}
407409
}
408410
@@ -415,6 +417,15 @@ pub impl ImportResolution {
415417
}
416418
}
417419
420+
pub struct ImportState {
421+
used: bool,
422+
warned: bool
423+
}
424+
425+
pub fn ImportState() -> ImportState {
426+
ImportState{ used: false, warned: false }
427+
}
428+
418429
/// The link from a module up to its nearest parent node.
419430
pub enum ParentLink {
420431
NoParentLink,
@@ -1415,6 +1426,7 @@ pub impl Resolver {
14151426
14161427
// Build up the import directives.
14171428
let module_ = self.get_module_from_parent(parent);
1429+
let state = @mut ImportState();
14181430
match view_path.node {
14191431
view_path_simple(binding, full_path, ns, _) => {
14201432
let ns = match ns {
@@ -1430,7 +1442,8 @@ pub impl Resolver {
14301442
module_,
14311443
module_path,
14321444
subclass,
1433-
view_path.span);
1445+
view_path.span,
1446+
state);
14341447
}
14351448
view_path_list(_, ref source_idents, _) => {
14361449
for (*source_idents).each |source_ident| {
@@ -1442,15 +1455,17 @@ pub impl Resolver {
14421455
module_,
14431456
module_path,
14441457
subclass,
1445-
view_path.span);
1458+
view_path.span,
1459+
state);
14461460
}
14471461
}
14481462
view_path_glob(_, _) => {
14491463
self.build_import_directive(privacy,
14501464
module_,
14511465
module_path,
14521466
@GlobImport,
1453-
view_path.span);
1467+
view_path.span,
1468+
state);
14541469
}
14551470
}
14561471
}
@@ -1573,7 +1588,8 @@ pub impl Resolver {
15731588
// avoid creating cycles in the
15741589
// module graph.
15751590
1576-
let resolution = @ImportResolution(Public, dummy_sp());
1591+
let resolution = @ImportResolution(Public, dummy_sp(),
1592+
@mut ImportState());
15771593
resolution.outstanding_references = 0;
15781594
15791595
match existing_module.parent_link {
@@ -1826,7 +1842,8 @@ pub impl Resolver {
18261842
module_: @Module,
18271843
module_path: @DVec<ident>,
18281844
subclass: @ImportDirectiveSubclass,
1829-
span: span) {
1845+
span: span,
1846+
state: @mut ImportState) {
18301847
let directive = @ImportDirective(privacy, module_path,
18311848
subclass, span);
18321849
module_.imports.push(directive);
@@ -1850,7 +1867,14 @@ pub impl Resolver {
18501867
}
18511868
None => {
18521869
debug!("(building import directive) creating new");
1853-
let resolution = @ImportResolution(privacy, span);
1870+
let resolution = @ImportResolution(privacy, span,
1871+
state);
1872+
let name = self.idents_to_str(module_path.get());
1873+
// Don't warn about unused intrinsics because they're
1874+
// automatically appended to all files
1875+
if name == ~"intrinsic::rusti" {
1876+
resolution.state.warned = true;
1877+
}
18541878
resolution.outstanding_references = 1;
18551879
module_.import_resolutions.insert(target, resolution);
18561880
}
@@ -2183,7 +2207,7 @@ pub impl Resolver {
21832207
return UnboundResult;
21842208
}
21852209
Some(target) => {
2186-
import_resolution.used = true;
2210+
import_resolution.state.used = true;
21872211
return BoundResult(target.target_module,
21882212
target.bindings);
21892213
}
@@ -2352,7 +2376,7 @@ pub impl Resolver {
23522376
module_result = UnboundResult;
23532377
}
23542378
Some(target) => {
2355-
import_resolution.used = true;
2379+
import_resolution.state.used = true;
23562380
module_result = BoundResult
23572381
(target.target_module,
23582382
target.bindings);
@@ -2419,6 +2443,7 @@ pub impl Resolver {
24192443
// everything it can to the list of import resolutions of the module
24202444
// node.
24212445
debug!("(resolving glob import) resolving %? glob import", privacy);
2446+
let state = @mut ImportState();
24222447
24232448
// We must bail out if the node has unresolved imports of any kind
24242449
// (including globs).
@@ -2445,7 +2470,8 @@ pub impl Resolver {
24452470
// Simple: just copy the old import resolution.
24462471
let new_import_resolution =
24472472
@ImportResolution(privacy,
2448-
target_import_resolution.span);
2473+
target_import_resolution.span,
2474+
state);
24492475
new_import_resolution.value_target =
24502476
copy target_import_resolution.value_target;
24512477
new_import_resolution.type_target =
@@ -2486,7 +2512,8 @@ pub impl Resolver {
24862512
match module_.import_resolutions.find(&ident) {
24872513
None => {
24882514
// Create a new import resolution from this child.
2489-
dest_import_resolution = @ImportResolution(privacy, span);
2515+
dest_import_resolution = @ImportResolution(privacy, span,
2516+
state);
24902517
module_.import_resolutions.insert
24912518
(ident, dest_import_resolution);
24922519
}
@@ -2713,7 +2740,7 @@ pub impl Resolver {
27132740
namespace);
27142741
}
27152742
Some(target) => {
2716-
import_resolution.used = true;
2743+
import_resolution.state.used = true;
27172744
return Success(copy target);
27182745
}
27192746
}
@@ -2962,7 +2989,7 @@ pub impl Resolver {
29622989
Some(target) => {
29632990
debug!("(resolving name in module) resolved to \
29642991
import");
2965-
import_resolution.used = true;
2992+
import_resolution.state.used = true;
29662993
return Success(copy target);
29672994
}
29682995
}
@@ -4560,7 +4587,7 @@ pub impl Resolver {
45604587
namespace)) {
45614588
(Some(def), Some(Public)) => {
45624589
// Found it.
4563-
import_resolution.used = true;
4590+
import_resolution.state.used = true;
45644591
return ImportNameDefinition(def);
45654592
}
45664593
(Some(_), _) | (None, _) => {
@@ -5034,9 +5061,13 @@ pub impl Resolver {
50345061
Some(def) => {
50355062
match def {
50365063
def_ty(trait_def_id) => {
5037-
self.
5064+
let added = self.
50385065
add_trait_info_if_containing_method(
50395066
found_traits, trait_def_id, name);
5067+
if added {
5068+
import_resolution.state.used =
5069+
true;
5070+
}
50405071
}
50415072
_ => {
50425073
// Continue.
@@ -5069,7 +5100,7 @@ pub impl Resolver {
50695100

50705101
fn add_trait_info_if_containing_method(found_traits: @DVec<def_id>,
50715102
trait_def_id: def_id,
5072-
name: ident) {
5103+
name: ident) -> bool {
50735104

50745105
debug!("(adding trait info if containing method) trying trait %d:%d \
50755106
for method '%s'",
@@ -5085,9 +5116,10 @@ pub impl Resolver {
50855116
trait_def_id.node,
50865117
self.session.str_of(name));
50875118
(*found_traits).push(trait_def_id);
5119+
true
50885120
}
50895121
Some(_) | None => {
5090-
// Continue.
5122+
false
50915123
}
50925124
}
50935125
}
@@ -5204,7 +5236,13 @@ pub impl Resolver {
52045236

52055237
fn check_for_unused_imports_in_module(module_: @Module) {
52065238
for module_.import_resolutions.each_value_ref |&import_resolution| {
5207-
if !import_resolution.used {
5239+
// Ignore dummy spans for things like automatically injected
5240+
// imports for the prelude, and also don't warn about the same
5241+
// import statement being unused more than once.
5242+
if !import_resolution.state.used &&
5243+
!import_resolution.state.warned &&
5244+
import_resolution.span != dummy_sp() {
5245+
import_resolution.state.warned = true;
52085246
match self.unused_import_lint_level {
52095247
warn => {
52105248
self.session.span_warn(import_resolution.span,

0 commit comments

Comments
 (0)