Commit Graph

55893 Commits

Author SHA1 Message Date
Jonathan Turner
74549f8ef2 Rollup merge of #35614 - srinivasreddy:syntax_ext_rustfmt, r=nikomatsakis
run rustfmt on libsyntax_ext folder
2016-08-17 06:25:24 -07:00
Jonathan Turner
559bfd68e3 Rollup merge of #35613 - matthew-piziak:array-docs-trait-justification, r=steveklabnik
provide additional justification for array interface design

Explain why Rust does not implement traits for large arrays.

Explain why most methods are implemented on slices rather than arrays.

Note: I'm dipping my toes in the water with a tiny PR. Especially looking for feedback on wording and style. Points of concern: appropriate level of top-level explanation; foreshadowing (is it appropriate to imply that we expect Rust's type system to eventually support size-generic arrays?); using `Foo` and `Bar` as type variables instead of e.g. `T` and `S`.

@peschkaj
2016-08-17 06:25:24 -07:00
Jonathan Turner
997a248c01 Rollup merge of #35610 - JessRudder:33637-doc-update-for-str-representaton, r=steveklabnik
Add note to docs for &str that example is to demo internals only

r? @steveklabnik

This adds a note below the &str representation example explaining that the example provided should not be used under normal circumstances..

Would it make sense to point people in the direction of the method(s) they should use instead?  I left it out in the interest of not complicating the documentation, but, there's definitely an argument to be made for adding a bit of guidance in there.
2016-08-17 06:25:24 -07:00
Jonathan Turner
b8859f6956 Rollup merge of #35595 - urschrei:associated_types_docfix, r=steveklabnik
Clarify type declaration language in Associated Types docs

A small fix for the Associated Types docs

r? @steveklabnik
2016-08-17 06:25:23 -07:00
Jonathan Turner
d3f55e1e86 Rollup merge of #35415 - silenuss:e0030-formatting, r=jonathandturner
Update compiler error 0030 to use new error format.

Part of #35233,
Addresses #35204

r? @jonathandturner
2016-08-17 06:25:23 -07:00
Jonathan Turner
e83bff90ff Rollup merge of #34370 - steveklabnik:keyword-ref-mention, r=Manishearth
A disclaimer about keywords.

Some people cite this list as "zomg Rust has so many keywords," so make
it clear that these aren't all used by the language today.
2016-08-17 06:25:22 -07:00
bors
d6d0590469 Auto merge of #35605 - eddyb:substs, r=nikomatsakis
Remove the ParamSpace separation from formal and actual generics in rustc.

This is the first step towards enabling the typesystem implemented by `rustc` to be extended
(with generic modules, HKT associated types, generics over constants, etc.).

The current implementation splits all formal (`ty::Generics`) and actual (`Substs`) lifetime and type parameters (and even `where` clauses) into 3 "parameter spaces":
* `TypeSpace` for `enum`, `struct`, `trait` and `impl`
* `SelfSpace` for `Self` in a `trait`
* `FnSpace` for functions and methods

For example, in `<X as Trait<A, B>>::method::<T, U>`, the `Substs` are `[[A, B], [X], [T, U]]`.
The representation uses a single `Vec` with 2 indices where it's split into the 3 "parameter spaces".
Such a simplistic approach doesn't scale beyond the Rust 1.0 typesystem, and its existence was mainly motivated by keeping code manipulating generic parameters correct, across all possible situations.

Summary of changes:
* `ty::Generics` are uniformly stored and can be queried with `tcx.lookup_generics(def_id)`
 * the `typeck::collect` changes for this resulted in a function to lazily compute the `ty::Generics` for a local node, given only its `DefId` - this can be further generalized to other kinds of type information
* `ty::Generics` and `ty::GenericPredicates` now contain only their own parameters (or `where` clauses, respectively), and refer to their "parent", forming a linked list
 * right now most items have one level of nesting, only associated items and variants having two
 * in the future, if `<X as mod1<A>::mod2<B>::mod3::Trait<C>>::Assoc<Y>` is supported, it would be represented by item with the path `mod1::mod2::mod3::Trait::Assoc`, and 4 levels of generics: `mod1` with `[A]`, `mod2` with `[B]`, `Trait` with `[X, C]` and `Assoc` with `[Y]`
* `Substs` gets two new APIs for working with arbitrary items:
 * `Substs::for_item(def_id, mk_region, mk_type)` will construct `Substs` expected by the definition `def_id`, calling `mk_region` for lifetime parameters and `mk_type` for type parameters, and it's guaranteed to *always* return `Substs` compatible with `def_id`
 * `substs.rebase_onto(from_base_def_id, to_base_substs)` can be used if `substs` is for an item nested within `from_base_def_id` (e.g. an associated item), to replace the "outer parameters" with `to_base_substs` - for example, you can translate a method's `Substs` between a `trait` and an `impl` (in both directions) if you have the `DefId` of one and `Substs` for the other
* trait objects, without a `Self` in their `Substs`, use *solely* `ExistentialTraitRef` now, letting `TraitRef` assume it *always* has a `Self` present
* both `TraitRef` and `ExistentialTraitRef` get methods which do operations on their `Substs` which are valid only for traits (or trait objects, respectively)
* `Substs` loses its "parameter spaces" distinction, with effectively no code creating `Substs` in an ad-hoc manner, or inspecting them, without knowing what shape they have already

Future plans:
* combine both lifetimes and types in a single `Vec<Kind<'tcx>>` where `Kind` would be a tagged pointer that can be `Ty<'tcx>`, `&'tcx ty::Region` or, in the future, potentially-polymorphic constants
 * this would require some performance investigation, if it implies a lot of dynamic checks
* introduce an abstraction for `(T, Substs)`, where the `Substs` are even more hidden away from code
manipulating it; a precedent for this is `Instance` in trans, which has `T = DefId`; @nikomatsakis also referred to this, as "lazy substitution", when `T = Ty`
* rewrite type pretty-printing to fully take advantage of this to inject actual in the exact places of formal generic parameters in any paths
* extend the set of type-level information (e.g. beyond `ty::Generics`) that can be lazily queried during `typeck` and introduce a way to do those queries from code that can't refer to `typeck` directly
 * this is almost unrelated but is necessary for DAG-shaped recursion between constant evaluation and type-level information, i.e. for implementing generics over constants

r? @nikomatsakis
cc @rust-lang/compiler

cc @nrc Could get any perf numbers ahead of merging this?
2016-08-16 22:52:55 -07:00
Eduard Burtescu
9453d9b8ad rustc: remove ParamSpace from Substs. 2016-08-17 06:32:00 +03:00
Eduard Burtescu
6f5e455c2d rustc: split GenericPredicates of a method from its parent predicates. 2016-08-17 05:50:57 +03:00
Eduard Burtescu
3e74e5bffe rustc: split Generics of a method from its parent Generics. 2016-08-17 05:50:57 +03:00
Eduard Burtescu
c1cfd58cbd rustc: remove SelfSpace from ParamSpace. 2016-08-17 05:50:57 +03:00
Eduard Burtescu
4158673ad7 rustc: reduce Substs and Generics to a simple immutable API. 2016-08-17 05:50:57 +03:00
Eduard Burtescu
bfdfa1ce1d rustc_typeck: use Substs::from_generics instead of manually building them. 2016-08-17 05:50:57 +03:00
Eduard Burtescu
4b25f08512 rustc: move trait objects from TraitRef to ExistentialTraitRef. 2016-08-17 05:50:57 +03:00
Eduard Burtescu
5ef6af09e3 rustc: move defaulting's use of &mut Substs from InferCtxt to typeck. 2016-08-17 05:50:57 +03:00
Eduard Burtescu
c87063f07e rustc: avoid using subst::VecPerParamSpace::{empty,new} directly. 2016-08-17 05:50:57 +03:00
Eduard Burtescu
77dc61b5c6 rustc: force all raw accesses to VecPerParamSpace through as_full_slice. 2016-08-17 05:50:57 +03:00
Eduard Burtescu
b354ae95a2 rustc: move the SelfSpace before TypeSpace in Substs. 2016-08-17 05:50:57 +03:00
Eduard Burtescu
e314636b86 rustc: use Vec instead of VecPerParamSpace for ty::GenericPredicates. 2016-08-17 05:50:57 +03:00
bors
9376da6f77 Auto merge of #35559 - frewsxcv:slice-iter-as-ref, r=alexcrichton
Implement `AsRef<[T]>` for `std::slice::Iter`.

`AsRef` is designed for conversions that are "cheap" (as per
the API docs). It is the case that retrieving the underlying
data of `std::slice::Iter` is cheap. In my opinion, there's no
ambiguity about what slice data will be returned, otherwise,
I would be more cautious about implementing `AsRef`.
2016-08-16 19:44:10 -07:00
bors
1bf5fa3269 Auto merge of #35538 - cgswords:libproc_macro, r=nrc
Kicking off libproc_macro

This PR introduces `libproc_macro`, which is currently quite bare-bones (just a few macro construction tools and an initial `quote!` macro).

This PR also introduces a few test cases for it, and an additional `shim` file (at `src/libsyntax/ext/proc_macro_shim.rs` to allow a facsimile usage of Macros 2.0 *today*!
2016-08-16 16:35:10 -07:00
bors
514d4cef24 Auto merge of #35354 - tomgarcia:covariant-drain, r=alexcrichton
Made vec_deque::Drain, hash_map::Drain, and hash_set::Drain covariant

Fixed the rest of the Drain iterators.
2016-08-16 13:26:15 -07:00
cgswords
98c8e0a05d Proc_macro is alive 2016-08-16 13:17:36 -07:00
bors
db7300d414 Auto merge of #35637 - japaric:no-builtins-lto, r=alexcrichton
exclude `#![no_builtins]` crates from LTO

this prevents intrinsics like `memcpy` from being mis-optimized to
infinite recursive calls when LTO is used.

fixes #31544
closes #35540

---

r? @alexcrichton
cc @Amanieu
2016-08-16 10:13:18 -07:00
Corey Farwell
dc22186efb Add basic unit test for std::slice::Iter::as_slice. 2016-08-16 11:20:43 -04:00
Corey Farwell
3808dc3560 Implement AsRef<[T]> for std::slice::Iter.
`AsRef` is designed for conversions that are "cheap" (as per
the API docs). It is the case that retrieving the underlying
data of `std::slice::Iter` is cheap. In my opinion, there's no
ambiguity about what slice data will be returned, otherwise,
I would be more cautious about implementing `AsRef`.
2016-08-16 11:14:52 -04:00
bors
1de5b7e8c2 Auto merge of #35617 - jseyfried:fix_unused_cfg_attr_path, r=eddyb
Fix incorrect unused import warnings on `cfg_attr`ed `path` attributes

Fixes #35584.
r? @eddyb
2016-08-16 06:32:20 -07:00
bors
e25542cb02 Auto merge of #35162 - canndrew:bang_type_coerced, r=nikomatsakis
Implement the `!` type

This implements the never type (`!`) and hides it behind the feature gate `#[feature(never_type)]`. With the feature gate off, things should build as normal (although some error messages may be different). With the gate on, `!` is usable as a type and diverging type variables (ie. types that are unconstrained by anything in the code) will default to `!` instead of `()`.
2016-08-16 00:12:12 -07:00
Jorge Aparicio
e996405696 test that a no_builtins crate is passed to the linker 2016-08-15 18:24:14 -05:00
bors
197be89f36 Auto merge of #35680 - GuillaumeGomez:err_codes, r=jonathandturner
Err codes

r? @jonathandturner
2016-08-15 11:35:01 -07:00
bors
f65d96fe3f Auto merge of #35340 - michaelwoerister:incr-comp-cli-args, r=nikomatsakis
Take commandline arguments into account for incr. comp.

Implements the conservative strategy described in https://github.com/rust-lang/rust/issues/33727.

From now one, every time a new commandline option is added, one has to specify if it influences the incremental compilation cache. I've tried to implement this as automatic as possible: One just has to added either the `[TRACKED]` or the `[UNTRACKED]` marker next to the field. The `Options`, `CodegenOptions`, and `DebuggingOptions` definitions in `session::config` show plenty of examples.

The PR removes some cruft from `session::config::Options`, mostly unnecessary copies of flags also present in `DebuggingOptions` or `CodeGenOptions` in the same struct.

One notable removal is the `cfg` field that contained the values passed via `--cfg` commandline arguments. I chose to remove it because (1) its content is only a subset of what later is stored in `hir::Crate::config` and it's pretty likely that reading the cfgs from `Options` would not be what you wanted, and (2) we could not incorporate it into the dep-tracking hash of the `Options` struct because of how the test framework works, leaving us with a piece of untracked but vital data.

It is now recommended (just as before) to access the crate config via the `krate()` method in the HIR map.

Because the `cfg` field is not present in the `Options` struct any more, some methods in the `CompilerCalls` trait now take the crate config as an explicit parameter -- which might constitute a breaking change for plugin authors.
2016-08-15 08:35:18 -07:00
Steve Klabnik
85bbbad592 A disclaimer about keywords.
Some people cite this list as "zomg Rust has so many keywords," so make
it clear that these aren't all used by the language today.
2016-08-15 10:52:42 -04:00
Guillaume Gomez
92779194ed Add new error code tests 2016-08-15 16:47:45 +02:00
Guillaume Gomez
844c6e3d5c Add E0394 error explanation 2016-08-15 16:47:17 +02:00
bors
b72fa8ca95 Auto merge of #35567 - creativcoder:e0261, r=jonathandturner
Update E0261 and E0262 to new error format

Fixes #35516 and  #35517 . Part of #35233
r? @jonathandturner
2016-08-15 05:12:35 -07:00
silenuss
fa61f82bf2 Update compiler error 0030 to use new error format. 2016-08-15 00:21:13 -06:00
Andrew Cann
f59f1f0914 Fix bug for ! in old trans 2016-08-15 13:32:12 +08:00
bors
f0bab98695 Auto merge of #35638 - ahmedcharles:url, r=alexcrichton
Upgrade linkchecker to url 1.2.0.
2016-08-14 21:38:21 -07:00
Jorge Aparicio
35eba85c3d refactor: use CStore::is_no_builtins 2016-08-14 21:56:26 -05:00
bors
47e6da2a01 Auto merge of #35427 - cardoe:arm-musl-targets, r=alexcrichton
add GNU make files for arm-unknown-linux-musleabi

For Yocto (Embedded Linux meta distro) Rust is provided via the [meta-rust layer](https://github.com/meta-rust/meta-rust). In this project there have been patches to add `arm-unknown-linux-musleabi`. Rust recently acquired that support via #35060 but only for rustbuild. meta-rust is currently only able to build Rust support with the existing GNU Makefiles. This adds `arm-unknown-linux-musleabi` support to Rust for the GNU Makefiles until meta-rust is able to sort out why using rustbuild does not work for it.

/cc @srwalter @derekstraka @jmesmon @japaric
2016-08-14 18:36:33 -07:00
bors
13ff307f07 Auto merge of #35666 - eddyb:rollup, r=eddyb
Rollup of 30 pull requests

- Successful merges: #34941, #35392, #35444, #35447, #35491, #35533, #35539, #35558, #35573, #35574, #35577, #35586, #35588, #35594, #35596, #35597, #35598, #35606, #35611, #35615, #35616, #35620, #35622, #35640, #35643, #35644, #35646, #35647, #35648, #35661
- Failed merges: #35395, #35415
2016-08-14 15:27:15 -07:00
bors
1d5b758bab Auto merge of #35409 - eddyb:mir-storage-stmts, r=nikomatsakis
[MIR] Add Storage{Live,Dead} statements to emit llvm.lifetime.{start,end}.

Storage live ranges are tracked for all MIR variables and temporaries with a drop scope.
`StorageLive` is lowered to `llvm.lifetime.start` and `StorageDead` to `llvm.lifetime.end`.

There are some improvements possible here, such as:
* pack multiple storage liveness statements by using the index of first local + `u64` bitset
* enforce that locals are not directly accessed outside their storage live range
* shrink storage live ranges for never-borrowed locals to initialization -> last use
* emit storage liveness statements for *all* temporaries
 * however, the remaining ones are *always* SSA immediates, so they'd be noop in MIR trans
 * could have a flag on the temporary that its storage is irrelevant (a la C's old `register`)
   * would also deny borrows if necessary
    * this seems like an overcompliation and with packing & optimizations it may be pointless

Even in the current state, it helps stage2 `rustc` compile `boiler` without overflowing (see #35408).

A later addition fixes #26764 and closes #27372 by emitting `.section` directives for dylib metadata to avoid them being allocated into memory or read as `.note`. For this PR, those bugs were tripping valgrind.
2016-08-14 12:28:48 -07:00
Eduard-Mihai Burtescu
bcee2edc54 Rollup merge of #35661 - IvanUkhov:raw-vec, r=alexcrichton
Fix a couple of typos in RawVec

Hi,

The pull request is to fix a couple of typos in `liballoc/raw_vec.rs`.

Regards,
Ivan
2016-08-14 20:29:53 +03:00
Eduard-Mihai Burtescu
43cd345a9e Rollup merge of #35648 - ahmedcharles:pred, r=alexcrichton
Predicates haven't existed in almost 5 years.

This test probably adds negative value other than historical amusement.
2016-08-14 20:29:53 +03:00
Eduard-Mihai Burtescu
c63adb1712 Rollup merge of #35647 - ahmedcharles:spelling, r=alexcrichton
Ensure that attributes are spelled properly.
2016-08-14 20:29:53 +03:00
Eduard-Mihai Burtescu
f73f1282f5 Rollup merge of #35646 - theypsilon:master, r=jonathandturner
E0094 error message updated

Part of #35233
Fixes #35231

r? @jonathandturner
2016-08-14 20:29:52 +03:00
Eduard-Mihai Burtescu
50aa568709 Rollup merge of #35644 - garekkream:update-E0302-new-error-format, r=jonathandturner
Update E0302 to the new format

Part of #35233.
Fixes #35523.

r? @jonathandturner
2016-08-14 20:29:52 +03:00
Eduard-Mihai Burtescu
f91d242ad6 Rollup merge of #35643 - garekkream:update-E0301-new-error-format, r=jonathandturner
Update E0301 to the new format

Part of #35233.
Fixes #35522.

r? @jonathandturner
2016-08-14 20:29:52 +03:00
Eduard-Mihai Burtescu
42b3df23e2 Rollup merge of #35640 - ahmedcharles:dead, r=alexcrichton
compiletest: Remove dead code.
2016-08-14 20:29:52 +03:00
Eduard-Mihai Burtescu
2294fc4e4b Rollup merge of #35622 - matthew-piziak:convert-docs-typos, r=apasel422
fix small typos in std::convert documentation

Fix subject-verb agreement in copypasta: "`AsRef` dereference" to
"`AsRef` dereferences".

Formalize "eg" to "e.g." Italicization of common Latin abbreviations
seems to be going out of style in written English, so I left it plain.
2016-08-14 20:29:52 +03:00