about summary refs log tree commit diff
path: root/src/librustc/middle/trans/expr.rs
AgeCommit message (Collapse)AuthorLines
2014-11-18Move trans, back, driver, and back into a new crate, rustc_trans. Reduces ↵Niko Matsakis-2248/+0
memory usage significantly and opens opportunities for more parallel compilation.
2014-11-17Switch to purely namespaced enumsSteven Fackler-0/+4
This breaks code that referred to variant names in the same namespace as their enum. Reexport the variants in the old location or alter code to refer to the new locations: ``` pub enum Foo { A, B } fn main() { let a = A; } ``` => ``` pub use self::Foo::{A, B}; pub enum Foo { A, B } fn main() { let a = A; } ``` or ``` pub enum Foo { A, B } fn main() { let a = Foo::A; } ``` [breaking-change]
2014-11-17auto merge of #19027 : nick29581/rust/coercions-4, r=alexcrichtonbors-7/+7
The forwards compatible parts of #18645, rebased. Converts implicit coercions from `[T, ..n]` to `&[T]` into explicit references.
2014-11-17Fix fallout from coercion removalNick Cameron-7/+7
2014-11-16fallout from deprecating find_copy and get_copyAlexis Beingessner-2/+2
2014-11-07Make TyTrait embed a `TraitRef`, so that when we extend TraitRef, it ↵Niko Matsakis-3/+3
naturally carries over to object types. I wanted to embed an `Rc<TraitRef>`, but I was foiled by the current static rules, which prohibit non-Sync values from being stored in static locations. This means that the constants for `ty_int` and so forth cannot be initialized.
2014-11-06rollup merge of #18615 : huonw/simdAlex Crichton-8/+29
2014-11-06Fallout from collection conventionsAlexis Beingessner-7/+7
2014-11-05Translate SIMD construction as `insertelement`s and a single store.Huon Wilson-8/+29
This almost completely avoids GEPi's and pointer manipulation, postponing it until the end with one big write of the whole vector. This leads to a small speed-up in compilation, and makes it easier for LLVM to work with the values, e.g. with `--opt-level=0`, pub fn foo() -> f32x4 { f32x4(0.,0.,0.,0.) } was previously compiled to define <4 x float> @_ZN3foo20h74913e8b13d89666eaaE() unnamed_addr #0 { entry-block: %sret_slot = alloca <4 x float> %0 = getelementptr inbounds <4 x float>* %sret_slot, i32 0, i32 0 store float 0.000000e+00, float* %0 %1 = getelementptr inbounds <4 x float>* %sret_slot, i32 0, i32 1 store float 0.000000e+00, float* %1 %2 = getelementptr inbounds <4 x float>* %sret_slot, i32 0, i32 2 store float 0.000000e+00, float* %2 %3 = getelementptr inbounds <4 x float>* %sret_slot, i32 0, i32 3 store float 0.000000e+00, float* %3 %4 = load <4 x float>* %sret_slot ret <4 x float> %4 } but now becomes define <4 x float> @_ZN3foo20h74913e8b13d89666eaaE() unnamed_addr #0 { entry-block: ret <4 x float> zeroinitializer }
2014-11-03rollup merge of #18505 : bkoropoff/issue-18487Alex Crichton-13/+19
2014-10-31Fix trans of index overload expressions with DST result typesBrian Koropoff-13/+19
Closes #18487
2014-11-01Remove FnStyle from DefFn and DefStaticMethodNick Cameron-3/+3
2014-10-30rollup merge of #18445 : alexcrichton/index-mutAlex Crichton-1/+1
Conflicts: src/libcollections/vec.rs
2014-10-30rollup merge of #18413 : bkoropoff/issue-18412Alex Crichton-3/+5
2014-10-30collections: Enable IndexMut for some collectionsAlex Crichton-1/+1
This commit enables implementations of IndexMut for a number of collections, including Vec, RingBuf, SmallIntMap, TrieMap, TreeMap, and HashMap. At the same time this deprecates the `get_mut` methods on vectors in favor of using the indexing notation. cc #18424
2014-10-29Rename fail! to panic!Steve Klabnik-2/+2
https://github.com/rust-lang/rfcs/pull/221 The current terminology of "task failure" often causes problems when writing or speaking about code. You often want to talk about the possibility of an operation that returns a Result "failing", but cannot because of the ambiguity with task failure. Instead, you have to speak of "the failing case" or "when the operation does not succeed" or other circumlocutions. Likewise, we use a "Failure" header in rustdoc to describe when operations may fail the task, but it would often be helpful to separate out a section describing the "Err-producing" case. We have been steadily moving away from task failure and toward Result as an error-handling mechanism, so we should optimize our terminology accordingly: Result-producing functions should be easy to describe. To update your code, rename any call to `fail!` to `panic!` instead. Assuming you have not created your own macro named `panic!`, this will work on UNIX based systems: grep -lZR 'fail!' . | xargs -0 -l sed -i -e 's/fail!/panic!/g' You can of course also do this by hand. [breaking-change]
2014-10-28Fix ICE assigning methods to local variablesBrian Koropoff-3/+5
This just adds some missing match cases in ty and trans Closes #18412
2014-10-28Remove ty_bot from the type systemJakub Bukaj-8/+5
We now instead use a fresh variable for expressions that diverge.
2014-10-27rollup merge of #18332 : jbcrail/fix-commentsAlex Crichton-2/+2
2014-10-27rollup merge of #18250 : dotdash/fix_aliasingAlex Crichton-2/+2
2014-10-25Fix spelling mistakes in comments.Joseph Crail-2/+2
2014-10-24Add a lint for not using field pattern shorthandsP1start-1/+1
Closes #17792.
2014-10-23Fix codegen breaking aliasing rules for functions with sret resultsBjörn Steinbrink-2/+2
This reverts commit a0ec902e239b2219edf1a18b036dd32c18d3be42 "Avoid unnecessary temporary on assignments". Leaving out the temporary for the functions return value can lead to a situation that conflicts with rust's aliasing rules. Given this: ````rust fn func(f: &mut Foo) -> Foo { /* ... */ } fn bar() { let mut foo = Foo { /* ... */ }; foo = func(&mut foo); } ```` We effectively get two mutable references to the same variable `foo` at the same time. One for the parameter `f`, and one for the hidden out-pointer. So we can't just `trans_into` the destination directly, but must use `trans` to get a new temporary slot from which the result can be copied.
2014-10-22Part of #6993. Moved a bunch of uses of Ident to NameJonathan S-1/+1
2014-10-19Remove a large amount of deprecated functionalityAlex Crichton-7/+6
Spring cleaning is here! In the Fall! This commit removes quite a large amount of deprecated functionality from the standard libraries. I tried to ensure that only old deprecated functionality was removed. This is removing lots and lots of deprecated features, so this is a breaking change. Please consult the deprecation messages of the deleted code to see how to migrate code forward if it still needs migration. [breaking-change]
2014-10-18auto merge of #18041 : arielb1/rust/no-size-overflow, r=pnkfelixbors-1/+1
Should fix #17913. Also clean-up u64/u32-ness. I really should split this commit and add tests (I have no idea how to add them).
2014-10-16librustc: Remove all uses of {:?}.Luqman Aden-12/+12
2014-10-15Use the correct LLVM integer sizesAriel Ben-Yehuda-1/+1
Use the integer sizes LLVM uses, rather than having random projections laying around. Sizes are u64, Alignments are u32, C_*int is target-dependent but 64-bit is fine (the int -> C_int conversion is non-precision-losing, but it can be preceded by `as int` conversions which are, so it is somewhat ugly. However, being able to suffix a `u` to properly infer integer types is nice).
2014-10-09rustc: Add `const` globals to the languageAlex Crichton-38/+37
This change is an implementation of [RFC 69][rfc] which adds a third kind of global to the language, `const`. This global is most similar to what the old `static` was, and if you're unsure about what to use then you should use a `const`. The semantics of these three kinds of globals are: * A `const` does not represent a memory location, but only a value. Constants are translated as rvalues, which means that their values are directly inlined at usage location (similar to a #define in C/C++). Constant values are, well, constant, and can not be modified. Any "modification" is actually a modification to a local value on the stack rather than the actual constant itself. Almost all values are allowed inside constants, whether they have interior mutability or not. There are a few minor restrictions listed in the RFC, but they should in general not come up too often. * A `static` now always represents a memory location (unconditionally). Any references to the same `static` are actually a reference to the same memory location. Only values whose types ascribe to `Sync` are allowed in a `static`. This restriction is in place because many threads may access a `static` concurrently. Lifting this restriction (and allowing unsafe access) is a future extension not implemented at this time. * A `static mut` continues to always represent a memory location. All references to a `static mut` continue to be `unsafe`. This is a large breaking change, and many programs will need to be updated accordingly. A summary of the breaking changes is: * Statics may no longer be used in patterns. Statics now always represent a memory location, which can sometimes be modified. To fix code, repurpose the matched-on-`static` to a `const`. static FOO: uint = 4; match n { FOO => { /* ... */ } _ => { /* ... */ } } change this code to: const FOO: uint = 4; match n { FOO => { /* ... */ } _ => { /* ... */ } } * Statics may no longer refer to other statics by value. Due to statics being able to change at runtime, allowing them to reference one another could possibly lead to confusing semantics. If you are in this situation, use a constant initializer instead. Note, however, that statics may reference other statics by address, however. * Statics may no longer be used in constant expressions, such as array lengths. This is due to the same restrictions as listed above. Use a `const` instead. [breaking-change] [rfc]: https://github.com/rust-lang/rfcs/pull/246
2014-10-02rustc: remove support for Gc.Eduard Burtescu-39/+2
2014-10-02syntax: ast: remove TyBox and UnBox.Eduard Burtescu-3/+0
2014-10-01auto merge of #17653 : kaini/rust/master, r=alexcrichtonbors-1/+1
Fixes that unit-like structs cannot be used if they are re-exported and used in another crate. (ICE) The relevant changes are in `rustc::metadata::{decoder, encoder}` and `rustc::middle::ty`. A test case is included. The problem is that the expressoin `UnitStruct` is an `ExprPath` to an `DefFn`, which is of expr kind `RvalueDatumExpr`, but for unit-struct ctors the expr kind should be `RvalueDpsExpr`. I fixed this (in a I guess clean way) by introducing `CtorFn` in the metadata and including a `is_ctor` flag in `DefFn`.
2014-09-30Produce a better error for irrefutable `if let` patternsKevin Ballard-1/+1
Modify ast::ExprMatch to include a new value of type ast::MatchSource, making it easy to tell whether the match was written literally or produced via desugaring. This allows us to customize error messages appropriately.
2014-09-30Fixes ICE when using reexported unit-like structsMichael Kainer-1/+1
Fixes that unit-like structs cannot be used if they are reexported and used in another crate. The compiler fails with an ICE, because unit-like structs are exported as DefFn and the expression `UnitStruct` is interpreted as function pointer instead of a call to the constructor. To resolve this ambiguity tuple-like struct constructors are now exported as CtorFn. When `rustc::metadata::decoder` finds a CtorFn it sets a new flag `is_ctor` in DefFn to true. Relevant changes are in `rustc::metadata::{encoder, decoder}` and in `rustc::middle::ty`. Closes #12660 and #16973.
2014-09-25debuginfo: Make sure that all calls to drop glue are associated with debug ↵Michael Woerister-13/+57
locations. This commit makes rustc emit debug locations for all call and invoke statements in LLVM IR, if they are contained within a function that debuginfo is enabled for. This is important because LLVM does not handle the case where a function body containing debuginfo is inlined into another function with debuginfo, but the inlined call statement does not have a debug location. In this case, LLVM will not know where (in terms of source code coordinates) the function was inlined to and we end up with some statements still linked to the source locations in there original, non-inlined function without any indication that they are indeed an inline-copy. Later, when generating DWARF from the IR, LLVM will interpret this as corrupt IR and abort. Unfortunately, the undesirable case described above can still occur when using LTO. If there is a crate compiled without debuginfo calling into a crate compiled with debuginfo, we again end up with the conditions triggering the error. This is why some LTO tests still fail with the dreaded assertion, if the standard library was built with debuginfo enabled. That is, `RUSTFLAGS_STAGE2=-g make rustc-stage2` will succeed but `RUSTFLAGS_STAGE2=-g make check` will still fail after this commit has been merged. This is a problem that has to be dealt with separately. Fixes #17201 Fixes #15816 Fixes #15156
2014-09-19rollup merge of #17338 : nick29581/variants-namespaceAlex Crichton-3/+3
2014-09-19rollup merge of #17318 : nick29581/sliceAlex Crichton-6/+34
2014-09-19Add enum variants to the type namespaceNick Cameron-3/+3
Change to resolve and update compiler and libs for uses. [breaking-change] Enum variants are now in both the value and type namespaces. This means that if you have a variant with the same name as a type in scope in a module, you will get a name clash and thus an error. The solution is to either rename the type or the variant.
2014-09-19Implement slicing syntax.Nick Cameron-6/+34
`expr[]`, `expr[expr..]`, `expr[..expr]`,`expr[expr..expr]` Uses the Slice and SliceMut traits. Allows ... as well as .. in range patterns.
2014-09-18rustc: remove Gc<Def> and depth from DefUpvar.Eduard Burtescu-1/+1
2014-09-18rustc: add a closure depth to DefUpvar.Eduard Burtescu-1/+1
2014-09-18rustc: remove BindingMode from DefLocal.Eduard Burtescu-1/+1
2014-09-18rustc: remove DefArg and DefBinding in favor of DefLocal.Eduard Burtescu-24/+13
2014-09-16Run cleanup for base struct in functional struct update expressionsJakub Wieczorek-6/+6
Fixes #17302.
2014-09-15trans -- stop tracking vtables precisely, instead recompute as needed.Niko Matsakis-3/+21
2014-09-14rustc: fix fallout from using ptr::P.Eduard Burtescu-35/+34
2014-09-12remove dead and broken tvec ~[T] code pathDaniel Micay-19/+1
`Box<[T]>` is created by allocating `Box<[T, ..n]>` and coercing it so this code path is never used. It's also broken because it clamps the capacity of the memory allocations to 4 elements and that's incompatible with sized deallocation. This dates back to when `~[T]` was a growable vector type implemented as: *{ { tydesc, ref_count, prev, next }, { length, capacity, data[] } } Since even empty vectors had to allocate, it started off the capacity of all vectors at 4 as a heuristic. It's not possible to grow `Box<[T]>` and there is no need for a memory allocation when it's empty, so it would be a terrible heuristic today even if it worked.
2014-09-11auto merge of #17110 : thestinger/rust/dst, r=cmrbors-23/+5
The pointer in the slice must not be null, because enum representations make that assumption. The `exchange_malloc` function returns a non-null sentinel for the zero size case, and it must not be passed to the `exchange_free` lang item. Since the length is always equal to the true capacity, a branch on the length is enough for most types. Slices of zero size types are statically special cased to never attempt deallocation. This is the same implementation as `Vec<T>`. Closes #14395
2014-09-10Implement tuple and tuple struct indexingP1start-8/+30
This allows code to access the fields of tuples and tuple structs: let x = (1i, 2i); assert_eq!(x.1, 2); struct Point(int, int); let origin = Point(0, 0); assert_eq!(origin.0, 0); assert_eq!(origin.1, 0);
2014-09-09fixes for Box<[T]>Daniel Micay-23/+5
The pointer in the slice must not be null, because enum representations make that assumption. The `exchange_malloc` function returns a non-null sentinel for the zero size case, and it must not be passed to the `exchange_free` lang item. Since the length is always equal to the true capacity, a branch on the length is enough for most types. Slices of zero size types are statically special cased to never attempt deallocation. This is the same implementation as `Vec<T>`. Closes #14395