about summary refs log tree commit diff
path: root/src/librustc/metadata
AgeCommit message (Collapse)AuthorLines
2014-10-09rustc: Add `const` globals to the languageAlex Crichton-11/+18
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-07Use slice syntax instead of slice_to, etc.Nick Cameron-5/+5
2014-10-03Set the `non_uppercase_statics` lint to warn by defaultP1start-1/+2
2014-10-02rollup merge of #17666 : eddyb/take-garbage-outAlex Crichton-2/+0
Conflicts: src/libcollections/lib.rs src/libcore/lib.rs src/librustdoc/lib.rs src/librustrt/lib.rs src/libserialize/lib.rs src/libstd/lib.rs src/test/run-pass/issue-8898.rs
2014-10-02Revert "Use slice syntax instead of slice_to, etc."Aaron Turon-5/+5
This reverts commit 40b9f5ded50ac4ce8c9323921ec556ad611af6b7.
2014-10-02rustc: remove support for Gc.Eduard Burtescu-2/+0
2014-10-02Use slice syntax instead of slice_to, etc.Nick Cameron-5/+5
2014-10-01auto merge of #17654 : gereeter/rust/no-unnecessary-cell, r=alexcrichtonbors-1/+1
There is more that could be done, but this was the low hanging fruit.
2014-10-01auto merge of #17653 : kaini/rust/master, r=alexcrichtonbors-3/+6
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-30Fixes ICE when using reexported unit-like structsMichael Kainer-3/+6
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-30librustc: Stop looking in metadata in type contents.Patrick Walton-0/+35
4x improvement in pre-trans compile time for rustc.
2014-09-30Removed some unnecessary RefCells from resolveJonathan S-1/+1
2014-09-25auto merge of #17378 : Gankro/rust/hashmap-entry, r=aturonbors-4/+12
Deprecates the `find_or_*` family of "internal mutation" methods on `HashMap` in favour of the "external mutation" Entry API as part of RFC 60. Part of #17320, but this still needs to be done on the rest of the maps. However they don't have any internal mutation methods defined, so they can be done without deprecating or breaking anything. Work on `BTree` is part of the complete rewrite in #17334. The implemented API deviates from the API described in the RFC in two key places: * `VacantEntry.set` yields a mutable reference to the inserted element to avoid code duplication where complex logic needs to be done *regardless* of whether the entry was vacant or not. * `OccupiedEntry.into_mut` was added so that it is possible to return a reference into the map beyond the lifetime of the Entry itself, providing functional parity to `VacantEntry.set`. This allows the full find_or_insert functionality to be implemented using this API. A PR will be submitted to the RFC to amend this. [breaking-change]
2014-09-24handling fallout from entry apiAlexis Beingessner-4/+12
2014-09-20Move bundled gcc and its libs out into $rust/rustlib/<triple>/gcc/(bin|lib). ↵Vadim Chugunov-2/+6
This way the libs won't be on the -L library search path, and won't confuse external gcc, if one is used. The bundled gcc itself will still be able to find them, because it searches for libs relative to own install location.
2014-09-17librustc: Implement associated types behind a feature gate.Patrick Walton-35/+175
The implementation essentially desugars during type collection and AST type conversion time into the parameter scheme we have now. Only fully qualified names--e.g. `<T as Foo>::Bar`--are supported.
2014-09-17rollup merge of #17310 : ↵Alex Crichton-3/+3
nikomatsakis/type-bounds-generalize-to-multiple-object-bounds
2014-09-17rustdoc: Correctly distinguish enums and typesP1start-2/+2
This is done by adding a new field to the `DefTy` variant of `middle::def::Def`, which also clarifies an error message in the process. Closes #16712.
2014-09-16Fallout from renamingAaron Turon-12/+12
2014-09-16Generalize lifetime bounds on type parameters to support multipleNiko Matsakis-3/+3
lifetime bounds. This doesn't really cause any difficulties, because we already had to accommodate the fact that multiple implicit bounds could accumulate. Object types still require precisely one lifetime bound. This is a pre-step towards generalized where clauses (once you have lifetime bounds in where clauses, it is harder to restrict them to exactly one).
2014-09-15trans -- stop tracking vtables precisely, instead recompute as needed.Niko Matsakis-15/+16
2014-09-14auto merge of #17163 : pcwalton/rust/impls-next-to-struct, r=alexcrichtonbors-2/+4
type they provide an implementation for. This breaks code like: mod foo { struct Foo { ... } } impl foo::Foo { ... } Change this code to: mod foo { struct Foo { ... } impl Foo { ... } } Closes #17059. RFC #155. [breaking-change] r? @brson
2014-09-14auto merge of #13316 : eddyb/rust/ast-ptr, r=brsonbors-92/+59
Replaces Gc<T> in the AST with a custom owned smart pointer, P<T>. Fixes #7929. ## Benefits * **Identity** (affinity?): sharing AST nodes is bad for the various analysis passes (e.g. one could bypass borrowck with a shared `ExprAddrOf` node taking a mutable borrow), the only reason we haven't hit any serious issues with it is because of inefficient folding passes which will always deduplicate any such shared nodes. Even if we were to switch to an arena, this would still hold, i.e. we wouldn't just use `&'a T` in the AST, but rather an wrapper (`P<'a, T>`?). * **Immutability**: `P<T>` disallows mutating its inner `T` (unless that contains an `Unsafe` interior, which won't happen in the AST), unlike `~T`. * **Efficiency**: folding can reuse allocation space for `P<T>` and `Vec<T>`, the latter even when the input and output types differ (as it would be the case with arenas or an AST with type parameters to toggle macro support). Also, various algorithms have been changed from copying `Gc<T>` to using `&T` and iterators. * **Maintainability**: there is another reason I didn't just replace `Gc<T>` with `~T`: `P<T>` provides a fixed interface (`Deref`, `and_then` and `map`) which can remain fully functional even if the implementation changes (using a special thread-local heap, for example). Moreover, switching to, e.g. `P<'a, T>` (for a contextual arena) is easy and mostly automated.
2014-09-14rustc: fix fallout from using ptr::P.Eduard Burtescu-92/+59
2014-09-14auto merge of #17189 : bkoropoff/rust/extern-existing-crate, r=alexcrichtonbors-2/+2
When checking for an existing crate, compare against the `crate_metadata::name` field, which is the crate name which was requested during resolution, rather than the result of the `crate_metadata::name()` method, which is the crate name within the crate metadata, as these may not match when using the --extern option to `rustc`. This fixes spurious "multiple crate version" warnings under the following scenario: - The crate `foo`, is referenced multiple times - `--extern foo=./path/to/libbar.rlib` is specified to rustc - The internal crate name of `libbar.rlib` is not `foo` The behavior surrounding `Context::should_match_name` and the comments in `loader.rs` both lead me to believe that this scenario is intended to work. Fixes #17186
2014-09-13librustc: Forbid inherent implementations that aren't adjacent to thePatrick Walton-2/+4
type they provide an implementation for. This breaks code like: mod foo { struct Foo { ... } } impl foo::Foo { ... } Change this code to: mod foo { struct Foo { ... } impl Foo { ... } } Additionally, if you used the I/O path extension methods `stat`, `lstat`, `exists`, `is_file`, or `is_dir`, note that these methods have been moved to the the `std::io::fs::PathExtensions` trait. This breaks code like: fn is_it_there() -> bool { Path::new("/foo/bar/baz").exists() } Change this code to: use std::io::fs::PathExtensions; fn is_it_there() -> bool { Path::new("/foo/bar/baz").exists() } Closes #17059. RFC #155. [breaking-change]
2014-09-12Track the visited AST's lifetime throughout Visitor.Eduard Burtescu-4/+4
2014-09-12Remove largely unused context from Visitor.Eduard Burtescu-21/+21
2014-09-11Fix check for existing crate when using --externBrian Koropoff-1/+1
When checking for an existing crate, compare against the `crate_metadata::name` field, which is the crate name which was requested during resolution, rather than the result of the `crate_metadata::name()` method, which is the crate name within the crate metadata, as these may not match when using the --extern option to `rustc`. This fixes spurious "multiple crate version" warnings under the following scenario: - The crate `foo`, is referenced multiple times - `--extern foo=./path/to/libbar.rlib` is specified to rustc - The internal crate name of `libbar.rlib` is not `foo` The behavior surrounding `Context::should_match_name` and the comments in `loader.rs` both lead me to believe that this scenario is intended to work. Fixes #17186
2014-09-11Make debug message about resolving `extern crate` statements more helpfulBrian Koropoff-1/+1
2014-09-11Append target-specific tools directory ($(RUST)/bin/rustlib/<triple>/bin/) ↵Vadim Chugunov-4/+16
to PATH during linking, so that rustc can invoke them.
2014-09-08rustc: fix fallout from the addition of a 'tcx lifetime on tcx.Eduard Burtescu-13/+14
2014-09-07Changed addl_lib_search_paths from HashSet to Vecinrustwetrust-2/+2
This makes the extra library paths given to the gcc linker come in the same order as the -L options on the rustc command line.
2014-09-05reuse original symbols for inlined itemsStuart Pernsteiner-4/+5
When inlining an item from another crate, use the original symbol from that crate's metadata instead of generating a new symbol using the `ast::NodeId` of the inlined copy. This requires exporting symbols in the crate metadata in a few additional cases. Having predictable symbols for inlined items will be useful later to avoid generating duplicate object code for inlined items.
2014-08-27Implement generalized object and type parameter bounds (Fixes #16462)Niko Matsakis-174/+276
2014-08-26DST coercions and DST structsNick Cameron-4/+7
[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-25auto merge of #16740 : alexcrichton/rust/issue-16725, r=pcwaltonbors-0/+1
Closes #16725
2014-08-25rustc: Encode the visibility of foreign itemsAlex Crichton-0/+1
The privacy pass of the compiler was previously not taking into account the privacy of foreign items, or bindings to external functions. This commit fixes this oversight by encoding the visibility of foreign items into the metadata for each crate. Any code relying on this will start to fail to compile and the bindings must be marked with `pub` to indicate that they can be used externally. Closes #16725 [breaking-change]
2014-08-24Adjust the error messages to match the pattern "expected foo, found bar"Jonas Hietala-2/+2
Closes #8492
2014-08-18libsyntax: Remove the `use foo = bar` syntax from the language in favorPatrick Walton-1/+1
of `use bar as foo`. Change all uses of `use foo = bar` to `use bar as foo`. Implements RFC #47. Closes #16461. [breaking-change]
2014-08-16librustc: Forbid external crates, imports, and/or items from beingPatrick Walton-1/+0
declared with the same name in the same scope. This breaks several common patterns. First are unused imports: use foo::bar; use baz::bar; Change this code to the following: use baz::bar; Second, this patch breaks globs that import names that are shadowed by subsequent imports. For example: use foo::*; // including `bar` use baz::bar; Change this code to remove the glob: use foo::{boo, quux}; use baz::bar; Or qualify all uses of `bar`: use foo::{boo, quux}; use baz; ... baz::bar ... Finally, this patch breaks code that, at top level, explicitly imports `std` and doesn't disable the prelude. extern crate std; Because the prelude imports `std` implicitly, there is no need to explicitly import it; just remove such directives. The old behavior can be opted into via the `import_shadowing` feature gate. Use of this feature gate is discouraged. This implements RFC #116. Closes #16464. [breaking-change]
2014-08-16auto merge of #16505 : dotdash/rust/extern_realpath, r=alexcrichtonbors-3/+4
Crates that are resolved normally have their path canonicalized and all symlinks resolved. This does currently not happen for paths specified using the --extern option to rustc, which can lead to rustc thinking that it encountered two different versions of a crate, when it's actually the same version found through different paths. Fixes #16496
2014-08-15Properly canonicalize crate paths specified via --externBjörn Steinbrink-3/+4
Crates that are resolved normally have their path canonicalized and all symlinks resolved. This does currently not happen for paths specified using the --extern option to rustc, which can lead to rustc thinking that it encountered two different versions of a crate, when it's actually the same version found through different paths. To fix this, we must store the canonical path for crates found via --extern and also use the canonical path when comparing paths. Fixes #16496
2014-08-15auto merge of #16435 : vadimcn/rust/windows, r=pcwaltonbors-3/+3
Using "win32" to mean "Windows" is confusing, especially now, that Rust supports win64 builds. Let's call spade a spade.
2014-08-14librustc: Stop assuming that implementations and traits only containPatrick Walton-195/+311
methods. This paves the way to associated items by introducing an extra level of abstraction ("impl-or-trait item") between traits/implementations and methods. This new abstraction is encoded in the metadata and used throughout the compiler where appropriate. There are no functional changes; this is purely a refactoring.
2014-08-14librustc: Tie up loose ends in unboxed closures.Patrick Walton-10/+29
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-13librustc: Parse, but do not fully turn on, the `ref` keyword forPatrick Walton-1/+2
by-reference upvars. This partially implements RFC 38. A snapshot will be needed to turn this on, because stage0 cannot yet parse the keyword. Part of #12381.
2014-08-12Replace all references to "Win32" with "Windows".Vadim Chugunov-3/+3
For historical reasons, "Win32" has been used in Rust codebase to mean "Windows OS in general". This is confusing, especially now, that Rust supports Win64 builds. [breaking-change]
2014-08-09librustc: Encode upvar_borrow_map in metadata.Luqman Aden-1/+2
2014-08-08auto merge of #16285 : alexcrichton/rust/rename-share, r=huonwbors-2/+2
This leaves the `Share` trait at `std::kinds` via a `#[deprecated]` `pub use` statement, but the `NoShare` struct is no longer part of `std::kinds::marker` due to #12660 (the build cannot bootstrap otherwise). All code referencing the `Share` trait should now reference the `Sync` trait, and all code referencing the `NoShare` type should now reference the `NoSync` type. The functionality and meaning of this trait have not changed, only the naming. Closes #16281 [breaking-change]