Commit Graph

140477 Commits

Author SHA1 Message Date
bors 84c08f82b4 Auto merge of #83044 - kubo39:set-llvm-code-model, r=nikic
Add support for storing code model to LLVM module IR

This patch avoids undefined behavior by linking different object files.
Also this would it could be propagated properly to LTO.

See https://reviews.llvm.org/D52322 and https://reviews.llvm.org/D52323.

This patch is based on https://github.com/rust-lang/rust/pull/74002
2021-03-14 11:46:57 +00:00
bors f293f70dd8 Auto merge of #83094 - GuillaumeGomez:crates-js-location, r=Nemo157
crates.js should use root_path and not static_root_path

r? `@Nemo157`
2021-03-14 09:16:23 +00:00
Motoki Ikeda 5ec0540da5 Fix a typo in thread_local_dtor.rs 2021-03-14 16:39:29 +09:00
Motoki Ikeda 71a784d763 Fix a typo in `swap_nonoverlapping_bytes` 2021-03-14 16:32:15 +09:00
Joshua Nelson e161a2fd73 Remove unused `opt_local_def_id_to_hir_id` function
Found while investigating #82933 - all LocalDefIds are expected to have
HirIds, there's no point in pretending otherwise.
2021-03-14 01:37:13 -05:00
bors 2caeeb0527 Auto merge of #83028 - GuillaumeGomez:prevent-js-error-if-no-filter, r=Nemo157
Prevent JS error when there is no dependency or other crate documented (or --disable-per-crate-search has been used)

When there is only one crate, the dropdown is removed, creating an error (that you can see pretty easily on docs.rs for example).

r? `@jyn514`
2021-03-14 06:35:19 +00:00
bors 1381dcfdc5 Auto merge of #83105 - JohnTitor:rollup-tqpm8pb, r=JohnTitor
Rollup of 10 pull requests

Successful merges:

 - #81465 (Add documentation about formatting `Duration` values)
 - #82121 (Implement Extend and FromIterator for OsString)
 - #82617 (Document `everybody_loops`)
 - #82789 (Get with field index from pattern slice instead of directly indexing)
 - #82798 (Rename `rustdoc` to `rustdoc::all`)
 - #82804 (std: Fix a bug on the wasm32-wasi target opening files)
 - #82943 (Demonstrate best practice for feeding stdin of a child processes)
 - #83066 (Add `reverse` search alias for Iterator::rev())
 - #83070 (Update cargo)
 - #83081 (Fix panic message of `assert_failed_inner`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-03-14 04:09:02 +00:00
Yuki Okushi f8206ac63d
Rollup merge of #83081 - hyd-dev:assert-message, r=m-ou-se
Fix panic message of `assert_failed_inner`

cc https://github.com/rust-lang/rust/pull/79100#discussion_r593731020

r? ``@m-ou-se``
2021-03-14 13:07:37 +09:00
Yuki Okushi bc79367d32
Rollup merge of #83070 - ehuss:update-cargo, r=ehuss
Update cargo

7 commits in 970bc67c3775781b9708c8a36893576b9459c64a..32da9eaa5de5be241cf8096ca6b749a157194f77
2021-03-07 18:09:40 +0000 to 2021-03-13 01:18:40 +0000
- Fix logic for determining prefer-dynamic for a dylib. (rust-lang/cargo#9252)
- Fix issue with filtering exclusive target dependencies. (rust-lang/cargo#9255)
- Update pkgid-spec docs. (rust-lang/cargo#9249)
- Wordsmith the edition documentation a bit more (rust-lang/cargo#9233)
- Package ID specification urls must contain a host (rust-lang/cargo#9188)
- Add documentation for JSON message_path. (rust-lang/cargo#9247)
- Fix filter_platform to run on targets other than x86. (rust-lang/cargo#9246)
2021-03-14 13:07:36 +09:00
Yuki Okushi 54546a893d
Rollup merge of #83066 - Seppel3210:master, r=joshtriplett
Add `reverse` search alias for Iterator::rev()

When searching for "reverse" in rustdoc you can't find the rev method on Iterator so here is a search alias for that.
2021-03-14 13:07:35 +09:00
Yuki Okushi dda9d0589f
Rollup merge of #82943 - kornelski:threadstdio, r=joshtriplett
Demonstrate best practice for feeding stdin of a child processes

Documentation change.

It's possible to create a deadlock with stdin/stdout I/O on a single thread:

* the child process may fill its stdout buffer, and have to wait for the parent process to read it,
* but the parent process may be waiting until its stdin write finishes before reading the stdout.

Therefore, the parent process should use separate threads for writing and reading.

These examples are not deadlocking in practice, because they use short strings, but I think it's better to demonstrate code that works even for long writes. The problem is non-obvious and tricky to debug (it seems that even libstd has a similar issue: #45572).

This also demonstrates how to use stdio with threads: it's not obvious that `.take()` can be used to avoid fighting with the borrow checker.

I've checked that the modified examples run fine.
2021-03-14 13:07:34 +09:00
Yuki Okushi 9ce0820eef
Rollup merge of #82804 - alexcrichton:fix-wasi, r=pnkfelix
std: Fix a bug on the wasm32-wasi target opening files

This commit fixes an issue pointed out in #82758 where LTO changed the
behavior of a program. It turns out that LTO was not at fault here, it
simply uncovered an existing bug. The bindings to
`__wasilibc_find_relpath` assumed that the relative portion of the path
returned was always contained within thee input `buf` we passed in. This
isn't actually the case, however, and sometimes the relative portion of
the path may reference a sub-portion of the input string itself.

The fix here is to use the relative path pointer coming out of
`__wasilibc_find_relpath` as the source of truth. The `buf` used for
local storage is discarded in this function and the relative path is
copied out unconditionally. We might be able to get away with some
`Cow`-like business or such to avoid the extra allocation, but for now
this is probably the easiest patch to fix the original issue.
2021-03-14 13:07:33 +09:00
Yuki Okushi 33614023a1
Rollup merge of #82798 - jyn514:rustdoc-group, r=Manishearth,GuillaumeGomez
Rename `rustdoc` to `rustdoc::all`

When rustdoc lints were changed to be tool lints, the `rustdoc` group was removed, leading to spurious warnings like

```
warning: unknown lint: `rustdoc`
```

The lint group still worked when rustdoc ran, since rustdoc added the group itself.

This renames the group to `rustdoc::all` for consistency with `clippy::all` and the rest of the rustdoc lints.

Follow-up to #80527.
r? ``@Manishearth``
2021-03-14 13:07:32 +09:00
Yuki Okushi 0d9a6edb50
Rollup merge of #82789 - csmoe:issue-82772, r=estebank
Get with field index from pattern slice instead of directly indexing

Closes #82772
r? ``@estebank``

https://github.com/rust-lang/rust/pull/82789#issuecomment-796921977
> ``@estebank`` So the real cause is we only generate single pattern for Box here
615b03aeaa/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs (L1130-L1132)
But in the replacing function, it tries to index on the 1-length pattern slice with field 1, thus out of bounds.
615b03aeaa/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs (L1346)
2021-03-14 13:07:31 +09:00
Yuki Okushi f0ebc10410
Rollup merge of #82617 - camelid:everybody_loops-docs, r=jyn514
Document `everybody_loops`

cc `@jyn514`
2021-03-14 13:07:30 +09:00
Yuki Okushi 67bc866e59
Rollup merge of #82121 - lopopolo:pathbuf-osstring-extend, r=joshtriplett
Implement Extend and FromIterator for OsString

Add the following trait impls:

- `impl Extend<OsString> for OsString`
- `impl<'a> Extend<&'a OsStr> for OsString`
- `impl FromIterator<OsString> for OsString`
- `impl<'a> FromIterator<&'a OsStr> for OsString`

Because `OsString` is a platform string with no particular semantics, concatenating them together seems acceptable.

I came across a use case for these trait impls in https://github.com/artichoke/artichoke/pull/1089:

Artichoke is a Ruby interpreter. Its CLI accepts multiple `-e` switches for executing inline Ruby code, like:

```console
$ cargo -q run --bin artichoke -- -e '2.times {' -e 'puts "foo: #{__LINE__}"' -e '}'
foo: 2
foo: 2
```

I use `clap` for command line argument parsing, which collects these `-e` commands into a `Vec<OsString>`. To pass these commands to the interpreter for `Eval`, I need to join them together. Combining these impls with `Iterator::intersperse` https://github.com/rust-lang/rust/issues/79524 would enable me to build a single bit of Ruby code.

Currently, I'm doing something like:

```rust
let mut commands = commands.into_iter();
let mut buf = if let Some(command) = commands.next() {
    command
} else {
    return Ok(Ok(()));
};
for command in commands {
    buf.push("\n");
    buf.push(command);
}
```

If there's interest, I'd also like to add impls for `Cow<'a, OsStr>`, which would avoid allocating the `"\n"` `OsString` in the concatenate + intersperse use case.
2021-03-14 13:07:28 +09:00
Yuki Okushi 6caa350503
Rollup merge of #81465 - joshtriplett:duration-formatting-documentation, r=m-ou-se
Add documentation about formatting `Duration` values

Explain why Duration has a Debug impl but not a Display impl, and
mention the use of Unicode.
2021-03-14 13:07:27 +09:00
Erik Desjardins 0f9af604cf bless tests 2021-03-13 23:04:38 -05:00
Camelid 13884dc2af Update `rustdoc-ui` versions of the `doc-attr` test
It seems there are two copies of it: one in `src/test/ui/attributes/`
and one in `src/test/rustdoc-ui/`. I'm guessing this is to test that the
lint is emitted both when you run the compiler and when you run rustdoc.
2021-03-13 16:36:38 -08:00
Camelid 5134047c40 Add hyphen to "crate level"
"crate level attribute" -> "crate-level attribute"
2021-03-13 16:29:49 -08:00
Simon Vandel Sillesen 35566bfd7d Do not emit alloca for ZST local even if it is uninitialized 2021-03-13 18:01:14 -05:00
Simon Vandel Sillesen bb36e3c7e7 Move ZST check inside UsedLocals 2021-03-13 18:00:28 -05:00
Simon Vandel Sillesen 4e901be57d Extend SimplifyLocals to remove ZST writes 2021-03-13 17:58:11 -05:00
Camelid fe64970ed1 Add another test case 2021-03-13 13:55:15 -08:00
Camelid 7e972a39b8 Report error for each invalid nested attribute 2021-03-13 13:55:15 -08:00
Camelid 8164a74eef Document `everybody_loops` 2021-03-13 13:52:48 -08:00
Camelid 7189c05bf8 Lint non-meta doc attributes
E.g., `#[doc(123)]`.
2021-03-13 13:25:27 -08:00
Camelid 9613a88db5 Refactor `check_doc_attrs` body
This change makes it easier to follow the control flow.

I also moved the end-of-line comments attached to some symbols to before
the symbol listing. This allows rustfmt to format the code; otherwise no
formatting occurs (see rust-lang/rustfmt#4750).
2021-03-13 13:13:27 -08:00
Josh Triplett 8fd2f0c81f Add documentation about formatting `Duration` values
Explain why Duration has a Debug impl but not a Display impl, and
mention the use of Unicode.
2021-03-13 13:06:30 -08:00
Amanieu d'Antras fa3694fada Always lower asm! to valid HIR 2021-03-13 20:49:32 +00:00
bors acca818928 Auto merge of #83064 - cjgillot:fhash, r=jackh726
Tweaks to stable hashing
2021-03-13 20:21:40 +00:00
Guillaume Gomez 48a3bcd860 crates.js should use root_path and not static_root_path 2021-03-13 21:21:03 +01:00
Aaron Hill 06546d4b40
Avoid sorting predicates by `DefId`
Fixes issue #82920

Even if an item does not change between compilation sessions, it may end
up with a different `DefId`, since inserting/deleting an item affects
the `DefId`s of all subsequent items. Therefore, we use a `DefPathHash`
in the incremental compilation system, which is stable in the face of
changes to unrelated items.

In particular, the query system will consider the inputs to a query to
be unchanged if any `DefId`s in the inputs have their `DefPathHash`es
unchanged. Queries are pure functions, so the query result should be
unchanged if the query inputs are unchanged.

Unfortunately, it's possible to inadvertantly make a query result
incorrectly change across compilations, by relying on the specific value
of a `DefId`. Specifically, if the query result is a slice that gets
sorted by `DefId`, the precise order will depend on how the `DefId`s got
assigned in a particular compilation session. If some definitions end up
with different `DefId`s (but the same `DefPathHash`es) in a subsequent
compilation session, we will end up re-computing a *different* value for
the query, even though the query system expects the result to unchanged
due to the unchanged inputs.

It turns out that we have been sorting the predicates computed during
`astconv` by their `DefId`. These predicates make their way into the
`super_predicates_that_define_assoc_type`, which ends up getting used to
compute the vtables of trait objects. This, re-ordering these predicates
between compilation sessions can lead to undefined behavior at runtime -
the query system will re-use code built with a *differently ordered*
vtable, resulting in the wrong method being invoked at runtime.

This PR avoids sorting by `DefId` in `astconv`, fixing the
miscompilation. However, it's possible that other instances of this
issue exist - they could also be easily introduced in the future.

To fully fix this issue, we should
1. Turn on `-Z incremental-verify-ich` by default. This will cause the
   compiler to ICE whenver an 'unchanged' query result changes between
   compilation sessions, instead of causing a miscompilation.
2. Remove the `Ord` impls for `CrateNum` and `DefId`. This will make it
   difficult to introduce ICEs in the first place.
2021-03-13 13:45:12 -05:00
bors e7e1dc158c Auto merge of #83007 - Aaron1011:incr-verify-default, r=Mark-Simulacrum
Turn `-Z incremental-verify-ich` on by default

Issue #82920 showed that the kind of bugs caught by this flag have
soundness implications.
2021-03-13 17:52:22 +00:00
Michael Howell d92f8405ce Remove tab character 2021-03-13 10:29:21 -07:00
Michael Howell 26f85cc172 Avoid potential collisions with `constructor` and the search query 2021-03-13 10:28:36 -07:00
Michael Howell 7834aeb95c Add comments regarding object shapes in buildIndex 2021-03-13 10:14:11 -07:00
Aaron Hill 7d7c81a114
Always run `incremental_verify_ich` when re-computing query results
Issue #82920 showed that the kind of bugs caught by this flag have
soundness implications.

This causes performance regressions of up to 15.2% during incremental
compilation, but this is necessary to catch miscompilations caused by
bugs in query implementations.
2021-03-13 12:00:38 -05:00
Michael Howell b7d14b1b4d Fix jslint warnings 2021-03-13 09:54:19 -07:00
Hiroki Noda 71418384d7 Use only x86_64 flag 2021-03-14 01:46:00 +09:00
Michael Howell ca04ce3645 Use null instead of undefined here 2021-03-13 09:34:52 -07:00
Michael Howell b76a3d3592
Update src/librustdoc/html/static/main.js
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2021-03-13 09:32:40 -07:00
bors 56f74c52c1 Auto merge of #83069 - tgnottingham:simplify-query-cache-iter, r=cjgillot
rustc_query_system: simplify QueryCache::iter

Minor cleanup to reduce a small amount of complexity and code bloat.
Reduces the number of mono items in rustc_query_impl by 15%.
2021-03-13 15:11:25 +00:00
Camille GILLOT ab1782975a Iterate on crate_inherent_impls for metadata. 2021-03-13 14:17:55 +01:00
bors 32dce353de Auto merge of #82891 - cjgillot:monoparent, r=petrochenkov
Make def_key and HIR parenting consistent.

r? `@petrochenkov`
2021-03-13 12:28:04 +00:00
hyd-dev 7ecb5d8601
Add regression tests 2021-03-13 20:10:04 +08:00
hyd-dev bc8093ed55
Fix panic message of `assert_failed_inner` 2021-03-13 18:50:43 +08:00
bors 178bd9130e Auto merge of #82878 - sexxi-goose:repr_packed, r=nikomatsakis
2229: Handle capturing a reference into a repr packed struct

RFC 1240 states that it is unsafe to capture references into a
packed-struct. This PR ensures that when a closure captures a precise
path, we aren't violating this safety constraint.

To acheive so we restrict the capture precision to the struct itself.

An interesting edge case where we decided to restrict precision:
```rust
struct Foo(String);

let foo: Foo;
let c = || {
    println!("{}", foo.0);
    let x = foo.0;
}
```

Given how closures get desugared today, foo.0 will be moved into the
closure, making the `println!`, safe. However this can be very subtle
and also will be unsafe if the closure gets inline.

Closes: https://github.com/rust-lang/project-rfc-2229/issues/33

r? `@nikomatsakis`
2021-03-13 09:47:07 +00:00
Sebastian Widua f201746625 Add `reverse` search alias for Iterator::rev() 2021-03-13 10:07:01 +01:00
bors ec487bf3cf Auto merge of #82760 - WaffleLapkin:unleak_extend_from_within, r=kennytm
Fix leak in Vec::extend_from_within

Fixes #82533
2021-03-13 07:06:01 +00:00