Skip to content

Commit 9a30e3d

Browse files
committed
---
yaml --- r: 56517 b: refs/heads/auto c: edc11a9 h: refs/heads/master i: 56515: 22b993c v: v3
1 parent d9682f3 commit 9a30e3d

File tree

7 files changed

+218
-150
lines changed

7 files changed

+218
-150
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 00ede34fcb4d6de11e49360964565c8e487a678e
17+
refs/heads/auto: edc11a9f09060b355010b8cc71da45c4f35eadf0
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

branches/auto/src/librustc/back/link.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -904,9 +904,6 @@ pub fn link_binary(sess: Session,
904904
// extern libraries might live, based on the addl_lib_search_paths
905905
cc_args.push_all(rpath::get_rpath_flags(sess, &output));
906906
907-
// Finally add all the linker arguments provided on the command line
908-
cc_args.push_all(sess.opts.linker_args);
909-
910907
debug!("%s link args: %s", cc_prog, str::connect(cc_args, ~" "));
911908
// We run 'cc' here
912909
let prog = run::program_output(cc_prog, cc_args);

branches/auto/src/librustc/driver/driver.rs

Lines changed: 53 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -645,16 +645,9 @@ pub fn build_session_options(binary: @~str,
645645
Some(s) => s
646646
};
647647
648-
let addl_lib_search_paths = getopts::opt_strs(matches, ~"L").map(|s| Path(*s));
649-
650-
let linker_args = getopts::opt_strs(matches, ~"linker").flat_map( |a| {
651-
let mut args = ~[];
652-
for str::each_split_char(*a, ',') |arg| {
653-
args.push(str::from_slice(arg));
654-
}
655-
args
656-
});
657-
648+
let addl_lib_search_paths =
649+
getopts::opt_strs(matches, ~"L")
650+
.map(|s| Path(*s));
658651
let cfg = parse_cfgspecs(getopts::opt_strs(matches, ~"cfg"), demitter);
659652
let test = opt_present(matches, ~"test");
660653
let android_cross_path = getopts::opt_maybe_str(
@@ -671,7 +664,6 @@ pub fn build_session_options(binary: @~str,
671664
jit: jit,
672665
output_type: output_type,
673666
addl_lib_search_paths: addl_lib_search_paths,
674-
linker_args: linker_args,
675667
maybe_sysroot: sysroot_opt,
676668
target_triple: target,
677669
target_feature: target_feature,
@@ -745,66 +737,62 @@ pub fn parse_pretty(sess: Session, name: &str) -> pp_mode {
745737
// rustc command line options
746738
pub fn optgroups() -> ~[getopts::groups::OptGroup] {
747739
~[
748-
optflag("", "bin", "Compile an executable crate (default)"),
749-
optflag("c", "", "Compile and assemble, but do not link"),
750-
optmulti("", "cfg", "Configure the compilation
751-
environment", "SPEC"),
752-
optflag("", "emit-llvm",
753-
"Produce an LLVM bitcode file"),
754-
optflag("h", "help","Display this message"),
755-
optmulti("L", "", "Add a directory to the library search path",
756-
"PATH"),
757-
optflag("", "lib", "Compile a library crate"),
758-
optmulti("", "linker", "FLAGS is a comma-separated list of flags
759-
passed to the linker", "FLAGS"),
760-
optflag("", "ls", "List the symbols defined by a library crate"),
761-
optflag("", "no-trans",
762-
"Run all passes except translation; no output"),
763-
optflag("O", "", "Equivalent to --opt-level=2"),
764-
optopt("o", "", "Write output to <filename>", "FILENAME"),
765-
optopt("", "opt-level",
766-
"Optimize with possible levels 0-3", "LEVEL"),
767-
optopt( "", "out-dir",
768-
"Write output to compiler-chosen filename
769-
in <dir>", "DIR"),
770-
optflag("", "parse-only",
771-
"Parse only; do not compile, assemble, or link"),
772-
optflagopt("", "pretty",
773-
"Pretty-print the input instead of compiling;
740+
optflag(~"", ~"bin", ~"Compile an executable crate (default)"),
741+
optflag(~"c", ~"", ~"Compile and assemble, but do not link"),
742+
optmulti(~"", ~"cfg", ~"Configure the compilation
743+
environment", ~"SPEC"),
744+
optflag(~"", ~"emit-llvm",
745+
~"Produce an LLVM bitcode file"),
746+
optflag(~"h", ~"help",~"Display this message"),
747+
optmulti(~"L", ~"", ~"Add a directory to the library search path",
748+
~"PATH"),
749+
optflag(~"", ~"lib", ~"Compile a library crate"),
750+
optflag(~"", ~"ls", ~"List the symbols defined by a library crate"),
751+
optflag(~"", ~"no-trans",
752+
~"Run all passes except translation; no output"),
753+
optflag(~"O", ~"", ~"Equivalent to --opt-level=2"),
754+
optopt(~"o", ~"", ~"Write output to <filename>", ~"FILENAME"),
755+
optopt(~"", ~"opt-level",
756+
~"Optimize with possible levels 0-3", ~"LEVEL"),
757+
optopt( ~"", ~"out-dir",
758+
~"Write output to compiler-chosen filename
759+
in <dir>", ~"DIR"),
760+
optflag(~"", ~"parse-only",
761+
~"Parse only; do not compile, assemble, or link"),
762+
optflagopt(~"", ~"pretty",
763+
~"Pretty-print the input instead of compiling;
774764
valid types are: normal (un-annotated source),
775765
expanded (crates expanded),
776766
typed (crates expanded, with type annotations),
777767
or identified (fully parenthesized,
778-
AST nodes and blocks with IDs)", "TYPE"),
779-
optflag("", "print-link-args", "Prints all the arguments that would be
780-
passed to the linker."),
781-
optflag("S", "", "Compile only; do not assemble or link"),
782-
optflag("", "save-temps",
783-
"Write intermediate files (.bc, .opt.bc, .o)
768+
AST nodes and blocks with IDs)", ~"TYPE"),
769+
optflag(~"S", ~"", ~"Compile only; do not assemble or link"),
770+
optflag(~"", ~"save-temps",
771+
~"Write intermediate files (.bc, .opt.bc, .o)
784772
in addition to normal output"),
785-
optopt("", "sysroot",
786-
"Override the system root", "PATH"),
787-
optflag("", "test", "Build a test harness"),
788-
optopt("", "target",
789-
"Target triple cpu-manufacturer-kernel[-os]
773+
optopt(~"", ~"sysroot",
774+
~"Override the system root", ~"PATH"),
775+
optflag(~"", ~"test", ~"Build a test harness"),
776+
optopt(~"", ~"target",
777+
~"Target triple cpu-manufacturer-kernel[-os]
790778
to compile for (see chapter 3.4 of http://www.sourceware.org/autobook/
791-
for detail)", "TRIPLE"),
792-
optopt("", "target-feature",
793-
"Target specific attributes (llc -mattr=help
794-
for detail)", "FEATURE"),
795-
optopt("", "android-cross-path",
796-
"The path to the Android NDK", "PATH"),
797-
optmulti("W", "warn",
798-
"Set lint warnings", "OPT"),
799-
optmulti("A", "allow",
800-
"Set lint allowed", "OPT"),
801-
optmulti("D", "deny",
802-
"Set lint denied", "OPT"),
803-
optmulti("F", "forbid",
804-
"Set lint forbidden", "OPT"),
805-
optmulti("Z", "", "Set internal debugging options", "FLAG"),
806-
optflag( "v", "version",
807-
"Print version info and exit"),
779+
for detail)", ~"TRIPLE"),
780+
optopt(~"", ~"target-feature",
781+
~"Target specific attributes (llc -mattr=help
782+
for detail)", ~"FEATURE"),
783+
optopt(~"", ~"android-cross-path",
784+
~"The path to the Android NDK", "PATH"),
785+
optmulti(~"W", ~"warn",
786+
~"Set lint warnings", ~"OPT"),
787+
optmulti(~"A", ~"allow",
788+
~"Set lint allowed", ~"OPT"),
789+
optmulti(~"D", ~"deny",
790+
~"Set lint denied", ~"OPT"),
791+
optmulti(~"F", ~"forbid",
792+
~"Set lint forbidden", ~"OPT"),
793+
optmulti(~"Z", ~"", ~"Set internal debugging options", "FLAG"),
794+
optflag( ~"v", ~"version",
795+
~"Print version info and exit"),
808796
]
809797
}
810798

branches/auto/src/librustc/driver/session.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ pub struct options {
122122
jit: bool,
123123
output_type: back::link::output_type,
124124
addl_lib_search_paths: ~[Path],
125-
linker_args: ~[~str],
126125
maybe_sysroot: Option<Path>,
127126
target_triple: ~str,
128127
target_feature: ~str,
@@ -300,7 +299,6 @@ pub fn basic_options() -> @options {
300299
jit: false,
301300
output_type: link::output_type_exe,
302301
addl_lib_search_paths: ~[],
303-
linker_args:~[],
304302
maybe_sysroot: None,
305303
target_triple: host_triple(),
306304
target_feature: ~"",

branches/auto/src/librustc/middle/typeck/check/_match.rs

Lines changed: 104 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,18 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::pat, path: @ast::Path,
175175
kind_name = "structure";
176176
}
177177
_ => {
178-
tcx.sess.span_fatal(
179-
pat.span,
180-
fmt!("mismatched types: expected `%s` but found enum or \
181-
structure",
182-
fcx.infcx().ty_to_str(expected)));
178+
let resolved_expected =
179+
fcx.infcx().ty_to_str(fcx.infcx().resolve_type_vars_if_possible(expected));
180+
fcx.infcx().type_error_message_str(pat.span,
181+
|actual| {
182+
fmt!("mismatched types: expected `%s` but found %s",
183+
resolved_expected, actual)},
184+
~"an enum or structure pattern",
185+
None);
186+
fcx.write_error(pat.id);
187+
kind_name = "[error]";
188+
arg_types = (copy subpats).get_or_default(~[]).map(|_|
189+
ty::mk_err());
183190
}
184191
}
185192

@@ -486,74 +493,44 @@ pub fn check_pat(pcx: &pat_ctxt, pat: @ast::pat, expected: ty::t) {
486493
}
487494
ast::pat_tup(ref elts) => {
488495
let s = structure_of(fcx, pat.span, expected);
489-
let ex_elts = match s {
490-
ty::ty_tup(ref elts) => elts,
491-
_ => {
492-
tcx.sess.span_fatal
493-
(pat.span,
494-
fmt!("mismatched types: expected `%s`, found tuple",
495-
fcx.infcx().ty_to_str(expected)));
496-
}
497-
};
498496
let e_count = elts.len();
499-
if e_count != ex_elts.len() {
500-
tcx.sess.span_fatal
501-
(pat.span, fmt!("mismatched types: expected a tuple \
502-
with %u fields, found one with %u \
503-
fields", ex_elts.len(), e_count));
504-
}
505-
let mut i = 0u;
506-
for elts.each |elt| {
507-
check_pat(pcx, *elt, ex_elts[i]);
508-
i += 1u;
497+
match s {
498+
ty::ty_tup(ref ex_elts) if e_count == ex_elts.len() => {
499+
for elts.eachi |i, elt| {
500+
check_pat(pcx, *elt, ex_elts[i]);
501+
}
502+
fcx.write_ty(pat.id, expected);
503+
}
504+
_ => {
505+
for elts.each |elt| {
506+
check_pat(pcx, *elt, ty::mk_err());
507+
}
508+
let actual = ty::mk_tup(tcx, elts.map(|pat_var| {
509+
fcx.node_ty(pat_var.id)
510+
}));
511+
// use terr_tuple_size if both types are tuples
512+
let type_error = match s {
513+
ty::ty_tup(ref ex_elts) =>
514+
ty::terr_tuple_size(ty::expected_found{expected: ex_elts.len(),
515+
found: e_count}),
516+
_ => ty::terr_mismatch
517+
};
518+
fcx.infcx().report_mismatched_types(pat.span,
519+
expected,
520+
actual,
521+
&type_error);
522+
fcx.write_error(pat.id);
523+
}
509524
}
510-
511-
fcx.write_ty(pat.id, expected);
512525
}
513526
ast::pat_box(inner) => {
514-
match structure_of(fcx, pat.span, expected) {
515-
ty::ty_box(e_inner) => {
516-
check_pat(pcx, inner, e_inner.ty);
517-
fcx.write_ty(pat.id, expected);
518-
}
519-
_ => {
520-
tcx.sess.span_fatal(
521-
pat.span,
522-
~"mismatched types: expected `" +
523-
fcx.infcx().ty_to_str(expected) +
524-
~"` found box");
525-
}
526-
}
527+
check_pointer_pat(pcx, At, inner, pat.id, pat.span, expected);
527528
}
528529
ast::pat_uniq(inner) => {
529-
match structure_of(fcx, pat.span, expected) {
530-
ty::ty_uniq(e_inner) => {
531-
check_pat(pcx, inner, e_inner.ty);
532-
fcx.write_ty(pat.id, expected);
533-
}
534-
_ => {
535-
tcx.sess.span_fatal(
536-
pat.span,
537-
~"mismatched types: expected `" +
538-
fcx.infcx().ty_to_str(expected) +
539-
~"` found uniq");
540-
}
541-
}
530+
check_pointer_pat(pcx, Uniq, inner, pat.id, pat.span, expected);
542531
}
543532
ast::pat_region(inner) => {
544-
match structure_of(fcx, pat.span, expected) {
545-
ty::ty_rptr(_, e_inner) => {
546-
check_pat(pcx, inner, e_inner.ty);
547-
fcx.write_ty(pat.id, expected);
548-
}
549-
_ => {
550-
tcx.sess.span_fatal(
551-
pat.span,
552-
~"mismatched types: expected `" +
553-
fcx.infcx().ty_to_str(expected) +
554-
~"` found borrowed pointer");
555-
}
556-
}
533+
check_pointer_pat(pcx, Borrowed, inner, pat.id, pat.span, expected);
557534
}
558535
ast::pat_vec(ref before, slice, ref after) => {
559536
let default_region_var =
@@ -577,11 +554,25 @@ pub fn check_pat(pcx: &pat_ctxt, pat: @ast::pat, expected: ty::t) {
577554
(mt, default_region_var)
578555
},
579556
_ => {
580-
tcx.sess.span_fatal(
581-
pat.span,
582-
fmt!("mismatched type: expected `%s` but found vector",
583-
fcx.infcx().ty_to_str(expected))
584-
);
557+
for before.each |&elt| {
558+
check_pat(pcx, elt, ty::mk_err());
559+
}
560+
for slice.each |&elt| {
561+
check_pat(pcx, elt, ty::mk_err());
562+
}
563+
for after.each |&elt| {
564+
check_pat(pcx, elt, ty::mk_err());
565+
}
566+
let resolved_expected =
567+
fcx.infcx().ty_to_str(fcx.infcx().resolve_type_vars_if_possible(expected));
568+
fcx.infcx().type_error_message_str(pat.span,
569+
|actual| {
570+
fmt!("mismatched types: expected `%s` but found %s",
571+
resolved_expected, actual)},
572+
~"a vector pattern",
573+
None);
574+
fcx.write_error(pat.id);
575+
return;
585576
}
586577
};
587578
for before.each |elt| {
@@ -605,3 +596,46 @@ pub fn check_pat(pcx: &pat_ctxt, pat: @ast::pat, expected: ty::t) {
605596
}
606597
}
607598
599+
// Helper function to check @, ~ and & patterns
600+
pub fn check_pointer_pat(pcx: &pat_ctxt,
601+
pointer_kind: PointerKind,
602+
inner: @ast::pat,
603+
pat_id: ast::node_id,
604+
span: span,
605+
expected: ty::t) {
606+
let fcx = pcx.fcx;
607+
let check_inner: &fn(ty::mt) = |e_inner| {
608+
check_pat(pcx, inner, e_inner.ty);
609+
fcx.write_ty(pat_id, expected);
610+
};
611+
match structure_of(fcx, span, expected) {
612+
ty::ty_box(e_inner) if pointer_kind == At => {
613+
check_inner(e_inner);
614+
}
615+
ty::ty_uniq(e_inner) if pointer_kind == Uniq => {
616+
check_inner(e_inner);
617+
}
618+
ty::ty_rptr(_, e_inner) if pointer_kind == Borrowed => {
619+
check_inner(e_inner);
620+
}
621+
_ => {
622+
check_pat(pcx, inner, ty::mk_err());
623+
let resolved_expected =
624+
fcx.infcx().ty_to_str(fcx.infcx().resolve_type_vars_if_possible(expected));
625+
fcx.infcx().type_error_message_str(span, |actual| {
626+
fmt!("mismatched types: expected `%s` but found %s",
627+
resolved_expected, actual)},
628+
fmt!("an %s pattern", match pointer_kind {
629+
At => "@-box",
630+
Uniq => "~-box",
631+
Borrowed => "&-pointer"
632+
}),
633+
None);
634+
fcx.write_error(pat_id);
635+
}
636+
}
637+
}
638+
639+
#[deriving(Eq)]
640+
enum PointerKind { At, Uniq, Borrowed }
641+

0 commit comments

Comments
 (0)