Skip to content

Commit 4211167

Browse files
committed
---
yaml --- r: 46431 b: refs/heads/auto c: 1b04be6 h: refs/heads/master i: 46429: 82c68c7 46427: f62cd2d 46423: 5d24495 46415: 0cf36e2 46399: ddcb6a7 v: v3
1 parent 4dd9edc commit 4211167

File tree

17 files changed

+227
-22
lines changed

17 files changed

+227
-22
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ 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: bad4463a6b793aa627afe5aeb6a4af54b9562c23
17+
refs/heads/auto: 1b04be6858bdf7c3ab06a45b8e4049d1042a5a3d
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"Highlight the 78th text column
2+
"Feature became available in v7.3
3+
if version >= 703
4+
set colorcolumn=78
5+
endif

branches/auto/src/etc/vim/syntax/rust.vim

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,15 @@ syn match rustFloat display "\<[0-9][0-9_]*\.[0-9_]\+\(f\|f32\|f64\)\>
103103
syn match rustFloat display "\<[0-9][0-9_]*\.[0-9_]\+\%([eE][+-]\=[0-9_]\+\)\>"
104104
syn match rustFloat display "\<[0-9][0-9_]*\.[0-9_]\+\%([eE][+-]\=[0-9_]\+\)\(f\|f32\|f64\)\>"
105105

106+
"rustLifetime must appear before rustCharacter, or chars will get the lifetime highlighting
107+
syn match rustLifetime display "\'\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*"
106108
syn match rustCharacter "'\([^'\\]\|\\\(['nrt\\\"]\|x\x\{2}\|u\x\{4}\|U\x\{8}\)\)'"
107109

108110
syn region rustComment start="/\*" end="\*/" contains=rustComment,rustTodo
109111
syn region rustComment start="//" skip="\\$" end="$" contains=rustTodo keepend
110112

111-
syn keyword rustTodo TODO FIXME XXX NB
113+
114+
syn keyword rustTodo TODO FIXME XXX NB unsafe
112115

113116
hi def link rustHexNumber rustNumber
114117
hi def link rustBinNumber rustNumber
@@ -134,6 +137,7 @@ hi def link rustType Type
134137
hi def link rustTodo Todo
135138
hi def link rustAttribute PreProc
136139
hi def link rustStorage StorageClass
140+
hi def link rustLifetime Special
137141

138142
" Other Suggestions:
139143
" hi rustAssert ctermfg=yellow

branches/auto/src/etc/x86.supp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,55 @@
366366
...
367367
}
368368

369+
{
370+
enum-instruction-scheduling-1
371+
Memcheck:Cond
372+
fun:*fold_mod*
373+
...
374+
}
375+
376+
{
377+
enum-instruction-scheduling-2
378+
Memcheck:Cond
379+
fun:*fold_nmod*
380+
...
381+
}
382+
383+
{
384+
enum-instruction-scheduling-3
385+
Memcheck:Cond
386+
fun:*fold_crate*
387+
...
388+
}
389+
390+
{
391+
enum-instruction-scheduling-4
392+
Memcheck:Cond
393+
fun:*fold_enum*
394+
...
395+
}
396+
397+
{
398+
enum-instruction-scheduling-5
399+
Memcheck:Cond
400+
fun:*write_variant*
401+
...
402+
}
403+
404+
{
405+
enum-instruction-scheduling-6
406+
Memcheck:Cond
407+
fun:*merge_method_attrs*
408+
...
409+
}
410+
411+
{
412+
enum-instruction-scheduling-7
413+
Memcheck:Cond
414+
fun:*parse_config_*
415+
...
416+
}
417+
369418
{
370419
llvm-user-new-leak
371420
Memcheck:Leak

branches/auto/src/librustc/lib/llvm.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,15 @@ pub enum FileType {
184184
ObjectFile = 1
185185
}
186186

187+
pub enum Metadata {
188+
MD_dbg = 0,
189+
MD_tbaa = 1,
190+
MD_prof = 2,
191+
MD_fpmath = 3,
192+
MD_range = 4,
193+
MD_tbaa_struct = 5
194+
}
195+
187196
// Opaque pointer types
188197
pub enum Module_opaque {}
189198
pub type ModuleRef = *Module_opaque;

branches/auto/src/librustc/middle/trans/_match.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,13 +1361,29 @@ pub fn compile_submatch(bcx: block,
13611361
if opts.len() > 0u {
13621362
match opts[0] {
13631363
var(_, vdef) => {
1364-
if (*ty::enum_variants(tcx, vdef.enm)).len() == 1u {
1364+
let variants = ty::enum_variants(tcx, vdef.enm);
1365+
if variants.len() == 1 {
13651366
kind = single;
13661367
} else {
13671368
let enumptr =
13681369
PointerCast(bcx, val, T_opaque_enum_ptr(ccx));
13691370
let discrimptr = GEPi(bcx, enumptr, [0u, 0u]);
1370-
test_val = Load(bcx, discrimptr);
1371+
1372+
1373+
assert variants.len() > 1;
1374+
let min_discrim = do variants.foldr(0) |&x, y| {
1375+
int::min(x.disr_val, y)
1376+
};
1377+
let max_discrim = do variants.foldr(0) |&x, y| {
1378+
int::max(x.disr_val, y)
1379+
};
1380+
1381+
test_val = LoadRangeAssert(bcx, discrimptr,
1382+
min_discrim as c_ulonglong,
1383+
(max_discrim + 1)
1384+
as c_ulonglong,
1385+
lib::llvm::True);
1386+
13711387
kind = switch;
13721388
}
13731389
}

branches/auto/src/librustc/middle/trans/build.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ use lib::llvm::llvm;
1414
use lib::llvm::{CallConv, TypeKind, AtomicBinOp, AtomicOrdering};
1515
use lib::llvm::{Opcode, IntPredicate, RealPredicate, True, False};
1616
use lib::llvm::{ValueRef, TypeRef, BasicBlockRef, BuilderRef, ModuleRef};
17-
use libc::{c_uint, c_int};
17+
use libc::{c_uint, c_int, c_ulonglong};
1818
use middle::trans::common::*;
19+
use middle::trans::machine::llsize_of_real;
1920

2021
use core::cast::transmute;
2122
use core::cast;
@@ -536,6 +537,25 @@ pub fn Load(cx: block, PointerVal: ValueRef) -> ValueRef {
536537
}
537538
}
538539
540+
pub fn LoadRangeAssert(cx: block, PointerVal: ValueRef, lo: c_ulonglong,
541+
hi: c_ulonglong, signed: lib::llvm::Bool) -> ValueRef {
542+
let value = Load(cx, PointerVal);
543+
544+
unsafe {
545+
let t = llvm::LLVMGetElementType(llvm::LLVMTypeOf(PointerVal));
546+
let min = llvm::LLVMConstInt(t, lo, signed);
547+
let max = llvm::LLVMConstInt(t, hi, signed);
548+
549+
550+
do vec::as_imm_buf([min, max]) |ptr, len| {
551+
llvm::LLVMSetMetadata(value, lib::llvm::MD_range as c_uint,
552+
llvm::LLVMMDNode(ptr, len as c_uint));
553+
}
554+
}
555+
556+
value
557+
}
558+
539559
pub fn Store(cx: block, Val: ValueRef, Ptr: ValueRef) {
540560
unsafe {
541561
if cx.unreachable { return; }

branches/auto/src/librustc/middle/trans/datum.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,13 @@ pub impl Datum {
431431
} else {
432432
match self.mode {
433433
ByValue => self.val,
434-
ByRef => Load(bcx, self.val)
434+
ByRef => {
435+
if ty::type_is_bool(self.ty) {
436+
LoadRangeAssert(bcx, self.val, 0, 2, lib::llvm::True)
437+
} else {
438+
Load(bcx, self.val)
439+
}
440+
}
435441
}
436442
}
437443
}

branches/auto/src/librustc/middle/trans/expr.rs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -491,11 +491,29 @@ fn trans_rvalue_stmt_unadjusted(bcx: block, expr: @ast::expr) -> block {
491491
ast::expr_swap(dst, src) => {
492492
let dst_datum = unpack_datum!(bcx, trans_lvalue(bcx, dst));
493493
let src_datum = unpack_datum!(bcx, trans_lvalue(bcx, src));
494-
let scratch = scratch_datum(bcx, dst_datum.ty, false);
495494

496-
let bcx = dst_datum.move_to_datum(bcx, INIT, scratch);
497-
let bcx = src_datum.move_to_datum(bcx, INIT, dst_datum);
498-
return scratch.move_to_datum(bcx, INIT, src_datum);
495+
// If the source and destination are the same, then don't swap.
496+
// Avoids performing an overlapping memcpy
497+
let dst_datum_ref = dst_datum.to_ref_llval(bcx);
498+
let src_datum_ref = src_datum.to_ref_llval(bcx);
499+
let cmp = ICmp(bcx, lib::llvm::IntEQ,
500+
src_datum_ref,
501+
dst_datum_ref);
502+
503+
let swap_cx = base::sub_block(bcx, ~"swap");
504+
let next_cx = base::sub_block(bcx, ~"next");
505+
506+
CondBr(bcx, cmp, next_cx.llbb, swap_cx.llbb);
507+
508+
let scratch = scratch_datum(swap_cx, dst_datum.ty, false);
509+
510+
let swap_cx = dst_datum.move_to_datum(swap_cx, INIT, scratch);
511+
let swap_cx = src_datum.move_to_datum(swap_cx, INIT, dst_datum);
512+
let swap_cx = scratch.move_to_datum(swap_cx, INIT, src_datum);
513+
514+
Br(swap_cx, next_cx.llbb);
515+
516+
return next_cx;
499517
}
500518
ast::expr_assign_op(op, dst, src) => {
501519
return trans_assign_op(bcx, expr, op, dst, src);

branches/auto/src/librustc/middle/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2823,7 +2823,7 @@ pub pure fn ty_fn_ret(fty: t) -> t {
28232823
}
28242824
}
28252825

2826-
fn is_fn_ty(fty: t) -> bool {
2826+
pub fn is_fn_ty(fty: t) -> bool {
28272827
match get(fty).sty {
28282828
ty_bare_fn(_) => true,
28292829
ty_closure(_) => true,

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path,
9292
match structure_of(pcx.fcx, pat.span, expected) {
9393
ty::ty_enum(_, ref expected_substs) => {
9494
// Lookup the enum and variant def ids:
95-
let v_def = lookup_def(pcx.fcx, path.span, pat.id);
95+
let v_def = lookup_def(pcx.fcx, pat.span, pat.id);
9696
let v_def_ids = ast_util::variant_def_ids(v_def);
9797

9898
// Assign the pattern the type of the *enum*, not the variant.
@@ -125,8 +125,17 @@ pub fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path,
125125
kind_name = "variant";
126126
}
127127
ty::ty_struct(struct_def_id, ref expected_substs) => {
128+
// Lookup the struct ctor def id
129+
let s_def = lookup_def(pcx.fcx, pat.span, pat.id);
130+
let s_def_id = ast_util::def_id_of_def(s_def);
131+
128132
// Assign the pattern the type of the struct.
129-
let struct_tpt = ty::lookup_item_type(tcx, struct_def_id);
133+
let ctor_tpt = ty::lookup_item_type(tcx, s_def_id);
134+
let struct_tpt = if ty::is_fn_ty(ctor_tpt.ty) {
135+
{ty: ty::ty_fn_ret(ctor_tpt.ty), ..ctor_tpt}
136+
} else {
137+
ctor_tpt
138+
};
130139
instantiate_path(pcx.fcx, path, struct_tpt, pat.span, pat.id,
131140
pcx.block_region);
132141

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -438,9 +438,10 @@ pub impl LookupContext {
438438

439439
let trait_methods = ty::trait_methods(tcx, init_trait_id);
440440
let pos = {
441-
match trait_methods.position(|m| {
442-
m.self_ty != ast::sty_static &&
443-
m.ident == self.m_name })
441+
// FIXME #3453 can't use trait_methods.position
442+
match vec::position(*trait_methods,
443+
|m| (m.self_ty != ast::sty_static &&
444+
m.ident == self.m_name))
444445
{
445446
Some(pos) => pos,
446447
None => {
@@ -623,7 +624,9 @@ pub impl LookupContext {
623624
}
624625

625626
let idx = {
626-
match impl_info.methods.position(|m| m.ident == self.m_name) {
627+
// FIXME #3453 can't use impl_info.methods.position
628+
match vec::position(impl_info.methods,
629+
|m| m.ident == self.m_name) {
627630
Some(idx) => idx,
628631
None => { return; } // No method with the right name.
629632
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,10 @@ pub fn resolve_type_vars_in_fn(fcx: @mut FnCtxt,
275275
|_bm, pat_id, span, _path| {
276276
resolve_type_vars_for_node(wbcx, span, pat_id);
277277
}
278+
// Privacy needs the type for the whole pattern, not just each binding
279+
if !pat_util::pat_is_binding(fcx.tcx().def_map, arg.pat) {
280+
resolve_type_vars_for_node(wbcx, arg.pat.span, arg.pat.id);
281+
}
278282
}
279283
return wbcx.success;
280284
}

branches/auto/src/librustc/middle/typeck/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ pub struct CrateCtxt {
208208
// Functions that write types into the node type table
209209
pub fn write_ty_to_tcx(tcx: ty::ctxt, node_id: ast::node_id, ty: ty::t) {
210210
debug!("write_ty_to_tcx(%d, %s)", node_id, ppaux::ty_to_str(tcx, ty));
211-
oldsmallintmap::insert(*tcx.node_types, node_id as uint, ty);
211+
tcx.node_types.insert(node_id as uint, ty);
212212
}
213213
pub fn write_substs_to_tcx(tcx: ty::ctxt,
214214
node_id: ast::node_id,
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// error-pattern: mismatched types
2+
3+
struct S { a: int }
4+
enum E { C(int) }
5+
6+
fn main() {
7+
match S { a: 1 } {
8+
C(_) => (),
9+
_ => ()
10+
}
11+
}

branches/auto/src/test/run-pass/vec-position.rs renamed to branches/auto/src/test/run-pass/issue-4875.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,15 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// regression test for issue 4875
12+
13+
pub struct Foo<T> {
14+
data: T,
15+
}
16+
17+
fn foo<T>(Foo{_}: Foo<T>) {
18+
}
19+
1120
pub fn main() {
12-
let mut v = ~[1, 2, 3];
13-
assert v.position(|x| *x == 1) == Some(0);
14-
assert v.position(|x| *x == 3) == Some(2);
15-
assert v.position(|x| *x == 17) == None;
1621
}
22+
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Issue #5041 - avoid overlapping memcpy when src and dest of a swap are the same
12+
13+
pub fn main() {
14+
let mut test = TestDescAndFn {
15+
desc: TestDesc {
16+
name: DynTestName(~"test"),
17+
should_fail: false
18+
},
19+
testfn: DynTestFn(|| ()),
20+
};
21+
do_swap(&mut test);
22+
}
23+
24+
fn do_swap(test: &mut TestDescAndFn) {
25+
*test <-> *test;
26+
}
27+
28+
pub enum TestName {
29+
DynTestName(~str)
30+
}
31+
32+
pub enum TestFn {
33+
DynTestFn(~fn()),
34+
DynBenchFn(~fn(&mut int))
35+
}
36+
37+
pub struct TestDesc {
38+
name: TestName,
39+
should_fail: bool
40+
}
41+
42+
pub struct TestDescAndFn {
43+
desc: TestDesc,
44+
testfn: TestFn,
45+
}

0 commit comments

Comments
 (0)