Commit Graph

59217 Commits

Author SHA1 Message Date
Florian Diebold
8f6bb85b98 rustc_mir: fix compilation 2016-11-29 13:04:27 +01:00
Florian Diebold
8e754736dc rustc_const_eval: fix compilation 2016-11-29 13:04:27 +01:00
Florian Diebold
f55482e7c9 rustc: replace body exprs by their ids 2016-11-29 13:04:27 +01:00
Florian Diebold
069a2442b8 Add exprs map to crate, collect item blocks there 2016-11-29 13:04:27 +01:00
Jeffrey Seyfried
c871637e43 Remove resolver.record_resolution(). 2016-11-29 04:47:47 +00:00
bors
5de15be5ec Auto merge of #38046 - rkruppe:fix-32bit-rustbuild, r=alexcrichton
Fix rustbuild on 32 bit Linux

This is cherry-picked from #37817 which seems to be stalled and currently needs to be rebased anyway.

r? @alexcrichton (who authored this change)
2016-11-28 21:44:44 -06:00
Esteban Küber
4226930ddf Show Trait instead of <Struct as Trait> in E0323
For a given file

```
trait Foo {
    fn bar(&self);
}

pub struct FooConstForMethod;

impl Foo for FooConstForMethod {
    const bar: u64 = 1;
}
```

show

```
error[E0323]: item `bar` is an associated const, which doesn't match its trait `Foo`
```

instead of

```
error[E0323]: item `bar` is an associated const, which doesn't match its trait `<FooConstForMethod as Foo>`
```
2016-11-28 17:59:24 -08:00
Mark-Simulacrum
8b82fd7a94 Remove allocation in push_type_params 2016-11-28 18:09:15 -07:00
Mark-Simulacrum
a79c80d0b0 Adds TyCtxt::require_lang_item(LangItem) to simplify lang item requires.
Replaces instances of tcx.lang_items.require(..) with fatal unwrap with
this method.
2016-11-28 18:09:15 -07:00
Mark-Simulacrum
9b803ec421 Remove auto_traits from PartitionedBounds 2016-11-28 18:09:15 -07:00
Mark-Simulacrum
bb35d50cad Refactor TyTrait to contain a interned ExistentialPredicate slice.
Renames TyTrait to TyDynamic.
2016-11-28 18:09:13 -07:00
Jeffrey Seyfried
8fe525dd1c Simplify binding.module(). 2016-11-29 00:18:41 +00:00
Jeffrey Seyfried
7bccc9d769 Clean up formatting. 2016-11-29 00:18:40 +00:00
Jeffrey Seyfried
e9e178a581 Refactor away ResolveResult. 2016-11-29 00:18:39 +00:00
Jeffrey Seyfried
af2d89c7f6 Refactor path resoloution. 2016-11-29 00:18:34 +00:00
Jeffrey Seyfried
cb9f14e987 Use Def::Err to signal that an error has already been reported where possible. 2016-11-28 23:30:03 +00:00
Ariel Ben-Yehuda
5c0eb6ecb7 evaluate obligations in LIFO order during closure projection
This is an annoying gotcha with the projection cache's handling of
nested obligations.

Nested projection obligations enter the issue in this case:
```
DEBUG:rustc::traits::project: AssociatedTypeNormalizer: depth=3
normalized
<std::iter::Map<std::ops::Range<i32>,
[closure@not-a-recursion-error.rs:5:30: 5:53]> as
std::iter::IntoIterator>::Item to _#7t with 12 add'l obligations
```

Here the normalization result is the result of the nested impl
`<[closure@not-a-recursion-error.rs:5:30: 5:53] as FnMut(i32)>::Output`,
which is an additional obligation that is a part of "add'l obligations".

By itself, this is proper behaviour - the additional obligation is
returned, and the RFC 447 rules ensure that it is processed before the
output `#_7t` is used in any way.

However, the projection cache breaks this - it caches the
`<std::iter::Map<std::ops::Range<i32>,[closure@not-a-recursion-error.rs:5:30:
5:53]> as std::iter::IntoIterator>::Item = #_7t` resolution. Now
everybody else that attempts to look up the projection will just get
`#_7t` *without* any additional obligations. This obviously causes all
sorts of trouble (here a spurious `EvaluatedToAmbig` results in
specializations not being discarded
[here](9ca50bd4d5/src/librustc/traits/select.rs (L1705))).

The compiler works even with this projection cache gotcha because in most
cases during "one-pass evaluation". we tend to process obligations in LIFO
order - after an obligation is added to the cache, we process its nested
obligations before we do anything else (and if we have a cycle, we handle
it specifically) - which makes sure the inference variables are resolved
before they are used.

That "LIFO" order That was not done when projecting out of a closure, so
let's just fix that for the time being.

Fixes #38033.
2016-11-29 01:09:30 +02:00
Niko Matsakis
72fbf9f0fe fixup test cases 2016-11-28 17:06:10 -05:00
Mikhail Modin
67a24c2e18 add hint to fix error for immutable ref in arg 2016-11-29 00:32:34 +03:00
bors
1c448574bc Auto merge of #37791 - petrochenkov:where, r=nikomatsakis
Support `?Sized` in where clauses

Implemented as described in https://github.com/rust-lang/rust/issues/20503#issuecomment-258677026 - `?Trait` bounds are moved on type parameter definitions when possible, reported as errors otherwise.
(It'd be nice to unify bounds and where clauses in HIR, but this is mostly blocked by rustdoc now - it needs to render bounds in pleasant way and the best way to do it so far is to mirror what was written in source code.)

Fixes https://github.com/rust-lang/rust/issues/20503
r? @nikomatsakis
2016-11-28 15:15:17 -06:00
Robin Kruppe
6e35cc94de Remove unused functions from rustc_llvm 2016-11-28 21:59:26 +01:00
Robin Kruppe
85dc08e525 Don't assume llvm::StringRef is null terminated
StringRefs have a length and their contents are not usually null-terminated.
The solution is to either copy the string data (in rustc_llvm::diagnostic) or take the size into account (in LLVMRustPrintPasses).
I couldn't trigger a bug caused by this (apparently all the strings returned in practice are actually null-terminated) but this is more correct and more future-proof.
2016-11-28 17:33:13 +01:00
Alex Crichton
7506990914 rustbuild: Cross-compiled LLVM depens on host
We use the host's tblgen so we need to be sure to always build the host first.

Closes #38037
2016-11-28 07:13:47 -08:00
Mark-Simulacrum
64e97d9b33 Remove BuiltinBound and BuiltinBounds. 2016-11-28 06:37:08 -07:00
Mark-Simulacrum
607af7218b Refactor BuiltinBounds to Vec<DefId> on TraitObject. 2016-11-28 06:37:08 -07:00
Mark-Simulacrum
46c7a117f8 Privatize TraitObject.principal and add a method accessor, returning Option. 2016-11-28 06:37:08 -07:00
Andrew Cann
246edb8628 Make core::fmt::Void a non-empty type.
Because we handle artifically-constructed references to it in live code which
is a totally broken thing to do.
2016-11-28 21:22:41 +08:00
bors
39c267a8d5 Auto merge of #38024 - jseyfried:avoid_needless_proc_macro_deps, r=nrc
Avoid loading needless proc-macro dependencies

Fixes #37958 when no proc-macros are exported; in particular, without `pub extern crate proc_macros;`, `#![feature(macro_reexport)]`, or `#![feature(use_extern_macros)]`.

I opened https://github.com/rust-lang/cargo/issues/3334 for exported proc macros.

r? @alexcrichton
2016-11-28 07:03:43 -06:00
Robin Kruppe
02249e813e Define VISIBILITY_HIDDEN when compiling compiler-rt
This is cherry-picked from #37817 which seems to be stalled and currently needs to be rebased anyway.

r? @alexcrichton (who authored this change)
2016-11-28 12:23:57 +01:00
bors
0b399e5e99 Auto merge of #37676 - eddyb:lazy-7, r=nikomatsakis
[7/n] rustc: desugar UFCS in HIR and don't use DefMap for associated resolutions.

_This is part of a series ([prev](https://github.com/rust-lang/rust/pull/37412) | [next](https://github.com/rust-lang/rust/pull/37688)) of patches designed to rework rustc into an out-of-order on-demand pipeline model for both better feature support (e.g. [MIR-based](https://github.com/solson/miri) early constant evaluation) and incremental execution of compiler passes (e.g. type-checking), with beneficial consequences to IDE support as well.
If any motivation is unclear, please ask for additional PR description clarifications or code comments._

<hr>

Previously, a path like `T::Assoc::method`, while equivalent to `<<T>::Assoc>::method`, wasn't desugared in any way at the HIR level and everything inspecting it had to either deal with knowing only `T` (before typeck) or knowing only the definition of `method` (after typeck).
Such a path also had only one `NodeId` and associated resolution during typeck modified `DefMap`, in a way that would be hard for incremental recompilation to track, and inconvenient for partial type conversions from HIR to `Ty`, which are required to break faux-cycles in on-demand type collection.

The desugarings performed by this PR are as follows:
* `use a::{b,c};` is flattened to `use a as _; use a::b; use a::c;`
  * as resolution is complete, `use a as _;` doesn't do anything, except get checked for stability
* `Vec::new` (an expression) becomes `Vec<..>::new<..>`, to distinguish it from `<Vec>::new<..>`
  * the "infer all parameters" `<..>` form is internal and not even pretty-printed
  * used when there are no type parameters at all, in an expression or pattern path segment
* `T::A::B` becomes `<<T>::A>::B` in a type, and `<<T<..>>::A<..>>::B<..>` in an expression/pattern
  * one additional `hir::Ty` node is created for each prefix, starting with the fully-resolved type (`T`) and extending it with each segment (e.g. `<T>::A`)
* fully-resolved paths contain their `Def` in HIR, getting rid of the `DefMap` and absolving incremental recompilation of needing to manually look up nodes to handle that side information

Not keeping the `DefMap` around meant that associated resolutions had to be stored somewhere else:
* expressions and patterns use a new `NodeId -> Def` map in `ty::Tables`
  * compatible with the future per-body (constant / `fn` / closure) `Tables`
* types are accessible via `Ty` and the usual per-item generics / predicates / type
  * `rustdoc` and `save-analysis` are the only situations which insist on mapping syntactical types to semantical ones, or at least understand the resolution of associated types, therefore the type conversion cache, i.e. a `NodeId -> Ty` map, is exposed by typeck for this purpose
  * stability had to be split into a pass that runs on HIR and checks the results of name resolution, and impromptu checks triggered by `typeck` for associated paths, methods, fields, etc.
  * privacy using semantic types results in accurate reachability for `impl Trait`, which fixes #35870, and thorough introspection of associated types, which may allow relaxing private-in-public checking on bounds, while keeping the intended ban on projections with private type parameters

cc @petrochenkov
2016-11-27 23:32:57 -06:00
Jeffrey Seyfried
1fd9041b82 Avoid loading needless proc-macro dependencies. 2016-11-28 03:37:02 +00:00
Eduard-Mihai Burtescu
372c6df564 rustc_typeck: don't record associated type resolutions. 2016-11-28 05:12:41 +02:00
Eduard Burtescu
548e681f2f rustc_privacy: switch private-in-public checking to Ty. 2016-11-28 05:12:41 +02:00
Eduard Burtescu
fcdb4def83 rustc: track fields in the HIR map. 2016-11-28 05:12:41 +02:00
Eduard-Mihai Burtescu
36d33d6b71 rustc_privacy: visit Ty instead of HIR types in EmbargoVisitor. 2016-11-28 05:09:28 +02:00
bors
c7ddb8946b Auto merge of #38019 - sourcefrog:doc-separator, r=frewsxcv
Clearer description of std::path::MAIN_SEPARATOR.
2016-11-27 20:22:44 -06:00
Eduard Burtescu
9aaf26e7aa rustc: rework stability to be on-demand for type-directed lookup. 2016-11-28 04:18:11 +02:00
Eduard Burtescu
f97c132cac rustc: use Span's allow_internal_unstable instead of hir::BlockCheckMode. 2016-11-28 04:18:10 +02:00
Eduard Burtescu
da47c2e2ac rustc_typeck: save the type cache for rustdoc and save-analysis. 2016-11-28 04:18:10 +02:00
Eduard-Mihai Burtescu
962633cdbb rustc: embed path resolutions into the HIR instead of keeping DefMap. 2016-11-28 04:18:10 +02:00
Eduard-Mihai Burtescu
bc096549e8 rustc: desugar use a::{b,c}; into use a::b; use a::c; in HIR. 2016-11-28 04:18:10 +02:00
Eduard Burtescu
6ebc6d8154 rustc: track hir::{TraitRef, Visibility} in the HIR map. 2016-11-28 04:18:10 +02:00
Eduard Burtescu
16b5c2cfef rustc: desugar UFCS as much as possible during HIR lowering. 2016-11-28 04:18:10 +02:00
Eduard Burtescu
34d1352f0e rustc: encode the optionality of type parameters in HIR paths. 2016-11-28 04:18:10 +02:00
bors
03bdaade2a Auto merge of #38022 - arthurprs:micro-opt-hm, r=bluss
Use displacement instead of initial bucket in HashMap code

Use displacement instead of initial bucket in HashMap code. It makes the code a bit cleaner and also saves a few instructions (handy since it'll be using some to do some sort of adaptive behavior soon).
2016-11-27 17:06:58 -06:00
arthurprs
178e29df7d Use displacement instead of initial bucket in HashMap code 2016-11-27 21:38:46 +01:00
bors
9ca50bd4d5 Auto merge of #38027 - rkruppe:llvm-printpasses-fwdcompat, r=alexcrichton
[LLVM 4.0] LLVMRustPrintPasses

Adapt `LLVMRustPrintPasses` to LLVM 4.0 preferring `StringRef` over `char *`

cc #37609
2016-11-27 13:51:40 -06:00
Stefan Schindler
28b64dc1b9 Use keywords::Invalid 2016-11-27 17:59:36 +01:00
bors
2008732975 Auto merge of #37983 - GuillaumeGomez:tcp_listener_doc, r=frewsxcv
Add examples for TcpListener struct

r? @frewsxcv
2016-11-27 10:39:41 -06:00
Stefan Schindler
2dc3fdf2bd Resolve visibility issues
use syntax::ast::Name; is a reexport of syntax::symbol::Symbol(u32);
2016-11-27 16:45:09 +01:00