]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoRollup merge of #80572 - thomcc:ok_or_err, r=m-ou-se
Dylan DPC [Wed, 17 Feb 2021 22:51:13 +0000 (23:51 +0100)]
Rollup merge of #80572 - thomcc:ok_or_err, r=m-ou-se

Add a `Result::into_ok_or_err` method to extract a `T` from `Result<T, T>`

When updating code to handle the semi-recent deprecation of `compare_and_swap` in favor of `compare_exchange`, which returns `Result<T, T>`, I wanted this. I've also wanted it with code using `slice::binary_search` before.

The name (and perhaps the documentation) is the hardest part here, but this name seems consistent with the other Result methods, and equivalently memorable.

3 years agoRollup merge of #77728 - lygstate:master, r=Amanieu
Dylan DPC [Wed, 17 Feb 2021 22:51:12 +0000 (23:51 +0100)]
Rollup merge of #77728 - lygstate:master, r=Amanieu

Expose force_quotes on Windows.

On Windows, the arg quotes and not quotes have different effect
for the program it called, if the program called are msys2/cygwin program.
Refer to
https://github.com/msys2/MSYS2-packages/issues/2176

This also solve the issues comes from

https://internals.rust-lang.org/t/std-process-on-windows-is-escaping-raw-literals-which-causes-problems-with-chaining-commands/8163

Tracking issue:
https://github.com/rust-lang/rust/issues/82227

3 years agoAuto merge of #82235 - GuillaumeGomez:rollup-oflxc08, r=GuillaumeGomez
bors [Wed, 17 Feb 2021 19:39:58 +0000 (19:39 +0000)]
Auto merge of #82235 - GuillaumeGomez:rollup-oflxc08, r=GuillaumeGomez

Rollup of 11 pull requests

Successful merges:

 - #79981 (Add 'consider using' message to overflowing_literals)
 - #82094 (To digit simplification)
 - #82105 (Don't fail to remove files if they are missing)
 - #82136 (Fix ICE: Use delay_span_bug for mismatched subst/hir arg)
 - #82169 (Document that `assert!` format arguments are evaluated lazily)
 - #82174 (Replace File::create and write_all with fs::write)
 - #82196 (Add caveat to Path::display() about lossiness)
 - #82198 (Use internal iteration in Iterator::is_sorted_by)
 - #82204 (Update books)
 - #82207 (rustdoc: treat edition 2021 as unstable)
 - #82231 (Add long explanation for E0543)

Failed merges:

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

3 years agoRollup merge of #82231 - jesusprubio:add-long-explanation-e0543, r=GuillaumeGomez
Guillaume Gomez [Wed, 17 Feb 2021 19:38:08 +0000 (20:38 +0100)]
Rollup merge of #82231 - jesusprubio:add-long-explanation-e0543, r=GuillaumeGomez

Add long explanation for E0543

Helps with #61137

3 years agoRollup merge of #82207 - ehuss:rustdoc-2021, r=jyn514
Guillaume Gomez [Wed, 17 Feb 2021 19:38:07 +0000 (20:38 +0100)]
Rollup merge of #82207 - ehuss:rustdoc-2021, r=jyn514

rustdoc: treat edition 2021 as unstable

This ensures that `--edition=2021` requires `-Z unstable-options` in rustdoc.

3 years agoRollup merge of #82204 - ehuss:update-books, r=ehuss
Guillaume Gomez [Wed, 17 Feb 2021 19:38:05 +0000 (20:38 +0100)]
Rollup merge of #82204 - ehuss:update-books, r=ehuss

Update books

## nomicon

1 commits in bbf06ad39d1f45654047e9596b750cc6e6d1b693..adca786547d08fe676b2fc7a6f08c2ed5280ca38
2021-01-22 07:07:31 -0800 to 2021-02-16 16:34:20 +0900
- Merge pull request rust-lang-nursery/nomicon#254 from mdaverde/ml/adds-compiler-err-lifetimes

## reference

9 commits in f02b09eb6e8af340ad1256a54adb7aae2ff3163e..361367c126290ac17cb4089f8d38fd8b2ac43f98
2021-01-22 01:53:02 -0800 to 2021-02-15 09:58:13 -0800
- Define turbofish in the glossary (rust-lang-nursery/reference#964)
- Remove enum variant expr (rust-lang-nursery/reference#963)
- One sentence is one line src/expressions/* (rust-lang-nursery/reference#962)
- Referencify bool type (rust-lang-nursery/reference#940)
- Fix typo in type cast expression table (rust-lang-nursery/reference#959)
- Define rust (rust-lang-nursery/reference#953)
- Remove "Memory Ownership" chapter (rust-lang-nursery/reference#952)
- Added setting nightly as a requirement for running tests (rust-lang-nursery/reference#955)
- Refactored build steps for better readability (rust-lang-nursery/reference#936)

## book

13 commits in e724bd826580ff95df48a8533af7dec1080693d4..db5e8a5105aa22979490dce30e33b68d8645761d
2021-01-20 08:19:49 -0600 to 2021-02-12 16:58:20 -0500
- Update to Rust 1.50
- Fix issue rust-lang/book#2574 - Improve the explanation about the behaviour of `read_line`. (rust-lang/book#2575)
- closures: replace "is called" with "is defined" (rust-lang/book#2556)
- Minor clarification: types -&gt; values in ch16-04 (rust-lang/book#2587)
- fixed hidden code listing (rust-lang/book#2610)
- Merge remote-tracking branch 'origin/pr/2604'
-  (rust-lang/book#2601)
- Merge remote-tracking branch 'origin/pr/2589'
- Fix text wrapping
- Some small rewordings I noticed while rereading just now
-  (rust-lang/book#2592)
- Removed 'of' between type alias in Ch 19-04. (rust-lang/book#2581)
- Merge remote-tracking branch 'origin/pr/2554'

## rust-by-example

2 commits in f633769acef68574427a6fae6c06f13bc2199573..551cc4bc8394feccea6acd21f86d9a4e1d2271a0
2021-01-13 20:58:25 -0300 to 2021-02-03 17:12:37 -0300
- remove // (rust-lang/rust-by-example#1409)
- Update arc.md (rust-lang/rust-by-example#1406)

## edition-guide

3 commits in b91a9a881ee007c12e74e844460ec407cf07a50f..1da3c411f17adb1ba5de1683bb6acee83362b54a
2020-11-02 11:02:03 -0600 to 2021-02-16 16:46:40 -0800
- Update link for no_std. (rust-lang-nursery/edition-guide#231)
- Add git link to the source. (rust-lang-nursery/edition-guide#228)
- Update musl libc link (rust-lang-nursery/edition-guide#230)

## embedded-book

1 commits in ceec19e873be87c6ee5666b030c6bb612f889a96..4cf7981696a85c3e633076c6401611bd3f6346c4
2021-01-03 13:13:10 +0000 to 2021-02-11 10:55:22 +0000
- Fix installing dateutil since it is now a dependency of the GHP import script  (rust-embedded/book#282)

3 years agoRollup merge of #82198 - SkiFire13:optimize-iter-is-sorted, r=sfackler
Guillaume Gomez [Wed, 17 Feb 2021 19:38:04 +0000 (20:38 +0100)]
Rollup merge of #82198 - SkiFire13:optimize-iter-is-sorted, r=sfackler

Use internal iteration in Iterator::is_sorted_by

3 years agoRollup merge of #82196 - Manishearth:display-caveat, r=m-ou-se
Guillaume Gomez [Wed, 17 Feb 2021 19:38:03 +0000 (20:38 +0100)]
Rollup merge of #82196 - Manishearth:display-caveat, r=m-ou-se

Add caveat to Path::display() about lossiness

It's worth calling out that this API may do a lossy display.

r? ```@m-ou-se```

3 years agoRollup merge of #82174 - est31:master, r=oli-obk
Guillaume Gomez [Wed, 17 Feb 2021 19:38:01 +0000 (20:38 +0100)]
Rollup merge of #82174 - est31:master, r=oli-obk

Replace File::create and write_all with fs::write

Also don't convert to u8 buffers and back
when we are only creating strings.

3 years agoRollup merge of #82169 - not-an-aardvark:assert-lazy-format-expressions, r=sfackler
Guillaume Gomez [Wed, 17 Feb 2021 19:38:00 +0000 (20:38 +0100)]
Rollup merge of #82169 - not-an-aardvark:assert-lazy-format-expressions, r=sfackler

Document that `assert!` format arguments are evaluated lazily

It can be useful to do some computation in `assert!` format arguments, in order to get better error messages. For example:

```rust
assert!(
    some_condition,
    "The state is invalid. Details: {}",
    expensive_call_to_get_debugging_info(),
);
```

It seems like `assert!` only evaluates the format arguments if the assertion fails, which is useful but doesn't appear to be documented anywhere. This PR documents the behavior and adds some tests.

3 years agoRollup merge of #82136 - edward-shen:mismatched-subst-and-hir, r=lcnr
Guillaume Gomez [Wed, 17 Feb 2021 19:37:58 +0000 (20:37 +0100)]
Rollup merge of #82136 - edward-shen:mismatched-subst-and-hir, r=lcnr

Fix ICE: Use delay_span_bug for mismatched subst/hir arg

Fixes #82126.

3 years agoRollup merge of #82105 - nagisa:nagisa/ensure-removed, r=petrochenkov
Guillaume Gomez [Wed, 17 Feb 2021 19:37:57 +0000 (20:37 +0100)]
Rollup merge of #82105 - nagisa:nagisa/ensure-removed, r=petrochenkov

Don't fail to remove files if they are missing

In the backend we may want to remove certain temporary files, but in
certain other situations these files might not be produced in the first
place. We don't exactly care about that, and the intent is really that
these files are gone after a certain point in the backend.

Here we unify the backend file removing calls to use `ensure_removed`
which will attempt to delete a file, but will not fail if it does not
exist (anymore).

The tradeoff to this approach is, of course, that we may miss instances
were we are attempting to remove files at wrong paths due to some bug –
compilation would silently succeed but the temporary files would remain
there somewhere.

3 years agoRollup merge of #82094 - gilescope:to_digit_speedup2, r=m-ou-se
Guillaume Gomez [Wed, 17 Feb 2021 19:37:55 +0000 (20:37 +0100)]
Rollup merge of #82094 - gilescope:to_digit_speedup2, r=m-ou-se

To digit simplification

I found out the other day that all the ascii digits have the first four bits as one would hope them to. (Eg. char `2` ends `0b0010`). There are two bits to indicate it's in the digit range ( `0b0011_0000`). If it is a true digit then all the higher bits aside from these two will be 0 (as ascii is the lowest part of the unicode u32 spectrum). So XORing with `0b11_0000` should mean we either get the number 0-9 or alternativly we get a larger number in the u32 space. If we get something that's not 0-9 then it will be discarded as it will be greater than the radix.

The code seems so fast though that there's quite a lot of noise in the benchmarks so it's not that easy to prove conclusively that it's faster as well as less instructions.

The non-fast path I was toying with as well wondering if we could do this as then we'd only have one return and less instructions still:
```
           match self {
                'a'..='z' => self as u32 - 'a' as u32 + 10,
                'A'..='Z' => self as u32 - 'A' as u32 + 10,
                _ => { radix = 10; self as u32 ^ ASCII_DIGIT_MASK},
            }
```

Here's the [godbolt](https://godbolt.org/z/883c9n).

( H/T to ``@byteshadow`` for pointing out xor was what I needed)

3 years agoRollup merge of #79981 - camelid:overflowing_literals-inference-error, r=lcnr
Guillaume Gomez [Wed, 17 Feb 2021 19:37:48 +0000 (20:37 +0100)]
Rollup merge of #79981 - camelid:overflowing_literals-inference-error, r=lcnr

Add 'consider using' message to overflowing_literals

Fixes #79744.

Ironically, the `overflowing_literals` handler for binary or hex already
had this message! You would think it would be the other way around :)

cc ```@scottmcm```

3 years agoExpose force_quotes on Windows.
Yonggang Luo [Thu, 8 Oct 2020 22:26:31 +0000 (22:26 +0000)]
Expose force_quotes on Windows.

Quotes the arg and not quotes the arg have different effect on Windows when the program called
are msys2/cygwin program.
Refer to https://github.com/msys2/MSYS2-packages/issues/2176

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
3 years agoAdd long explanation for E0543
Jesus Rubio [Wed, 17 Feb 2021 17:08:30 +0000 (18:08 +0100)]
Add long explanation for E0543

3 years agoAdd link to tracking issue #82223
Thom Chiovoloni [Wed, 17 Feb 2021 17:04:03 +0000 (09:04 -0800)]
Add link to tracking issue #82223

3 years agoRename Result::ok_or_err to Result::into_ok_or_err
Thom Chiovoloni [Wed, 17 Feb 2021 16:54:52 +0000 (08:54 -0800)]
Rename Result::ok_or_err to Result::into_ok_or_err

3 years agoFix doc link for slice::binary_search
Thom Chiovoloni [Fri, 1 Jan 2021 03:50:24 +0000 (19:50 -0800)]
Fix doc link for slice::binary_search

3 years agoAdd a `Result::ok_or_err` method to extract a `T` from `Result<T, T>`
Thom Chiovoloni [Fri, 1 Jan 2021 02:17:25 +0000 (18:17 -0800)]
Add a `Result::ok_or_err` method to extract a `T` from `Result<T, T>`

3 years agoAuto merge of #82116 - tmiasko:box-error, r=oli-obk
bors [Wed, 17 Feb 2021 16:47:18 +0000 (16:47 +0000)]
Auto merge of #82116 - tmiasko:box-error, r=oli-obk

Reduce size of InterpErrorInfo to 8 bytes

r? `@ghost`

3 years agoAuto merge of #82197 - tmiasko:try-get-cached, r=cjgillot
bors [Wed, 17 Feb 2021 04:07:35 +0000 (04:07 +0000)]
Auto merge of #82197 - tmiasko:try-get-cached, r=cjgillot

Inline try_get_cached

3 years agorustdoc: treat edition 2021 as unstable
Eric Huss [Wed, 17 Feb 2021 03:17:01 +0000 (19:17 -0800)]
rustdoc: treat edition 2021 as unstable

3 years agoUpdate books
Eric Huss [Wed, 17 Feb 2021 01:19:28 +0000 (17:19 -0800)]
Update books

3 years agoEnsure debug_assert! tests get run
Teddy Katz [Wed, 17 Feb 2021 00:05:30 +0000 (19:05 -0500)]
Ensure debug_assert! tests get run

3 years agoUse -Ccodegen-units=1 to make issue-23458 test deterministic
Tomasz Miąsko [Wed, 17 Feb 2021 00:00:00 +0000 (00:00 +0000)]
Use -Ccodegen-units=1 to make issue-23458 test deterministic

The test case fails with either one error or two errors.
Use a single code generation unit to avoid nondeterminism.

3 years agoReduce size of InterpErrorInfo to 8 bytes
Tomasz Miąsko [Sun, 14 Feb 2021 00:00:00 +0000 (00:00 +0000)]
Reduce size of InterpErrorInfo to 8 bytes

3 years agoAuto merge of #81611 - cjgillot:meowner, r=estebank
bors [Tue, 16 Feb 2021 22:14:32 +0000 (22:14 +0000)]
Auto merge of #81611 - cjgillot:meowner, r=estebank

Only store a LocalDefId in some HIR nodes

Some HIR nodes are guaranteed to be HIR owners: Item, TraitItem, ImplItem, ForeignItem and MacroDef.
As a consequence, we do not need to store the `HirId`'s `local_id`, and we can directly store a `LocalDefId`.

This allows to avoid a bit of the dance with `tcx.hir().local_def_id` and `tcx.hir().local_def_id_to_hir_id` mappings.

3 years agoOptimize Iterator::is_sorted_by by using Iterator::all for internal iteration
Giacomo Stevanato [Tue, 16 Feb 2021 20:49:56 +0000 (21:49 +0100)]
Optimize Iterator::is_sorted_by by using Iterator::all for internal iteration

3 years agoAdd caveat to Path::display() about lossiness
Manish Goregaokar [Tue, 16 Feb 2021 19:45:46 +0000 (11:45 -0800)]
Add caveat to Path::display() about lossiness

3 years agoAuto merge of #82192 - GuillaumeGomez:rollup-gi1639b, r=GuillaumeGomez
bors [Tue, 16 Feb 2021 19:21:22 +0000 (19:21 +0000)]
Auto merge of #82192 - GuillaumeGomez:rollup-gi1639b, r=GuillaumeGomez

Rollup of 6 pull requests

Successful merges:

 - #82145 (Fix ES5 errors (IE11))
 - #82160 (Fix typo in rustc_infer::infer::UndoLog)
 - #82161 (Add long explanation for E0545)
 - #82163 (avoid full-slicing slices)
 - #82175 (validation: fix invalid-fn-ptr error message)
 - #82184 ([Minor] Update discriminant_value docs)

Failed merges:

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

3 years agoRollup merge of #82184 - petertodd:2021-discriminant-value-doc, r=nagisa
Guillaume Gomez [Tue, 16 Feb 2021 18:21:21 +0000 (19:21 +0100)]
Rollup merge of #82184 - petertodd:2021-discriminant-value-doc, r=nagisa

[Minor] Update discriminant_value docs

Updated for new `DiscriminantKind` trait.

3 years agoRollup merge of #82175 - RalfJung:invalid-fn-ptr, r=oli-obk
Guillaume Gomez [Tue, 16 Feb 2021 18:21:21 +0000 (19:21 +0100)]
Rollup merge of #82175 - RalfJung:invalid-fn-ptr, r=oli-obk

validation: fix invalid-fn-ptr error message

https://github.com/rust-lang/rust/pull/82061 changed the code here to print an `ImmTy` instead of a `ScalarMaybeUninit`; that was an accident. So go back to printing a `ScalarMaybeUninit`.

r? ```@oli-obk```

3 years agoRollup merge of #82163 - matthiaskrgr:slice, r=jyn514
Guillaume Gomez [Tue, 16 Feb 2021 18:21:20 +0000 (19:21 +0100)]
Rollup merge of #82163 - matthiaskrgr:slice, r=jyn514

avoid full-slicing slices

If we already have a slice, there is no need to get another full-range slice from that, just use the original.
clippy::redundant_slicing

3 years agoRollup merge of #82161 - jesusprubio:add-long-explanation-e0545, r=GuillaumeGomez
Guillaume Gomez [Tue, 16 Feb 2021 18:21:19 +0000 (19:21 +0100)]
Rollup merge of #82161 - jesusprubio:add-long-explanation-e0545, r=GuillaumeGomez

Add long explanation for E0545

Helps with #61137

3 years agoRollup merge of #82160 - pierwill:patch-2, r=lcnr
Guillaume Gomez [Tue, 16 Feb 2021 18:21:18 +0000 (19:21 +0100)]
Rollup merge of #82160 - pierwill:patch-2, r=lcnr

Fix typo in rustc_infer::infer::UndoLog

Also use double quotes.

3 years agoRollup merge of #82145 - GuillaumeGomez:es5-checks, r=Nemo157
Guillaume Gomez [Tue, 16 Feb 2021 18:21:14 +0000 (19:21 +0100)]
Rollup merge of #82145 - GuillaumeGomez:es5-checks, r=Nemo157

Fix ES5 errors (IE11)

rustdoc is supposed to run on IE11 but someone reported me that it wasn't. I just confirmed it by using `es-check` with the `es5` option like this:

```
$ es-check es5 src/librustdoc/html/static/*.js
```

The PR fixes those issues and add CI checks to prevent regressions.

`@Mark-Simulacrum:` I added checks in the CI, but not sure if it's the correct way to do it. Any help on that side would be very appreciated!

r? `@Nemo157`

3 years agoAuto merge of #82150 - RalfJung:miri, r=RalfJung
bors [Tue, 16 Feb 2021 16:22:56 +0000 (16:22 +0000)]
Auto merge of #82150 - RalfJung:miri, r=RalfJung

update Miri

This pulls in the recent cargo-miri fixes by `@hyd-dev.`
Cc `@rust-lang/miri` r? `@ghost`
Fixes https://github.com/rust-lang/rust/issues/82173

3 years agoReplace File::create and write_all with fs::write
est31 [Tue, 16 Feb 2021 07:09:07 +0000 (08:09 +0100)]
Replace File::create and write_all with fs::write

Also don't convert to u8 buffers and back
when we are only creating strings.

3 years ago[Minor] Update discriminant_value docs
Peter Todd [Tue, 16 Feb 2021 13:16:31 +0000 (08:16 -0500)]
[Minor] Update discriminant_value docs

3 years agoupdate Miri
Ralf Jung [Tue, 16 Feb 2021 10:17:42 +0000 (11:17 +0100)]
update Miri

3 years agoadd test
Ralf Jung [Tue, 16 Feb 2021 10:14:34 +0000 (11:14 +0100)]
add test

3 years agovalidation: fix invalid-fn-ptr error message
Ralf Jung [Tue, 16 Feb 2021 08:57:21 +0000 (09:57 +0100)]
validation: fix invalid-fn-ptr error message

3 years agoAuto merge of #82058 - gilescope:to_digit_speedup, r=lcnr
bors [Tue, 16 Feb 2021 08:38:11 +0000 (08:38 +0000)]
Auto merge of #82058 - gilescope:to_digit_speedup, r=lcnr

no need to check assertion on fast path as will always hold.

V small change. Easy to review though!

3 years agoDocument that `assert!` format arguments are evaluated lazily
Teddy Katz [Tue, 16 Feb 2021 02:06:00 +0000 (21:06 -0500)]
Document that `assert!` format arguments are evaluated lazily

It can be useful to do some computation in `assert!` format arguments, in order to get better error messages. For example:

```rust
assert!(
    some_condition,
    "The state is invalid. Details: {}",
    expensive_call_to_get_debugging_info(),
);
```

It seems like `assert!` only evaluates the format arguments if the assertion fails, which is useful but doesn't appear to be documented anywhere. This PR documents the behavior and adds some tests.

3 years agoAuto merge of #81734 - richkadel:fixfordash, r=pnkfelix
bors [Tue, 16 Feb 2021 05:45:10 +0000 (05:45 +0000)]
Auto merge of #81734 - richkadel:fixfordash, r=pnkfelix

Ensures `make` tests run under /bin/dash (if available), like CI, and fixes a Makefile

Note: This cherrypicks #81688 (`@pnkfelix)`

Updates `tools.mk` to explicitly require `SHELL := /bin/dash`, since CI uses `dash` but other environments (including developer local machines) may default to `bash`.

Replaces bash-specific shell command in one Makefile with a dash-compatible alternative, and re-enables the affected Makefile test.

Removes apparently redundant definition of `UNAME`.

Also see: [zulip discussion thread](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/how.20to.20run.2Fbless.20src.2Ftest.2Frun-make-fulldeps.2Fcoverage.20.3F)

r? `@pnkfelix`

FYI: `@wesleywiser` `@tmandry`

3 years agoAuto merge of #82153 - jonas-schievink:rollup-ls5r943, r=jonas-schievink
bors [Tue, 16 Feb 2021 02:14:13 +0000 (02:14 +0000)]
Auto merge of #82153 - jonas-schievink:rollup-ls5r943, r=jonas-schievink

Rollup of 19 pull requests

Successful merges:

 - #81503 (Suggest to create a new `const` item if the `fn` in the array is a `const fn`)
 - #81897 (Add match pattern diagnostics regression test)
 - #81975 (Seal the CommandExt, OsStrExt and OsStringExt traits)
 - #82009 (const_generics: Dont evaluate array length const when handling errors)
 - #82060 (Fix typos in BTreeSet::{first, last} docs)
 - #82061 (CTFE validation: catch ReadPointerAsBytes and better error)
 - #82063 (Fixed minor typo in catch_unwind docs)
 - #82067 (const_generics: Fix incorrect ty::ParamEnv::empty() usage)
 - #82077 (Edit `rustc_arena::DropArena` docs)
 - #82096 (Fix a typo)
 - #82106 (Remove unnecessary `Option` in `default_doc`)
 - #82107 (expand: Some cleanup)
 - #82118 (Add missing env!-decl variant)
 - #82119 (Fix typo in link to CreateSymbolicLinkW documentation.)
 - #82120 (Stabilize Arguments::as_str)
 - #82129 (Remove redundant bool_to_option feature gate)
 - #82133 (Update link for extern prelude.)
 - #82141 (32-bit ARM: Emit `lr` instead of `r14` when specified as an `asm!` output register.)
 - #82147 (:arrow_up: rust-analyzer)

Failed merges:

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

3 years agoInline try_get_cached
Tomasz Miąsko [Tue, 16 Feb 2021 00:00:00 +0000 (00:00 +0000)]
Inline try_get_cached

3 years agoavoid full-slicing slices
Matthias Krüger [Mon, 15 Feb 2021 23:30:06 +0000 (00:30 +0100)]
avoid full-slicing slices

If we already have a slice, there is no need to get another full-range slice from that, just use the original.
clippy::redundant_slicing

3 years agoRemove HirItemLike.
Camille GILLOT [Mon, 1 Feb 2021 10:32:26 +0000 (11:32 +0100)]
Remove HirItemLike.

3 years agoTrait impls are Items, therefore HIR owners.
Camille GILLOT [Mon, 1 Feb 2021 10:12:49 +0000 (11:12 +0100)]
Trait impls are Items, therefore HIR owners.

3 years agoUse less HirId when referring to items.
Camille GILLOT [Sun, 31 Jan 2021 17:21:04 +0000 (18:21 +0100)]
Use less HirId when referring to items.

3 years agoOnly store a LocalDefId in hir::MacroDef.
Camille GILLOT [Sun, 31 Jan 2021 17:20:18 +0000 (18:20 +0100)]
Only store a LocalDefId in hir::MacroDef.

3 years agoIndex Modules using their LocalDefId.
Camille GILLOT [Sun, 31 Jan 2021 16:58:57 +0000 (17:58 +0100)]
Index Modules using their LocalDefId.

3 years agoFix E0657.
Camille GILLOT [Sun, 31 Jan 2021 10:01:49 +0000 (11:01 +0100)]
Fix E0657.

3 years agoOnly store a LocalDefId in hir::ForeignItem.
Camille GILLOT [Sun, 31 Jan 2021 23:33:38 +0000 (00:33 +0100)]
Only store a LocalDefId in hir::ForeignItem.

3 years agoOnly store a LocalDefId in hir::ImplItem.
Camille GILLOT [Sat, 30 Jan 2021 22:25:03 +0000 (23:25 +0100)]
Only store a LocalDefId in hir::ImplItem.

3 years agoOnly store a LocalDefId in hir::TraitItem.
Camille GILLOT [Sat, 30 Jan 2021 19:46:50 +0000 (20:46 +0100)]
Only store a LocalDefId in hir::TraitItem.

3 years agoOnly store a LocalDefId in hir::Item.
Camille GILLOT [Sat, 30 Jan 2021 16:47:51 +0000 (17:47 +0100)]
Only store a LocalDefId in hir::Item.

Items are guaranteed to be HIR owner.

3 years agoUse an ItemId inside mir::GlobalAsm.
Camille GILLOT [Sat, 30 Jan 2021 18:18:48 +0000 (19:18 +0100)]
Use an ItemId inside mir::GlobalAsm.

3 years agoUse ItemId as a strongly typed index.
Camille GILLOT [Sat, 30 Jan 2021 11:06:04 +0000 (12:06 +0100)]
Use ItemId as a strongly typed index.

3 years agoAdd assertions on HIR enum sizes.
Camille GILLOT [Fri, 29 Jan 2021 18:27:56 +0000 (19:27 +0100)]
Add assertions on HIR enum sizes.

3 years agoRemove useless Named trait.
Camille GILLOT [Sat, 30 Jan 2021 10:28:28 +0000 (11:28 +0100)]
Remove useless Named trait.

3 years agoAdd long explanation for E0545
Jesus Rubio [Mon, 15 Feb 2021 18:16:39 +0000 (19:16 +0100)]
Add long explanation for E0545

3 years agoFix typo in rustc_infer::infer::UndoLog
pierwill [Mon, 15 Feb 2021 18:02:03 +0000 (10:02 -0800)]
Fix typo in rustc_infer::infer::UndoLog

Also use double quotes.

3 years agoRollup merge of #82147 - lnicola:rust-analyzer-2021-02-15, r=jonas-schievink
Jonas Schievink [Mon, 15 Feb 2021 15:07:12 +0000 (16:07 +0100)]
Rollup merge of #82147 - lnicola:rust-analyzer-2021-02-15, r=jonas-schievink

:arrow_up: rust-analyzer

3 years agoRollup merge of #82141 - jrvanwhy:issue-82052, r=sanxiyn
Jonas Schievink [Mon, 15 Feb 2021 15:07:11 +0000 (16:07 +0100)]
Rollup merge of #82141 - jrvanwhy:issue-82052, r=sanxiyn

32-bit ARM: Emit `lr` instead of `r14` when specified as an `asm!` output register.

On 32-bit ARM platforms, the register `r14` has the alias `lr`. When used as an output register in `asm!`, rustc canonicalizes the name to `r14`. LLVM only knows the register by the name `lr`, and rejects it. This changes rustc's LLVM code generation to output `lr` instead.

closes #82052

r? ``@nagisa``

3 years agoRollup merge of #82133 - ehuss:extern-prelude-link, r=jyn514
Jonas Schievink [Mon, 15 Feb 2021 15:07:10 +0000 (16:07 +0100)]
Rollup merge of #82133 - ehuss:extern-prelude-link, r=jyn514

Update link for extern prelude.

There was some reorganization in the reference as part of https://github.com/rust-lang/reference/pull/937.

3 years agoRollup merge of #82129 - est31:master, r=jyn514
Jonas Schievink [Mon, 15 Feb 2021 15:07:09 +0000 (16:07 +0100)]
Rollup merge of #82129 - est31:master, r=jyn514

Remove redundant bool_to_option feature gate

3 years agoRollup merge of #82120 - sfackler:arguments-as-str, r=dtolnay
Jonas Schievink [Mon, 15 Feb 2021 15:07:08 +0000 (16:07 +0100)]
Rollup merge of #82120 - sfackler:arguments-as-str, r=dtolnay

Stabilize Arguments::as_str

Closes #74442

3 years agoRollup merge of #82119 - m-ou-se:typo, r=dtolnay
Jonas Schievink [Mon, 15 Feb 2021 15:07:06 +0000 (16:07 +0100)]
Rollup merge of #82119 - m-ou-se:typo, r=dtolnay

Fix typo in link to CreateSymbolicLinkW documentation.

3 years agoRollup merge of #82118 - lukaslueg:env_decl, r=m-ou-se
Jonas Schievink [Mon, 15 Feb 2021 15:07:05 +0000 (16:07 +0100)]
Rollup merge of #82118 - lukaslueg:env_decl, r=m-ou-se

Add missing env!-decl variant

Resolves #82117

3 years agoRollup merge of #82107 - petrochenkov:minexpclean, r=Aaron1011
Jonas Schievink [Mon, 15 Feb 2021 15:07:04 +0000 (16:07 +0100)]
Rollup merge of #82107 - petrochenkov:minexpclean, r=Aaron1011

expand: Some cleanup

See individual commits for details.

r? ``@Aaron1011``

3 years agoRollup merge of #82106 - jyn514:cleanup-bootstrap, r=Mark-Simulacrum
Jonas Schievink [Mon, 15 Feb 2021 15:07:02 +0000 (16:07 +0100)]
Rollup merge of #82106 - jyn514:cleanup-bootstrap, r=Mark-Simulacrum

Remove unnecessary `Option` in `default_doc`

Previously, there were two different ways to encode the same info: `None` or
`Some(&[])`. Now there is only one way, `&[]`.

3 years agoRollup merge of #82096 - TaKO8Ki:fix-typo, r=GuillaumeGomez
Jonas Schievink [Mon, 15 Feb 2021 15:07:01 +0000 (16:07 +0100)]
Rollup merge of #82096 - TaKO8Ki:fix-typo, r=GuillaumeGomez

Fix a typo

This pull request fixes a typo.

3 years agoRollup merge of #82077 - pierwill:edit-droparena, r=lcnr
Jonas Schievink [Mon, 15 Feb 2021 15:07:00 +0000 (16:07 +0100)]
Rollup merge of #82077 - pierwill:edit-droparena, r=lcnr

Edit `rustc_arena::DropArena` docs

- Add a "Safety" section, edit formatting for clarity
- Add missing punctuation in code comments

3 years agoRollup merge of #82067 - BoxyUwU:hahaicantthinkofabadpun, r=oli-obk
Jonas Schievink [Mon, 15 Feb 2021 15:06:59 +0000 (16:06 +0100)]
Rollup merge of #82067 - BoxyUwU:hahaicantthinkofabadpun, r=oli-obk

const_generics: Fix incorrect ty::ParamEnv::empty() usage

Fixes #80561

Not sure if I should keep the `debug!(..)`s or not but its the second time I've needed them so they sure seem useful lol

cc ``@lcnr``
r? ``@oli-obk``

3 years agoRollup merge of #82063 - NULLx76:fix-minor-typo, r=jonas-schievink
Jonas Schievink [Mon, 15 Feb 2021 15:06:58 +0000 (16:06 +0100)]
Rollup merge of #82063 - NULLx76:fix-minor-typo, r=jonas-schievink

Fixed minor typo in catch_unwind docs

Changed "a an exception" to "an exception" inside of the `std::panic::catch_unwind` docs.

3 years agoRollup merge of #82061 - RalfJung:ctfe-read-pointer-as-bytes, r=oli-obk
Jonas Schievink [Mon, 15 Feb 2021 15:06:57 +0000 (16:06 +0100)]
Rollup merge of #82061 - RalfJung:ctfe-read-pointer-as-bytes, r=oli-obk

CTFE validation: catch ReadPointerAsBytes and better error

r? ``@oli-obk``
Fixes https://github.com/rust-lang/rust/issues/79690
Cc https://github.com/rust-lang/miri/issues/1706

3 years agoRollup merge of #82060 - taiki-e:typo, r=m-ou-se
Jonas Schievink [Mon, 15 Feb 2021 15:06:56 +0000 (16:06 +0100)]
Rollup merge of #82060 - taiki-e:typo, r=m-ou-se

Fix typos in BTreeSet::{first, last} docs

map -> set

3 years agoRollup merge of #82009 - BoxyUwU:idontknooow, r=varkor
Jonas Schievink [Mon, 15 Feb 2021 15:06:55 +0000 (16:06 +0100)]
Rollup merge of #82009 - BoxyUwU:idontknooow, r=varkor

const_generics: Dont evaluate array length const when handling errors

Fixes #79518
Fixes #78246

cc ````@lcnr````

This was ICE'ing because we dont pass in the correct ``ParamEnv`` which meant that there was no ``Self: Foo`` predicate to make ``Self::Assoc`` well formed which caused an ICE when trying to normalize ``Self::Assoc`` in the mir interpreter

r? ````@varkor````

3 years agoRollup merge of #81975 - Amanieu:seal2, r=m-ou-se
Jonas Schievink [Mon, 15 Feb 2021 15:06:54 +0000 (16:06 +0100)]
Rollup merge of #81975 - Amanieu:seal2, r=m-ou-se

Seal the CommandExt, OsStrExt and OsStringExt traits

A crater run (https://github.com/rust-lang/rust/pull/81213#issuecomment-767651811) has shown that this does not break any existing code.

This also unblocks #77728.

Based on #81213.

r? ````@m-ou-se````
cc ````@lygstate````

3 years agoRollup merge of #81897 - vandenheuvel:match_exhaustive_diagnostics_regression_test...
Jonas Schievink [Mon, 15 Feb 2021 15:06:53 +0000 (16:06 +0100)]
Rollup merge of #81897 - vandenheuvel:match_exhaustive_diagnostics_regression_test, r=Mark-Simulacrum

Add match pattern diagnostics regression test

Closes #72377 by adding a regression test.

This test case fails on stable but now works on beta and nightly. It *should* have worked already for years, the crucial point whether it is mentioned that some uncovered patterns are not explicitly mentioned.

3 years agoRollup merge of #81503 - henryboisdequin:fix-const-fn-arr-err-msg, r=estebank
Jonas Schievink [Mon, 15 Feb 2021 15:06:47 +0000 (16:06 +0100)]
Rollup merge of #81503 - henryboisdequin:fix-const-fn-arr-err-msg, r=estebank

Suggest to create a new `const` item if the `fn` in the array is a `const fn`

Fixes #73734. If the `fn` in the array repeat expression is a `const fn`, suggest creating a new `const` item. On nightly, suggest creating an inline `const` block. This PR also removes the `suggest_const_in_array_repeat_expressions` as it is no longer necessary.

Example:

```rust
fn main() {
    // Should not compile but hint to create a new const item (stable) or an inline const block (nightly)
    let strings: [String; 5] = [String::new(); 5];
    println!("{:?}", strings);
}

```

Gives this error:

```
error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not satisfied
 --> $DIR/const-fn-in-vec.rs:3:32
  |
2 |     let strings: [String; 5] = [String::new(); 5];
  |                             ^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `String`
  |
  = note: the `Copy` trait is required because the repeated element will be copied
```

With this change, this is the error message:

```
error[E0277]: the trait bound `String: Copy` is not satisfied
  --> $DIR/const-fn-in-vec.rs:3:32
   |
LL |     let strings: [String; 5] = [String::new(); 5];
   |                                ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
   |
   = help: moving the function call to a new `const` item will resolve the error
```

3 years ago:arrow_up: rust-analyzer
Laurențiu Nicola [Mon, 15 Feb 2021 12:58:36 +0000 (14:58 +0200)]
:arrow_up: rust-analyzer

3 years agoAuto merge of #81855 - cjgillot:ensure-cache, r=oli-obk
bors [Mon, 15 Feb 2021 12:11:59 +0000 (12:11 +0000)]
Auto merge of #81855 - cjgillot:ensure-cache, r=oli-obk

Check the result cache before the DepGraph when ensuring queries

Split out of https://github.com/rust-lang/rust/pull/70951

Calling `ensure` on already forced queries is a common operation.
Looking at the results cache first is faster than checking the DepGraph for a green node.

3 years agoFix ES5 errors (IE11)
Guillaume Gomez [Mon, 15 Feb 2021 09:11:37 +0000 (10:11 +0100)]
Fix ES5 errors (IE11)

3 years ago32-bit ARM: Emit `lr` instead of `r14` when specified as an `asm!` output register.
Johnathan Van Why [Mon, 15 Feb 2021 06:05:33 +0000 (22:05 -0800)]
32-bit ARM: Emit `lr` instead of `r14` when specified as an `asm!` output register.

On 32-bit ARM platforms, the register `r14` has the alias `lr`. When used as an output register in `asm!`, rustc canonicalizes the name to `r14`. LLVM only knows the register by the name `lr`, and rejects it. This changes rustc's LLVM code generation to output `lr` instead.

3 years agoUpdate methods.rs
Squirrel [Mon, 15 Feb 2021 07:39:15 +0000 (07:39 +0000)]
Update methods.rs

Remove unused const

3 years agoUse wrapping sub
Squirrel [Mon, 15 Feb 2021 07:35:28 +0000 (07:35 +0000)]
Use wrapping sub

Co-authored-by: Mara <m-ou.se@m-ou.se>
3 years agoRevise HIR lowering comment
Edward Shen [Mon, 15 Feb 2021 05:28:58 +0000 (00:28 -0500)]
Revise HIR lowering comment

3 years agoFix test issue reference
Edward Shen [Mon, 15 Feb 2021 05:03:57 +0000 (00:03 -0500)]
Fix test issue reference

3 years agoUse delay_span_bug for mismatched subst/hir arg
Edward Shen [Mon, 15 Feb 2021 04:59:45 +0000 (23:59 -0500)]
Use delay_span_bug for mismatched subst/hir arg

3 years agoUpdate link for extern prelude.
Eric Huss [Mon, 15 Feb 2021 03:38:40 +0000 (19:38 -0800)]
Update link for extern prelude.

3 years agoRemove redundant bool_to_option feature gate
est31 [Mon, 15 Feb 2021 02:55:52 +0000 (03:55 +0100)]
Remove redundant bool_to_option feature gate

3 years agoStabilize Arguments::as_str
Steven Fackler [Sun, 14 Feb 2021 22:47:08 +0000 (17:47 -0500)]
Stabilize Arguments::as_str

Closes #74442

3 years agoUpdate library/core/src/macros/mod.rs
lukaslueg [Sun, 14 Feb 2021 22:33:43 +0000 (23:33 +0100)]
Update library/core/src/macros/mod.rs

Co-authored-by: Joshua Nelson <joshua@yottadb.com>
3 years agoAuto merge of #82103 - Dylan-DPC:rollup-5wv8rid, r=Dylan-DPC
bors [Sun, 14 Feb 2021 22:26:21 +0000 (22:26 +0000)]
Auto merge of #82103 - Dylan-DPC:rollup-5wv8rid, r=Dylan-DPC

Rollup of 11 pull requests

Successful merges:

 - #80523 (#[doc(inline)] sym_generated)
 - #80920 (Visit more targets when validating attributes)
 - #81720 (Updated smallvec version due to RUSTSEC-2021-0003)
 - #81891 ([rustdoc-json] Make `header` a vec of modifiers, and FunctionPointer consistent)
 - #81912 (Implement the precise analysis pass for lint `disjoint_capture_drop_reorder`)
 - #81914 (Fixing bad suggestion for `_` in `const` type when a function #81885)
 - #81919 (BTreeMap: fix internal comments)
 - #81927 (Add a regression test for #32498)
 - #81965 (Fix MIR pretty printer for non-local DefIds)
 - #82029 (Use debug log level for developer oriented logs)
 - #82056 (fix ice (#82032))

Failed merges:

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

3 years agoFix typo in link to CreateSymbolicLinkW documentation.
Mara Bos [Sun, 14 Feb 2021 22:16:45 +0000 (23:16 +0100)]
Fix typo in link to CreateSymbolicLinkW documentation.

3 years agoAdd missing env!-decl variant
Lukas Lueg [Sun, 14 Feb 2021 21:39:47 +0000 (22:39 +0100)]
Add missing env!-decl variant

Resolves #82117