bors [Mon, 6 May 2019 00:16:16 +0000 (00:16 +0000)]
Auto merge of #60261 - matklad:one-escape, r=petrochenkov
introduce unescape module
A WIP PR to gauge early feedback
Currently, we deal with escape sequences twice: once when we [lex](https://github.com/rust-lang/rust/blob/112f7e9ac564e2cfcfc13d599c8376a219fde1bc/src/libsyntax/parse/lexer/mod.rs#L928-L1065) a string, and a second time when we [unescape](https://github.com/rust-lang/rust/blob/112f7e9ac564e2cfcfc13d599c8376a219fde1bc/src/libsyntax/parse/mod.rs#L313-L366) literals. Note that we also produce different sets of diagnostics in these two cases.
This PR aims to remove this duplication, by introducing a new `unescape` module as a single source of truth for character escaping rules.
I think this would be a useful cleanup by itself, but I also need this for https://github.com/rust-lang/rust/pull/59706.
In the current state, the PR has `unescape` module which fully (modulo bugs) deals with string and char literals. I am quite happy about the state of this module
What this PR doesn't have yet are:
* [x] handling of byte and byte string literals (should be simple to add)
* [x] good diagnostics
* [x] actual removal of code from lexer (giant `scan_char_or_byte` should go away completely)
* [x] performance check
* [x] general cleanup of the new code
Diagnostics will be the most labor-consuming bit here, but they are mostly a question of just correctly adjusting spans to sub-tokens. The current setup for diagnostics is that `unescape` produces a plain old `enum` with various problems, and they are rendered into `Handler` separately. This bit is not actually required (it is possible to just pass the `Handler` in), but I like the separation between diagnostics and logic this approach imposes, and such separation should again be useful for #59706
bors [Sun, 5 May 2019 21:11:47 +0000 (21:11 +0000)]
Auto merge of #60567 - Manishearth:rollup-rjagqnw, r=Manishearth
Rollup of 5 pull requests
Successful merges:
- #60131 (Fix broken link in rustc_plugin doc)
- #60426 (Stop `-O`/`-C opt-level` and `-g`/`-C debuginfo` conflicting)
- #60515 (use span instead of div for since version)
- #60530 (rustc: rename all occurences of "freevar" to "upvar".)
- #60536 (Correct code points to match their textual description)
Rollup merge of #60536 - brainplot:fix-unicode-character, r=dtolnay
Correct code points to match their textual description
Probably due to a copy-paste error, in the sentence
> For example, despite looking similar, the 'é' character is one Unicode code point while 'é' is two Unicode code points:
the two `é`'s were actually the same character in the text (i.e. the same Unicode character U+00E9).
The code listing below instead had two different Unicode characters for the two `é`s, as it was supposed to.
The example shown wasn't clear at first so I started inspecting the text and found this out.
I simply copied the character from the code listing to the description surrounding the code.
It's a minor thing but I thought it would make things clearer for others, especially since the example is about how Rust handles `char`s.
Rollup merge of #60530 - eddyb:unfreevars, r=oli-obk
rustc: rename all occurences of "freevar" to "upvar".
Most of the more recent code talks about "(closure) upvars", so I believe that's the name we want to use.
There's also the possibility of using "capture" which is more user-facing, but I'd rather not change *both* "freevar" and "upvar" to something else in this one PR.
Rollup merge of #60426 - varkor:fix-duplicate-arg-handling, r=alexcrichton
Stop `-O`/`-C opt-level` and `-g`/`-C debuginfo` conflicting
Allow `-O` and `-C opt-level`, and `-g` and `-C debuginfo` to be specified simultaneously without conflict. In such cases, the rightmost provided option is chosen.
bors [Sun, 5 May 2019 12:30:14 +0000 (12:30 +0000)]
Auto merge of #60544 - petrochenkov:parder, r=eddyb
Rename `PathResolution` to `PartialRes`
Don't use `PartialRes` when `Res` is enough.
Rename `Res::kind_name` to `Res::descr` for consistency.
Remove `Res::Label`, paths can never resolve to labels.
Some further cleanup after https://github.com/rust-lang/rust/pull/60462
r? @eddyb
bors [Sun, 5 May 2019 06:34:13 +0000 (06:34 +0000)]
Auto merge of #60525 - eddyb:namespaces-not-kinds, r=petrochenkov
rustc: collapse relevant DefPathData variants into {Type,Value,Macro,Lifetime}Ns.
`DefPathData` was meant to disambiguate within each namespace, but over the years, that purpose was overlooked, and it started to serve a double-role as a sort of `DefKind` (which #60462 properly adds).
Now, we can go back to *only* categorizing namespaces (at least for the variants with names in them).
r? @petrochenkov or @nikomatsakis cc @michaelwoerister
bors [Sat, 4 May 2019 21:50:11 +0000 (21:50 +0000)]
Auto merge of #60415 - jespersm:pr_unused_import_45268, r=petrochenkov
Fix #45268 by saving all NodeId's for resolved traits.
This fixes #45268 by saving all NodeId's for resolved traits.
I've verifies this against master (but only on MacOS). However, with some recent changes in master, it appears that there are some failures on my machine. They are unrelated to my changes, anyway.
Changes:
````
Rustup to rustc 1.36.0-nightly (13fde05b1 2019-05-03)
Fix link in into_iter_on_array documentation
remove function body from "too many args" span
check closure arguments before use it
format code
fix suggestion for search_is_some
fix suggestion for search_is_some naively
change |&x| to |x| in stderr file
cargo fmt
useless_let_if_seq handle interior mutability
````
Fixes https://github.com/rust-lang/rust/issues/60534
bors [Sat, 4 May 2019 10:22:05 +0000 (10:22 +0000)]
Auto merge of #60117 - sunfishcode:wasi-os, r=sunfishcode
Categorize WASI as an "OS" rather than as an "environment".
This distinction is fairly abstract, but in practice, the main advantage
here is that LLVM's triple code considers WASI to be an OS, so this
makes rustc agree with that.
Changes:
````
Rustup to rustc 1.36.0-nightly (13fde05b1 2019-05-03)
Fix link in into_iter_on_array documentation
remove function body from "too many args" span
check closure arguments before use it
format code
fix suggestion for search_is_some
fix suggestion for search_is_some naively
change |&x| to |x| in stderr file
cargo fmt
useless_let_if_seq handle interior mutability
````
Rollup merge of #60527 - davidtwco:issue-60518, r=cramertj
Fix async fn lowering ICE with APIT.
Fixes #60518.
This PR fixes an ICE where simple bindings (which aren't replaced with replacement arguments during async fn lowering) were not being visited in the def collector and thus caused an ICE during HIR lowering for types that use their `DefId` at that point - such as `impl Trait`.
Rollup merge of #60520 - matklad:rustfmt-all-the-new-things, r=Centril
Add rustfmt toml
This commit adds an rustfmt.toml for using for **new** code.
Old code should continut to use old style, until we put automated
style checks in place.
See
https://internals.rust-lang.org/t/running-rustfmt-on-rust-lang-rust-and-other-rust-lang-repositories/8732/81
for the reason why we deviate from the default formatting. The TL;DR
is that currently compiler uses a pretty condensed style of code, and
default settings both create a huge diff and inflate the number of
lines. use_small_heuristics=Max fixes that.
version=Two is required for bug-fixes, which technically can't be made
to the stable first version
cc @Centril: I guess adding config file with agreed-upon formatting doesn't hurt :-)
Rollup merge of #60486 - spastorino:place-related-refactors, r=oli-obk
Place related refactors
Meanwhile I was working on Place 2 I'm finding some little things that I had on my branch but preferred to land a separate PR for things that are simpler to merge.
Rollup merge of #60449 - matthewjasper:impl-trait-outlives, r=pnkfelix
Constrain all regions in the concrete type for an opaque type
`push_outlives_components` skips some regions in a type, notably the signature
of a closure is ignored. Most of the time this is OK, but for opaque types the
concrete type is used when checking auto-trait bounds in other functions.
Rollup merge of #60429 - estebank:pub-path, r=michaelwoerister
Account for paths in incorrect pub qualifier help
Handle case where incorrect pub qualifier with a mod path is used and provide the same help given for all other incorrect qualifiers by making the `pub(crate)` parse check more specific.
Dan Gohman [Fri, 19 Apr 2019 16:59:35 +0000 (09:59 -0700)]
Categorize WASI as an "OS" rather than as an "environment".
This distinction is fairly abstract, but in practice, the main advantage
here is that LLVM's triple code considers WASI to be an OS, so this
makes rustc agree with that.
bors [Sat, 4 May 2019 03:18:14 +0000 (03:18 +0000)]
Auto merge of #59897 - tmandry:variantful-generators, r=eddyb
Multi-variant layouts for generators
This allows generators to overlap fields using variants, but doesn't do any such overlapping yet. It creates one variant for every state of the generator (unresumed, returned, panicked, plus one for every yield), and puts every stored local in each of the yield-point variants.
Required for optimizing generator layouts (#52924).
There was quite a lot of refactoring needed for this change. I've done my best in later commits to eliminate assumptions in the code that only certain kinds of types are multi-variant, and to centralize knowledge of the inner mechanics of generators in as few places as possible.
This change also emits debuginfo about the fields contained in each variant, as well as preserving debuginfo about stored locals while running in the generator.
Also, fixes #59972.
Future work:
- Use this change for an optimization pass that actually overlaps locals within the generator struct (#52924)
- In the type layout fields, don't include locals that are uninitialized for a particular variant, so miri and UB sanitizers can check our memory (see https://github.com/rust-lang/rust/issues/59972#issuecomment-483058172)
- Preserve debuginfo scopes across generator yield points
bors [Fri, 3 May 2019 23:11:17 +0000 (23:11 +0000)]
Auto merge of #60462 - eddyb:def-1-a-mere-resolution, r=petrochenkov
rustc: factor out most of hir::def::Def's variants into DefKind, and rename to Res.
The first two commits are about introducing `DefKind`, both to simplify/orthogonalize `hir::def::Def`, and to allow reasoning about the kind of a definition without dealing with the redundant `DefId`.
(There are likely more changes to be made, such as adding enough `DefKind` variants for `tcx.def_kind(def_id)` to return just `DefKind`, not `Option<DefKind>`, but this is pretty big as-is)
The third commit frees up the `Def` name (which we may want to use in the future for "definitions", in the sense of "entities with a `DefId`") by renaming `hir::def::Def` to `Res` ("resolution").
IMO this fits, as it represents all the possible name resolution results, not just "definitions (with a `DefId`)".
Quick examples:
```rust
// Before:
if tcx.describe_def(def_id) == Some(Def::Struct(def_id)) {...}
if let Def::Struct(def_id) = path.def {...}
```
```rust
// After:
if tcx.def_kind(def_id) == Some(DefKind::Struct) {...}
if let Res::Def(DefKind::Struct, def_id) = path.res {...}
```
David Wood [Fri, 3 May 2019 21:36:35 +0000 (22:36 +0100)]
Fix async fn lowering ICE with APIT.
This commit fixes an ICE where simple bindings (which aren't replaced
with replacement arguments during async fn lowering) were not being
visited in the def collector and thus caused an ICE during HIR lowering
for types that use their `DefId` at that point - such as `impl Trait`.
Aleksey Kladov [Fri, 3 May 2019 18:35:21 +0000 (21:35 +0300)]
Add rustfmt toml
This commit adds an rustfmt.toml for using for **new** code.
Old code should continut to use old style, until we put automated
style checks in place.
See
https://internals.rust-lang.org/t/running-rustfmt-on-rust-lang-rust-and-other-rust-lang-repositories/8732/81
for the reason why we deviate from the default formatting. The TL;DR
is that currently compiler uses a pretty condensed style of code, and
default settings both create a huge diff and inflate the number of
lines. use_small_heuristics=Max fixes that.
version=Two is required for bug-fixes, which technically can't be made
to the stable first version
bors [Fri, 3 May 2019 15:10:16 +0000 (15:10 +0000)]
Auto merge of #60510 - Centril:rollup-gsndjbp, r=Centril
Rollup of 12 pull requests
Successful merges:
- #59928 (Make deprecation lint `ambiguous_associated_items` deny-by-default)
- #60220 (report fatal errors during doctest parsing)
- #60373 (Tidy: ensure lang features are sorted by since)
- #60388 (Disallow non-explicit elided lifetimes in async fn)
- #60393 ( Do not suggest incorrect syntax on pattern type error due to borrow)
- #60401 (Rename `RUST_LOG` to `RUSTC_LOG`)
- #60409 (Require a trait in the bounds of existential types)
- #60455 (Resolve match arm ty when arms diverge)
- #60457 (Const prop refactoring)
- #60467 (Avoid repeated interning of static strings.)
- #60478 (minor compiler doc tweaks)
- #60501 (Propagate mutability from arguments to local bindings in async fn)