]> git.lizzy.rs Git - rust.git/log
rust.git
7 years agoRemove outdated comment about SVH.
Michael Woerister [Tue, 15 Nov 2016 20:22:15 +0000 (15:22 -0500)]
Remove outdated comment about SVH.

7 years agoICH: Hash MacroDefs in a mostly stable way.
Michael Woerister [Tue, 15 Nov 2016 20:20:39 +0000 (15:20 -0500)]
ICH: Hash MacroDefs in a mostly stable way.

7 years agoAdd error message when not finding the ICH of a DepNode.
Michael Woerister [Tue, 15 Nov 2016 16:55:34 +0000 (11:55 -0500)]
Add error message when not finding the ICH of a DepNode.

7 years agoAuto merge of #37749 - keeperofdakeys:should-panic, r=alexcrichton
bors [Fri, 18 Nov 2016 16:24:00 +0000 (08:24 -0800)]
Auto merge of #37749 - keeperofdakeys:should-panic, r=alexcrichton

Improvements to the #[should_panic] feature

Add more error checking for the `#[should_panic]` attribute, and print the expected panic string when it does not match.

Fixes https://github.com/rust-lang/rust/issues/29000

Eg:
```running 3 tests
test test2 ... ok
test test1 ... FAILED
: Panic did not include expected string 'foo'
test test3 ... FAILED

failures:

---- test1 stdout ----
thread 'test1' panicked at 'bar', test.rs:7
note: Run with `RUST_BACKTRACE=1` for a backtrace.

---- test3 stdout ----
thread 'test3' panicked at 'bar', test.rs:18

```

7 years agoAuto merge of #37769 - alexcrichton:rustbuild-python, r=brson
bors [Fri, 18 Nov 2016 13:03:03 +0000 (05:03 -0800)]
Auto merge of #37769 - alexcrichton:rustbuild-python, r=brson

rustbuild: Allow configuration of python interpreter

Add a configuration key to `config.toml`, read it from `./configure`, and add
auto-detection if none of those were specified.

Closes #35760

7 years agoWarn when a #[should_panic] test has an unexpected message
Josh Driver [Fri, 18 Nov 2016 10:31:19 +0000 (21:01 +1030)]
Warn when a #[should_panic] test has an unexpected message

7 years agoAuto merge of #37763 - liigo:rustdoc-playground, r=alexcrichton
bors [Fri, 18 Nov 2016 09:47:01 +0000 (01:47 -0800)]
Auto merge of #37763 - liigo:rustdoc-playground, r=alexcrichton

rustdoc: add cli argument `--playground-url`

Add a new cli argument `--playground-url` for rustdoc:

`rustdoc lib.rs --playground-url="https://play.rust-lang.org/"`

`rustdoc book.md --playground-url="https://play.rust-lang.org/"`

This makes it possible for tools like https://docs.rs to generate crate docs that can submit samples code to run at https://play.rust-lang.org, even if the crate's author *forgot* putting `#![doc(html_playground_url = "https://play.rust-lang.org/")]` to crate root. By the way, I'd like to say, many crate authors are not aware of existing of `#![doc(html_playground_url = "https://play.rust-lang.org/")]`.

`--playground-url` may be reset by `--markdown-playground-url` or `#![doc(html_playground_url=...)]`, so it's backward compatible.

@alexcrichton since you implemented playground-url related features.

7 years agoAuto merge of #37846 - jseyfried:fix_proc_macro_dep, r=alexcrichton
bors [Fri, 18 Nov 2016 04:56:03 +0000 (20:56 -0800)]
Auto merge of #37846 - jseyfried:fix_proc_macro_dep, r=alexcrichton

Fix bug in proc_macro dependency loading

Fixes #37839.
r? @alexcrichton

7 years agoAuto merge of #37660 - nikomatsakis:incremental-36349, r=eddyb
bors [Fri, 18 Nov 2016 01:31:01 +0000 (17:31 -0800)]
Auto merge of #37660 - nikomatsakis:incremental-36349, r=eddyb

Separate impl items from the parent impl

This change separates impl item bodies out of the impl itself. This gives incremental more resolution. In so doing, it refactors how the visitors work, and cleans up a bit of the collect/check logic (mostly by moving things out of collect that didn't really belong there, because they were just checking conditions).

However, this is not as effective as I expected, for a kind of frustrating reason. In particular, when invoking `foo.bar()` you still wind up with dependencies on private items. The problem is that the method resolution code scans that list for methods with the name `bar` -- and this winds up touching *all* the methods, even private ones.

I can imagine two obvious ways to fix this:

- separating fn bodies from fn sigs (#35078, currently being pursued by @flodiebold)
- a more aggressive model of incremental that @michaelwoerister has been advocating, in which we hash the intermediate results (e.g., the outputs of collect) so that we can see that the intermediate result hasn't changed, even if a particular impl item has changed.

So all in all I'm not quite sure whether to land this or not. =) It still seems like it has to be a win in some cases, but not with the test cases we have just now. I can try to gin up some test cases, but I'm not sure if they will be totally realistic. On the other hand, some of the early refactorings to the visitor trait seem worthwhile to me regardless.

cc #36349 -- well, this is basically a fix for that issue, I guess

r? @michaelwoerister

NB: Based atop of @eddyb's PR https://github.com/rust-lang/rust/pull/37402; don't land until that lands.

7 years agoAdd regression test.
Jeffrey Seyfried [Fri, 18 Nov 2016 00:51:24 +0000 (00:51 +0000)]
Add regression test.

7 years agoFix bug in loading proc macro dependencies.
Jeffrey Seyfried [Fri, 18 Nov 2016 00:03:10 +0000 (00:03 +0000)]
Fix bug in loading proc macro dependencies.

7 years agoAuto merge of #37424 - shiver:issue-37131, r=alexcrichton
bors [Thu, 17 Nov 2016 22:16:27 +0000 (14:16 -0800)]
Auto merge of #37424 - shiver:issue-37131, r=alexcrichton

Improved error reporting when target sysroot is missing.

Attempts to resolve #37131.
This is my first pull request on rust, so I would greatly appreciate any feedback you have on this.

Thanks!

7 years agoadd test for hashing trait impls
Niko Matsakis [Thu, 17 Nov 2016 20:12:43 +0000 (15:12 -0500)]
add test for hashing trait impls

7 years agoAuto merge of #37837 - GuillaumeGomez:rollup, r=GuillaumeGomez
bors [Thu, 17 Nov 2016 18:57:08 +0000 (10:57 -0800)]
Auto merge of #37837 - GuillaumeGomez:rollup, r=GuillaumeGomez

Rollup of 8 pull requests

- Successful merges: #37752, #37757, #37759, #37766, #37772, #37799, #37806, #37821
- Failed merges: #37442

7 years agocanonicalize base incremental path on windows
Niko Matsakis [Thu, 17 Nov 2016 17:44:46 +0000 (12:44 -0500)]
canonicalize base incremental path on windows

This sidesteps problems with long paths because the canonical path
includes the "magic long path prefix" on Windows.

7 years agofix change_private_impl_method_cc test
Niko Matsakis [Tue, 15 Nov 2016 02:02:29 +0000 (21:02 -0500)]
fix change_private_impl_method_cc test

7 years agofix oversight in closure translation
Niko Matsakis [Mon, 14 Nov 2016 23:23:07 +0000 (18:23 -0500)]
fix oversight in closure translation

(Unrelated to this PR series)

7 years agohash the contents of impl-item-ref by adding them to visitor
Niko Matsakis [Mon, 14 Nov 2016 16:00:02 +0000 (11:00 -0500)]
hash the contents of impl-item-ref by adding them to visitor

Also simplify some of the `ty::AssociatedItem` representation,
in particular by folding `has_value` into `hir::Defaultness`

7 years agomove impl wf check so they occur earlier
Niko Matsakis [Fri, 11 Nov 2016 14:52:46 +0000 (09:52 -0500)]
move impl wf check so they occur earlier

Needed to keep coherence from freaking out.

7 years agowhen creating an AssociatedItem, read data from impl, not impl item
Niko Matsakis [Fri, 11 Nov 2016 23:22:41 +0000 (18:22 -0500)]
when creating an AssociatedItem, read data from impl, not impl item

Before, when we created an AssociatedItem for impl item X, we would read
the impl item itself. Now we instead load up the impl I that contains X
and read the data from the `ImplItemRef` for X; actually, we do it for
all impl items in I pre-emptively.

This kills the last source of edges between a method X and a call to a
method Y defined in the same impl.

Fixes #37121

7 years agoRollup merge of #37821 - tshepang:nits, r=steveklabnik
Guillaume Gomez [Thu, 17 Nov 2016 18:40:58 +0000 (19:40 +0100)]
Rollup merge of #37821 - tshepang:nits, r=steveklabnik

doc: nits and typos on comments

7 years agoRollup merge of #37806 - GuillaumeGomez:net_examples, r=frewsxcv
Guillaume Gomez [Thu, 17 Nov 2016 18:40:58 +0000 (19:40 +0100)]
Rollup merge of #37806 - GuillaumeGomez:net_examples, r=frewsxcv

Net examples

r? @steveklabnik

7 years agoRollup merge of #37799 - michaelwoerister:ich-type-def-tests, r=nikomatsakis
Guillaume Gomez [Thu, 17 Nov 2016 18:40:58 +0000 (19:40 +0100)]
Rollup merge of #37799 - michaelwoerister:ich-type-def-tests, r=nikomatsakis

ICH: Add test case for type alias definitions

r? @nikomatsakis

7 years agoRollup merge of #37772 - durka:patch-32, r=petrochenkov
Guillaume Gomez [Thu, 17 Nov 2016 18:40:58 +0000 (19:40 +0100)]
Rollup merge of #37772 - durka:patch-32, r=petrochenkov

add test for #37765

Adds a test for #37765, a path parsing fix which removes the need for a parenthesis workaround.

Closes #37765.
cc #37290 @withoutboats
r? @petrochenkov

7 years agoRollup merge of #37766 - tarka:book-testing-concurrency-capture, r=steveklabnik
Guillaume Gomez [Thu, 17 Nov 2016 18:40:57 +0000 (19:40 +0100)]
Rollup merge of #37766 - tarka:book-testing-concurrency-capture, r=steveklabnik

Add sections about testing concurrency and stdout/err capture

7 years agoRollup merge of #37759 - robinst:trait-use-message-add-semicolon, r=eddyb
Guillaume Gomez [Thu, 17 Nov 2016 18:40:57 +0000 (19:40 +0100)]
Rollup merge of #37759 - robinst:trait-use-message-add-semicolon, r=eddyb

Add semicolon to "perhaps add a `use` for one of them" help

Similar to pull request #37430, this makes the message more copy-paste
friendly and aligns it with other messages like:

    help: you can import it into scope: use foo::Bar;

r? @eddyb

7 years agoRollup merge of #37757 - rust-lang:E0002-precision, r=brson
Guillaume Gomez [Thu, 17 Nov 2016 18:40:57 +0000 (19:40 +0100)]
Rollup merge of #37757 - rust-lang:E0002-precision, r=brson

Uncomment some long error explanation

Retry of #37058.

r? @steveklabnik
cc @brson

7 years agoRollup merge of #37752 - arielb1:incoherent-error, r=nikomatsakis
Guillaume Gomez [Thu, 17 Nov 2016 18:40:57 +0000 (19:40 +0100)]
Rollup merge of #37752 - arielb1:incoherent-error, r=nikomatsakis

coherence: skip impls with an erroneous trait ref

Impls with a erroneous trait ref are already ignored in the first part
of coherence, so ignore them in the second part too. This avoids
cascading coherence errors when 1 impl of a trait has an error.

r? @nikomatsakis

7 years agoAuto merge of #37732 - jseyfried:use_extern_macros, r=nrc
bors [Thu, 17 Nov 2016 15:43:50 +0000 (07:43 -0800)]
Auto merge of #37732 - jseyfried:use_extern_macros, r=nrc

Support `use`ing externally defined macros behind `#![feature(use_extern_macros)]`

With `#![feature(use_extern_macros)]`,
 - A name collision between macros from different upstream crates is much less of an issue since we can `use` the macros in different submodules or rename with `as`.
 - We can reexport macros with `pub use`, so `#![feature(macro_reexport)]` is no longer needed.
 - These reexports are allowed in any module, so crates can expose a macro-modular interface.

If a macro invocation can resolve to both a `use` import and a `macro_rules!` or `#[macro_use]`, it is an ambiguity error.

r? @nrc

7 years agoAuto merge of #37793 - jseyfried:fix_proc_macro_def_ids, r=nrc
bors [Thu, 17 Nov 2016 12:38:08 +0000 (04:38 -0800)]
Auto merge of #37793 - jseyfried:fix_proc_macro_def_ids, r=nrc

Fix proc macro def ids

Update some `CStore` methods to also work correctly with proc macro def ids.
Fixes #37788.
r? @nrc

7 years agoAuto merge of #37717 - nikomatsakis:region-obligations-pre, r=eddyb
bors [Thu, 17 Nov 2016 09:18:51 +0000 (01:18 -0800)]
Auto merge of #37717 - nikomatsakis:region-obligations-pre, r=eddyb

Refactoring towards region obligation

Two refactorings towards the intermediate goal of propagating region obligations through the `InferOk` structure (which in turn leads to the possibility of lazy normalization).

1. Remove `TypeOrigin` and add `ObligationCause`
    - as we converge subtyping and obligations and so forth, the ability to keep these types distinct gets harder
2. Propagate obligations from `InferOk` into the surrounding fulfillment context

After these land, I have a separate branch (which still needs a bit of work) that can make the actual change to stop directly adding subregion edges and instead propagate obligations. (This should also make it easier to fix the unsoundness in specialization around lifetimes.)

r? @eddyb

7 years agoCleanup formatting.
Jeffrey Seyfried [Thu, 17 Nov 2016 08:16:32 +0000 (08:16 +0000)]
Cleanup formatting.

7 years agoAdd tests.
Jeffrey Seyfried [Sat, 12 Nov 2016 09:38:12 +0000 (09:38 +0000)]
Add tests.

7 years agoAdd feature `use_extern_macros`.
Jeffrey Seyfried [Thu, 10 Nov 2016 10:29:36 +0000 (10:29 +0000)]
Add feature `use_extern_macros`.

7 years agoRefactor out `PerNS`.
Jeffrey Seyfried [Thu, 10 Nov 2016 06:19:54 +0000 (06:19 +0000)]
Refactor out `PerNS`.

7 years agoAdd field `expansion: Mark` to `NameBinding`.
Jeffrey Seyfried [Mon, 7 Nov 2016 22:23:26 +0000 (22:23 +0000)]
Add field `expansion: Mark` to `NameBinding`.

7 years agoRefactor `Resolver::builtin_macros` to use `NameBinding`s instead of `DefId`s.
Jeffrey Seyfried [Mon, 7 Nov 2016 22:08:26 +0000 (22:08 +0000)]
Refactor `Resolver::builtin_macros` to use `NameBinding`s instead of `DefId`s.

7 years agoResolve imports during expansion.
Jeffrey Seyfried [Thu, 10 Nov 2016 10:11:25 +0000 (10:11 +0000)]
Resolve imports during expansion.

7 years agoAdd field `module.unresolved_invocations`.
Jeffrey Seyfried [Fri, 11 Nov 2016 10:51:15 +0000 (10:51 +0000)]
Add field `module.unresolved_invocations`.

7 years agodoc: nits and typos on comments
Tshepang Lekhonkhobe [Thu, 17 Nov 2016 06:32:04 +0000 (08:32 +0200)]
doc: nits and typos on comments

7 years agoImproved error reporting when target sysroot is missing.
Robert Vally [Thu, 17 Nov 2016 05:59:28 +0000 (13:59 +0800)]
Improved error reporting when target sysroot is missing.

7 years agoAuto merge of #37607 - dns2utf8:doc_grammar, r=alexcrichton
bors [Thu, 17 Nov 2016 05:02:55 +0000 (21:02 -0800)]
Auto merge of #37607 - dns2utf8:doc_grammar, r=alexcrichton

Fix grammar verification

 * Use make check-lexer to verify the grammar.
 * Extend grammar/README
 * Add make clean-grammar rule
 * Add target check-build-lexer-verifier to make tidy, so it will build the verifier with every build and catch future errors

This is the continuation of #34994

r? @steveklabnik @jonathandturner @alexcrichton

7 years agoAuto merge of #37375 - GuillaumeGomez:cast_message, r=arielb1
bors [Thu, 17 Nov 2016 00:30:27 +0000 (16:30 -0800)]
Auto merge of #37375 - GuillaumeGomez:cast_message, r=arielb1

Improve reference cast help message

Fixes #37338.

7 years agoRevert "Bump the bootstrap cargo to match the one paired with 1.13"
Brian Anderson [Thu, 17 Nov 2016 00:11:10 +0000 (00:11 +0000)]
Revert "Bump the bootstrap cargo to match the one paired with 1.13"

This reverts commit 5ad235c8c0416ebab0b80e4750b84c061ef6cc6b.

7 years agoMerge pull request #37635 from brson/bootstrap
Brian Anderson [Thu, 17 Nov 2016 00:08:41 +0000 (16:08 -0800)]
Merge pull request #37635 from brson/bootstrap

Bump the bootstrap cargo to match the one paired with 1.13

7 years agoFix grammar verification
Stefan Schindler [Sat, 23 Jul 2016 11:51:54 +0000 (13:51 +0200)]
Fix grammar verification

 * Use `make check-lexer` to verify the grammar.
 * Extend grammar/README
 * Add make clean-grammar rule
 * Add target `check-build-lexer-verifier` to `make tidy`, so it will build the verifier with every build and catch future errors
 * Search for antlr4 with configure and find

7 years agoImprove reference cast help message
Guillaume Gomez [Mon, 24 Oct 2016 12:52:14 +0000 (14:52 +0200)]
Improve reference cast help message

7 years agoAdd regression test.
Jeffrey Seyfried [Wed, 16 Nov 2016 07:30:35 +0000 (07:30 +0000)]
Add regression test.

7 years agoAdd examples for Ipv4Addr
Guillaume Gomez [Wed, 16 Nov 2016 19:40:01 +0000 (20:40 +0100)]
Add examples for Ipv4Addr

7 years agoinclude a Name and Span for each item in the HIR of the impl
Niko Matsakis [Thu, 10 Nov 2016 14:47:00 +0000 (09:47 -0500)]
include a Name and Span for each item in the HIR of the impl

7 years agoadd a `nested_visit_map` method
Niko Matsakis [Wed, 9 Nov 2016 21:45:26 +0000 (16:45 -0500)]
add a `nested_visit_map` method

This allows you to enable *all* nested visits in a future-compatible
sort of way. Moreover, if you choose to override the `visit_nested`
methods yourself, you can "future-proof" against omissions by overriding
`nested_visit_map` to panic.

7 years agomove duplicate checking into TypeCheck
Niko Matsakis [Wed, 9 Nov 2016 01:27:28 +0000 (20:27 -0500)]
move duplicate checking into TypeCheck

This completes the effort to not touch the impl-items during
`Collect(Impl)`.

7 years agomove `convert_impl_item` into the main loop
Niko Matsakis [Wed, 9 Nov 2016 01:26:59 +0000 (20:26 -0500)]
move `convert_impl_item` into the main loop

This is better because the edges will be accounted to
the impl item itself

7 years agomove the impl-params-constrained check out of collect
Niko Matsakis [Wed, 9 Nov 2016 00:23:09 +0000 (19:23 -0500)]
move the impl-params-constrained check out of collect

This helps with incr. comp. because otherwise the Collect(Impl) check
winds up touching all of the impl items; since Collect(Impl) also
produces the types for the impl header, this creates a polluted graph
where the impl types depend on the impl items.

7 years agofactor out collection of impl-items into a distinct fn
Niko Matsakis [Tue, 8 Nov 2016 18:23:59 +0000 (13:23 -0500)]
factor out collection of impl-items into a distinct fn

7 years agofix dep-graph checking to account for implitems
Niko Matsakis [Fri, 11 Nov 2016 15:02:10 +0000 (10:02 -0500)]
fix dep-graph checking to account for implitems

7 years agomake distinct Hir() nodes in the graph for impl items
Niko Matsakis [Tue, 8 Nov 2016 16:16:39 +0000 (11:16 -0500)]
make distinct Hir() nodes in the graph for impl items

7 years agofallout from separating impl-items from impls
Niko Matsakis [Fri, 4 Nov 2016 22:20:15 +0000 (18:20 -0400)]
fallout from separating impl-items from impls

Basically adding `visit_impl_item` in various places and so forth.

7 years agoAdd missing urls and improve internal doc representation
Guillaume Gomez [Wed, 16 Nov 2016 18:56:01 +0000 (19:56 +0100)]
Add missing urls and improve internal doc representation

7 years agoseparate impl-items from the impl in the HIR
Niko Matsakis [Wed, 2 Nov 2016 22:25:31 +0000 (18:25 -0400)]
separate impl-items from the impl in the HIR

This commit does not change how the incremental accounting is done, so
changes (or accessses) to an impl-item are still tagged to the enclosing
impl.

This commits adds the "main guts" of this change. It does not build on
its own.

7 years agorefactor Visitor into ItemLikeVisitor and intravisit::Visitor
Niko Matsakis [Wed, 2 Nov 2016 22:22:59 +0000 (18:22 -0400)]
refactor Visitor into ItemLikeVisitor and intravisit::Visitor

There are now three patterns (shallow, deep, and nested visit).  These
are described in detail on the docs in `itemlikevisit::ItemLikeVisitor`.

7 years agoICH: Add test case for type alias definitions
Michael Woerister [Wed, 16 Nov 2016 16:56:18 +0000 (11:56 -0500)]
ICH: Add test case for type alias definitions

7 years agoAuto merge of #37545 - alexcrichton:crt-static, r=brson
bors [Wed, 16 Nov 2016 16:25:38 +0000 (08:25 -0800)]
Auto merge of #37545 - alexcrichton:crt-static, r=brson

rustc: Implement #[link(cfg(..))] and crt-static

This commit is an implementation of [RFC 1721] which adds a new target feature
to the compiler, `crt-static`, which can be used to select how the C runtime for
a target is linked. Most targets dynamically linke the C runtime by default with
the notable exception of some of the musl targets.

[RFC 1721]: https://github.com/rust-lang/rfcs/blob/master/text/1721-crt-static.md

This commit first adds the new target-feature, `crt-static`. If enabled, then
the `cfg(target_feature = "crt-static")` will be available. Targets like musl
will have this enabled by default. This feature can be controlled through the
standard target-feature interface, `-C target-feature=+crt-static` or
`-C target-feature=-crt-static`.

Next this adds an gated and unstable `#[link(cfg(..))]` feature to enable the
`crt-static` semantics we want with libc. The exact behavior of this attribute
is a little squishy, but it's intended to be a forever-unstable
implementation detail of the liblibc crate.

Specifically the `#[link(cfg(..))]` annotation means that the `#[link]`
directive is only active in a compilation unit if that `cfg` value is satisfied.
For example when compiling an rlib, these directives are just encoded and
ignored for dylibs, and all staticlibs are continued to be put into the rlib as
usual. When placing that rlib into a staticlib, executable, or dylib, however,
the `cfg` is evaluated *as if it were defined in the final artifact* and the
library is decided to be linked or not.

Essentially, what'll happen is:

* On MSVC with `-C target-feature=-crt-static`, the `msvcrt.lib` library will be
  linked to.
* On MSVC with `-C target-feature=+crt-static`, the `libcmt.lib` library will be
  linked to.
* On musl with `-C target-feature=-crt-static`, the object files in liblibc.rlib
  are removed and `-lc` is passed instead.
* On musl with `-C target-feature=+crt-static`, the object files in liblibc.rlib
  are used and `-lc` is not passed.

This commit does **not** include an update to the liblibc module to implement
these changes. I plan to do that just after the 1.14.0 beta release is cut to
ensure we get ample time to test this feature.

cc #37406

7 years agorustc: Implement #[link(cfg(..))] and crt-static
Alex Crichton [Mon, 31 Oct 2016 23:40:13 +0000 (16:40 -0700)]
rustc: Implement #[link(cfg(..))] and crt-static

This commit is an implementation of [RFC 1721] which adds a new target feature
to the compiler, `crt-static`, which can be used to select how the C runtime for
a target is linked. Most targets dynamically linke the C runtime by default with
the notable exception of some of the musl targets.

[RFC 1721]: https://github.com/rust-lang/rfcs/blob/master/text/1721-crt-static.md

This commit first adds the new target-feature, `crt-static`. If enabled, then
the `cfg(target_feature = "crt-static")` will be available. Targets like musl
will have this enabled by default. This feature can be controlled through the
standard target-feature interface, `-C target-feature=+crt-static` or
`-C target-feature=-crt-static`.

Next this adds an gated and unstable `#[link(cfg(..))]` feature to enable the
`crt-static` semantics we want with libc. The exact behavior of this attribute
is a little squishy, but it's intended to be a forever-unstable
implementation detail of the liblibc crate.

Specifically the `#[link(cfg(..))]` annotation means that the `#[link]`
directive is only active in a compilation unit if that `cfg` value is satisfied.
For example when compiling an rlib, these directives are just encoded and
ignored for dylibs, and all staticlibs are continued to be put into the rlib as
usual. When placing that rlib into a staticlib, executable, or dylib, however,
the `cfg` is evaluated *as if it were defined in the final artifact* and the
library is decided to be linked or not.

Essentially, what'll happen is:

* On MSVC with `-C target-feature=-crt-static`, the `msvcrt.lib` library will be
  linked to.
* On MSVC with `-C target-feature=+crt-static`, the `libcmt.lib` library will be
  linked to.
* On musl with `-C target-feature=-crt-static`, the object files in liblibc.rlib
  are removed and `-lc` is passed instead.
* On musl with `-C target-feature=+crt-static`, the object files in liblibc.rlib
  are used and `-lc` is not passed.

This commit does **not** include an update to the liblibc module to implement
these changes. I plan to do that just after the 1.14.0 beta release is cut to
ensure we get ample time to test this feature.

cc #37406

7 years agoAuto merge of #37774 - frewsxcv:path-doc-example, r=brson
bors [Wed, 16 Nov 2016 13:06:30 +0000 (05:06 -0800)]
Auto merge of #37774 - frewsxcv:path-doc-example, r=brson

Update top-level path doc examples to show results.

None

7 years agoAuto merge of #37773 - ollie27:rustdoc_inline_glob, r=brson
bors [Wed, 16 Nov 2016 09:17:53 +0000 (01:17 -0800)]
Auto merge of #37773 - ollie27:rustdoc_inline_glob, r=brson

rustdoc: Fix some local inlining issues

* Only inline public items when inlining glob imports.
* Never inline while in a private module or a child of a private module.
* Never inline impls. This allowed the removal of a workaround in the
rendering code.

7 years agoImprove proc macro def ids.
Jeffrey Seyfried [Wed, 16 Nov 2016 06:10:34 +0000 (06:10 +0000)]
Improve proc macro def ids.

7 years agoAuto merge of #37764 - nnethercote:shrink-scope_auxiliary, r=nikomatsakis
bors [Wed, 16 Nov 2016 04:43:53 +0000 (20:43 -0800)]
Auto merge of #37764 - nnethercote:shrink-scope_auxiliary, r=nikomatsakis

Remove `scope_auxiliary`.

`scope_auxiliary` is a big part of the high memory usage in #36799. It's only used for MIR dumping. I have taken a hubristic approach: I have assumed that particular use is unimportant and removed `scope_auxiliary` and related things. This reduces peak RSS by ~10% for a cut-down version of the program in #36799.

If that assumption is wrong perhaps we can avoid building `scope_auxiliary` unless MIR dumping is enabled.

7 years agoAuto merge of #37758 - euclio:unstable, r=brson
bors [Tue, 15 Nov 2016 23:59:52 +0000 (15:59 -0800)]
Auto merge of #37758 - euclio:unstable, r=brson

do not use deprecated text for unstable docs

![2016-11-13-18 55 23](https://cloud.githubusercontent.com/assets/1372438/20249943/d7f684a2-a9d2-11e6-8c5a-a2bfe354b9aa.png)
![2016-11-13-18 55 12](https://cloud.githubusercontent.com/assets/1372438/20249942/d7f6595a-a9d2-11e6-9240-07f5a89367f4.png)

![2016-11-13-18 54 00](https://cloud.githubusercontent.com/assets/1372438/20249946/da176d46-a9d2-11e6-8f34-c09cff9bcc15.png)
![2016-11-13-18 54 45](https://cloud.githubusercontent.com/assets/1372438/20249941/d7d9837a-a9d2-11e6-99f4-e4bf8807b1c9.png)

7 years agoregister `infer-ok` obligations properly
Niko Matsakis [Wed, 24 Aug 2016 22:09:46 +0000 (18:09 -0400)]
register `infer-ok` obligations properly

Or at least, more properly. I think I left one or two FIXMEs still in
there.

cc #32730

7 years agoremove TypeOrigin and use ObligationCause instead
Niko Matsakis [Mon, 7 Nov 2016 18:25:06 +0000 (13:25 -0500)]
remove TypeOrigin and use ObligationCause instead

In general having all these different structs for "origins" is not
great, since equating types can cause obligations and vice-versa.  I
think we should gradually collapse these things. We almost certainly
also need to invest a big more energy into the `error_reporting` code to
rationalize it: this PR does kind of the minimal effort in that
direction.

7 years agoAuto merge of #37742 - mrhota:llvm_debuginfo, r=alexcrichton
bors [Tue, 15 Nov 2016 17:10:23 +0000 (09:10 -0800)]
Auto merge of #37742 - mrhota:llvm_debuginfo, r=alexcrichton

Add llvm debuginfo configure option

CC @nnethercote @Mark-Simulacrum

We add a new configure option, `--enable-llvm-debuginfo`, to do exactly what you'd think.

Re: #31033

Fixes #37738

7 years agoAuto merge of #37714 - alexcrichton:builtins-hidden, r=nikomatsakis
bors [Tue, 15 Nov 2016 12:42:28 +0000 (04:42 -0800)]
Auto merge of #37714 - alexcrichton:builtins-hidden, r=nikomatsakis

rustc: Flag all builtins functions as hidden

When compiling compiler-rt you typically compile with `-fvisibility=hidden`
which to ensure that all symbols are hidden in shared objects and don't show up
in symbol tables. This is important for these intrinsics being linked in every
crate to ensure that we're not unnecessarily bloating the public ABI of Rust
crates.

This should help allow the compiler-builtins project with Rust-defined builtins
start landing in-tree as well.

7 years agoAuto merge of #37672 - japaric:msp430, r=alexcrichton
bors [Tue, 15 Nov 2016 09:27:47 +0000 (01:27 -0800)]
Auto merge of #37672 - japaric:msp430, r=alexcrichton

enable the MSP430 LLVM backend

to let people experiment with this target out of tree.

The MSP430 architecture is used in 16-bit microcontrollers commonly used
in Digital Signal Processing applications.

---

How this was tested:

Declaring a custom target with the following specification:

``` json
{
  "arch": "msp430",
  "data-layout": "e-m:e-p:16:16-i32:16:32-a:16-n8:16",
  "executables": true,
  "linker": "msp430-gcc",
  "llvm-target": "msp430",
  "max-atomic-width": 0,
  "no-integrated-as": true,
  "os": "none",
  "panic-strategy": "abort",
  "relocation-model": "static",
  "target-endian": "little",
  "target-pointer-width": "16"
}
```

And this minimal file:

``` rust

pub fn start() -> ! {
    loop {}
}

trait Copy {}

trait Sized {}
```

Produces the following object files:

```
$ rustc --target=msp430 --emit=obj foo.rs

$ msp430-objdump -Cd foo.o

foo.o:     file format elf32-msp430

Disassembly of section .text.start:

00000000 <start>:
   0:   21 83           decd    r1
   2:   00 3c           jmp     $+2             ;abs 0x4
   4:   00 3c           jmp     $+2             ;abs 0x6
   6:   ff 3f           jmp     $+0             ;abs 0x6

$ rustc --target=msp430 --emit=obj foo.rs -O

$ msp430-objdump -Cd foo.o

foo.o:     file format elf32-msp430

Disassembly of section .text.start:

00000000 <start>:
   0:   ff 3f           jmp     $+0             ;abs 0x0
```

---

r? @alexcrichton
~~TODO get this working with Makefiles so nightly releases include this backend~~
~~TODO measure the increase in binary size~~ +187KiB (+0.47%)
~~FIXME --emit=obj produces empty object files~~

7 years agoAuto merge of #37775 - alexcrichton:try-fix-dox, r=brson
bors [Tue, 15 Nov 2016 02:12:26 +0000 (18:12 -0800)]
Auto merge of #37775 - alexcrichton:try-fix-dox, r=brson

rustbuild: Tweak default rule inclusion

If a rule is flagged with `default(true)` then the pseudo-rule `default:foo`
will include that. If a rule is also flagged with `.host(true)`, however, then
the rule shouldn't be included for targets that aren't in the host array. This
adds a filter to ensure we don't pull in host rules for targets by accident.

7 years agoAuto merge of #37771 - alexcrichton:fix-nightlies, r=brson
bors [Mon, 14 Nov 2016 22:04:54 +0000 (14:04 -0800)]
Auto merge of #37771 - alexcrichton:fix-nightlies, r=brson

test: Move missing-items to a ui test

This test is failing on nightly for unknown reasons, and my best guess is a
difference in grep versions which is interpreting symbols differently. For now
let's just move this to a ui test and hope it fixes nightlies.

7 years agoUpdate top-level path doc examples to show results.
Corey Farwell [Mon, 14 Nov 2016 20:51:15 +0000 (15:51 -0500)]
Update top-level path doc examples to show results.

7 years agorustbuild: Tweak default rule inclusion
Alex Crichton [Mon, 14 Nov 2016 20:50:38 +0000 (12:50 -0800)]
rustbuild: Tweak default rule inclusion

If a rule is flagged with `default(true)` then the pseudo-rule `default:foo`
will include that. If a rule is also flagged with `.host(true)`, however, then
the rule shouldn't be included for targets that aren't in the host array. This
adds a filter to ensure we don't pull in host rules for targets by accident.

7 years agoAuto merge of #37740 - bluss:corrected-vec-collect, r=alexcrichton
bors [Mon, 14 Nov 2016 19:07:29 +0000 (11:07 -0800)]
Auto merge of #37740 - bluss:corrected-vec-collect, r=alexcrichton

Restore Vec::from_iter() specialization

Since I said "no intentional functional change" in the previous commit,
I guess it was inevitable there were unintentional changes. Not
functional, but optimization-wise. This restores the extend
specialization's use in Vec::from_iter. (commit 1).

Also use specialization in from_iter to reduce allocation code duplication
for the TrustedLen case (commit 2).

Bug introduced in PR #37709

7 years agorustdoc: Fix some local inlining issues
Oliver Middleton [Mon, 14 Nov 2016 18:24:47 +0000 (18:24 +0000)]
rustdoc: Fix some local inlining issues

* Only inline public items when inlining glob imports.
* Never inline while in a private module or a child of a private module.
* Never inline impls. This allowed the removal of a workaround in the
rendering code.

7 years agoadd test for #37765
Alex Burka [Mon, 14 Nov 2016 17:35:37 +0000 (12:35 -0500)]
add test for #37765

7 years agotest: Move missing-items to a ui test
Alex Crichton [Mon, 14 Nov 2016 17:23:17 +0000 (09:23 -0800)]
test: Move missing-items to a ui test

This test is failing on nightly for unknown reasons, and my best guess is a
difference in grep versions which is interpreting symbols differently. For now
let's just move this to a ui test and hope it fixes nightlies.

7 years agoRemove thread-per-CPU bit as it may not be accurate.
Steve Smith [Mon, 14 Nov 2016 16:43:25 +0000 (16:43 +0000)]
Remove thread-per-CPU bit as it may not be accurate.

7 years agorustbuild: Allow configuration of python interpreter
Alex Crichton [Mon, 14 Nov 2016 16:04:39 +0000 (08:04 -0800)]
rustbuild: Allow configuration of python interpreter

Add a configuration key to `config.toml`, read it from `./configure`, and add
auto-detection if none of those were specified.

Closes #35760

7 years agoTypo in new section
Steve Smith [Mon, 14 Nov 2016 14:21:35 +0000 (14:21 +0000)]
Typo in new section

7 years agoAuto merge of #37755 - polo-language:doc-punct, r=GuillaumeGomez
bors [Mon, 14 Nov 2016 14:00:27 +0000 (06:00 -0800)]
Auto merge of #37755 - polo-language:doc-punct, r=GuillaumeGomez

Improved punctuation, capitalization, and sentence structure of code snippet comments

r? @GuillaumeGomez

7 years agoAdd sections about concurrency and stdout/err capture to the Testing chapter of the...
Steve Smith [Mon, 14 Nov 2016 13:52:43 +0000 (13:52 +0000)]
Add sections about concurrency and stdout/err capture to the Testing chapter of the book.

7 years agoAdd warnings when the #[should_panic] attribute is invalid
Josh Driver [Sun, 13 Nov 2016 09:09:27 +0000 (19:39 +1030)]
Add warnings when the #[should_panic] attribute is invalid

7 years agoAuto merge of #37278 - matklad:lone-lifetime, r=jseyfried
bors [Mon, 14 Nov 2016 10:46:12 +0000 (02:46 -0800)]
Auto merge of #37278 - matklad:lone-lifetime, r=jseyfried

Fix syntax error in the compiler

Currently `rustc` accepts the following code: `fn f<'a>() where 'a {}`. This should be a syntax error, shouldn't it?

Not sure if my changes actually compile, waiting for the LLVM to build.

7 years agodon't build an object file for emit=asm,llvm-ir
Jorge Aparicio [Mon, 14 Nov 2016 08:37:46 +0000 (03:37 -0500)]
don't build an object file for emit=asm,llvm-ir

7 years agoAuto merge of #37754 - frewsxcv:path-push, r=GuillaumeGomez
bors [Mon, 14 Nov 2016 07:31:54 +0000 (23:31 -0800)]
Auto merge of #37754 - frewsxcv:path-push, r=GuillaumeGomez

Minor rewriting of `std::path::Path::push` doc example.

None

7 years agoFix where clauses parsing
Aleksey Kladov [Wed, 19 Oct 2016 15:21:27 +0000 (18:21 +0300)]
Fix where clauses parsing

Don't allow lifetimes without any bounds at all

7 years agoRemove `scope_auxiliary`.
Nicholas Nethercote [Thu, 3 Nov 2016 03:22:57 +0000 (14:22 +1100)]
Remove `scope_auxiliary`.

This reduces the peak RSS for a cut-down version of the program
in #36799 by 10%, from 951MB to 856MB.

7 years agorustdoc: add cli argument `--playground-url`
Liigo [Fri, 11 Nov 2016 07:36:49 +0000 (15:36 +0800)]
rustdoc: add cli argument `--playground-url`

7 years agoAuto merge of #37640 - michaelwoerister:llvm-type-names, r=brson
bors [Mon, 14 Nov 2016 03:46:34 +0000 (19:46 -0800)]
Auto merge of #37640 - michaelwoerister:llvm-type-names, r=brson

trans: Make type names in LLVM IR independent of crate-nums and source locations.

UPDATE:
This PR makes the type names we assign in LLVM IR independent of the type definition's location in the source code and the order in which extern crates are loaded. The new type names look like the old ones, except for closures and the `<crate-num>.` prefix being gone. Resolution of name clashes (e.g. of the same type in different crate versions) is left to LLVM (which will just append `.<counter>` to the name).

ORIGINAL TEXT:
This PR makes the type names we assign in LLVM IR independent of the type definition's location in the source code. Before, the type of closures contained the closures definition location. The new naming scheme follows the same pattern that we already use for symbol names: We have a human readable prefix followed by a hash that makes sure we don't have any collisions. Here is an example of what the new names look like:

```rust
// prog.rs - example program

mod mod1
{
    pub struct Struct<T>(pub T);
}

fn main() {
    use mod1::Struct;

    let _s = Struct(0u32);
    let _t = Struct('h');
    let _x = Struct(Struct(0i32));
}
```
Old:
```llvm
%"mod1::Struct<u32>" = type { i32 }
%"mod1::Struct<char>" = type { i32 }
%"mod1::Struct<mod1::Struct<i32>>" = type { %"mod1::Struct<i32>" }
%"mod1::Struct<i32>" = type { i32 }
```
New:
```llvm
%"prog::mod1::Struct<u32>::ejDrT" = type { i32 }
%"prog::mod1::Struct<char>::2eEAU" = type { i32 }
%"prog::mod1::Struct<prog::mod1::Struct<i32>>::ehCqR" = type { %"prog::mod1::Struct<i32>::$fAo2" }
%"prog::mod1::Struct<i32>::$fAo2" = type { i32 }
```

As you can see, the new names are slightly more verbose, but also more consistent. There is no difference now between a local type and one from another crate (before, non-local types where prefixed with `<crate-num>.` as in `2.std::mod1::Type1`).

There is a bit of design space here. For example, we could leave off the crate name for local definitions (making names shorter but less consistent):
```llvm
%"mod1::Struct<u32>::ejDrT" = type { i32 }
%"mod1::Struct<char>::2eEAU" = type { i32 }
%"mod1::Struct<mod1::Struct<i32>>::ehCqR" = type { %"mod1::Struct<i32>::$fAo2" }
%"mod1::Struct<i32>::$fAo2" = type { i32 }
```

We could also put the hash in front, which might be more readable:
```llvm
%"ejDrT.mod1::Struct<u32>" = type { i32 }
%"2eEAU.mod1::Struct<char>" = type { i32 }
%"ehCqR.mod1::Struct<mod1::Struct<i32>>" = type { %"$fAo2.mod1::Struct<i32>" }
%"$fAo2.mod1::Struct<i32>" = type { i32 }
```

We could probably also get rid of the hash if we used full DefPaths and crate-nums (though I'm not yet a 100% sure if crate-nums could mess with incremental compilation).

```llvm
%"mod1::Struct<u32>" = type { i32 }
%"mod1::Struct<char>" = type { i32 }
%"mod1::Struct<mod1::Struct<i32>>" = type { %"mod1::Struct<i32>" }
%"mod1::Struct<i32>" = type { i32 }
%"2.std::mod1::Type1" = type { ... }
```
I would prefer the solution with the hashes because it is nice and consistent conceptually, but visually it's admittedly a bit uglier. Maybe @rust-lang/compiler would like to bikeshed a little about this.

On a related note: Has anyone ever tried if the LTO-linker will merge equal types with different names?
(^ @brson, @alexcrichton ^)
If not, that would be a reason to make type names more consistent.

7 years agoAdd semicolon to "perhaps add a `use` for one of them" help
Robin Stocker [Mon, 14 Nov 2016 01:57:19 +0000 (12:57 +1100)]
Add semicolon to "perhaps add a `use` for one of them" help

Similar to pull request #37430, this makes the message more copy-paste
friendly and aligns it with other messages like:

    help: you can import it into scope: use foo::Bar;

7 years agoRemove unused method CrateContext::rotate().
Michael Woerister [Mon, 7 Nov 2016 19:40:52 +0000 (14:40 -0500)]
Remove unused method CrateContext::rotate().

7 years agoAdapt accidentally fixed test case.
Michael Woerister [Mon, 7 Nov 2016 18:33:21 +0000 (13:33 -0500)]
Adapt accidentally fixed test case.

7 years agoFix codegen test after change of llvm type naming scheme
Michael Woerister [Tue, 8 Nov 2016 18:23:57 +0000 (13:23 -0500)]
Fix codegen test after change of llvm type naming scheme

7 years agoMake names of types used in LLVM IR stable.
Michael Woerister [Fri, 4 Nov 2016 21:37:42 +0000 (17:37 -0400)]
Make names of types used in LLVM IR stable.

Before this PR, type names could depend on the cratenum being used
for a given crate and also on the source location of closures.
Both are undesirable for incremental compilation where we cache
LLVM IR and don't want it to depend on formatting or in which
order crates are loaded.