bors [Fri, 17 May 2019 03:52:27 +0000 (03:52 +0000)]
Auto merge of #60817 - ecstatic-morse:issue-60779, r=Centril
Add stubs to keyword docs
Resolves #60779.
This commit gives each stable keyword a short entry in the "Keywords" section in the docs for `std`. The newly added entries are only a single line each and contain the main purpose of the keyword. I changed some of the existing summary lines for consistency's sake. Each line is either an imperative ("name the type of a trait object" for `dyn`), or an object ("An abstract data type" for `enum`). I tried to avoid using the keyword itself or the word "keyword" in the summary.
Later commits can flesh out each keyword with an example for each context in which it can appear as well as a link to the appropriate part of the rust book.
**edit:**
Here's the list of keywords and summaries (sans formatting) to ease reviewing. I'll try to keep this up to date as I make changes:
keyword | summary
-- | --
Self | The implementing type within a `trait` or `impl` block, or the current type within a type definition.
as | Cast between types, or rename an import.
async | ExperimentalReturn a Future instead of blocking the current thread.
await | ExperimentalSuspend execution until the result of a Future is ready.
break | Exit early from a loop.
const | Compile-time constants and deterministic functions.
continue | Skip to the next iteration of a loop.
crate | A Rust binary or library.
dyn | Name the type of a trait object.
else | What to do when an if condition does not hold.
enum | A type that can be any one of several variants.
extern | Link to or import external code.
false | A value of type bool representing logical false.
fn | A function or function pointer.
for | Iteration with in, trait implementation with impl, or higher-ranked trait bounds (for<'a>).
if | Evaluate a block if a condition holds.
impl | Implement some functionality for a type.
in | Iterate over a series of values with for.
let | Bind a value to a variable.
loop | Loop indefinitely.
match | Control flow based on pattern matching.
mod | Organize code into modules.
move | Capture a closure's environment by value.
mut | A mutable binding, reference, or pointer.
pub | Make an item visible to others.
ref | Bind by reference during pattern matching.
return | Return a value from a function.
self | The receiver of a method, or the current module.
static | A place that is valid for the duration of a program.
struct | A type that is composed of other types.
super | The parent of the current module.
trait | A common interface for a class of types.
true | A value of type bool representing logical true.
type | Define an alias for an existing type.
union | The Rust equivalent of a C-style union.
unsafe | Code or interfaces whose memory safety cannot be verified by the type system.
use | Import or rename items from other crates or modules.
where | Add constraints that must be upheld to use an item.
while | Loop while a condition is upheld.
bors [Fri, 17 May 2019 00:55:01 +0000 (00:55 +0000)]
Auto merge of #60898 - Centril:rollup-76o2g8a, r=Centril
Rollup of 6 pull requests
Successful merges:
- #60685 (Switch to SPDX 2.1 license expression)
- #60687 (Fix .natvis visualizers.)
- #60805 (remove compiletest's dependency on `filetime`)
- #60862 (Get ty from local_decls instead of using Place)
- #60873 (Parse alternative incorrect uses of await and recover)
- #60894 (Add entry-like methods to HashSet)
Rollup merge of #60687 - MaulingMonkey:pr-fix-natvis-files, r=alexcrichton
Fix .natvis visualizers.
### Updated to handle these changes:
- `core::ptr::*` lost their `__0` elements and are just plain pointers
- `core::ptr::*` probably shouldn't dereference in `DisplayString` s
- `VecDeque` probably *should* dereference it's buf pointer to display individual items.
- `VecDeque` and `Vec` use `core::ptr::*` s
- `VecDeque` and `LinkedList` moved modules again.
### Retested - still working fine, left alone:
- `String`, `&str`, `Option`
### Side Chatter
- Props to Alex for pointing out this was broken in the `#ides-and-editors` Discord channel
- It'd be nice if there was a sane way to automate unit testing these visualizers.
(I assume COM automation of Visual Studio would be a no go on the build servers, and probably really incredibly painful to write too! Suggestions welcome...)
Rollup merge of #60685 - dtolnay:spdx, r=nikomatsakis
Switch to SPDX 2.1 license expression
[According to the Cargo Reference:](https://doc.rust-lang.org/cargo/reference/manifest.html)
> This is an SPDX 2.1 license expression for this package. Currently crates.io will validate the license provided against a whitelist of known license and exception identifiers from the SPDX license list 2.4. Parentheses are not currently supported.
>
> Multiple licenses can be separated with a \`/\`, although that usage is deprecated. Instead, use a license expression with AND and OR operators to get more explicit semantics.
The notation with slashes is deprecated in favor of explicit AND or OR.
As I understand it, Rust's license is MIT *OR* Apache-2.0 matching the meaning of *OR* defined by [SPDX Specification 2.1](https://spdx.org/spdx-specification-21-web-version):
> If presented with a choice between two or more licenses, use the disjunctive binary "OR" operator to construct a new license expression, where both the left and right operands are valid license expression values.
Dylan MacKenzie [Tue, 14 May 2019 09:32:55 +0000 (02:32 -0700)]
Add all keywords to keyword docs
This commit gives each stable keyword a short entry in the "Keywords"
section in the docs for `std`. The newly added entries are a single
summary line and a note that the documentation is not yet complete. I
changed some of the existing summary lines for consistency's sake. Each
line is either a verb phrase ("name the type of a trait object" for
`dyn`), or an object ("A value of type `bool` representing logical true"
for `true`). I tried to avoid using the keyword itself or the word
"keyword" in the summary.
Later PRs can flesh out each keyword with an example of each
context in which a keyword can appear and a link to the rust book.
Keywords which are not close to stable rust such as `box` (which is
getting unstabilized) or `try` are ignored in this PR.
Rollup merge of #60278 - ehuss:doc-html_root_url, r=GuillaumeGomez
Document the `html_root_url` doc attribute value.
I'm not sure if this was intentionally not documented, but I think it would be good to include. This was added in #9691. `--extern-html-root-url` is unstable, but I don't think it hurts to mention it.
bors [Thu, 16 May 2019 18:57:00 +0000 (18:57 +0000)]
Auto merge of #60874 - ehuss:update-cargo, r=alexcrichton
Update cargo
17 commits in 759b6161a328db1d4863139e90875308ecd25a75..c4fcfb725b4be00c72eb9cf30c7d8b095577c280
2019-05-06 20:47:49 +0000 to 2019-05-15 19:48:47 +0000
- tests: registry: revert readonly permission after running tests. (rust-lang/cargo#6947)
- Remove Candidate (rust-lang/cargo#6946)
- Fix for "Running cargo update without a Cargo.lock ignores arguments" rust-lang/cargo#6872 (rust-lang/cargo#6904)
- Fix a minor mistake in the changelog. (rust-lang/cargo#6944)
- Give a better error message when crates.io requests time out (rust-lang/cargo#6936)
- Re-enable compatibility with readonly CARGO_HOME (rust-lang/cargo#6940)
- Fix version of `ignore`. (rust-lang/cargo#6938)
- Stabilize offline mode. (rust-lang/cargo#6934)
- zsh: Add doc options to include non-public items documentation (rust-lang/cargo#6929)
- zsh: Suggest --lib option as binary template now the default (rust-lang/cargo#6926)
- Migrate package include/exclude to gitignore patterns. (rust-lang/cargo#6924)
- Implement the Cargo half of pipelined compilation (take 2) (rust-lang/cargo#6883)
- Always include `Cargo.toml` when packaging. (rust-lang/cargo#6925)
- Remove unnecessary calls to masquerade_as_nightly_cargo. (rust-lang/cargo#6923)
- download: fix "Downloaded 1 crates" message (crates -> crate) (rust-lang/cargo#6920)
- Changed RUST_LOG usage to CARGO_LOG to avoid confusion. (rust-lang/cargo#6918)
- crate download: don't print that a crate was the largest download if it was the only download (rust-lang/cargo#6916)
bors [Thu, 16 May 2019 09:58:30 +0000 (09:58 +0000)]
Auto merge of #60877 - Centril:rollup-j0o5mo5, r=Centril
Rollup of 6 pull requests
Successful merges:
- #59825 (string: implement From<&String> for String)
- #59923 (Fix convert module's documentation links)
- #60691 (Include expression to wait for to the span of Await)
- #60769 (Update rustc book CLI docs.)
- #60816 (README.md: Mention MSVC 2017+, not 2013(!))
- #60851 (Move `box` from the stable keyword to unstable keywords list)
Rollup merge of #60769 - ehuss:rustc-cli-docs, r=steveklabnik
Update rustc book CLI docs.
This adds a little detail (and missing flags) to the rustc book. There is still a lot of information missing, but this seemed like a good step to expanding it.
Rollup merge of #59825 - jsgf:from-ref-string, r=sfackler
string: implement From<&String> for String
Allow Strings to be created from borrowed Strings. This is mostly
to make things like passing `&String` to an `impl Into<String>`
parameter frictionless.
bors [Wed, 15 May 2019 04:34:14 +0000 (04:34 +0000)]
Auto merge of #60775 - hellow554:no_bitrig, r=joshtriplett
Remove bitrig support from rust
Resolves #60743
using `find` and `rg` I delete every occurence of "bitrig" in the sources, expect for the llvm submodule (is this correct?).
There's also this file https://github.com/rust-lang/rls/blob/5b8e99bb61958ca8abcb7c5eda70521726be1065/rls-analysis/test_data/rust-analysis/libstd-af9bacceee784405.json which contains a bitrig string in it. What to do with that?
bors [Tue, 14 May 2019 20:50:26 +0000 (20:50 +0000)]
Auto merge of #60834 - Centril:rollup-fikyi9i, r=Centril
Rollup of 9 pull requests
Successful merges:
- #60130 (Add implementations of last in terms of next_back on a bunch of DoubleEndedIterators)
- #60443 (as_ptr returns a read-only pointer)
- #60444 (forego caching for all participants in cycles, apart from root node)
- #60719 (Allow subdirectories to be tested by x.py test)
- #60780 (fix Miri)
- #60788 (default to $ARCH-apple-macosx10.7.0 LLVM triple for darwin targets)
- #60799 (Allow late-bound regions in existential types)
- #60808 (Improve the "must use" lint for `Future`)
- #60819 (submodules: update clippy from 3710ec59 to ad3269c4)
Changes:
````
Rustfmt all the things
Clippy dogfood
Update for compiletest changes
Use symbols instead of strings
Rustup to rustc 1.36.0-nightly (1764b2972 2019-05-12)
Add regression test for identity_conversion FP
UI test cleanup: Extract many_single_char_names tests
Add tests for empty_loop lint
Add in_macro again
Rename in_macro to in_macro_or_desugar
````
r? @oli-obk
Rollup merge of #60788 - froydnj:apple-target-modifications-followup, r=estebank
default to $ARCH-apple-macosx10.7.0 LLVM triple for darwin targets
Over in #60378, we made `rustc` switch LLVM target triples dynamically
based on the `MACOSX_DEPLOYMENT_TARGET` environment variable. This
change was made to align with `clang`'s behavior, and therefore make
cross-language LTO feasible on OS X. Otherwise, `rustc` would produce
LLVM bitcode files with a target triple of `x86_64-apple-darwin`,
`clang` would produce LLVM bitcode files with a target triple of
`x86_64-apple-macosx$VERSION`, and the linker would complain.
This change worked fine, except for one corner case: if you didn't have
`MACOSX_DEPLOYMENT_TARGET` set, and you wanted to do LTO on just Rust
code, you'd get warning messages similar to:
```
warning: Linking two modules of different target triples: ' is 'x86_64-apple-macosx10.7.0' whereas 'main.7rcbfp3g-cgu.4' is 'x86_64-apple-darwin'
```
This message occurs because libstd is compiled with
`MACOSX_DEPLOYMENT_TARGET` set to 10.7. The LLVM bitcode distributed in
libstd's rlibs, then, is tagged with the target triple of
`x86_64-apple-macosx10.7.0`, while the bitcode `rustc` produces for
"user" code is tagged with the target triple of `x86_64-apple-darwin`.
It's not good to have LTO on just Rust code (probably much more common
than cross-language LTO) warn by default. These warnings also break
Cargo's testsuite.
This change defaults to acting as though `MACOSX_DEPLOYMENT_TARGET` was
set to 10.7. "user" code will then be given a target triple that is
equivalent to the target triple libstd bitcode is already using. The
above warning will therefore go away.
`rustc` already assumes that compiling without
`MACOSX_DEPLOYMENT_TARGET` means that we're compiling for a target
compatible with OS X 10.7 (e.g. that things like TLS work properly). So
this change is really just making things conform more closely to the
status quo.
(It's also worth noting that before and after this patch, compiling with
`MACOSX_DEPLOYMENT_TARGET` set to, say, 10.9, works just fine: target
triples with an "apple" version ignore OS versions when checking
compatibility, so bitcode with a `x86_64-apple-macosx10.7.0` triple works just
fine with bitcode with a `x86_64-apple-macosx10.9.0` triple.)
As far as I can tell, multiple `--test-args` flags are ignored (only the first is respected), so if you specify a subdirectory, you won't also be able to filter using `--test-args`. If you don't specify a subdirectory, `--test-args` will continue working as usual, so this is strictly an improvement on the current state of affairs.
Rollup merge of #60444 - nikomatsakis:issue-60010-cycle-error-investigation, r=pnkfelix
forego caching for all participants in cycles, apart from root node
This is a targeted fix for #60010, which uncovered a pretty bad failure of our caching strategy in the face of coinductive cycles. The problem is explained in the comment in the PR on the new field, `in_cycle`, but I'll reproduce it here:
> Starts out as false -- if, during evaluation, we encounter a
> cycle, then we will set this flag to true for all participants
> in the cycle (apart from the "head" node). These participants
> will then forego caching their results. This is not the most
> efficient solution, but it addresses #60010. The problem we
> are trying to prevent:
>
> - If you have `A: AutoTrait` requires `B: AutoTrait` and `C: NonAutoTrait`
> - `B: AutoTrait` requires `A: AutoTrait` (coinductive cycle, ok)
> - `C: NonAutoTrait` requires `A: AutoTrait` (non-coinductive cycle, not ok)
>
> you don't want to cache that `B: AutoTrait` or `A: AutoTrait`
> is `EvaluatedToOk`; this is because they were only considered
> ok on the premise that if `A: AutoTrait` held, but we indeed
> encountered a problem (later on) with `A: AutoTrait. So we
> currently set a flag on the stack node for `B: AutoTrait` (as
> well as the second instance of `A: AutoTrait`) to supress
> caching.
>
> This is a simple, targeted fix. The correct fix requires
> deeper changes, but would permit more caching: we could
> basically defer caching until we have fully evaluated the
> tree, and then cache the entire tree at once.
I'm not sure what the impact of this fix will be in terms of existing crates or performance: we were accepting incorrect code before, so there will perhaps be some regressions, and we are now caching less.
As the comment above notes, we could do a lot better than this fix, but that would involve more invasive rewrites. I thought it best to start with something simple.
r? @pnkfelix -- but let's do crater/perf run
cc @arielb1
Rollup merge of #60443 - RalfJung:as_ptr, r=SimonSapin
as_ptr returns a read-only pointer
Add comments to `as_ptr` methods to warn that these are read-only pointers, and writing to them is UB.
[It was pointed out](https://internals.rust-lang.org/t/as-ptr-vs-as-mut-ptr/9940) that `CStr` does not even have an `as_mut_ptr`. I originally was going to add one, but there is no method at all that would mutate a `CStr`. Was that a deliberate choice or should I add an `as_mut_ptr` (similar to [what I did for `str`](https://github.com/rust-lang/rust/pull/58200))?
Rollup merge of #60130 - khuey:efficient_last, r=sfackler
Add implementations of last in terms of next_back on a bunch of DoubleEndedIterators
Provided a `DoubleEndedIterator` has finite length, `Iterator::last` is equivalent to `DoubleEndedIterator::next_back`. But searching forwards through the iterator when it's unnecessary is obviously not good for performance. I ran into this on one of the collection iterators.
I tried adding appropriate overloads for a bunch of the iterator adapters like filter, map, etc, but I ran into a lot of type inference failures after doing so.
The other interesting case is what to do with `Repeat`. Do we consider it part of the contract that `Iterator::last` will loop forever on it? The docs do say that the iterator will be evaluated until it returns None. This is also relevant for the adapters, it's trivially easy to observe whether a `Map` adapter invoked its closure a zillion times or just once for the last element.
bors [Tue, 14 May 2019 15:58:33 +0000 (15:58 +0000)]
Auto merge of #60787 - alexcrichton:error-type-id-destabilize-master, r=pietroalbini
Destabilize the `Error::type_id` function
This commit destabilizes the `Error::type_id` function in the standard library.
This does so by effectively reverting #58048, restoring the `#[unstable]`
attribute. The security mailing list has recently been notified of a
vulnerability relating to the stabilization of this function. First stabilized
in Rust 1.34.0, a stable function here allows users to implement a custom
return value for this function:
struct MyType;
impl Error for MyType {
fn type_id(&self) -> TypeId {
// Enable safe casting to `String` by accident.
TypeId::of::<String>()
}
}
This, when combined with the `Error::downcast` family of functions, allows
safely casting a type to any other type, clearly a memory safety issue! A
formal announcement has been made to the [security mailing list](https://groups.google.com/forum/#!topic/rustlang-security-announcements/aZabeCMUv70) as well as [the blog](https://blog.rust-lang.org/2019/05/13/Security-advisory.html)
This commit simply destabilizes the `Error::type_id` which, although breaking
for users since Rust 1.34.0, is hoped to have little impact and has been deemed
sufficient to mitigate this issue for the stable channel. The long-term fate of
the `Error::type_id` API will be discussed at #60784.
Changes:
````
Rustfmt all the things
Clippy dogfood
Update for compiletest changes
Use symbols instead of strings
Rustup to rustc 1.36.0-nightly (1764b2972 2019-05-12)
Add regression test for identity_conversion FP
UI test cleanup: Extract many_single_char_names tests
Add tests for empty_loop lint
Add in_macro again
Rename in_macro to in_macro_or_desugar
````
bors [Tue, 14 May 2019 03:09:46 +0000 (03:09 +0000)]
Auto merge of #60794 - Centril:rollup-vlguvns, r=Centril
Rollup of 5 pull requests
Successful merges:
- #60176 (Explain error when yielding a reference to a local variable)
- #60201 (coretest: Downgrade deny to warn)
- #60562 (Add #[doc(hidden)] attribute on compiler generated module.)
- #60710 (Use `delay_span_bug` for error cases when checking `AnonConst` parent)
- #60770 (add impl_trait_in_bindings to INCOMPLETE_FEATURES)
Nathan Froyd [Mon, 13 May 2019 15:03:48 +0000 (11:03 -0400)]
default to $ARCH-apple-macosx10.7.0 LLVM triple for darwin targets
Over in #60378, we made `rustc` switch LLVM target triples dynamically
based on the `MACOSX_DEPLOYMENT_TARGET` environment variable. This
change was made to align with `clang`'s behavior, and therefore make
cross-language LTO feasible on OS X. Otherwise, `rustc` would produce
LLVM bitcode files with a target triple of `x86_64-apple-darwin`,
`clang` would produce LLVM bitcode files with a target triple of
`x86_64-apple-macosx$VERSION`, and the linker would complain.
This change worked fine, except for one corner case: if you didn't have
`MACOSX_DEPLOYMENT_TARGET` set, and you wanted to do LTO on just Rust
code, you'd get warning messages similar to:
```
warning: Linking two modules of different target triples: ' is 'x86_64-apple-macosx10.7.0' whereas 'main.7rcbfp3g-cgu.4' is 'x86_64-apple-darwin'
```
This message occurs because libstd is compiled with
`MACOSX_DEPLOYMENT_TARGET` set to 10.7. The LLVM bitcode distributed in
libstd's rlibs, then, is tagged with the target triple of
`x86_64-apple-macosx10.7.0`, while the bitcode `rustc` produces for
"user" code is tagged with the target triple of `x86_64-apple-darwin`.
It's not good to have LTO on just Rust code (probably much more common
than cross-language LTO) warn by default. These warnings also break
Cargo's testsuite.
This change defaults to acting as though `MACOSX_DEPLOYMENT_TARGET` was
set to 10.7. "user" code will then be given a target triple that is
equivalent to the target triple libstd bitcode is already using. The
above warning will therefore go away.
`rustc` already assumes that compiling without
`MACOSX_DEPLOYMENT_TARGET` means that we're compiling for a target
compatible with OS X 10.7 (e.g. that things like TLS work properly). So
this change is really just making things conform more closely to the
status quo.
(It's also worth noting that before and after this patch, compiling with
`MACOSX_DEPLOYMENT_TARGET` set to, say, 10.9, works just fine: target
triples with an "apple" version ignore OS versions when checking
compatibility, so bitcode with a `x86_64-apple-macosx10.7.0` triple works just
fine with bitcode with a `x86_64-apple-macosx10.9.0` triple.)
Rollup merge of #60201 - RalfJung:core-tests, r=alexcrichton
coretest: Downgrade deny to warn
The `deny` causes a build failure in https://github.com/RalfJung/miri-test-libstd. Since we use `-D warnings` for rustc builds, `warn` should be enough to lead to compile errors here, without impeding external builds.
Alex Crichton [Mon, 13 May 2019 15:14:02 +0000 (08:14 -0700)]
Destabilize the `Error::type_id` function
This commit destabilizes the `Error::type_id` function in the standard library.
This does so by effectively reverting #58048, restoring the `#[unstable]`
attribute. The security mailing list has recently been notified of a
vulnerability relating to the stabilization of this function. First stabilized
in Rust 1.34.0, a stable function here allows users to implement a custom
return value for this function:
struct MyType;
impl Error for MyType {
fn type_id(&self) -> TypeId {
// Enable safe casting to `String` by accident.
TypeId::of::<String>()
}
}
This, when combined with the `Error::downcast` family of functions, allows
safely casting a type to any other type, clearly a memory safety issue! A
security announcement will be shortly posted to the security mailing list as
well as the Rust Blog, and when those links are available they'll be filled in
for this PR as well.
This commit simply destabilizes the `Error::type_id` which, although breaking
for users since Rust 1.34.0, is hoped to have little impact and has been deemed
sufficient to mitigate this issue for the stable channel. The long-term fate of
the `Error::type_id` API will be discussed at #60784.
bors [Mon, 13 May 2019 00:28:38 +0000 (00:28 +0000)]
Auto merge of #60630 - nnethercote:use-Symbol-more, r=petrochenkov
Use `Symbol` more
A `Symbol` can be equated with a string (e.g. `&str`). This involves a
TLS lookup to get the chars (and a Mutex lock in a parallel compiler)
and then a char-by-char comparison. This functionality is convenient but
avoids one of the main benefits of `Symbol`s, which is fast equality
comparisons.
This PR removes the `Symbol`/string equality operations, forcing a lot
of existing string occurrences to become `Symbol`s. Fortunately, these
are almost all static strings (many are attribute names) and we can add
static `Symbol`s as necessary, and very little extra interning occurs.
The benefits are (a) a slight speedup (possibly greater in a parallel
compiler), and (b) the code is a lot more principled about `Symbol` use.
The main downside is verbosity, particularly with more `use
syntax::symbol::symbols` items.