Commit Graph

102742 Commits

Author SHA1 Message Date
Esteban Küber
7d61484b46 Do not ICE in if without else in async fn 2019-11-13 15:22:45 -08:00
bors
3f07f1cd78 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
2019-11-13 23:22:03 +00:00
Esteban Küber
41372631ff Fix ICE when trying to suggest Type<> instead of Type() 2019-11-13 14:45:58 -08:00
Esteban Küber
bc1bd95e5a Do not ICE on recovery from unmet associated type bound obligation 2019-11-13 14:28:15 -08:00
Camille GILLOT
7214b9ad48 Retire BraceStructTypeFoldableImpl and TupleStructTypeFoldableImpl. 2019-11-13 21:48:13 +01:00
Camille GILLOT
d5f5e706ef Use TypeFoldable derive macro in librustc_traits. 2019-11-13 21:37:37 +01:00
Camille GILLOT
17692b5849 Use TypeFoldable derive macro. 2019-11-13 21:36:57 +01:00
bors
ded5ee0013 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)
2019-11-13 20:10:54 +00:00
Camille GILLOT
9e28e9c545 Create TypeFoldable derive proc-macro. 2019-11-13 20:49:04 +01:00
Dylan MacKenzie
7552bd662f Use ast::Mutability 2019-11-13 10:46:44 -08:00
Dylan MacKenzie
5e048da5a5 Bless miri unleashed test now that errors are mandatory 2019-11-13 10:44:14 -08:00
Dylan MacKenzie
86734b13bb 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.
2019-11-13 10:44:14 -08:00
Dylan MacKenzie
70aa781c2d Change control flow error to delay span bug 2019-11-13 10:44:14 -08:00
Dylan MacKenzie
0123cbdc31 Fix broken doc-test 2019-11-13 10:44:14 -08:00
Dylan MacKenzie
eff83e5f49 Small fixes to comments 2019-11-13 10:44:14 -08:00
Dylan MacKenzie
281e898ecf 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.
2019-11-13 10:44:14 -08:00
Dylan MacKenzie
3ce8ca45d6 Bless const tests with improved diagnostics 2019-11-13 10:44:14 -08:00
Dylan MacKenzie
67336bb399 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.
2019-11-13 10:44:14 -08:00
Dylan MacKenzie
92386e8e57 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.
2019-11-13 10:44:13 -08:00
Dylan MacKenzie
267733b796 Enable const-checking HIR bodies 2019-11-13 10:44:13 -08:00
Dylan MacKenzie
3a84efd0cc Add HIR pass to check for ifs and loops 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.
2019-11-13 10:44:13 -08:00
Dylan MacKenzie
33b62be862 Get FnSig by HirId 2019-11-13 10:44:13 -08:00
Dylan MacKenzie
8b7d2bc270 Add E0744 for control flow in consts 2019-11-13 10:44:13 -08:00
Tomasz Miąsko
1ac470f70c compiletest: Avoid double negation in ignore condition 2019-11-13 18:29:55 +01:00
Tomasz Miąsko
8c6e297816 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.
2019-11-13 17:59:42 +01:00
Robin Kruppe
a1f67ad949 Revert "Auto merge of #65134 - davidtwco:issue-19834-improper-ctypes-in-extern-C-fn, r=rkruppe"
This reverts commit 3f0e16473d, reversing
changes made to 61a551b493.
2019-11-13 17:00:47 +01:00
Yuki Okushi
030fa9a337 Avoid using same code 2019-11-14 00:47:53 +09:00
Benjamin Sago
c154297e6d
Fix broken links in Ipv4Addr::is_benchmarking docs 2019-11-13 15:09:40 +00:00
bors
695fe96517 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
2019-11-13 13:16:53 +00:00
Yuki Okushi
d52dafd2a8
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.
2019-11-13 22:09:31 +09:00
Yuki Okushi
fab583bdfc
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.
2019-11-13 22:09:29 +09:00
Yuki Okushi
f735cd2f89
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.
2019-11-13 22:09:28 +09:00
Yuki Okushi
5683fe5a48
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
2019-11-13 22:09:26 +09:00
Yuki Okushi
60ba5c70fc
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.
2019-11-13 22:09:25 +09:00
Yuki Okushi
1cbd34faf2
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
2019-11-13 22:09:23 +09:00
Yuki Okushi
c75a48a924
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
2019-11-13 22:09:22 +09:00
Yuki Okushi
961d51dcbb
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`.
2019-11-13 22:09:20 +09:00
Yuki Okushi
689cc04614
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.
2019-11-13 22:09:19 +09:00
Yuki Okushi
fac098291e
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.
2019-11-13 22:09:17 +09:00
Yuki Okushi
be3fcf4832
Rollup merge of #66186 - GuillaumeGomez:long-err-explanation-E0623, r=Dylan-DPC
Add long error explanation for E0623

Part of #61137.

r? @Dylan-DPC
2019-11-13 22:09:15 +09:00
Yuki Okushi
6eea5001b5
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
2019-11-13 22:09:13 +09:00
Yuki Okushi
e365d5aac6
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()`.
2019-11-13 22:09:11 +09:00
Yuki Okushi
4ac230ad3d
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
2019-11-13 22:09:10 +09:00
Philip Munksgaard
b03afd5fc4
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.
2019-11-13 12:44:43 +01:00
Mazdak Farrokhzad
dcd91d5ceb parser: don't use unreachable!() in fn unexpected. 2019-11-13 12:05:37 +01:00
Elichai Turkel
0cd111fe97
Doc: Fix link to Exten in Vec::set_len 2019-11-13 12:53:24 +02:00
Ralf Jung
861698a493 make things ugly 2019-11-13 09:31:08 +01:00
Ralf Jung
5b5ae01340 expand docs 2019-11-13 09:11:09 +01:00
Ralf Jung
19ebe2fb6d clarify why we can do the ptr cast 2019-11-13 09:07:52 +01:00
Ralf Jung
aba385abbd
Trailing full stop
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-11-13 09:05:57 +01:00