Commit Graph

142 Commits

Author SHA1 Message Date
Stuart Pernsteiner
cf35cb365a make CrateContext fields private 2014-09-05 09:18:53 -07:00
bors
5924937a5a auto merge of #16883 : jakub-/rust/issue-16648, r=pcwalton
They were only correct in the simplest case. Some of the optimisations
are certainly possible but should be introduced carefully and only
when the whole pattern codegen infrastructure is in a better shape.

Fixes #16648.
2014-09-04 06:41:04 +00:00
Nick Cameron
52d6d3be48 DST raw pointers - *-pointers are fat pointers 2014-09-02 10:05:00 +12:00
Jakub Wieczorek
6f35ede5a4 Remove the branch merging optimisations for slice patterns
They were only correct in the simplest case. Some of the optimisations
are certainly possible but should be introduced carefully and only
when the whole pattern codegen infrastructure is in a better shape.

Fixes #16648.
2014-08-30 19:50:46 +02:00
Nick Cameron
52ef46251e Rebasing changes 2014-08-26 16:07:32 +12:00
Nick Cameron
3e626375d8 DST coercions and DST structs
[breaking-change]

1. The internal layout for traits has changed from (vtable, data) to (data, vtable). If you were relying on this in unsafe transmutes, you might get some very weird and apparently unrelated errors. You should not be doing this! Prefer not to do this at all, but if you must, you should use raw::TraitObject rather than hardcoding rustc's internal representation into your code.

2. The minimal type of reference-to-vec-literals (e.g., `&[1, 2, 3]`) is now a fixed size vec (e.g., `&[int, ..3]`) where it used to be an unsized vec (e.g., `&[int]`). If you want the unszied type, you must explicitly give the type (e.g., `let x: &[_] = &[1, 2, 3]`). Note in particular where multiple blocks must have the same type (e.g., if and else clauses, vec elements), the compiler will not coerce to the unsized type without a hint. E.g., `[&[1], &[1, 2]]` used to be a valid expression of type '[&[int]]'. It no longer type checks since the first element now has type `&[int, ..1]` and the second has type &[int, ..2]` which are incompatible.

3. The type of blocks (including functions) must be coercible to the expected type (used to be a subtype). Mostly this makes things more flexible and not less (in particular, in the case of coercing function bodies to the return type). However, in some rare cases, this is less flexible. TBH, I'm not exactly sure of the exact effects. I think the change causes us to resolve inferred type variables slightly earlier which might make us slightly more restrictive. Possibly it only affects blocks with unreachable code. E.g., `if ... { fail!(); "Hello" }` used to type check, it no longer does. The fix is to add a semicolon after the string.
2014-08-26 12:38:51 +12:00
Nick Cameron
34d607f9c9 Use the slice repr for ~[T] 2014-08-26 12:37:45 +12:00
Vadim Chugunov
68811817f7 Complete renaming of win32 to windows 2014-08-23 02:11:28 -07:00
Corey Richardson
6e8ff99958 librustc: handle repr on structs, require it for ffi, unify with packed
As of RFC 18, struct layout is undefined. Opting into a C-compatible struct
layout is now down with #[repr(C)]. For consistency, specifying a packed
layout is now also down with #[repr(packed)]. Both can be specified.

To fix errors caused by this, just add #[repr(C)] to the structs, and change
 #[packed] to #[repr(packed)]

Closes #14309

[breaking-change]
2014-08-20 21:02:23 -04:00
Patrick Walton
8d27232141 librustc: Tie up loose ends in unboxed closures.
This patch primarily does two things: (1) it prevents lifetimes from
leaking out of unboxed closures; (2) it allows unboxed closure type
notation, call notation, and construction notation to construct closures
matching any of the three traits.

This breaks code that looked like:

    let mut f;
    {
        let x = &5i;
        f = |&mut:| *x + 10;
    }

Change this code to avoid having a reference escape. For example:

    {
        let x = &5i;
        let mut f; // <-- move here to avoid dangling reference
        f = |&mut:| *x + 10;
    }

I believe this is enough to consider unboxed closures essentially
implemented. Further issues (for example, higher-rank lifetimes) should
be filed as followups.

Closes #14449.

[breaking-change]
2014-08-14 08:53:25 -07:00
Jakub Wieczorek
59edfdd2ab Add Drop support for enums
Fixes #13041.
2014-07-22 23:45:49 +02:00
Luqman Aden
ad27e2625a librustc: Set enum discriminant only after field translation. 2014-07-18 11:58:45 -07:00
Patrick Walton
02adaca4dc librustc: Implement unboxed closures with mutable receivers 2014-07-18 09:01:37 -07:00
Brian Anderson
3096d9bf94 rustc_llvm: Remove the inner llvm module
This makes it much saner for clients to use the library since
they don't have to worry about shadowing one llvm with another.
2014-07-14 12:27:08 -07:00
Richo Healey
12c334a77b std: Rename the ToStr trait to ToString, and to_str to to_string.
[breaking-change]
2014-07-08 13:01:43 -07:00
bors
a3257804df auto merge of #15406 : luqmana/rust/nop, r=pcwalton
Extend the null ptr optimization to work with slices, closures, procs, & trait objects by using the internal pointers as the discriminant.

This decreases the size of `Option<&[int]>` (and similar) by one word.
2014-07-08 00:31:42 +00:00
Björn Steinbrink
dd4112bf79 Store booleans as i8 in memory to improve optimizations by LLVM
LLVM doesn't really like types with a bit-width that isn't a multiple of
8 and disable various optimizations if it encounters such types used
with loads/stores. OTOH, booleans must be represented as i1 when used as
SSA values. To get the best results, we must use i1 for SSA values, and
i8 when storing the value to memory.

By using range asserts on loads, LLVM can eliminate the required
zero-extend and truncate operations.

Fixes #15203
2014-07-06 22:12:10 +02:00
Björn Steinbrink
d2a22f520c Remove remainders from when booleans were i8 2014-07-06 22:12:00 +02:00
Luqman Aden
7cce75f839 librustc: Apply null pointer optimization to slices, closures and trait
objects.
2014-07-04 01:33:33 -07:00
Niko Matsakis
9e3d0b002a librustc: Remove the fallback to int from typechecking.
This breaks a fair amount of code. The typical patterns are:

* `for _ in range(0, 10)`: change to `for _ in range(0u, 10)`;

* `println!("{}", 3)`: change to `println!("{}", 3i)`;

* `[1, 2, 3].len()`: change to `[1i, 2, 3].len()`.

RFC #30. Closes #6023.

[breaking-change]
2014-06-24 17:18:48 -07:00
bors
82ec1aef29 auto merge of #14963 : w3ln4/rust/master, r=alexcrichton
The aim of these changes is not working out a generic bi-endianness architectures support but to allow people develop for little endian MIPS machines (issue #7190).
2014-06-24 13:46:54 +00:00
Pawel Olzacki
34a384a128 Added Mipsel architecture support 2014-06-24 11:12:10 +02:00
Brendan Zabarauskas
ff9f92ce52 Merge the Bitwise and ByteOrder traits into the Int trait
This reduces the complexity of the trait hierarchy.
2014-06-18 17:01:34 -07:00
Nick Cameron
8e7213f65b Remove TraitStore from ty_trait
Use ty_rptr/ty_uniq(ty_trait) rather than TraitStore to represent trait types.
Also addresses (but doesn't close) #12470.
Part of the work towards DST (#12938).

[breaking-change] lifetime parameters in `&mut trait` are now invariant. They used to be contravariant.
2014-06-18 10:30:33 +12:00
Joseph Crail
c2c9946372 Fix more misspelled comments and strings. 2014-06-10 11:24:17 -04:00
Brian Anderson
50942c7695 core: Rename container mod to collections. Closes #12543
Also renames the `Container` trait to `Collection`.

[breaking-change]
2014-06-08 21:29:57 -07:00
Niko Matsakis
f24a53757e Move subst data structures into subst.rs, fix capitalization 2014-06-06 19:46:38 -04:00
Patrick Walton
36195eb91f libstd: Remove ~str from all libstd modules except fmt and str. 2014-05-22 14:42:01 -07:00
Luqman Aden
28243a5c0e librustc: Separate NullablePointer into RawNullablePointer and StructWrappedNullablePointer. 2014-05-16 17:24:49 -04:00
Luqman Aden
d104dabae9 Make some NullablePointer enums FFI-compatible with the base pointer type. 2014-05-16 17:24:49 -04:00
Patrick Walton
090040bf40 librustc: Remove ~EXPR, ~TYPE, and ~PAT from the language, except
for `~str`/`~[]`.

Note that `~self` still remains, since I forgot to add support for
`Box<self>` before the snapshot.

How to update your code:

* Instead of `~EXPR`, you should write `box EXPR`.

* Instead of `~TYPE`, you should write `Box<Type>`.

* Instead of `~PATTERN`, you should write `box PATTERN`.

[breaking-change]
2014-05-06 23:12:54 -07:00
bors
fd625dda9a auto merge of #13271 : stepancheg/rust/align, r=pcwalton
This patch fixes issue #13186.

When generating constant expression for enum, it is possible that
alignment of expression may be not equal to alignment of type.  In that
case space after last struct field must be padded to match size of value
and size of struct. This commit adds that padding.

See detailed explanation in src/test/run-pass/trans-tag-static-padding.rs
2014-05-05 10:06:39 -07:00
Nick Cameron
5854811082 Refactor rslt to Result::new 2014-05-03 23:14:56 +12:00
Falco Hirschenberger
6c26cbb602 Add lint check for negating uint literals and variables.
See #11273 and #13318
2014-05-03 00:13:26 +02:00
Nick Cameron
f3c33893b6 Remove internal support for fixed length strings 2014-04-29 13:10:23 +12:00
Nick Cameron
c0ff3caae1 Refactor ty_str to use a ~(str) representation.
Similar to my recent changes to ~[T]/&[T], these changes remove the vstore abstraction and represent str types as ~(str) and &(str). The Option<uint> in ty_str is the length of the string, None if the string is dynamically sized.
2014-04-28 21:02:18 +12:00
Eduard Burtescu
938eaaa304 rustc: de-@ adt::Repr. 2014-04-22 19:20:12 +03:00
Eduard Burtescu
c709c1efc6 rustc: remove obsolete monomorphization modes. 2014-04-22 19:06:55 +03:00
Stepan Koltsov
7fefc1c7f4 Append missing padding after last field of struct
This patch fixes issue #13186.

When generating constant expression for enum, it is possible that
alignment of expression may be not equal to alignment of type.  In that
case space after last struct field must be padded to match size of value
and size of struct. This commit adds that padding.

See detailed explanation in src/test/run-pass/trans-tag-static-padding.rs
2014-04-12 18:56:34 +00:00
Corey Richardson
0459ee77d0 Fix fallout from std::libc separation 2014-04-04 09:31:44 -07:00
Corey Richardson
a9bf099000 middle: trans: adt: remove dead code 2014-04-02 11:17:21 -04:00
Alex Crichton
89fa141cd7 rustc: Switch field privacy as necessary 2014-03-31 15:47:36 -07:00
Daniel Micay
cbbc1fc843 vec: convert append and append_one to methods
These were only free functions on `~[T]` because taking self by-value
used to be broken.
2014-03-31 01:13:48 -04:00
Marvin Löbel
c356e3ba6a Removed deprecated functions map and flat_map for vectors and slices. 2014-03-30 03:47:04 +02:00
Alex Crichton
0dbb909bf7 rustc: Fix fallout of removing get() 2014-03-22 08:48:20 -07:00
Alex Crichton
da3625161d Removing imports of std::vec_ng::Vec
It's now in the prelude.
2014-03-20 09:30:14 -07:00
Daniel Micay
14f656d1a7 rename std::vec_ng -> std::vec
Closes #12771
2014-03-20 04:25:32 -04:00
Eduard Burtescu
0bb6de3076 De-@ move maps and rework parts of trans. 2014-03-17 09:53:08 +02:00
Eduard Burtescu
9b1fee898f De-@ ty::ctxt usage. 2014-03-17 09:53:06 +02:00
Eduard Burtescu
4fae06824c De-@ Session usage. 2014-03-17 09:53:06 +02:00