]> git.lizzy.rs Git - rust.git/log
rust.git
4 years agoRollup merge of #66197 - Centril:transparent-ast, r=varkor
Tyler Mandry [Fri, 15 Nov 2019 13:44:47 +0000 (14:44 +0100)]
Rollup merge of #66197 - Centril:transparent-ast, r=varkor

Push `ast::{ItemKind, ImplItemKind}::OpaqueTy` hack down into lowering

We currently have a hack in the form of `ast::{ItemKind, ImplItemKind}::OpaqueTy` which is constructed literally when you write `type Alias = impl Trait;` but not e.g. `type Alias = Vec<impl Trait>;`. Per https://github.com/rust-lang/rfcs/pull/2515, this needs to change to allow `impl Trait` in nested positions.  This PR achieves this change for the syntactic aspect but not the semantic one, which will require changes in lowering and def collection. In the interim, `TyKind::opaque_top_hack` is introduced to avoid knock-on changes in lowering, collection, and resolve. These hacks can then be removed and fixed one by one until the desired semantics are supported.

r? @varkor

4 years agoAuto merge of #66438 - JohnTitor:rollup-qpv3wia, r=JohnTitor
bors [Fri, 15 Nov 2019 09:37:24 +0000 (09:37 +0000)]
Auto merge of #66438 - JohnTitor:rollup-qpv3wia, r=JohnTitor

Rollup of 12 pull requests

Successful merges:

 - #65557 (rename Error::iter_chain() and remove Error::iter_sources())
 - #66013 (Avoid hashing the key twice in `get_query()`.)
 - #66306 (Remove cannot mutate statics in initializer of another static error)
 - #66338 (Update mdbook.)
 - #66388 (Do not ICE on recovery from unmet associated type bound obligation)
 - #66390 (Fix ICE when trying to suggest `Type<>` instead of `Type()`)
 - #66391 (Do not ICE in `if` without `else` in `async fn`)
 - #66398 (Remove some stack frames from `.async` calls)
 - #66410 (miri: helper methods for max values of machine's usize/isize)
 - #66418 (Link to tracking issue in HIR const-check error code description)
 - #66419 (Don't warn labels beginning with `_` on unused_labels lint)
 - #66428 (Cleanup unused function)

Failed merges:

r? @ghost

4 years agoRollup merge of #66428 - dns2utf8:cleanup_unused_function, r=GuillaumeGomez
Yuki Okushi [Fri, 15 Nov 2019 09:36:35 +0000 (18:36 +0900)]
Rollup merge of #66428 - dns2utf8:cleanup_unused_function, r=GuillaumeGomez

Cleanup unused function

The argument was not used.

r? @GuillaumeGomez

4 years agoRollup merge of #66419 - JohnTitor:ignore-underscore, r=varkor
Yuki Okushi [Fri, 15 Nov 2019 09:36:34 +0000 (18:36 +0900)]
Rollup merge of #66419 - JohnTitor:ignore-underscore, r=varkor

Don't warn labels beginning with `_` on unused_labels lint

Fixes #66382

r? @varkor

4 years agoRollup merge of #66418 - ecstatic-morse:hir-const-check-err-msg, r=estebank
Yuki Okushi [Fri, 15 Nov 2019 09:36:32 +0000 (18:36 +0900)]
Rollup merge of #66418 - ecstatic-morse:hir-const-check-err-msg, r=estebank

Link to tracking issue in HIR const-check error code description

This is a follow up to #66170 that addresses [this comment](https://github.com/rust-lang/rust/pull/66170#discussion_r344021268).

As an aside, the only other error code whose description uses the phrase "tracking issue" is `E0202`. We may want to come up with standards around this, especially since error codes are now centralized and easier to keep track of (thanks @GuillaumeGomez).

r? @estebank (since they +1'ed the comment)

4 years agoRollup merge of #66410 - RalfJung:miri-machine-max, r=oli-obk
Yuki Okushi [Fri, 15 Nov 2019 09:36:31 +0000 (18:36 +0900)]
Rollup merge of #66410 - RalfJung:miri-machine-max, r=oli-obk

miri: helper methods for max values of machine's usize/isize

We recently wanted this in Miri.

r? @oli-obk

4 years agoRollup merge of #66398 - sfackler:no-async-nesting, r=Centril
Yuki Okushi [Fri, 15 Nov 2019 09:36:29 +0000 (18:36 +0900)]
Rollup merge of #66398 - sfackler:no-async-nesting, r=Centril

Remove some stack frames from `.async` calls

The `Context` argument is currently smuggled through TLS for
async-generated futures. The current infrastructure is closure-based,
and results in an extra 6 stack frames when .awaiting an async-generated
future!

```
  12: foo::async_b::{{closure}}
             at src/main.rs:10
  13: <std::future::GenFuture<T> as core::future::future::Future>::poll::{{closure}}
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734/src/libstd/future.rs:43
  14: std::future::set_task_context
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734/src/libstd/future.rs:79
  15: <std::future::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734/src/libstd/future.rs:43
  16: std::future::poll_with_tls_context::{{closure}}
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734/src/libstd/future.rs:121
  17: std::future::get_task_context
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734/src/libstd/future.rs:111
  18: std::future::poll_with_tls_context
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734/src/libstd/future.rs:121
  19: foo::async_a::{{closure}}
             at src/main.rs:6
```

While the long (medium?) term solution is to remove the use of TLS
entirely, we can improve things a bit in the meantime. In particular,
this commit does 2 things:

1. `get_task_context` has been inlined into `poll_with_tls_context`,
    removing 2 frames (16 and 17 above).
2. `set_task_context` now returns a guard type that resets the TLS
    rather than taking a closure, removing 2 frames (13 and 14 above).

We can also remove frame 18 by removing `poll_with_tls_context` in favor
of a `get_task_context` function which returns a guard, but that
requires adjusting the code generated for .await, so I've left that off
for now.

4 years agoRollup merge of #66391 - estebank:if-else-async-ice, r=Centril
Yuki Okushi [Fri, 15 Nov 2019 09:36:28 +0000 (18:36 +0900)]
Rollup merge of #66391 - estebank:if-else-async-ice, r=Centril

Do not ICE in `if` without `else` in `async fn`

Fix #66387.

4 years agoRollup merge of #66390 - estebank:parenice, r=Centril
Yuki Okushi [Fri, 15 Nov 2019 09:36:26 +0000 (18:36 +0900)]
Rollup merge of #66390 - estebank:parenice, r=Centril

Fix ICE when trying to suggest `Type<>` instead of `Type()`

Fixes #66286, but the output has no span:

```
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait

error: aborting due to previous error

For more information about this error, try `rustc --explain E0214`.
```

4 years agoRollup merge of #66388 - estebank:melt-ice, r=Centril
Yuki Okushi [Fri, 15 Nov 2019 09:36:25 +0000 (18:36 +0900)]
Rollup merge of #66388 - estebank:melt-ice, r=Centril

Do not ICE on recovery from unmet associated type bound obligation

Fix #66353.

r? @Centril

4 years agoRollup merge of #66338 - ehuss:update-mdbook, r=alexcrichton
Yuki Okushi [Fri, 15 Nov 2019 09:36:23 +0000 (18:36 +0900)]
Rollup merge of #66338 - ehuss:update-mdbook, r=alexcrichton

Update mdbook.

This brings in some important updates to fix some rendering issues in the books. In particular fixing hidden lines in code blocks, and some escaping issues.  More details at https://github.com/rust-lang/mdBook/blob/master/CHANGELOG.md

This also requires updating mdbook-linkcheck.

4 years agoRollup merge of #66306 - spastorino:remove-error-handled-by-miri, r=oli-obk
Yuki Okushi [Fri, 15 Nov 2019 09:36:22 +0000 (18:36 +0900)]
Rollup merge of #66306 - spastorino:remove-error-handled-by-miri, r=oli-obk

Remove cannot mutate statics in initializer of another static error

r? @oli-obk

This is just a refactoring. As the removed code itself said, it only a heuristic catching a few cases early instead of leaving it all to const eval. It's easy to work around the static check and then run into the miri-engine check.

4 years agoRollup merge of #66013 - nnethercote:avoid-hashing-twice-in-get_query, r=Zoxc
Yuki Okushi [Fri, 15 Nov 2019 09:36:20 +0000 (18:36 +0900)]
Rollup merge of #66013 - nnethercote:avoid-hashing-twice-in-get_query, r=Zoxc

Avoid hashing the key twice in `get_query()`.

For a single-threaded parallel compiler, this reduces instruction counts
across several benchmarks, by up to 2.8%.

The commit also adds documentation about `Sharded`'s use of `FxHasher`.

r? @Zoxc

4 years agoRollup merge of #65557 - haraldh:error_iter_rename, r=sfackler
Yuki Okushi [Fri, 15 Nov 2019 09:36:18 +0000 (18:36 +0900)]
Rollup merge of #65557 - haraldh:error_iter_rename, r=sfackler

rename Error::iter_chain() and remove Error::iter_sources()

~~Rename~~
* ~~Error::iter_chain() -> Error::chained()~~
* ~~Error::iter_sources() -> Error::ancestors()~~
* ~~ErrorIter -> Chained and Ancestors~~

according to
https://github.com/rust-lang/rust/issues/58520#issuecomment-527704110

Tracker:
https://github.com/rust-lang/rust/issues/58520

Edit:

Rename
* Error::iter_chain() -> Error::chained()
* ErrorIter -> Chain

So, it seems, that even Path::ancestors() includes itself. So, to avoid confusion and simplify it more, I reduced PR  #65557 to only have `chained` and `Chain`.

Rationale:

   1. Such iterators are helpful. They should better be stabilized sooner than later.
   1. self should be included. It is easy to .skip(1) it.  Not including self is harmful because it is harder to add self to the iterator than to remove it.
   1. The chosen name should be telling and reflect the fact that self is included. `.chained()` was chosen in honor of error-chain and because the iterator iterates over the chain of errors that is somehow included in self.
   1. The resulting iterator is named `Chain` because the `error::Chain` is what we want to have.

4 years agoAuto merge of #64432 - gnzlbg:simplify_truncate, r=alexcrichton
bors [Fri, 15 Nov 2019 01:23:51 +0000 (01:23 +0000)]
Auto merge of #64432 - gnzlbg:simplify_truncate, r=alexcrichton

Make the semantics of Vec::truncate(N) consistent with slices.

This commit simplifies the implementation of `Vec::truncate(N)` and
makes its semantics identical to dropping the `[vec.len() - N..]`
sub-slice tail of the vector, which is the same behavior as dropping a
vector containing the same sub-slice.

This changes two unspecified aspects of `Vec::truncate` behavior:

* the drop order, from back-to-front to front-to-back,
* the behavior of `Vec::truncate` on panics: if dropping one element of
  the tail panics, currently, `Vec::truncate` panics, but with this PR all other
  elements are still dropped, and if dropping a second element of the tail
  panics, with this PR, the program aborts.

Programs can trivially observe both changes. For example
([playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=7bef575b83b06e82b3e3529e4edbcac7)):

```rust
fn main() {
    struct Bomb(usize);
    impl Drop for Bomb {
        fn drop(&mut self) {
            panic!(format!("{}", self.0));
        }
    }
    let mut v = vec![Bomb(0), Bomb(1)];
    std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
        v.truncate(0);
    }));
    assert_eq!(v.len(), 1);
    std::mem::forget(v);
}
```

panics printing `1` today and succeeds. With this change, it panics
printing `0` first (due to the drop order change), and then aborts
with a double-panic printing `1`, just like dropping the
`[Bomb(0), Bomb(1)]` slice does, or dropping
`vec![Bomb(0), Bomb(1)]` does.

This needs to go through a crater run.

r? @SimonSapin

4 years agoCode cleanup to remove douplacte var definition
Stefan Schindler [Thu, 14 Nov 2019 23:45:08 +0000 (00:45 +0100)]
Code cleanup to remove douplacte var definition

Also move the declaration outside the loop since they accumulate state with each iteration

4 years agoRemove unused argument
Stefan Schindler [Thu, 14 Nov 2019 23:19:48 +0000 (00:19 +0100)]
Remove unused argument

4 years agoAuto merge of #66414 - JohnTitor:clippyup, r=Manishearth
bors [Thu, 14 Nov 2019 22:08:58 +0000 (22:08 +0000)]
Auto merge of #66414 - JohnTitor:clippyup, r=Manishearth

Update Clippy

Fixes #66409

r? @Manishearth

4 years agoreview comments
Esteban Küber [Thu, 14 Nov 2019 19:34:46 +0000 (11:34 -0800)]
review comments

4 years agoreview comments
Esteban Küber [Thu, 14 Nov 2019 19:08:56 +0000 (11:08 -0800)]
review comments

4 years agoDon't warn labels beginning with `_`
Yuki Okushi [Thu, 14 Nov 2019 18:05:03 +0000 (03:05 +0900)]
Don't warn labels beginning with `_`

4 years agoLink to tracking issue in HIR const-check error
Dylan MacKenzie [Thu, 14 Nov 2019 17:42:01 +0000 (09:42 -0800)]
Link to tracking issue in HIR const-check error

4 years agoAuto merge of #66314 - GuillaumeGomez:move-error-codes, r=Centril
bors [Thu, 14 Nov 2019 14:11:38 +0000 (14:11 +0000)]
Auto merge of #66314 - GuillaumeGomez:move-error-codes, r=Centril

Move error codes

Works towards #66210.

r? @Centril

Oh btw, for the ones interested, I used this python script to get all error codes content sorted into one final file:

<details>

```python
from os import listdir
from os.path import isdir, isfile, join

def get_error_codes(error_codes, f_path):
    with open(f_path) as f:
        short_mode = False
        lines = f.read().split("\n")
        i = 0
        while i < len(lines):
            line = lines[i]
            if not short_mode and line.startswith("E0") and line.endswith(": r##\""):
                error = line
                error += "\n"
                i += 1
                while i < len(lines):
                    line = lines[i]
                    error += line
                    if line.endswith("\"##,"):
                        break
                    error += "\n"
                    i += 1
                error_codes["long"].append(error)
            elif line == ';':
                short_mode = True
            elif short_mode is True and len(line) > 0 and line != "}":
                error_codes["short"].append(line)
                while i + 1 < len(lines):
                    line = lines[i + 1].strip()
                    if not line.startswith("//"):
                        break
                    parts = line.split("//")
                    if len(parts) < 2:
                        break
                    if parts[1].strip().startswith("E0"):
                        break
                    error_codes["short"][-1] += "\n"
                    error_codes["short"][-1] += lines[i + 1]
                    i += 1
            i += 1

def loop_dirs(error_codes, cur_dir):
    for entry in listdir(cur_dir):
        f = join(cur_dir, entry)
        if isfile(f) and entry == "error_codes.rs":
            get_error_codes(error_codes, f)
        elif isdir(f) and not entry.startswith("librustc_error_codes"):
            loop_dirs(error_codes, f)

def get_error_code(err):
    x = err.split(",")
    if len(x) < 2:
        return err
    x = x[0]
    if x.strip().startswith("//"):
        x = x.split("//")[1].strip()
    return x.strip()

def write_into_file(error_codes, f_path):
    with open(f_path, "w") as f:
        f.write("// Error messages for EXXXX errors.  Each message should start and end with a\n")
        f.write("// new line, and be wrapped to 80 characters.  In vim you can `:set tw=80` and\n")
        f.write("// use `gq` to wrap paragraphs. Use `:set tw=0` to disable.\n\n")
        f.write("syntax::register_diagnostics! {\n\n")
        error_codes["long"].sort()
        for i in error_codes["long"]:
            f.write(i)
            f.write("\n\n")
        f.write(";\n")
        error_codes["short"] = sorted(error_codes["short"], key=lambda err: get_error_code(err))
        for i in error_codes["short"]:
            f.write(i)
            f.write("\n")
        f.write("}\n")

error_codes = {
    "long": [],
    "short": []
}
loop_dirs(error_codes, "src")
write_into_file(error_codes, "src/librustc_error_codes/src/error_codes.rs")
```
</details>

And to move the error codes into their own files:

<details>

```python
import os

try:
    os.mkdir("src/librustc_error_codes/error_codes")
except OSError:
    print("Seems like folder already exist, moving on!")
data = ''
with open("src/librustc_error_codes/error_codes.rs") as f:
    x = f.read().split('\n')
    i = 0
    short_part = False
    while i < len(x):
        line = x[i]
        if short_part is False and line.startswith('E0') and line.endswith(': r##"'):
            err_code = line.split(':')[0]
            i += 1
            content = ''
            while i < len(x):
                if x[i] == '"##,':
                    break
                content += x[i]
                content += '\n'
                i += 1
            f_path = "src/librustc_error_codes/error_codes/{}.md".format(err_code)
            with open(f_path, "w") as ff:
                ff.write(content)
            data += '{}: include_str!("./error_codes/{}.md"),'.format(err_code, err_code)
        elif short_part is False and line == ';':
            short_part is True
            data += ';\n'
        else:
            data += line
            data += '\n'
        i += 1
with open("src/librustc_error_codes/error_codes.rs", "w") as f:
    f.write(data)
```
</details>

4 years agoTAIT: adjust tests
Mazdak Farrokhzad [Thu, 7 Nov 2019 19:12:34 +0000 (20:12 +0100)]
TAIT: adjust tests

4 years agoTAIT: --bless some span changes for the better
Mazdak Farrokhzad [Thu, 7 Nov 2019 18:46:21 +0000 (19:46 +0100)]
TAIT: --bless some span changes for the better

4 years agoTAIT: adjust resolve
Mazdak Farrokhzad [Thu, 7 Nov 2019 18:39:21 +0000 (19:39 +0100)]
TAIT: adjust resolve

4 years agoTAIT: adjust save-analysis
Mazdak Farrokhzad [Thu, 7 Nov 2019 18:15:48 +0000 (19:15 +0100)]
TAIT: adjust save-analysis

4 years agoTAIT: remove redundant check from ast_validation
Mazdak Farrokhzad [Thu, 7 Nov 2019 18:15:33 +0000 (19:15 +0100)]
TAIT: remove redundant check from ast_validation

4 years agoTAIT: use hack in ->HIR to avoid more changes
Mazdak Farrokhzad [Thu, 7 Nov 2019 18:13:22 +0000 (19:13 +0100)]
TAIT: use hack in ->HIR to avoid more changes

4 years agoTAIT: parse recursively instead of hack.
Mazdak Farrokhzad [Thu, 7 Nov 2019 17:19:41 +0000 (18:19 +0100)]
TAIT: parse recursively instead of hack.

4 years agoTAIT: feature gate recursive locations
Mazdak Farrokhzad [Thu, 7 Nov 2019 16:59:58 +0000 (17:59 +0100)]
TAIT: feature gate recursive locations

4 years agoTAIT: remove `OpaqueTy` in AST.
Mazdak Farrokhzad [Thu, 7 Nov 2019 13:56:49 +0000 (14:56 +0100)]
TAIT: remove `OpaqueTy` in AST.

4 years agoMove E0210 to new error location
Guillaume Gomez [Thu, 14 Nov 2019 12:08:23 +0000 (13:08 +0100)]
Move E0210 to new error location

4 years agomove E0744 to new error code
Guillaume Gomez [Wed, 13 Nov 2019 23:26:16 +0000 (00:26 +0100)]
move E0744 to new error code

4 years agoUpdate rustc --explain to the new error codes format
Guillaume Gomez [Wed, 13 Nov 2019 19:54:43 +0000 (20:54 +0100)]
Update rustc --explain to the new error codes format

4 years agomove E0623 into the new error code format
Guillaume Gomez [Wed, 13 Nov 2019 17:01:19 +0000 (18:01 +0100)]
move E0623 into the new error code format

4 years agoAdapt error index generator to the new format
Guillaume Gomez [Wed, 13 Nov 2019 14:27:59 +0000 (15:27 +0100)]
Adapt error index generator to the new format

4 years agoFix error codes index generation
Guillaume Gomez [Tue, 12 Nov 2019 15:58:37 +0000 (16:58 +0100)]
Fix error codes index generation

4 years agoFix ui tests with better error code usage
Guillaume Gomez [Tue, 12 Nov 2019 11:09:02 +0000 (12:09 +0100)]
Fix ui tests with better error code usage

4 years agoPut each error code long explanation into their own markdown file
Guillaume Gomez [Tue, 12 Nov 2019 10:45:21 +0000 (11:45 +0100)]
Put each error code long explanation into their own markdown file

4 years agoClean some error codes diagnostics
Guillaume Gomez [Mon, 11 Nov 2019 22:34:57 +0000 (23:34 +0100)]
Clean some error codes diagnostics

4 years agofix tidy issue on file length
Guillaume Gomez [Mon, 11 Nov 2019 22:19:10 +0000 (23:19 +0100)]
fix tidy issue on file length

4 years agoregen
Guillaume Gomez [Mon, 11 Nov 2019 21:47:05 +0000 (22:47 +0100)]
regen

4 years agoRemove unused error_codes.rs files
Guillaume Gomez [Mon, 11 Nov 2019 21:46:36 +0000 (22:46 +0100)]
Remove unused error_codes.rs files

4 years agoUpdate to use new librustc_error_codes library
Guillaume Gomez [Mon, 11 Nov 2019 21:46:56 +0000 (22:46 +0100)]
Update to use new librustc_error_codes library

4 years agoCreate new librustc_error_codes lib and move error codes declaration inside it
Guillaume Gomez [Mon, 11 Nov 2019 21:45:32 +0000 (22:45 +0100)]
Create new librustc_error_codes lib and move error codes declaration inside it

4 years agoUpdate Clippy
Yuki Okushi [Thu, 14 Nov 2019 12:04:08 +0000 (21:04 +0900)]
Update Clippy

4 years agoAuto merge of #66378 - rkruppe:revert-pr-65134, r=pnkfelix
bors [Thu, 14 Nov 2019 11:06:41 +0000 (11:06 +0000)]
Auto merge of #66378 - rkruppe:revert-pr-65134, r=pnkfelix

Revert #65134

To stop giving people on nightly reasons to `allow(improper_ctypes)` while tweaks to the lint are being prepared.

cc #66220

4 years agomiri: helper methods for max values of machine's usize/isize
Ralf Jung [Thu, 14 Nov 2019 09:38:15 +0000 (10:38 +0100)]
miri: helper methods for max values of machine's usize/isize

4 years agoAuto merge of #66403 - JohnTitor:rollup-7obuivl, r=JohnTitor
bors [Thu, 14 Nov 2019 08:03:01 +0000 (08:03 +0000)]
Auto merge of #66403 - JohnTitor:rollup-7obuivl, r=JohnTitor

Rollup of 9 pull requests

Successful merges:

 - #66253 (Improve errors after re rebalance coherence)
 - #66264 (fix an ICE in macro's diagnostic message)
 - #66349 (expand source_util macros with def-site context)
 - #66351 (Tweak non-char/numeric in range pattern diagnostic)
 - #66360 (Fix link to Exten in Vec::set_len)
 - #66361 (parser: don't use `unreachable!()` in `fn unexpected`.)
 - #66363 (Improve error message in make_tests)
 - #66369 (compiletest: Obtain timestamps for common inputs only once)
 - #66372 (Fix broken links in Ipv4Addr::is_benchmarking docs)

Failed merges:

r? @ghost

4 years agoRollup merge of #66372 - ogham:patch-2, r=jonas-schievink
Yuki Okushi [Thu, 14 Nov 2019 05:16:27 +0000 (14:16 +0900)]
Rollup merge of #66372 - ogham:patch-2, r=jonas-schievink

Fix broken links in Ipv4Addr::is_benchmarking docs

[The documentation for `Ipv4Addr::is_benchmarking`](https://doc.rust-lang.org/nightly/std/net/struct.Ipv4Addr.html#method.is_benchmarking) is correct — it has the right RFC number — but the Markdown links are broken. Looks like a copy-and-paste error and a typo.

This PR fixes the links to make them clickable.

4 years agoRollup merge of #66369 - tmiasko:compiletest-stamp, r=Mark-Simulacrum
Yuki Okushi [Thu, 14 Nov 2019 05:16:26 +0000 (14:16 +0900)]
Rollup merge of #66369 - tmiasko:compiletest-stamp, r=Mark-Simulacrum

compiletest: Obtain timestamps for common inputs only once

Obtain timestamps for common inputs (e.g., libraries in run-lib path, or
sources in `src/tool/compiletest/`) only once and reuse the result,
instead of repeating the work for each test case.

4 years agoRollup merge of #66363 - Munksgaard:patch-1, r=dtolnay
Yuki Okushi [Thu, 14 Nov 2019 05:16:25 +0000 (14:16 +0900)]
Rollup merge of #66363 - Munksgaard:patch-1, r=dtolnay

Improve error message in make_tests

We should use expect instead of unwrap.

This commit is based on https://github.com/laumann/compiletest-rs/pull/58. Thanks to @colin-kiegel.

4 years agoRollup merge of #66361 - Centril:66357, r=pnkfelix
Yuki Okushi [Thu, 14 Nov 2019 05:16:23 +0000 (14:16 +0900)]
Rollup merge of #66361 - Centril:66357, r=pnkfelix

parser: don't use `unreachable!()` in `fn unexpected`.

Fixes #66357

r? @estebank

4 years agoRollup merge of #66360 - elichai:2019-11-vec-link, r=dtolnay
Yuki Okushi [Thu, 14 Nov 2019 05:16:22 +0000 (14:16 +0900)]
Rollup merge of #66360 - elichai:2019-11-vec-link, r=dtolnay

Fix link to Exten in Vec::set_len

Fixes #66354

Unrelated to this PR, I think we should stop using `../../std/MODULE` and replace it with `../MODULE` that way if you're looking at docs in `core` or `alloc` clicking at a link won't forward you to `std`.

4 years agoRollup merge of #66351 - JohnTitor:tweak-range-err-msg, r=Centril
Yuki Okushi [Thu, 14 Nov 2019 05:16:20 +0000 (14:16 +0900)]
Rollup merge of #66351 - JohnTitor:tweak-range-err-msg, r=Centril

Tweak non-char/numeric in range pattern diagnostic

Fixes #66283

r? @estebank

4 years agoRollup merge of #66349 - euclio:def-site-builtins, r=petrochenkov
Yuki Okushi [Thu, 14 Nov 2019 05:16:19 +0000 (14:16 +0900)]
Rollup merge of #66349 - euclio:def-site-builtins, r=petrochenkov

expand source_util macros with def-site context

cc @petrochenkov

See https://internals.rust-lang.org/t/spans-from-built-in-macro-expansions-are-not-from-expansion/11276/2 for context.

4 years agoRollup merge of #66264 - guanqun:fix-mbe-missing-close-delim, r=estebank
Yuki Okushi [Thu, 14 Nov 2019 05:16:17 +0000 (14:16 +0900)]
Rollup merge of #66264 - guanqun:fix-mbe-missing-close-delim, r=estebank

fix an ICE in macro's diagnostic message

This has two small fixes:
1. for the left brace, we don't need `<space>{`, simply `{` is enough.
2. for the right brace, it tries to peel off one character even when the close delim is missing. Without this fix, it would crash in some cases. (as shown in the new test case)

r? @estebank

4 years agoRollup merge of #66253 - ohadravid:improve-errors-after-re-rebalance-coherence, r...
Yuki Okushi [Thu, 14 Nov 2019 05:16:16 +0000 (14:16 +0900)]
Rollup merge of #66253 - ohadravid:improve-errors-after-re-rebalance-coherence, r=estebank

Improve errors after re rebalance coherence

Following #65247, I noticed that some error messages should be updated to reflect the changes of `re_rebalance_coherence` (also there was a [note](https://rust-lang.github.io/rfcs/2451-re-rebalancing-coherence.html#teaching-users) in the RFC about it).

First, error message `E0210` was updated to match the RFC, and I also tried to improve a little the error when the "order" of types is problematic.

For code like this:
```
#![feature(re_rebalance_coherence)] // Now stable

struct Wrap<T>(T);

impl<T> From<Wrap<T>> for T {
    fn from(x: Wrap<T>) -> T {
        x.0
    }
}
```

The old error was:
```
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
 --> src/lib.rs:5:6
  |
5 | impl<T> From<Wrap<T>> for T {
  |      ^ type parameter `T` must be used as the type parameter for some local type
  |
  = note: only traits defined in the current crate can be implemented for a type parameter

```

and the new error is:
```
error[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`Wrap<T>`)
  --> main.rs:66:6
   |
66 | impl<T> From<Wrap<T>> for T {
   |      ^ type parameter `T` must be covered by another type when it appears before the first local type (`Wrap<T>`)
   |
   = note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local, and no uncovered type parameters appear before that first local type
   = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait<T1, ..., Tn> for T0`, where `T0` is the first and `Tn` is the last
```

I tried to point at the uncovered `T`, but couldn't get something which was reliable (but I'll be happy to try if someone points me in the right direction).

r? @estebank
cc @nikomatsakis

Fixes #65247

4 years agoAuto merge of #66233 - cjgillot:constkind, r=oli-obk
bors [Thu, 14 Nov 2019 04:54:51 +0000 (04:54 +0000)]
Auto merge of #66233 - cjgillot:constkind, r=oli-obk

Split ConstValue into two enums

Hello,

Issue #59210 appeared abandoned, so I gave it a go.
Some further cleanup and refactoring may be mandated.

I did not test beyond `x.py check`, since my home computer dies compiling librustc.

Fixes #59210

4 years agoRemove some stack frames from `.async` calls
Steven Fackler [Thu, 14 Nov 2019 01:14:50 +0000 (17:14 -0800)]
Remove some stack frames from `.async` calls

The `Context` argument is currently smuggled through TLS for
async-generated futures. The current infrastructure is closure-based,
and results in an extra 6 stack frames when .awaiting an async-generated
future!

```
  12: foo::async_b::{{closure}}
             at src/main.rs:10
  13: <std::future::GenFuture<T> as core::future::future::Future>::poll::{{closure}}
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734/src/libstd/future.rs:43
  14: std::future::set_task_context
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734/src/libstd/future.rs:79
  15: <std::future::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734/src/libstd/future.rs:43
  16: std::future::poll_with_tls_context::{{closure}}
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734/src/libstd/future.rs:121
  17: std::future::get_task_context
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734/src/libstd/future.rs:111
  18: std::future::poll_with_tls_context
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734/src/libstd/future.rs:121
  19: foo::async_a::{{closure}}
             at src/main.rs:6
```

While the long (medium?) term solution is to remove the use of TLS
entirely, we can improve things a bit in the meantime. In particular,
this commit does 2 things:

1. `get_task_context` has been inlined into `poll_with_tls_context`,
    removing 2 frames (16 and 17 above).
2. `set_task_context` now returns a guard type that resets the TLS
    rather than taking a closure, removing 2 frames (13 and 14 above).

We can also remove frame 18 by removing `poll_with_tls_context` in favor
of a `get_task_context` function which returns a guard, but that
requires adjusting the code generated for .await, so I've left that off
for now.

4 years agoDo not ICE in `if` without `else` in `async fn`
Esteban Küber [Wed, 13 Nov 2019 23:22:45 +0000 (15:22 -0800)]
Do not ICE in `if` without `else` in `async fn`

4 years agoAuto merge of #66211 - kinnison:kinnison/fix-66159, r=GuillaumeGomez
bors [Wed, 13 Nov 2019 23:22:03 +0000 (23:22 +0000)]
Auto merge of #66211 - kinnison:kinnison/fix-66159, r=GuillaumeGomez

Fix ICE when documentation includes intra-doc-link

When collecting intra-doc-links we could trigger the loading of extra crates into the crate store due to name resolution finding crates referred to in documentation but not in code.  This might be due to
configuration differences or simply referring to something else.

This would cause an ICE because the newly loaded crate metadata existed in a crate store associated with the rustdoc global context, but the resolver had its own crate store cloned just before the documentation processing began and as such it could try and look up crates in a store which lacked them.

In this PR, I add support for `--extern-private` to the `rustdoc` tool so that it is supported for `compiletest` to then pass the crates in; and then I fix the issue by forcing the resolver to look over all the crates before we then lower the input ready for processing into documentation.

The first commit (the `--extern-private`) could be replaced with a commit which adds support for `--extern` to `compiletest` if preferred, though I think that adding `--extern-private` to `rustdoc` is more useful anyway since it makes the CLI a little more like `rustc`'s which might help reduce surprise for someone running it by hand or in their own test code.

The PR is meant to fix #66159 though it may also fix #65840.

cc @GuillaumeGomez

4 years agoFix ICE when trying to suggest `Type<>` instead of `Type()`
Esteban Küber [Wed, 13 Nov 2019 22:45:52 +0000 (14:45 -0800)]
Fix ICE when trying to suggest `Type<>` instead of `Type()`

4 years agoDo not ICE on recovery from unmet associated type bound obligation
Esteban Küber [Wed, 13 Nov 2019 22:28:15 +0000 (14:28 -0800)]
Do not ICE on recovery from unmet associated type bound obligation

4 years agoAuto merge of #66170 - ecstatic-morse:hir-const-check, r=Centril,oli-obk
bors [Wed, 13 Nov 2019 20:10:54 +0000 (20:10 +0000)]
Auto merge of #66170 - ecstatic-morse:hir-const-check, r=Centril,oli-obk

Add a HIR pass to check consts for `if`, `loop`, etc.

Resolves #66125.

This PR adds a HIR pass to check for high-level control flow constructs that are forbidden in a const-context. The MIR const-checker is unable to provide good spans for these since they are lowered to control flow primitives (e.g., `Goto` and `SwitchInt`), and these often don't map back to the underlying statement as a whole. This PR is intended only to improve diagnostics once `if` and `match` become commonplace in constants (behind a feature flag). The MIR const-checker will continue to operate unchanged, and will catch anything this check might miss.

In this implementation, the HIR const-checking pass is run much earlier than the MIR one, so it will supersede any errors from the latter. I will need some mentoring if we wish to change this, since I'm not familiar with the diagnostics system. Moving this pass into the same phase as the MIR const-checker could also help keep backwards compatibility for items like `const _: () = loop { break; };`, which are currently (erroneously?) accepted by the MIR const-checker (see #62272).

r? @Centril
cc @eddyb (since they filed #62272)

4 years agoUse `ast::Mutability`
Dylan MacKenzie [Wed, 13 Nov 2019 18:46:44 +0000 (10:46 -0800)]
Use `ast::Mutability`

4 years agoBless miri unleashed test now that errors are mandatory
Dylan MacKenzie [Mon, 11 Nov 2019 16:00:49 +0000 (08:00 -0800)]
Bless miri unleashed test now that errors are mandatory

4 years agoBless less verbose error messages
Dylan MacKenzie [Sat, 9 Nov 2019 17:29:57 +0000 (09:29 -0800)]
Bless less verbose error messages

The MIR const-checker errors for if/match/loop are now delay span bugs,
so nothing will be emitted unless the HIR checker misses something.

4 years agoChange control flow error to delay span bug
Dylan MacKenzie [Sat, 9 Nov 2019 17:07:13 +0000 (09:07 -0800)]
Change control flow error to delay span bug

4 years agoFix broken doc-test
Dylan MacKenzie [Fri, 8 Nov 2019 00:13:35 +0000 (16:13 -0800)]
Fix broken doc-test

4 years agoSmall fixes to comments
Dylan MacKenzie [Thu, 7 Nov 2019 18:02:01 +0000 (10:02 -0800)]
Small fixes to comments

4 years agoBless back-compat breakages
Dylan MacKenzie [Thu, 7 Nov 2019 01:45:10 +0000 (17:45 -0800)]
Bless back-compat breakages

This PR BREAKS CODE THAT WAS ACCEPTED ON STABLE. It's arguably a bug
that this was accepted in the first place, but here we are. See #62272
for more info.

4 years agoBless const tests with improved diagnostics
Dylan MacKenzie [Wed, 6 Nov 2019 20:29:30 +0000 (12:29 -0800)]
Bless const tests with improved diagnostics

4 years agoExtend const-loop and const-if to handle more cases
Dylan MacKenzie [Wed, 6 Nov 2019 20:26:59 +0000 (12:26 -0800)]
Extend const-loop and const-if to handle more cases

This makes sure that our HIR visitor is visiting as many
const-items as possible.

4 years agoRemove if/loop tests from min_const_fn
Dylan MacKenzie [Wed, 6 Nov 2019 20:24:23 +0000 (12:24 -0800)]
Remove if/loop tests from min_const_fn

These errors will be triggered before the MIR const-checker runs,
causing all other errors to be silenced. They are now checked in the
`const-{if,loop}` tests.

4 years agoEnable const-checking HIR bodies
Dylan MacKenzie [Wed, 6 Nov 2019 19:46:55 +0000 (11:46 -0800)]
Enable const-checking HIR bodies

4 years agoAdd HIR pass to check for `if`s and `loop`s in a `const`
Dylan MacKenzie [Wed, 6 Nov 2019 19:44:56 +0000 (11:44 -0800)]
Add HIR pass to check for `if`s and `loop`s in a `const`

These high-level constructs get mapped to control-flow primitives by the
time the MIR const-checker runs, making it hard to get the span for the
erroneous expression.

4 years agoGet `FnSig` by `HirId`
Dylan MacKenzie [Wed, 6 Nov 2019 19:43:33 +0000 (11:43 -0800)]
Get `FnSig` by `HirId`

4 years agoAdd E0744 for control flow in consts
Dylan MacKenzie [Wed, 6 Nov 2019 19:41:27 +0000 (11:41 -0800)]
Add E0744 for control flow in consts

4 years agocompiletest: Avoid double negation in ignore condition
Tomasz Miąsko [Wed, 13 Nov 2019 00:00:00 +0000 (00:00 +0000)]
compiletest: Avoid double negation in ignore condition

4 years agocompiletest: Obtain timestamps for common inputs only once
Tomasz Miąsko [Mon, 11 Nov 2019 00:00:00 +0000 (00:00 +0000)]
compiletest: Obtain timestamps for common inputs only once

Obtain timestamps for common inputs (e.g., libraries in run-lib path, or
sources in `src/tool/compiletest/`) only once and reuse the result,
instead of repeating the work for each test case.

No functional changes intended.

4 years agoRevert "Auto merge of #65134 - davidtwco:issue-19834-improper-ctypes-in-extern-C...
Robin Kruppe [Wed, 13 Nov 2019 16:00:47 +0000 (17:00 +0100)]
Revert "Auto merge of #65134 - davidtwco:issue-19834-improper-ctypes-in-extern-C-fn, r=rkruppe"

This reverts commit 3f0e16473de5ec010f44290a8c3ea1d90e0ad7a2, reversing
changes made to 61a551b4939ec1d5596e585351038b8fbd0124ba.

4 years agoAvoid using same code
Yuki Okushi [Wed, 13 Nov 2019 14:22:48 +0000 (23:22 +0900)]
Avoid using same code

4 years agoFix broken links in Ipv4Addr::is_benchmarking docs
Benjamin Sago [Wed, 13 Nov 2019 15:09:40 +0000 (15:09 +0000)]
Fix broken links in Ipv4Addr::is_benchmarking docs

4 years agoAuto merge of #66366 - JohnTitor:rollup-xlc1bj2, r=JohnTitor
bors [Wed, 13 Nov 2019 13:16:53 +0000 (13:16 +0000)]
Auto merge of #66366 - JohnTitor:rollup-xlc1bj2, r=JohnTitor

Rollup of 14 pull requests

Successful merges:

 - #65932 (download .tar.xz if python3 is used)
 - #66094 (Fix documentation for `Iterator::count()`.)
 - #66166 (rename cfg(rustdoc) into cfg(doc))
 - #66186 (Add long error explanation for E0623)
 - #66227 (docs: Fix link to BufWriter::flush)
 - #66248 (add raw ptr variant of UnsafeCell::get)
 - #66292 (add Result::map_or)
 - #66297 (Add a callback that allows compiler consumers to override queries.)
 - #66317 (Use a relative bindir for rustdoc to find rustc)
 - #66330 (Improve non-exhaustiveness handling in usefulness checking)
 - #66331 (Add some tests for fixed ICEs)
 - #66334 (Move Session fields to CrateStore)
 - #66335 (Move self-profile infrastructure to data structures)
 - #66337 (Remove dead code for encoding/decoding lint IDs)

Failed merges:

r? @ghost

4 years agoRollup merge of #66337 - Mark-Simulacrum:no-decode-lint-id, r=Dylan-DPC
Yuki Okushi [Wed, 13 Nov 2019 13:09:31 +0000 (22:09 +0900)]
Rollup merge of #66337 - Mark-Simulacrum:no-decode-lint-id, r=Dylan-DPC

Remove dead code for encoding/decoding lint IDs

This helps decouple the lint system from needing the implicit TLS TyCtxt
as well.

4 years agoRollup merge of #66335 - Mark-Simulacrum:self-profile-to-data, r=michaelwoerister
Yuki Okushi [Wed, 13 Nov 2019 13:09:29 +0000 (22:09 +0900)]
Rollup merge of #66335 - Mark-Simulacrum:self-profile-to-data, r=michaelwoerister

Move self-profile infrastructure to data structures

The single dependency on queries (QueryName) can be fairly easily
abstracted via a trait and this further decouples Session from librustc
(the primary goal).

This is intended as a precursor to moving Session out of librustc, but since that involves lots of smaller steps that move around code I'm splitting it up into separate PRs.

4 years agoRollup merge of #66334 - Mark-Simulacrum:sess-cstore, r=petrochenkov
Yuki Okushi [Wed, 13 Nov 2019 13:09:28 +0000 (22:09 +0900)]
Rollup merge of #66334 - Mark-Simulacrum:sess-cstore, r=petrochenkov

Move Session fields to CrateStore

`allocator_kind` and `injected_panic_runtime` are both query-like, this moves them out of Session and into CrateStore, avoiding the `Once` they previously had by clearing separating initialization and de-initialization.

4 years agoRollup merge of #66331 - JohnTitor:add-tests, r=Centril
Yuki Okushi [Wed, 13 Nov 2019 13:09:26 +0000 (22:09 +0900)]
Rollup merge of #66331 - JohnTitor:add-tests, r=Centril

Add some tests for fixed ICEs

Closes #30904 (fixed between nightly-2019-07-14 and nightly-2019-07-31)
Closes #40231 (example 1 is fixed in 1.32.0, example 2 is fixed in 1.38.0)
Closes #52432 (fixed in rustc 1.40.0-beta.1 (76b40532a 2019-11-05))
Closes #63279 (fixed in rustc 1.40.0-nightly (246be7e1a 2019-10-25))

r? @Centril

4 years agoRollup merge of #66330 - Nadrieril:nonexhaustive-constructor, r=varkor
Yuki Okushi [Wed, 13 Nov 2019 13:09:25 +0000 (22:09 +0900)]
Rollup merge of #66330 - Nadrieril:nonexhaustive-constructor, r=varkor

Improve non-exhaustiveness handling in usefulness checking

The comments around code paths for the `non_exhaustive` feature mention stuff like "we act as if the type had an extra unmatcheable constructor". So I thought I'd make this explicit by defining a special constructor that does exactly this.
This makes those code paths a bit more legible and less prone to error.

4 years agoRollup merge of #66317 - cuviper:bindir_relative, r=Mark-Simulacrum
Yuki Okushi [Wed, 13 Nov 2019 13:09:23 +0000 (22:09 +0900)]
Rollup merge of #66317 - cuviper:bindir_relative, r=Mark-Simulacrum

Use a relative bindir for rustdoc to find rustc

In bootstrap, we set `RUSTC_INSTALL_BINDIR` to `config.bindir`, so
rustdoc can find rustc relative to the toolchain sysroot. However, if a
distro script like Fedora's `%configure` sets an absolute path, then
rustdoc's `sysroot.join(bin_path)` ignores that sysroot altogether.

That would be OK once the toolchain is actually installed, but it breaks
the in-tree doc tests during the build, since `/usr/bin/rustc` is still
the old version. So now we try to make `RUSTC_INSTALL_BINDIR` relative
to the sysroot prefix in the first place.

r? @Mark-Simulacrum

4 years agoRollup merge of #66297 - vakaras:edit-queries, r=oli-obk
Yuki Okushi [Wed, 13 Nov 2019 13:09:22 +0000 (22:09 +0900)]
Rollup merge of #66297 - vakaras:edit-queries, r=oli-obk

Add a callback that allows compiler consumers to override queries.

This pull request adds an additional callback that allows compiler consumers such as Prusti and MIRAI to override queries. My hope is that in this way it will be possible to get access to the internal compiler information (e.g. borrow checker) without major changes to the compiler.

This pull request is work in progress because I am still testing if I can get the information which I need.

cc @nikomatsakis

r? @oli-obk

4 years agoRollup merge of #66292 - lzutao:result-map_or, r=SimonSapin
Yuki Okushi [Wed, 13 Nov 2019 13:09:20 +0000 (22:09 +0900)]
Rollup merge of #66292 - lzutao:result-map_or, r=SimonSapin

add Result::map_or

This PR adds this API to make it consistent with `Option::map_or`.

```rust
impl<T, E> Result<T, E> {
    pub fn map_or<U, F: FnOnce(T) -> U>(self, default: U, f: F) -> U {
        match self {
            Ok(t) => f(t),
            Err(_) => default,
        }
    }
}
```

This API is very small. We already has a similar API for `Option::map_or`.

4 years agoRollup merge of #66248 - RalfJung:unsafe_cell_raw_get, r=SimonSapin
Yuki Okushi [Wed, 13 Nov 2019 13:09:19 +0000 (22:09 +0900)]
Rollup merge of #66248 - RalfJung:unsafe_cell_raw_get, r=SimonSapin

add raw ptr variant of UnsafeCell::get

This has come up recently in https://github.com/rust-lang/rust/pull/66051 (Cc @Centril @pitdicker) as well as in discussion with @nikomatsakis and in unrelated discussion with @withoutboats.

4 years agoRollup merge of #66227 - bryanburgers:bufwriter-docs-fix-flush-link, r=Dylan-DPC
Yuki Okushi [Wed, 13 Nov 2019 13:09:17 +0000 (22:09 +0900)]
Rollup merge of #66227 - bryanburgers:bufwriter-docs-fix-flush-link, r=Dylan-DPC

docs: Fix link to BufWriter::flush

One of the links in the docs was being rendered as a literal
open-bracket followed by a single quote, instead of being transformed
into a link. Fix it to match the link earlier in the same paragraph.

4 years agoRollup merge of #66186 - GuillaumeGomez:long-err-explanation-E0623, r=Dylan-DPC
Yuki Okushi [Wed, 13 Nov 2019 13:09:15 +0000 (22:09 +0900)]
Rollup merge of #66186 - GuillaumeGomez:long-err-explanation-E0623, r=Dylan-DPC

Add long error explanation for E0623

Part of #61137.

r? @Dylan-DPC

4 years agoRollup merge of #66166 - GuillaumeGomez:rename-rustdoc-to-doc, r=QuietMisdreavus
Yuki Okushi [Wed, 13 Nov 2019 13:09:13 +0000 (22:09 +0900)]
Rollup merge of #66166 - GuillaumeGomez:rename-rustdoc-to-doc, r=QuietMisdreavus

rename cfg(rustdoc) into cfg(doc)

Needed by https://github.com/rust-lang/rust/pull/61351

r? @QuietMisdreavus

4 years agoRollup merge of #66094 - ArturKovacs:fix-count-doc, r=Dylan-DPC
Yuki Okushi [Wed, 13 Nov 2019 13:09:11 +0000 (22:09 +0900)]
Rollup merge of #66094 - ArturKovacs:fix-count-doc, r=Dylan-DPC

Fix documentation for `Iterator::count()`.

The documentation of std::core::Iterator::count() stated that the number returned is the number of times `next` is called on the iterator. However this is not true as the number of times `next` is called is exactly one plus the number returned by `count()`.

4 years agoRollup merge of #65932 - guanqun:download-xz, r=alexcrichton
Yuki Okushi [Wed, 13 Nov 2019 13:09:10 +0000 (22:09 +0900)]
Rollup merge of #65932 - guanqun:download-xz, r=alexcrichton

download .tar.xz if python3 is used

fixes https://github.com/rust-lang/rust/issues/65757