]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoRollup merge of #79655 - pickfire:visual-vec, r=m-ou-se
Yuki Okushi [Thu, 21 Jan 2021 11:04:38 +0000 (20:04 +0900)]
Rollup merge of #79655 - pickfire:visual-vec, r=m-ou-se

Add Vec visualization to understand capacity

Visualize vector while differentiating between stack and heap.

Inspired by cheats.rs, as this is probably the first place beginner go,
they could understand stack and heap, length and capacity with this. Not
sure if adding this means we should add to other places too.

Superseeds #76066

r? `@m-ou-se`

cc `@the8472` I put back the order of the fields as it feels weird, the note already explains that the order of fields is not guaranteed

3 years agoAuto merge of #81231 - jyn514:flaky-test-2, r=Mark-Simulacrum
bors [Thu, 21 Jan 2021 05:27:30 +0000 (05:27 +0000)]
Auto merge of #81231 - jyn514:flaky-test-2, r=Mark-Simulacrum

Remove flaky test

See https://github.com/rust-lang/rust/pull/81197 for what's going on
here; this is a temporary stopgap until someone has time to review the
proper fix.

r? `@ghost`

3 years agoRemove link to current section
Ivan Tham [Thu, 21 Jan 2021 05:18:12 +0000 (13:18 +0800)]
Remove link to current section

Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
3 years agoRemove flaky test
Joshua Nelson [Thu, 21 Jan 2021 00:18:23 +0000 (19:18 -0500)]
Remove flaky test

See https://github.com/rust-lang/rust/pull/81197 for what's going on
here; this is a temporary stopgap until someone has time to review the
proper fix.

3 years agoAuto merge of #81229 - m-ou-se:solaris-workaround, r=pietroalbini
bors [Wed, 20 Jan 2021 23:40:09 +0000 (23:40 +0000)]
Auto merge of #81229 - m-ou-se:solaris-workaround, r=pietroalbini

Work around missing -dev packages in solaris docker image.

This should hopefully make the `dist-various-2` docker build work again on CI, which is now blocking everything from getting merged.

r? `@pietroalbini`

3 years agoWork around missing -dev packages in solaris docker image.
Mara Bos [Wed, 20 Jan 2021 22:29:55 +0000 (23:29 +0100)]
Work around missing -dev packages in solaris docker image.

3 years agoAdd more details explaning the Vec visualization
Ivan Tham [Sat, 5 Dec 2020 02:21:54 +0000 (10:21 +0800)]
Add more details explaning the Vec visualization

Suggested by oli-obk

3 years agoAdd Vec visualization to understand capacity
Ivan Tham [Thu, 3 Dec 2020 02:56:13 +0000 (10:56 +0800)]
Add Vec visualization to understand capacity

Visualize vector while differentiating between stack and heap.

Inspired by cheats.rs, as this is probably the first place beginner go,
they could understand stack and heap, length and capacity with this. Not
sure if adding this means we should add to other places too.

Superseeds #76066

3 years agoAuto merge of #81118 - ojeda:metadata-obj, r=nagisa
bors [Wed, 20 Jan 2021 07:15:40 +0000 (07:15 +0000)]
Auto merge of #81118 - ojeda:metadata-obj, r=nagisa

Skip linking if it is not required

This allows to use `--emit=metadata,obj` and other metadata + non-link combinations.

Fixes #81117.

3 years agoAuto merge of #81063 - CraftSpider:jsondocck, r=jyn514
bors [Wed, 20 Jan 2021 04:10:36 +0000 (04:10 +0000)]
Auto merge of #81063 - CraftSpider:jsondocck, r=jyn514

Add JsonDocCk Tool for rustdoc-json

Implements a new test system for rustdoc JSON output, jsondocck. Modeled after htmldocck, this tool reads directives in the test file and checks them against the output. These directives use JSONPath, a pair to XPath for json. This obsoletes the old strict subset tool, allowing both finer-grained control of what is tested and better errors on failure.

Not sure on the changes to Cargo.lock, I can back that out if needed.

r? `@jyn514`

3 years agoNo longer require unstable for jsondocck, only build it for json tests
Rune Tynan [Wed, 20 Jan 2021 00:15:04 +0000 (19:15 -0500)]
No longer require unstable for jsondocck, only build it for json tests

3 years agoAuto merge of #79578 - alexcrichton:update-waasi, r=KodrAus
bors [Tue, 19 Jan 2021 22:20:58 +0000 (22:20 +0000)]
Auto merge of #79578 - alexcrichton:update-waasi, r=KodrAus

std: Update wasi-libc commit of the wasm32-wasi target

This brings in an implementation of `current_dir` and `set_current_dir`
(emulation in `wasi-libc`) as well as an updated version of finding
relative paths. This also additionally updates clang to the latest
release to build wasi-libc with.

3 years agoAddress review v2
Rune Tynan [Tue, 19 Jan 2021 19:21:05 +0000 (14:21 -0500)]
Address review v2

3 years agoAuto merge of #80957 - tgnottingham:direct_serialize_depgraph, r=michaelwoerister
bors [Tue, 19 Jan 2021 19:36:41 +0000 (19:36 +0000)]
Auto merge of #80957 - tgnottingham:direct_serialize_depgraph, r=michaelwoerister

Serialize dependency graph directly from DepGraph

Reduce memory usage by serializing dep graph directly from `DepGraph`,
rather than copying it into `SerializedDepGraph` and serializing that.

3 years agoShift another panic into an exit
Rune Tynan [Sat, 16 Jan 2021 06:27:26 +0000 (01:27 -0500)]
Shift another panic into an exit

3 years agoAddress review comments
Rune Tynan [Sat, 16 Jan 2021 05:29:47 +0000 (00:29 -0500)]
Address review comments

3 years agoAdd jsondocck tool, and use it for rustdoc JSON
Rune Tynan [Sat, 16 Jan 2021 01:34:15 +0000 (20:34 -0500)]
Add jsondocck tool, and use it for rustdoc JSON

3 years agoAuto merge of #79705 - ijackson:bufwriter-disassemble, r=m-ou-se
bors [Tue, 19 Jan 2021 16:42:19 +0000 (16:42 +0000)]
Auto merge of #79705 - ijackson:bufwriter-disassemble, r=m-ou-se

BufWriter: Provide into_raw_parts

If something goes wrong, one might want to unpeel the layers of nested
Writers to perform recovery actions on the underlying writer, or reuse
its resources.

`into_inner` can be used for this when the inner writer is still
working.  But when the inner writer is broken, and returning errors,
`into_inner` simply gives you the error from flush, and the same
`Bufwriter` back again.

Here I provide the necessary function, which I have chosen to call
`into_raw_parts`.

I had to do something with `panicked`.  Returning it to the caller as
a boolean seemed rather bare.  Throwing the buffered data away in this
situation also seems unfriendly: maybe the programmer knows something
about the underlying writer and can recover somehow.

So I went for a custom Error.  This may be overkill, but it does have
the nice property that a caller who actually wants to look at the
buffered data, rather than simply extracting the inner writer, will be
told by the type system if they forget to handle the panicked case.

If a caller doesn't need the buffer, it can just be discarded.  That
WriterPanicked is a newtype around Vec<u8> means that hopefully the
layouts of the Ok and Err variants can be very similar, with just a
boolean discriminant.  So this custom error type should compile down
to nearly no code.

*If this general idea is felt appropriate, I will open a tracking issue, etc.*

3 years agoAuto merge of #81186 - GuillaumeGomez:rollup-y2d04g9, r=GuillaumeGomez
bors [Tue, 19 Jan 2021 12:04:22 +0000 (12:04 +0000)]
Auto merge of #81186 - GuillaumeGomez:rollup-y2d04g9, r=GuillaumeGomez

Rollup of 8 pull requests

Successful merges:

 - #80382 (Improve search result tab handling)
 - #81112 (Remove unused alloc::std::ops re-export.)
 - #81115 (BTreeMap: prefer bulk_steal functions over specialized ones)
 - #81147 (Fix structured suggestion for explicit `drop` call)
 - #81161 (Remove inline script tags)
 - #81164 (Fix typo in simplify.rs)
 - #81166 (remove some outdated comments regarding  debug assertions)
 - #81168 (Fixes #81109 - Typo in pointer::wrapping_sub)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agoRollup merge of #81168 - soniasingla:doc/sonia, r=jonas-schievink
Guillaume Gomez [Tue, 19 Jan 2021 09:28:04 +0000 (10:28 +0100)]
Rollup merge of #81168 - soniasingla:doc/sonia, r=jonas-schievink

Fixes #81109 - Typo in pointer::wrapping_sub

Signed-off-by: soniasingla <soniasingla.1812@gmail.com>
Related to issue #81109

3 years agoRollup merge of #81166 - RalfJung:debug-assert-comments, r=Mark-Simulacrum
Guillaume Gomez [Tue, 19 Jan 2021 09:28:03 +0000 (10:28 +0100)]
Rollup merge of #81166 - RalfJung:debug-assert-comments, r=Mark-Simulacrum

remove some outdated comments regarding  debug assertions

https://github.com/rust-lang/rust/pull/79684 removed those debug assertions.

3 years agoRollup merge of #81164 - eltociear:patch-5, r=jonas-schievink
Guillaume Gomez [Tue, 19 Jan 2021 09:28:00 +0000 (10:28 +0100)]
Rollup merge of #81164 - eltociear:patch-5, r=jonas-schievink

Fix typo in simplify.rs

prexisting -> preexisting

3 years agoRollup merge of #81161 - GuillaumeGomez:remove-inline-script, r=Nemo157
Guillaume Gomez [Tue, 19 Jan 2021 09:27:58 +0000 (10:27 +0100)]
Rollup merge of #81161 - GuillaumeGomez:remove-inline-script, r=Nemo157

Remove inline script tags

Fixes #81133.

cc ``@pietroalbini``

r? ``@Nemo157``

3 years agoRollup merge of #81147 - estebank:drop-suggestion, r=varkor
Guillaume Gomez [Tue, 19 Jan 2021 09:27:56 +0000 (10:27 +0100)]
Rollup merge of #81147 - estebank:drop-suggestion, r=varkor

Fix structured suggestion for explicit `drop` call

3 years agoRollup merge of #81115 - ssomers:btree_drainy_refactor_4, r=Mark-Simulacrum
Guillaume Gomez [Tue, 19 Jan 2021 09:27:54 +0000 (10:27 +0100)]
Rollup merge of #81115 - ssomers:btree_drainy_refactor_4, r=Mark-Simulacrum

BTreeMap: prefer bulk_steal functions over specialized ones

The `steal_` functions (apart from their return value) are basically specializations of the more general `bulk_steal_` functions. This PR removes the specializations. The library/alloc benchmarks say this is never slower and up to 6% faster.

r? ``@Mark-Simulacrum``

3 years agoRollup merge of #81112 - m-ou-se:alloc-std-ops-reexport, r=KodrAus
Guillaume Gomez [Tue, 19 Jan 2021 09:27:53 +0000 (10:27 +0100)]
Rollup merge of #81112 - m-ou-se:alloc-std-ops-reexport, r=KodrAus

Remove unused alloc::std::ops re-export.

Removes unused re-export in alloc/lib.rs.

3 years agoRollup merge of #80382 - GuillaumeGomez:search-result-tab-picking, r=Nemo157,pickfire
Guillaume Gomez [Tue, 19 Jan 2021 09:27:50 +0000 (10:27 +0100)]
Rollup merge of #80382 - GuillaumeGomez:search-result-tab-picking, r=Nemo157,pickfire

Improve search result tab handling

Fixes #80378.

If the current search result tab is empty, it picks the first non-empty one. If all are empty, the current one doesn't change. It can be tested with "-> string" (where only the "returned elements" tab is not empty).

r? `@jyn514`

3 years agoAuto merge of #81110 - LeSeulArtichaut:fix-unused-unsafe-label, r=RalfJung
bors [Tue, 19 Jan 2021 08:59:37 +0000 (08:59 +0000)]
Auto merge of #81110 - LeSeulArtichaut:fix-unused-unsafe-label, r=RalfJung

Fix `unused_unsafe` label with `unsafe_block_in_unsafe_fn

Previously, the following code:

```rust
#![feature(unsafe_block_in_unsafe_fn)]

unsafe fn foo() {
    unsafe { unsf() }
}

unsafe fn unsf() {}
```

Would give the following warning:

```
warning: unnecessary `unsafe` block
 --> src/lib.rs:4:5
  |
4 |     unsafe { unsf() }
  |     ^^^^^^ unnecessary `unsafe` block
  |
  = note: `#[warn(unused_unsafe)]` on by default
```
which doesn't point out that the block is in an `unsafe fn`.

Tracking issue: #71668
cc #79208

3 years agoAuto merge of #81169 - dylni:fix-soundness-issue-for-replace-range, r=KodrAus
bors [Tue, 19 Jan 2021 05:58:51 +0000 (05:58 +0000)]
Auto merge of #81169 - dylni:fix-soundness-issue-for-replace-range, r=KodrAus

Fix soundness issue for `replace_range` and `range`

Fixes #81138 by only calling `start_bound` and `end_bound` once.

I also fixed the same issue for [`BTreeMap::range`](https://doc.rust-lang.org/std/collections/struct.BTreeMap.html#method.range) and [`BTreeSet::range`](https://doc.rust-lang.org/std/collections/struct.BTreeSet.html#method.range).

3 years agoFix soundness issue for `replace_range` and `range`
dylni [Tue, 19 Jan 2021 03:14:38 +0000 (22:14 -0500)]
Fix soundness issue for `replace_range` and `range`

3 years agoAuto merge of #81103 - zackmdavis:comma_trail, r=davidtwco
bors [Tue, 19 Jan 2021 02:54:58 +0000 (02:54 +0000)]
Auto merge of #81103 - zackmdavis:comma_trail, r=davidtwco

don't suggest erroneous trailing comma after `..`

In #76612, suggestions were added for missing fields in patterns. However, the suggestions are being inserted just at the end
of the last field in the pattern—before any trailing comma after the last field. This resulted in the "if you don't care about missing fields" suggestion to recommend code with a trailing comma after the field ellipsis (`..,`), which is actually not legal ("`..` must be at the end and cannot have a trailing comma")!

Incidentally, the doc-comment on `error_unmentioned_fields` was using `you_cant_use_this_field` as an example field name (presumably copy-paste inherited from the description of Issue #76077), but the present author found this confusing, because unmentioned fields aren't necessarily unusable.

The suggested code in the diff this commit introduces to `destructuring-assignment/struct_destructure_fail.stderr` doesn't work, but it didn't work beforehand, either (because of the "found reserved identifier `_`" thing), so you can't really call it a regression; it could be fixed in a separate PR.

Resolves #78511.

r? `@davidtwco` or `@estebank`

3 years agoAuto merge of #81042 - sasurau4:fix/unclear-error-with-trait, r=estebank
bors [Tue, 19 Jan 2021 00:00:21 +0000 (00:00 +0000)]
Auto merge of #81042 - sasurau4:fix/unclear-error-with-trait, r=estebank

Add suggestion for impl_candidates with E0283

Fix #42226

3 years agoAuto merge of #80707 - oli-obk:stability_hole_const_intrinsics, r=RalfJung
bors [Mon, 18 Jan 2021 20:54:36 +0000 (20:54 +0000)]
Auto merge of #80707 - oli-obk:stability_hole_const_intrinsics, r=RalfJung

Stability oddity with const intrinsics

cc `@RalfJung`

In https://github.com/rust-lang/rust/pull/80699#discussion_r551495670 `@usbalbin` realized we accepted some intrinsics as `const` without a `#[rustc_const_(un)stable]` attribute. I did some digging, and that example works because intrinsics inherit their stability from their parents... including `#[rustc_const_(un)stable]` attributes. While we may want to fix that (not sure, wasn't there just a MCPed PR that caused this on purpose?), we definitely want tests for it, thus this PR adding tests and some fun tracing statements.

3 years agoAuto merge of #81159 - ssomers:btree_cleanup_search, r=Mark-Simulacrum
bors [Mon, 18 Jan 2021 17:30:38 +0000 (17:30 +0000)]
Auto merge of #81159 - ssomers:btree_cleanup_search, r=Mark-Simulacrum

BTreeMap: convert search functions to methods

And further tweak the signature of `search_linear`, in preparation of a better #81094.

r? `@Mark-Simulacrum`

3 years agoBTreeMap: prefer bulk_steal functions over specialized ones
Stein Somers [Sun, 17 Jan 2021 11:59:44 +0000 (12:59 +0100)]
BTreeMap: prefer bulk_steal functions over specialized ones

3 years agoFixes #81109 - Typo in pointer::wrapping_sub
soniasingla [Mon, 18 Jan 2021 15:01:47 +0000 (20:31 +0530)]
Fixes #81109 - Typo in pointer::wrapping_sub

Signed-off-by: soniasingla <soniasingla.1812@gmail.com>
3 years agoAuto merge of #81165 - KodrAus:rollup-s7llxis, r=KodrAus
bors [Mon, 18 Jan 2021 14:36:30 +0000 (14:36 +0000)]
Auto merge of #81165 - KodrAus:rollup-s7llxis, r=KodrAus

Rollup of 12 pull requests

Successful merges:

 - #81038 (Update Clippy)
 - #81071 (rustc_parse_format: Fix character indices in find_skips)
 - #81100 (prevent potential bug in `encode_with_shorthand`.)
 - #81105 (Initialize a few variables directly)
 - #81116 (ConstProp: Copy body span instead of querying it)
 - #81121 (Avoid logging the whole MIR body in SimplifyCfg)
 - #81123 (Update cmp.rs)
 - #81125 (Add track_caller to .steal())
 - #81128 (validation test: turn some const_err back into validation failures)
 - #81131 (Edit rustc_middle::ty::cast docs)
 - #81142 (Replace let Some(..) = with .is_some())
 - #81153 (Remove unused linkcheck exceptions)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agoAdd test case for suggestion E0283
Daiki Ihara [Fri, 15 Jan 2021 13:33:51 +0000 (22:33 +0900)]
Add test case for suggestion E0283

3 years agoAdd suggestion for impl_candidates with E0283
Daiki Ihara [Fri, 15 Jan 2021 13:33:38 +0000 (22:33 +0900)]
Add suggestion for impl_candidates with E0283

Update compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs

Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
3 years agoremove some outdated comments regarding debug assertions
Ralf Jung [Mon, 18 Jan 2021 12:06:01 +0000 (13:06 +0100)]
remove some outdated comments regarding  debug assertions

3 years agoRollup merge of #81153 - jyn514:linkcheck, r=Manishearth
Ashley Mannix [Mon, 18 Jan 2021 11:53:43 +0000 (21:53 +1000)]
Rollup merge of #81153 - jyn514:linkcheck, r=Manishearth

Remove unused linkcheck exceptions

Found while working on https://github.com/deadlinks/cargo-deadlinks/issues/133.

r? `@Manishearth`

3 years agoRollup merge of #81142 - wcampbell0x2a:replace-Some-with-is-some, r=jonas-schievink
Ashley Mannix [Mon, 18 Jan 2021 11:53:41 +0000 (21:53 +1000)]
Rollup merge of #81142 - wcampbell0x2a:replace-Some-with-is-some, r=jonas-schievink

Replace let Some(..) = with .is_some()

3 years agoRollup merge of #81131 - pierwill:edit-rustc_middle-cast, r=varkor
Ashley Mannix [Mon, 18 Jan 2021 11:53:40 +0000 (21:53 +1000)]
Rollup merge of #81131 - pierwill:edit-rustc_middle-cast, r=varkor

Edit rustc_middle::ty::cast docs

Link to RFC 401 and add missing punctuation.

3 years agoRollup merge of #81128 - RalfJung:validation-testing, r=oli-obk
Ashley Mannix [Mon, 18 Jan 2021 11:53:37 +0000 (21:53 +1000)]
Rollup merge of #81128 - RalfJung:validation-testing, r=oli-obk

validation test: turn some const_err back into validation failures

This resolves the problem I raised at https://github.com/rust-lang/rust/pull/78407#discussion_r556732926.
r? `@oli-obk`

3 years agoRollup merge of #81125 - jyn514:track-caller, r=lcnr
Ashley Mannix [Mon, 18 Jan 2021 11:53:35 +0000 (21:53 +1000)]
Rollup merge of #81125 - jyn514:track-caller, r=lcnr

Add track_caller to .steal()

Before:

```
thread 'rustc' panicked at 'attempt to read from stolen value', /home/joshua/rustc/compiler/rustc_data_structures/src/steal.rs:43:15
```

After:

```
thread 'rustc' panicked at 'attempt to steal from stolen value', compiler/rustc_mir/src/transform/mod.rs:423:25
```

r? `@lcnr`

3 years agoRollup merge of #81123 - sirh3e:sirh3e-patch-1, r=sfackler
Ashley Mannix [Mon, 18 Jan 2021 11:53:33 +0000 (21:53 +1000)]
Rollup merge of #81123 - sirh3e:sirh3e-patch-1, r=sfackler

Update cmp.rs

Fixed space

3 years agoRollup merge of #81121 - tmiasko:simplify-cfg-no-dbg, r=jonas-schievink
Ashley Mannix [Mon, 18 Jan 2021 11:53:31 +0000 (21:53 +1000)]
Rollup merge of #81121 - tmiasko:simplify-cfg-no-dbg, r=jonas-schievink

Avoid logging the whole MIR body in SimplifyCfg

3 years agoRollup merge of #81116 - bugadani:body-span, r=wesleywiser
Ashley Mannix [Mon, 18 Jan 2021 11:53:30 +0000 (21:53 +1000)]
Rollup merge of #81116 - bugadani:body-span, r=wesleywiser

ConstProp: Copy body span instead of querying it

3 years agoRollup merge of #81105 - LingMan:init_directly, r=nagisa
Ashley Mannix [Mon, 18 Jan 2021 11:53:28 +0000 (21:53 +1000)]
Rollup merge of #81105 - LingMan:init_directly, r=nagisa

Initialize a few variables directly

Currently they are declared as `mut`, get initialized to a default value, and
then possibly overwritten.

By initializing to the final value directly, they don't need to be `mut` and
it's clear that they don't get mutated elsewhere later on.

3 years agoRollup merge of #81100 - lcnr:encode_with_shorthand, r=oli-obk
Ashley Mannix [Mon, 18 Jan 2021 11:53:26 +0000 (21:53 +1000)]
Rollup merge of #81100 - lcnr:encode_with_shorthand, r=oli-obk

prevent potential bug in `encode_with_shorthand`.

see https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Remove.20PredicateKind.20in.20favor.20of.20only.20Bin.E2.80.A6.20compiler-team.23397/near/223012169

3 years agoRollup merge of #81071 - osa1:fix_81006, r=estebank
Ashley Mannix [Mon, 18 Jan 2021 11:53:24 +0000 (21:53 +1000)]
Rollup merge of #81071 - osa1:fix_81006, r=estebank

rustc_parse_format: Fix character indices in find_skips

Fixes #81006

3 years agoRollup merge of #81038 - flip1995:clippyup, r=Manishearth
Ashley Mannix [Mon, 18 Jan 2021 11:53:22 +0000 (21:53 +1000)]
Rollup merge of #81038 - flip1995:clippyup, r=Manishearth

Update Clippy

Biweekly Clippy update

r? ``@Manishearth``

3 years agoFix typo in simplify.rs
Ikko Ashimine [Mon, 18 Jan 2021 11:52:10 +0000 (20:52 +0900)]
Fix typo in simplify.rs

prexisting -> preexisting

3 years agoAuto merge of #81015 - jyn514:feature-gate-ptr, r=camelid
bors [Mon, 18 Jan 2021 11:35:19 +0000 (11:35 +0000)]
Auto merge of #81015 - jyn514:feature-gate-ptr, r=camelid

Feature-gate `pointer` and `reference` in intra-doc links

r? `@camelid`

Addresses (but does not close) https://github.com/rust-lang/rust/issues/80896.

3 years agoOnly inherit const stability for methods of `impl const Trait` blocks
oli [Sat, 16 Jan 2021 19:59:21 +0000 (19:59 +0000)]
Only inherit const stability for methods of `impl const Trait` blocks

3 years agoRemove inline script tags
Guillaume Gomez [Mon, 18 Jan 2021 11:03:53 +0000 (12:03 +0100)]
Remove inline script tags

3 years agoAuto merge of #80995 - tmandry:instrument-method-checker, r=lcnr
bors [Mon, 18 Jan 2021 08:39:31 +0000 (08:39 +0000)]
Auto merge of #80995 - tmandry:instrument-method-checker, r=lcnr

Add tracing instrumentation to method typeck

I was recently digging into how this code works, and this instrumentation was helpful.

3 years agoBTreeMap: convert search functions to methods
Stein Somers [Mon, 30 Nov 2020 11:15:25 +0000 (12:15 +0100)]
BTreeMap: convert search functions to methods

3 years agoAuto merge of #80865 - oliviacrain:proj_based, r=RalfJung
bors [Mon, 18 Jan 2021 05:44:40 +0000 (05:44 +0000)]
Auto merge of #80865 - oliviacrain:proj_based, r=RalfJung

Use PlaceRef projection abstractions more consistently in rustc_mir

PlaceRef contains abstractions for dealing with the `projections` array. This PR uses these abstractions more consistently within the `rustc_mir` crate.

See associated issue: rust-lang/rust#80647.

r? `@RalfJung`

3 years agoRemove unused linkcheck exceptions
Joshua Nelson [Mon, 18 Jan 2021 03:19:03 +0000 (22:19 -0500)]
Remove unused linkcheck exceptions

3 years agoAuto merge of #81090 - ssomers:btree_drainy_refactor_2, r=Mark-Simulacrum
bors [Mon, 18 Jan 2021 02:43:19 +0000 (02:43 +0000)]
Auto merge of #81090 - ssomers:btree_drainy_refactor_2, r=Mark-Simulacrum

BTreeMap: offer merge in variants with more clarity

r? `@Mark-Simulacrum`

3 years agoFix structured suggestion for explicit `drop` call
Esteban Küber [Mon, 18 Jan 2021 00:48:52 +0000 (16:48 -0800)]
Fix structured suggestion for explicit `drop` call

3 years agoReplace let Some(..) = with .is_some()
wcampbell [Mon, 18 Jan 2021 00:06:12 +0000 (19:06 -0500)]
Replace let Some(..) = with .is_some()

Signed-off-by: wcampbell <wcampbell1995@gmail.com>
3 years agoAuto merge of #80537 - ehuss:macos-posix-spawn-chdir, r=dtolnay
bors [Sun, 17 Jan 2021 23:44:46 +0000 (23:44 +0000)]
Auto merge of #80537 - ehuss:macos-posix-spawn-chdir, r=dtolnay

Don't use posix_spawn_file_actions_addchdir_np on macOS.

There is a bug on macOS where using `posix_spawn_file_actions_addchdir_np` with a relative executable path will cause `posix_spawnp` to return ENOENT, even though it successfully spawned the process in the given directory.

`posix_spawn_file_actions_addchdir_np` was introduced in macOS 10.15 first released in Oct 2019.  I have tested macOS 10.15.7 and 11.0.1.

Example offending program:

```rust
use std::fs;
use std::os::unix::fs::PermissionsExt;
use std::process::*;

fn main() {
    fs::create_dir_all("bar").unwrap();
    fs::create_dir_all("foo").unwrap();
    fs::write("foo/foo.sh", "#!/bin/sh\necho hello ${PWD}\n").unwrap();
    let perms = fs::Permissions::from_mode(0o755);
    fs::set_permissions("foo/foo.sh", perms).unwrap();
    let c = Command::new("../foo/foo.sh").current_dir("bar").spawn();
    eprintln!("{:?}", c);
}
```

This prints:

```
Err(Os { code: 2, kind: NotFound, message: "No such file or directory" })
hello /Users/eric/Temp/bar
```

I wanted to open this PR to get some feedback on possible solutions.  Alternatives:
* Do nothing.
* Document the bug.
* Try to detect if the executable is a relative path on macOS, and avoid using `posix_spawn_file_actions_addchdir_np` only in that case.

I looked at the [XNU source code](https://opensource.apple.com/source/xnu/xnu-6153.141.1/bsd/kern/kern_exec.c.auto.html), but I didn't see anything obvious that would explain the behavior.  The actual chdir succeeds, it is something else further down that fails, but I couldn't see where.

EDIT: I forgot to mention, relative exe paths with `current_dir` in general are discouraged (see #37868).  I don't know if #37868 is fixable, since normalizing it would change the semantics for some platforms. Another option is to convert the executable to an absolute path with something like joining the cwd with the new cwd and the executable, but I'm uncertain about that.

3 years agoFix test to work with remote-test-server.
Eric Huss [Sun, 17 Jan 2021 22:03:23 +0000 (14:03 -0800)]
Fix test to work with remote-test-server.

remote-test-server does not set the current_dir, and leaves it
as `/`.

3 years agoAuto merge of #80679 - jackh726:predicate-kind-take2, r=lcnr
bors [Sun, 17 Jan 2021 20:49:11 +0000 (20:49 +0000)]
Auto merge of #80679 - jackh726:predicate-kind-take2, r=lcnr

Remove PredicateKind and instead only use Binder<PredicateAtom>

Originally brought up in https://github.com/rust-lang/rust/pull/76814#discussion_r546858171

r? `@lcnr`

3 years agoFeature-gate `pointer` and `reference` in intra-doc links
Joshua Nelson [Thu, 14 Jan 2021 16:55:52 +0000 (11:55 -0500)]
Feature-gate `pointer` and `reference` in intra-doc links

- Only feature gate associated items
- Add docs to unstable book

3 years agoEdit rustc_middle::ty::cast docs
pierwill [Sun, 17 Jan 2021 19:28:02 +0000 (11:28 -0800)]
Edit rustc_middle::ty::cast docs

Link to RFC 401 and add missing punctuation.

3 years agovalidation test: turn some const_err back into validation failures
Ralf Jung [Sun, 17 Jan 2021 18:49:20 +0000 (19:49 +0100)]
validation test: turn some const_err back into validation failures

3 years agoAuto merge of #80524 - jyn514:unknown-tool-lints, r=flip1995,matthewjasper
bors [Sun, 17 Jan 2021 17:52:01 +0000 (17:52 +0000)]
Auto merge of #80524 - jyn514:unknown-tool-lints, r=flip1995,matthewjasper

Don't make tools responsible for checking unknown and renamed lints

Previously, clippy (and any other tool emitting lints) had to have their
own separate UNKNOWN_LINTS pass, because the compiler assumed any tool
lint could be valid. Now, as long as any lint starting with the tool
prefix exists, the compiler will warn when an unknown lint is present.

This may interact with the unstable `tool_lint` feature, which I don't entirely understand, but it will take the burden off those external tools to add their own lint pass, which seems like a step in the right direction to me.

- Don't mark `ineffective_unstable_trait_impl` as an internal lint
- Use clippy's more advanced lint suggestions
- Deprecate the `UNKNOWN_CLIPPY_LINTS` pass (and make it a no-op)
- Say 'unknown lint `clippy::x`' instead of 'unknown lint x'

This is tested by existing clippy tests. When https://github.com/rust-lang/rust/pull/80527 merges, it will also be tested in rustdoc tests. AFAIK there is no way to test this with rustc directly.

3 years agoAdd test for Command::current_dir behavior.
Eric Huss [Fri, 8 Jan 2021 21:15:43 +0000 (13:15 -0800)]
Add test for Command::current_dir behavior.

3 years agoDon't use posix_spawn_file_actions_addchdir_np on macOS.
Eric Huss [Wed, 30 Dec 2020 22:56:51 +0000 (14:56 -0800)]
Don't use posix_spawn_file_actions_addchdir_np on macOS.

3 years agoWhitespace and typo
Jack Huey [Sun, 17 Jan 2021 17:50:04 +0000 (12:50 -0500)]
Whitespace and typo

3 years agoAdd comment about Encodable/Decodable impl
Jack Huey [Sun, 17 Jan 2021 17:32:05 +0000 (12:32 -0500)]
Add comment about Encodable/Decodable impl

3 years agoAdd track_caller to .steal()
Joshua Nelson [Sun, 17 Jan 2021 17:24:53 +0000 (12:24 -0500)]
Add track_caller to .steal()

Before:

```
thread 'rustc' panicked at 'attempt to read from stolen value', /home/joshua/rustc/compiler/rustc_data_structures/src/steal.rs:43:15
```

After:

```
thread 'rustc' panicked at 'attempt to steal from stolen value', compiler/rustc_mir/src/transform/mod.rs:423:25
```

3 years agoFix `unused_unsafe` label with `unsafe_block_in_unsafe_fn
LeSeulArtichaut [Sun, 17 Jan 2021 10:07:43 +0000 (11:07 +0100)]
Fix `unused_unsafe` label with `unsafe_block_in_unsafe_fn

3 years agoUpdate cmp.rs
Marvin Huber [Sun, 17 Jan 2021 15:11:48 +0000 (16:11 +0100)]
Update cmp.rs

Fixed space

3 years agoAvoid logging the whole MIR body in SimplifyCfg
Tomasz Miąsko [Sun, 17 Jan 2021 00:00:00 +0000 (00:00 +0000)]
Avoid logging the whole MIR body in SimplifyCfg

3 years agoAuto merge of #81113 - m-ou-se:rollup-a1unz4x, r=m-ou-se
bors [Sun, 17 Jan 2021 14:50:24 +0000 (14:50 +0000)]
Auto merge of #81113 - m-ou-se:rollup-a1unz4x, r=m-ou-se

Rollup of 13 pull requests

Successful merges:

 - #79298 (correctly deal with late-bound lifetimes in anon consts)
 - #80031 (resolve: Reject ambiguity built-in attr vs different built-in attr)
 - #80201 (Add benchmark and fast path for BufReader::read_exact)
 - #80635 (Improve diagnostics when closure doesn't meet trait bound)
 - #80765 (resolve: Simplify collection of traits in scope)
 - #80932 (Allow downloading LLVM on Windows and MacOS)
 - #80983 (Remove is_dllimport_foreign_item definition from cg_ssa)
 - #81064 (Support non-stage0 check)
 - #81080 (Force vec![] to expression position only)
 - #81082 (BTreeMap: clean up a few more comments)
 - #81084 (Use Option::map instead of open-coding it)
 - #81095 (Use Option::unwrap_or instead of open-coding it)
 - #81107 (Add NonZeroUn::is_power_of_two)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agoSkip linking if it is not required
Miguel Ojeda [Sun, 17 Jan 2021 14:06:47 +0000 (15:06 +0100)]
Skip linking if it is not required

This allows to use `--emit=metadata,obj` and other metadata
+ non-link combinations.

Fixes #81117.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
3 years agorustc_parse_format: Fix character indices in find_skips
Ömer Sinan Ağacan [Sat, 16 Jan 2021 09:46:57 +0000 (12:46 +0300)]
rustc_parse_format: Fix character indices in find_skips

Fixes #81006

3 years agoCopy body span instead of querying it
Dániel Buga [Sun, 17 Jan 2021 13:50:47 +0000 (14:50 +0100)]
Copy body span instead of querying it

3 years agoAdd regression test
oli [Mon, 4 Jan 2021 23:01:58 +0000 (23:01 +0000)]
Add regression test

3 years agoRemove an unnecessary field from a `NonConstOp`
oli [Mon, 4 Jan 2021 23:32:19 +0000 (23:32 +0000)]
Remove an unnecessary field from a `NonConstOp`

3 years agoRollup merge of #81107 - scottmcm:nonzero-is_power_of_two, r=kennytm
Mara Bos [Sun, 17 Jan 2021 12:25:01 +0000 (12:25 +0000)]
Rollup merge of #81107 - scottmcm:nonzero-is_power_of_two, r=kennytm

Add NonZeroUn::is_power_of_two

This saves instructions on both new and old machines <https://rust.godbolt.org/z/4fjTMz>
- On the default x64 target (with no fancy instructions available) it saves a few instructions by not needing to also check for zero.
- On newer targets (with BMI1) it uses `BLSR` for super-short assembly.

This can be used for things like checks against alignments stored in `NonZeroUsize`.

3 years agoRollup merge of #81095 - LingMan:unwrap, r=oli-obk
Mara Bos [Sun, 17 Jan 2021 12:24:59 +0000 (12:24 +0000)]
Rollup merge of #81095 - LingMan:unwrap, r=oli-obk

Use Option::unwrap_or instead of open-coding it

r? ```@oli-obk``` Noticed this while we were talking about the other PR just now 😆
```@rustbot``` modify labels +C-cleanup +T-compiler

3 years agoRollup merge of #81084 - LingMan:map, r=oli-obk
Mara Bos [Sun, 17 Jan 2021 12:24:58 +0000 (12:24 +0000)]
Rollup merge of #81084 - LingMan:map, r=oli-obk

Use Option::map instead of open-coding it

r? ```@oli-obk```
```@rustbot``` modify labels +C-cleanup +T-compiler

3 years agoRollup merge of #81082 - ssomers:btree_cleanup_comments, r=Mark-Simulacrum
Mara Bos [Sun, 17 Jan 2021 12:24:56 +0000 (12:24 +0000)]
Rollup merge of #81082 - ssomers:btree_cleanup_comments, r=Mark-Simulacrum

BTreeMap: clean up a few more comments

And mark `pop` as unsafe.
r? ```@Mark-Simulacrum```

3 years agoRollup merge of #81080 - bugadani:vec-diag, r=oli-obk,m-ou-se
Mara Bos [Sun, 17 Jan 2021 12:24:54 +0000 (12:24 +0000)]
Rollup merge of #81080 - bugadani:vec-diag, r=oli-obk,m-ou-se

Force vec![] to expression position only

r? `@oli-obk`

I went with the lazy way of only changing what broke. I moved the test to ui/macros because the diagnostics no longer give suggestions.

Closes #61933

3 years agoRollup merge of #81064 - Mark-Simulacrum:support-stage1-check, r=jyn514
Mara Bos [Sun, 17 Jan 2021 12:24:53 +0000 (12:24 +0000)]
Rollup merge of #81064 - Mark-Simulacrum:support-stage1-check, r=jyn514

Support non-stage0 check

Seems to work locally - a full stage 1 check succeeds, building std (because we can't get away with checking it), and then checking the compiler and other tools. This ran into the problem that a unconditional x.py check in stage 1 *both* checks and builds stage 1 std, and then has to clean up because for some reason the rmeta and rlib artifacts conflict (though I'm not actually entirely sure why, but it doesn't seem worth digging in in too much detail).

Ideally we wouldn't be building and checking like that but it's a minor worry as checking std is pretty fast and you can avoid it if you're aiming for speed by passing the compiler (e.g., compiler/rustc) explicitly.

r? ```@jyn514```

3 years agoRollup merge of #80983 - bjorn3:no_dup_is_dllimport_foreign_item, r=nagisa
Mara Bos [Sun, 17 Jan 2021 12:24:51 +0000 (12:24 +0000)]
Rollup merge of #80983 - bjorn3:no_dup_is_dllimport_foreign_item, r=nagisa

Remove is_dllimport_foreign_item definition from cg_ssa

It overwrites the definition from rustc_metadata.

cc https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/query.20provided.20twice/near/218927806

Marked as draft to test if this breaks anything.

3 years agoRollup merge of #80932 - jyn514:download-windows-llvm, r=Mark-Simulacrum
Mara Bos [Sun, 17 Jan 2021 12:24:49 +0000 (12:24 +0000)]
Rollup merge of #80932 - jyn514:download-windows-llvm, r=Mark-Simulacrum

Allow downloading LLVM on Windows and MacOS

- Don't ignore packaging `llvm/lib/` for `rust-dev` when LLVM is linked
statically
- Add `link-type.txt` so bootstrap knows whether llvm was linked
  statically or dynamically
- Don't assume CI LLVM is linked dynamically in `bootstrap::config`
- Fall back to dynamic linking if `link-type.txt` doesn't exist
- Fix existing bug that split the output of `llvm-config` on lines, not spaces
- Only special case MacOS when dynamic linking. Static linking works fine.
- Enable building LLVM tests

  This works around the following llvm bug:

  ```
  llvm-config: error: component libraries and shared library

  llvm-config: error: missing: /home/joshua/rustc2/build/x86_64-unknown-linux-gnu/llvm/build/lib/libgtest.a
  llvm-config: error: missing: /home/joshua/rustc2/build/x86_64-unknown-linux-gnu/llvm/build/lib/libgtest_main.a
  llvm-config: error: missing: /home/joshua/rustc2/build/x86_64-unknown-linux-gnu/llvm/build/lib/libLLVMTestingSupport.a
  thread 'main' panicked at 'command did not execute successfully: "/home/joshua/rustc2/build/x86_64-unknown-linux-gnu/llvm/build/bin/llvm-config" "--libfiles"
  ```

  I'm not sure why llvm-config thinks these are required, but to avoid
  the error, this builds them anyway.

- Bump version of `download-ci-llvm-stamp`

  `src/llvm-project` hasn't changed, but the generated tarball has.

Fixes https://github.com/rust-lang/rust/issues/77084.

# Current Status

This works on both MacOS and Windows! :tada: :tada: Thanks to ```@nagisa,``` ```@halkcyon,``` ```@Lokathor,``` ```@jryans,``` and ```@poliorcetics``` for helping me test!

The `if-available` check now supports all tier 1 platforms. Although only x64 apple and x64 msvc have been tested, none of the changes here are Windows or Mac specific, and I expect this to work anywhere that LLVM artifacts are uploaded to CI (i.e. the `rust-dev` component exists).

## Windows

Note that if you have an old version of MSVC build tools you'll need to update them. VS Build Tools 2019 14.28 and later are known to work. With old tools, you may see an error like the following:

```
error LNK2001: unresolved external symbol __imp___std_init_once_complete
```

3 years agoRollup merge of #80765 - petrochenkov:traitsinscope, r=matthewjasper
Mara Bos [Sun, 17 Jan 2021 12:24:47 +0000 (12:24 +0000)]
Rollup merge of #80765 - petrochenkov:traitsinscope, r=matthewjasper

resolve: Simplify collection of traits in scope

"Traits in scope" for a given location are collected by walking all scopes in type namespace, collecting traits in them and pruning traits that don't have an associated item with the given name and namespace.

Previously we tried to prune traits using some kind of hygienic resolution for associated items, but that was complex and likely incorrect, e.g. in #80762 correction to visibilites of trait items caused some traits to not be in scope anymore.
I previously had some comments and concerns about this in https://github.com/rust-lang/rust/pull/65351.

In this PR we are doing some much simpler pruning based on `Symbol` and `Namespace` comparisons, it should be enough to throw away 99.9% of unnecessary traits.
It is not necessary for pruning to be precise because for trait aliases, for example, we don't do any pruning at all, and precise hygienic resolution for associated items needs to be done in typeck anyway.

The somewhat unexpected effect is that trait imports introduced by macros 2.0 now bring traits into scope due to the removed hygienic check on associated item names.
I'm not sure whether it is desirable or not, but I think it's acceptable for now.
The old check was certainly incorrect because macros 2.0 did bring trait aliases into scope.
If doing this is not desirable, then we should come up with some other way to avoid bringing traits from macros 2.0 into scope, that would accommodate for trait aliases as well.

---

The PR also contains a couple of pure refactorings
- Scope walk is done by using `visit_scopes` instead of a hand-rolled version.
- Code is restructured to accomodate for rustdoc that also wants to query traits in scope, but doesn't want to filter them by associated items at all.

r? ```@matthewjasper```

3 years agoRollup merge of #80635 - sexxi-goose:use-place-instead-of-symbol, r=nikomatsakis`
Mara Bos [Sun, 17 Jan 2021 12:24:44 +0000 (12:24 +0000)]
Rollup merge of #80635 - sexxi-goose:use-place-instead-of-symbol, r=nikomatsakis`

Improve diagnostics when closure doesn't meet trait bound

Improves the diagnostics when closure doesn't meet trait bound by modifying `TypeckResuts::closure_kind_origins` such that `hir::Place` is used instead of `Symbol`. Using `hir::Place` to describe which capture influenced the decision of selecting a trait a closure satisfies to (Fn/FnMut/FnOnce, Copy) allows us to show precise path in the diagnostics when `capture_disjoint_field` feature is enabled.

Closes rust-lang/project-rfc-2229/issues/21

r? ```@nikomatsakis```

3 years agoRollup merge of #80201 - saethlin:bufreader-read-exact, r=KodrAus
Mara Bos [Sun, 17 Jan 2021 12:24:42 +0000 (12:24 +0000)]
Rollup merge of #80201 - saethlin:bufreader-read-exact, r=KodrAus

Add benchmark and fast path for BufReader::read_exact

At work, we have a wrapper type that implements this optimization. It would be nice if the standard library were faster.

Before:
```
test io::buffered::tests::bench_buffered_reader_small_reads       ... bench:       7,670 ns/iter (+/- 45)
```
After:
```
test io::buffered::tests::bench_buffered_reader_small_reads       ... bench:       4,457 ns/iter (+/- 41)
```

3 years agoRollup merge of #80031 - petrochenkov:builtina, r=estebank
Mara Bos [Sun, 17 Jan 2021 12:24:41 +0000 (12:24 +0000)]
Rollup merge of #80031 - petrochenkov:builtina, r=estebank

resolve: Reject ambiguity built-in attr vs different built-in attr

Fixes https://github.com/rust-lang/rust/issues/79798.

Resolution ensures that inert attributes cannot be used through imports like this, but built-in attributes don't go through initial resolution (only through resolution validation), so we have to keep some extra data (the built-in attribute name) to prevent it from happening.

3 years agoRollup merge of #79298 - lcnr:new-elysium, r=matthewjasper
Mara Bos [Sun, 17 Jan 2021 12:24:39 +0000 (12:24 +0000)]
Rollup merge of #79298 - lcnr:new-elysium, r=matthewjasper

correctly deal with late-bound lifetimes in anon consts

adds support for using late bound lifetimes of the parent context in anon consts.
```rust
#![feature(const_generics)]
const fn inner<'a>() -> usize where &'a (): Sized { 3 }

fn test<'a>() {
    let _: [u8; inner::<'a>()];
}
```
The lifetime `'a` is late bound in `test` so it's not included in its generics but is instead dealt with separately in borrowck.
This didn't previously work for anon consts as they have to use the late bound lifetimes of their parent which has
to be explicitly handled.

r? ```@matthewjasper``` cc ```@varkor``` ```@eddyb```

3 years agoAuto merge of #81058 - Smittyvb:wasm-num-tests, r=Mark-Simulacrum
bors [Sun, 17 Jan 2021 11:51:47 +0000 (11:51 +0000)]
Auto merge of #81058 - Smittyvb:wasm-num-tests, r=Mark-Simulacrum

Re-enable all num tests on WASM

This was partially done by #47365, but a few tests were missed in that PR.

3 years agoForce vec! to expressions only
Dániel Buga [Sat, 16 Jan 2021 15:32:51 +0000 (16:32 +0100)]
Force vec! to expressions only

3 years agoRemove dead code
Ryan Levick [Fri, 18 Dec 2020 11:27:36 +0000 (12:27 +0100)]
Remove dead code