Commit Graph

67423 Commits

Author SHA1 Message Date
Stuart Pernsteiner
347db068a5 hir::print: fix parenthesization of exprs 2017-09-06 13:01:15 -04:00
Stuart Pernsteiner
5b2151ea21 better explanatory comment for the pprust-expr-roundtrip test 2017-09-06 10:30:00 -04:00
Stuart Pernsteiner
b79dada453 pprust: fix parenthesization of exprs 2017-09-06 10:26:51 -04:00
bors
a209539060 Auto merge of #43849 - QuietMisdreavus:foreign-impls, r=steveklabnik
rustdoc: add new "Implementations on Foreign Types" section to traits

Demo screenshot:

![image](https://user-images.githubusercontent.com/5217170/29281219-c547f758-80e3-11e7-808f-49f592c65c5b.png)

Full demo available at https://tonberry.quietmisdreavus.net/foreign-test/foreign_test/trait.CheckIt.html

This PR splits the "Implementors" section on trait pages into two: First, for impls on types local to the crate, their impls are kept as-is, printing one line for the impl line, and any additional lines for associated types. However, for types external to the crate, they are now pulled up over the others and are printed (almost) like the summary impl on the type page itself. This gives any doc comments on these impls or methods to be exposed in the documentation.

There's just one small problem, though: [libstd docs apparently surface impls for libc and rand, possibly among others](https://tonberry.quietmisdreavus.net/foreign-std/std/marker/trait.Copy.html#foreign-impls). This adds this section to pages in the std docs where we might not want them to show up in the first place. I think this is a bug distinct from this PR, but it does make it drastically apparent.

~~My question, then, is this: Do we want this here? Taking it out involves fixing which impls are visible to rustdoc, possibly specifically when rendering the std facade. I'm convinced this is fine to land as-is, since it adds a feature specifically for non-std crates (i'm thinking of things like `num` or related crates that implement things on primitives or std types as part of their functionality).~~ (EDIT: I have an open PR to fix this: https://github.com/rust-lang/rust/pull/44026)
2017-09-06 11:24:18 +00:00
Oliver Schneider
5bb870faca Reintroduce the early returns 2017-09-06 12:25:46 +02:00
Oliver Schneider
02fb1b0b72 Fix a bug in the inliner 2017-09-06 10:33:53 +02:00
Oliver Schneider
ddd01455e9
Suggest changing literals instead of calling methods (fixes #44307) 2017-09-06 10:09:25 +02:00
Alex Crichton
ed938f08a9 rustc: Attempt to handle super long linker invocations
This commit adds logic to the compiler to attempt to handle super long linker
invocations by falling back to the `@`-file syntax if the invoked command is too
large. Each OS has a limit on how many arguments and how large the arguments can
be when spawning a new process, and linkers tend to be one of those programs
that can hit the limit!

The logic implemented here is to unconditionally attempt to spawn a linker and
then if it fails to spawn with an error from the OS that indicates the command
line is too big we attempt a fallback. The fallback is roughly the same for all
linkers where an argument pointing to a file, prepended with `@`, is passed.
This file then contains all the various arguments that we want to pass to the
linker.

Closes #41190
2017-09-05 21:07:02 -07:00
Zaki Manian
af3536dbbc Remove trailing white space 2017-09-05 18:46:21 -07:00
bors
f83d20eff7 Auto merge of #43426 - qnighy:intercrate-ambiguity-hints, r=nikomatsakis
Add hints when intercrate ambiguity causes overlap.

I'm going to tackle #23980.

# Examples

## Trait impl overlap caused by possible downstream impl

```rust
trait Foo<X> {}
trait Bar<X> {}
impl<X, T> Foo<X> for T where T: Bar<X> {}
impl<X> Foo<X> for i32 {}

fn main() {}
```

```
error[E0119]: conflicting implementations of trait `Foo<_>` for type `i32`:
 --> test1.rs:4:1
  |
3 | impl<X, T> Foo<X> for T where T: Bar<X> {}
  | ------------------------------------------ first implementation here
4 | impl<X> Foo<X> for i32 {}
  | ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32`
  |
  = note: downstream crates may implement Bar

error: aborting due to previous error
```

## Trait impl overlap caused by possible upstream update

```rust
trait Foo {}
impl<T> Foo for T where T: ::std::fmt::Octal {}
impl Foo for () {}

fn main() {}
```

```
error[E0119]: conflicting implementations of trait `Foo` for type `()`:
 --> test2.rs:3:1
  |
2 | impl<T> Foo for T where T: ::std::fmt::Octal {}
  | ----------------------------------------------- first implementation here
3 | impl Foo for () {}
  | ^^^^^^^^^^^^^^^^^^ conflicting implementation for `()`
  |
  = note: upstream crates may add new impl for std::fmt::Octal in future versions

error: aborting due to previous error
```

## Inherent impl overlap caused by possible downstream impl

```rust
trait Bar<X> {}

struct A<T, X>(T, X);
impl<X, T> A<T, X> where T: Bar<X> { fn f(&self) {} }
impl<X> A<i32, X> { fn f(&self) {} }

fn main() {}
```

```
error[E0592]: duplicate definitions with name `f`
 --> test3.rs:4:38
  |
4 | impl<X, T> A<T, X> where T: Bar<X> { fn f(&self) {} }
  |                                      ^^^^^^^^^^^^^^ duplicate definitions for `f`
5 | impl<X> A<i32, X> { fn f(&self) {} }
  |                     -------------- other definition for `f`
  |
  = note: downstream crates may implement Bar

error: aborting due to previous error
```

## Inherent impl overlap caused by possible upstream update

```rust
struct A<T>(T);

impl<T> A<T> where T: ::std::fmt::Octal { fn f(&self) {} }
impl A<()> { fn f(&self) {} }

fn main() {}
```

```
error[E0592]: duplicate definitions with name `f`
 --> test4.rs:3:43
  |
3 | impl<T> A<T> where T: ::std::fmt::Octal { fn f(&self) {} }
  |                                           ^^^^^^^^^^^^^^ duplicate definitions for `f`
4 | impl A<()> { fn f(&self) {} }
  |              -------------- other definition for `f`
  |
  = note: upstream crates may add new impl for std::fmt::Octal in future versions

error: aborting due to previous error
```
2017-09-06 00:28:15 +00:00
Jonathan A. Kollasch
847d1ffbe9 bootstrap: avoid m4 -B for NetBSD-built sparc64 OpenSSL 2017-09-05 16:31:14 -05:00
Jonathan A. Kollasch
2047a0d083 bootstrap: add openssl config for sparc64-unknown-netbsd 2017-09-05 16:31:14 -05:00
Josh Stone
110efe25fa Include rustc in the default ./x.py install
The default install used to include rustc, rust-std, and rust-docs, but
the refactoring in commit 6b3413d825 make rustc only default in
extended builds.  This commit makes rustc installed by default again.
2017-09-05 14:19:22 -07:00
Luca Barbato
c3041e8b9e Add support for Vector Sum Saturated on PowerPC 2017-09-05 20:30:47 +00:00
Luca Barbato
eec1c178b3 Add support for Vector Sum Across Partial 1/4 Saturated on PowerPC 2017-09-05 20:27:57 +00:00
Luca Barbato
668d8ff262 Add support for Vector Sum Across Partial 1/2 Saturated on PowerPC 2017-09-05 20:22:34 +00:00
Alex Crichton
c6445ba25b Clarify failure condition on tests 2017-09-05 11:55:01 -07:00
Simon Sapin
f912d771ba Make git commit info optional and per-package in channel manifests
At the moment it is always missing for Cargo and RLS.
Their respective build systems need to be modified to include
`git-commit-hash` files in their "dist" tarballs.
2017-09-05 19:38:28 +02:00
Ralf Jung
13cf229037 disable gcc warnings 2017-09-05 18:46:26 +02:00
QuietMisdreavus
a9f0f6df94 add "Implementations on Foreign Types" to the sidebar 2017-09-05 11:21:18 -05:00
QuietMisdreavus
b357a9c09c if not showing default docs on an impl, autohide the items 2017-09-05 11:21:18 -05:00
QuietMisdreavus
30e526805d rustdoc: add new "Implementations on Foreign Types" section to traits 2017-09-05 11:21:14 -05:00
Niko Matsakis
37c9a60a7d factor out helper method 2017-09-05 12:19:36 -04:00
Masaki Hara
099bb1ba8a Fix misdetection of upstream intercrate ambiguity. 2017-09-05 12:19:35 -04:00
Masaki Hara
4d503b0c74 Add downstream tests for intercrate ambiguity hints. 2017-09-05 12:19:35 -04:00
Masaki Hara
d153ff3f79 Print more detailed trait-ref for intercrate ambiguity. 2017-09-05 12:19:35 -04:00
Masaki Hara
84bfc33fac Unify intercrate ambiguity emitters into a function. 2017-09-05 12:19:35 -04:00
Masaki Hara
043786dcdf Fix a very subtle mistake in a ui test. 2017-09-05 12:19:35 -04:00
Masaki Hara
a59cc32ed4 Add tests for intercrate ambiguity hints. 2017-09-05 12:19:35 -04:00
Masaki Hara
bebd622198 Slightly modify hint messages. 2017-09-05 12:19:35 -04:00
Masaki Hara
d49f278263 Add hints when intercrate ambiguity causes overlap. 2017-09-05 12:19:33 -04:00
Alex Crichton
0cdc58a1bc rustc: Store InternedString in DefPathData
Previously a `Symbol` was stored there, but this ended up causing hash
collisions in situations that otherwise shouldn't have a hash collision. Only
the symbol's string value was hashed, but it was possible for distinct symbols
to have the same string value, fooling various calcuations into thinking that
these paths *didn't* need disambiguating data when in fact they did!

By storing `InternedString` instead we're hopefully triggering all the exising
logic to disambiguate paths with same-name `Symbol` but actually distinct
locations.
2017-09-05 07:47:27 -07:00
Alex Crichton
9a231961d5 rustc: Move stability functionality into queries
This commit primarily removes the `stability` field from `TyCtxt` as well as its
internal mutable state, instead using a query to build the stability index as
well as primarily using queries for other related lookups.

Like previous commits the calculation of the stability index is wrapped in a
`with_ignore` node to avoid regressing the current tests, and otherwise this
commit also introduces #44232 but somewhat intentionally so.
2017-09-05 07:37:58 -07:00
Alex Crichton
0182c8bbda rustc: Rename item_body query to extern_const_body
Should hopefully more accurately reflect what's happening! This commit also
removes the cache in the cstore implementation as it's already cached through
the query infrastructure.
2017-09-05 07:37:58 -07:00
Alex Crichton
7d9c98e475 rustc: Hide maybe_unused_* fields in queries
This commit makes the `maybe_unused_extern_crates` and
`maybe_unused_trait_imports` fields of `TyCtxt` private and ensures that they're
accessed with queries so the values and results can be tracked.
2017-09-05 07:37:58 -07:00
Alex Crichton
bf5550b9b2 rustc: Convert freevars to a query
This removes a public mutable (but not actually used mutably) field from the
`TyCtxt`, moving it over to a query to ensure that it's tracked over time.
2017-09-05 07:37:58 -07:00
Alex Crichton
490f34ac0c rustc: Remove CrateStore::used_crate*
This commit removes the `use_crates` and `used_crate_source` methods in favor of
a mix of queries and helper methods being used now instead.
2017-09-05 07:37:58 -07:00
Alex Crichton
0b7e0aaba5 rustc: Classify two more CrateStore methods untracked
These are only called pre-TyCtxt (e.g. lowering/resolve), so make it explicit in
the name that they're untracked and therefore unsuitable to called elsewhere.
2017-09-05 07:37:58 -07:00
Alex Crichton
88399a985a rustc: Migrate visible_parent_map to a query
Turns out it was basically already a query if you squinted hard enough!
2017-09-05 07:37:58 -07:00
Alex Crichton
84ae4b75be rustc: Migrate CrateStore::item_body to a query
This commit migrates the `item_body` method on `CrateStore` to a query instead
to enable better tracking of dependencies and whatnot.
2017-09-05 07:37:58 -07:00
Alex Crichton
953490ddfa rustc: Remove lang item methods from CrateStore
Given the previous commit, these are now trivially representable as queries!
2017-09-05 07:37:58 -07:00
Alex Crichton
a2e2aba07d rustc: Migrate lang items to a query
This commit moves the calculation of the `LanguageItems` structure into a
query rather than being calculated before the `TyCtxt` exists, with the eventual
end goal of removing some `CrateStore` methods.
2017-09-05 07:37:57 -07:00
Alex Crichton
43ae380191 rustc: Flag some CrateStore methods as "untracked"
The main use of `CrateStore` *before* the `TyCtxt` is created is during
resolution, but we want to be sure that any methods used before resolution are
not used after the `TyCtxt` is created. This commit starts moving the methods
used by resolve to all be named `{name}_untracked` where the rest of the
compiler uses just `{name}` as a query.

During this transition a number of new queries were added to account for
post-resolve usage of these methods.
2017-09-05 07:37:39 -07:00
Alex Crichton
fd61fa5aef rustc: Hide the named_region_map behind queries
This commit makes the `named_region_map` field of `GlobalCtxt` private by
encapsulating the fields behind new queries, and the new queries are also
targeted at particular `HirId` nodes instead of accessing the entire map.
2017-09-05 07:37:39 -07:00
Alex Crichton
64a70342e6 rustc: Remove a number of mutable fields in cstore
This commit started by moving methods from `CrateStore` to queries, but it ended
up necessitating some deeper refactorings to move more items in general to
queries.

Before this commit the *resolver* would walk over the AST and process foreign
modules (`extern { .. }` blocks) and collect `#[link]` annotations. It would
then also process the command line `-l` directives and such. This information
was then stored as precalculated lists in the `CrateStore` object for iterating
over later.

After this, commit, however, this pass no longer happens during resolution but
now instead happens through queries. A query for the linked libraries of a crate
will crawl the crate for `extern` blocks and then process the linkage
annotations at that time.
2017-09-05 07:37:28 -07:00
Alex Crichton
87ea0a19bf Ignore failing tests harder 2017-09-05 07:37:28 -07:00
Alex Crichton
1c7294eb54 rustc: Move implementations_of_trait to a query
While we're at it, make it two separate queries so one's for rustdoc and one's
for the compiler, hopefully being a bit more targeted.
2017-09-05 07:37:28 -07:00
Alex Crichton
4dec2a8f81 rustc: Fix a borrow mut error with debug assertions 2017-09-05 07:37:28 -07:00
Alex Crichton
4af1284053 Ignore failing incremental tests
These should hopefully get fixed with red/green, but until that time alas!
2017-09-05 07:37:27 -07:00
Alex Crichton
52b67f988d rustc: Move original_crate_name to a query 2017-09-05 07:37:27 -07:00