about summary refs log tree commit diff
path: root/src/librustc/util
AgeCommit message (Collapse)AuthorLines
2014-12-15Remove internal uses of `marker::NoCopy`Jorge Aparicio-6/+3
2014-12-14Rename FnStyle trait to Unsafety.Niko Matsakis-12/+12
2014-12-14Remove `proc` types/expressions from the parser, compiler, andNiko Matsakis-1/+8
language. Recommend `move||` instead.
2014-12-13librustc: use unboxed closuresJorge Aparicio-18/+28
2014-12-13librustc: fix falloutJorge Aparicio-1/+3
2014-12-12Switch to using predicates to drive checking. Correct various tests --Niko Matsakis-5/+5
in most cases, just the error message changed, but in some cases we are reporting new errors that OUGHT to have been reported before but we're overlooked (mostly involving the `'static` bound on `Send`).
2014-12-08librustc: Make `Copy` opt-in.Niko Matsakis-0/+5
This change makes the compiler no longer infer whether types (structures and enumerations) implement the `Copy` trait (and thus are implicitly copyable). Rather, you must implement `Copy` yourself via `impl Copy for MyType {}`. A new warning has been added, `missing_copy_implementations`, to warn you if a non-generic public type has been added that could have implemented `Copy` but didn't. For convenience, you may *temporarily* opt out of this behavior by using `#![feature(opt_out_copy)]`. Note though that this feature gate will never be accepted and will be removed by the time that 1.0 is released, so you should transition your code away from using it. This breaks code like: #[deriving(Show)] struct Point2D { x: int, y: int, } fn main() { let mypoint = Point2D { x: 1, y: 1, }; let otherpoint = mypoint; println!("{}{}", mypoint, otherpoint); } Change this code to: #[deriving(Show)] struct Point2D { x: int, y: int, } impl Copy for Point2D {} fn main() { let mypoint = Point2D { x: 1, y: 1, }; let otherpoint = mypoint; println!("{}{}", mypoint, otherpoint); } This is the backwards-incompatible part of #13231. Part of RFC #3. [breaking-change]
2014-12-06librustc: remove unnecessary `as_slice()` callsJorge Aparicio-1/+1
2014-12-04Remove dependence on typeck from ppaux.Niko Matsakis-19/+0
2014-12-04Move various data structures out of typeck and into ty.Niko Matsakis-10/+8
2014-11-26rollup merge of #19329: steveklabnik/doc_style_cleanup2Alex Crichton-44/+25
2014-11-26/*! -> //!Steve Klabnik-44/+25
Sister pull request of https://github.com/rust-lang/rust/pull/19288, but for the other style of block doc comment.
2014-11-25/** -> ///Steve Klabnik-4/+2
This is considered good convention.
2014-11-23std: Add a new top-level thread_local moduleAlex Crichton-5/+8
This commit removes the `std::local_data` module in favor of a new `std::thread_local` module providing thread local storage. The module provides two variants of TLS: one which owns its contents and one which is based on scoped references. Each implementation has pros and cons listed in the documentation. Both flavors have accessors through a function called `with` which yield a reference to a closure provided. Both flavors also panic if a reference cannot be yielded and provide a function to test whether an access would panic or not. This is an implementation of [RFC 461][rfc] and full details can be found in that RFC. This is a breaking change due to the removal of the `std::local_data` module. All users can migrate to the new thread local system like so: thread_local!(static FOO: Rc<RefCell<Option<T>>> = Rc::new(RefCell::new(None))) The old `local_data` module inherently contained the `Rc<RefCell<Option<T>>>` as an implementation detail which must now be explicitly stated by users. [rfc]: https://github.com/rust-lang/rfcs/pull/461 [breaking-change]
2014-11-20auto merge of #18750 : ↵bors-1/+2
nikomatsakis/rust/issue-18333-skolemize-open-existential, r=nrc In the general case, at least, it is not possible to make an object out of an unsized type. This is because the object type would have to store the fat pointer information for the `self` value *and* the vtable -- meaning it'd have to be a fat pointer with three words -- but for the compiler to know that the object requires three words, it would have to know the self-type of the object (is `self` a thin or fat pointer?), which of course it doesn't. Fixes #18333. r? @nick29581
2014-11-20Require that objects can only be made from Sized types. Fixes #18333.Niko Matsakis-1/+2
2014-11-20Refactored new CodeExtent type for improved abstraction.Felix S. Klock II-6/+6
(Previously, statically identifiable scopes/regions were solely identified with NodeId's; this refactoring prepares for a future where that 1:1 correspondence does not hold.)
2014-11-19Refactor QPath to take an ast::TraitRefNiko Matsakis-0/+4
2014-11-19rustc: fix fallout of adding the `'tcx` lifetime to `Ty`.Eduard Burtescu-154/+155
2014-11-19rustc: middle: rename `ty::t` to `Ty` and use it unqualified everywhere.Eduard Burtescu-5/+5
2014-11-18Allow impl's to have late-bound regions. Introduces another level ofNiko Matsakis-2/+45
region binding at the impl site, so for method types that come from impls, it is necessary to liberate/instantiate late-bound regions at multiple depths.
2014-11-18Switch the code to use De Bruijn indices rather than binder-ids.Niko Matsakis-7/+11
2014-11-18auto merge of #19050 : japaric/rust/moar-dst, r=aturonbors-5/+5
r? @aturon cc #16918
2014-11-17librustc: DSTify `ClassList`, `LlvmRepr` and `Repr`Jorge Aparicio-5/+5
2014-11-17Switch to purely namespaced enumsSteven Fackler-0/+1
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-16Try to remove ty_nil, some kind of error in exhaustiveness checkingNiko Matsakis-2/+1
2014-11-13std: Fix the return value of Duration::spanAlex Crichton-1/+1
The subtraction was erroneously backwards, returning negative durations! Closes #18925
2014-11-12time: Deprecate the library in the distributionAlex Crichton-7/+11
This commit deprecates the entire libtime library in favor of the externally-provided libtime in the rust-lang organization. Users of the `libtime` crate as-is today should add this to their Cargo manifests: [dependencies.time] git = "https://github.com/rust-lang/time" To implement this transition, a new function `Duration::span` was added to the `std::time::Duration` time. This function takes a closure and then returns the duration of time it took that closure to execute. This interface will likely improve with `FnOnce` unboxed closures as moving in and out will be a little easier. Due to the deprecation of the in-tree crate, this is a: [breaking-change] cc #18855, some of the conversions in the `src/test/bench` area may have been a little nicer with that implemented
2014-11-10Use FnvHashMap instead of HashMap in rustcAriel Ben-Yehuda-12/+2
2014-11-07Make TyTrait embed a `TraitRef`, so that when we extend TraitRef, it ↵Niko Matsakis-4/+4
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-06Fallout from collection conventionsAlexis Beingessner-5/+5
2014-11-05Better debug printoutsNiko Matsakis-9/+5
2014-11-05Implement new operator dispatch semantics.Niko Matsakis-0/+7
Key points are: 1. `a + b` maps directly to `Add<A,B>`, where `A` and `B` are the types of `a` and `b`. 2. Indexing and slicing autoderefs consistently.
2014-11-03rollup merge of #18506 : nikomatsakis/assoc-type-boundsAlex Crichton-20/+46
2014-11-03Move associated types into the Assoc space and add in the builtin boundsNiko Matsakis-16/+41
from the definition (including Sized).
2014-11-03Add a 4th space for associated types defined in a trait (currently unused)Niko Matsakis-4/+5
2014-11-02Convert some notes to help messagesP1start-1/+3
Closes #18126.
2014-11-01collections: Remove all collections traitsAlex Crichton-4/+4
As part of the collections reform RFC, this commit removes all collections traits in favor of inherent methods on collections themselves. All methods should continue to be available on all collections. This is a breaking change with all of the collections traits being removed and no longer being in the prelude. In order to update old code you should move the trait implementations to inherent implementations directly on the type itself. Note that some traits had default methods which will also need to be implemented to maintain backwards compatibility. [breaking-change] cc #18424
2014-10-31auto merge of #18440 : japaric/rust/hash, r=alexcrichtonbors-1/+1
- The signature of the `*_equiv` methods of `HashMap` and similar structures have changed, and now require one less level of indirection. Change your code from: ``` rust hashmap.find_equiv(&"Hello"); hashmap.find_equiv(&&[0u8, 1, 2]); ``` to: ``` rust hashmap.find_equiv("Hello"); hashmap.find_equiv(&[0u8, 1, 2]); ``` - The generic parameter `T` of the `Hasher::hash<T>` method have become `Sized?`. Downstream code must add `Sized?` to that method in their implementations. For example: ``` rust impl Hasher<FnvState> for FnvHasher { fn hash<T: Hash<FnvState>>(&self, t: &T) -> u64 { /* .. */ } } ``` must be changed to: ``` rust impl Hasher<FnvState> for FnvHasher { fn hash<Sized? T: Hash<FnvState>>(&self, t: &T) -> u64 { /* .. */ } // ^^^^^^ } ``` [breaking-change] --- After review I'll squash the commits and update the commit message with the above paragraph. r? @aturon cc #16918
2014-10-31DSTify HashJorge Aparicio-1/+1
- The signature of the `*_equiv` methods of `HashMap` and similar structures have changed, and now require one less level of indirection. Change your code from: ``` hashmap.find_equiv(&"Hello"); hashmap.find_equiv(&&[0u8, 1, 2]); ``` to: ``` hashmap.find_equiv("Hello"); hashmap.find_equiv(&[0u8, 1, 2]); ``` - The generic parameter `T` of the `Hasher::hash<T>` method have become `Sized?`. Downstream code must add `Sized?` to that method in their implementations. For example: ``` impl Hasher<FnvState> for FnvHasher { fn hash<T: Hash<FnvState>>(&self, t: &T) -> u64 { /* .. */ } } ``` must be changed to: ``` impl Hasher<FnvState> for FnvHasher { fn hash<Sized? T: Hash<FnvState>>(&self, t: &T) -> u64 { /* .. */ } // ^^^^^^ } ``` [breaking-change]
2014-10-31auto merge of #18264 : jakub-/rust/var-ids-in-error-messages, r=nikomatsakisbors-84/+100
This PR aims to improve the readability of diagnostic messages that involve unresolved type variables. Currently, messages like the following: ```rust mismatched types: expected `core::result::Result<uint,()>`, found `core::option::Option<<generic #1>>` <anon>:6 let a: Result<uint, ()> = None; ^~~~ mismatched types: expected `&mut <generic #2>`, found `uint` <anon>:7 f(42u); ^~~ ``` tend to appear unapproachable to new users. [0] While specific type var IDs are valuable in diagnostics that deal with more than one such variable, in practice many messages only mention one. In those cases, leaving out the specific number makes the messages slightly less terrifying. ```rust mismatched types: expected `core::result::Result<uint, ()>`, found `core::option::Option<_>` <anon>:6 let a: Result<uint, ()> = None; ^~~~ mismatched types: expected `&mut _`, found `uint` <anon>:7 f(42u); ^~~ ``` As you can see, I also tweaked the aesthetics slightly by changing type variables to use the type hole syntax _. For integer variables, the syntax used is: ```rust mismatched types: expected `core::result::Result<uint, ()>`, found `core::option::Option<_#1i>` <anon>:6 let a: Result<uint, ()> = Some(1); ``` and float variables: ```rust mismatched types: expected `core::result::Result<uint, ()>`, found `core::option::Option<_#1f>` <anon>:6 let a: Result<uint, ()> = Some(0.5); ``` [0] https://twitter.com/coda/status/517713085465772032 Closes https://github.com/rust-lang/rust/issues/2632. Closes https://github.com/rust-lang/rust/issues/3404. Closes https://github.com/rust-lang/rust/issues/18426.
2014-10-30Use the `_` representation for integral variables as wellJakub Bukaj-3/+2
2014-10-30collections: Enable IndexMut for some collectionsAlex Crichton-4/+4
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-29Always drop var IDs from type variables modulo -Z verbose, per PR discussionJakub Bukaj-59/+37
2014-10-29Address review commentsJakub Bukaj-3/+3
2014-10-29Improve the readability of diagnostics that involve unresolved type variablesJakub Bukaj-95/+134
Diagnostics such as the following ``` mismatched types: expected `core::result::Result<uint,()>`, found `core::option::Option<<generic #1>>` <anon>:6 let a: Result<uint, ()> = None; ^~~~ mismatched types: expected `&mut <generic #2>`, found `uint` <anon>:7 f(42u); ^~~ ``` tend to be fairly unappealing to new users. While specific type var IDs are valuable in diagnostics that deal with more than one such variable, in practice many messages only mention one. In those cases, leaving out the specific number makes the messages slightly less terrifying. In addition, type variables have been changed to use the type hole syntax `_` in diagnostics. With a variable ID, they're printed as `_#id` (e.g. `_#1`). In cases where the ID is left out, it's simply `_`. Integer and float variables have an additional suffix after the number, e.g. `_#1i` or `_#3f`.
2014-10-29Rename fail! to panic!Steve Klabnik-1/+1
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-28Address review commentsJakub Bukaj-6/+4
2014-10-28Remove ty_bot from the type systemJakub Bukaj-8/+23
We now instead use a fresh variable for expressions that diverge.
2014-10-27Fix monomorphization of unboxed closuresBrian Koropoff-1/+6
This adds a `Substs` field to `ty_unboxed_closure` and plumbs basic handling of it throughout the compiler. trans now correctly monomorphizes captured free variables and llvm function defs. This fixes uses of unboxed closures which reference a free type or region parameter from their environment in either their signature or free variables. Closes #16791