]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoRollup merge of #82176 - RalfJung:mir-fn-ptr-pretty, r=oli-obk
Guillaume Gomez [Sat, 20 Feb 2021 19:37:00 +0000 (20:37 +0100)]
Rollup merge of #82176 - RalfJung:mir-fn-ptr-pretty, r=oli-obk

fix MIR fn-ptr pretty-printing

An uninitialized function pointer would get printed as `{{uninit  fn()}` (notice the unbalanced parentheses), and a dangling fn ptr would ICE. This fixes both of that.

However, I have no idea how to add tests for this.

Also, I don't understand this MIR pretty-printing code. Somehow the print function `pretty_print_const_scalar` actually *returns* a transformed form of the const (but there is no doc comment explaining what is being returned); some match arms do `p!` while others do `self =`, and there's a wild mixture of `p!` and `write!`... all very mysterious and confusing.^^

r? ``@oli-obk``

3 years agoRollup merge of #81991 - osa1:issue81839, r=estebank
Guillaume Gomez [Sat, 20 Feb 2021 19:36:57 +0000 (20:36 +0100)]
Rollup merge of #81991 - osa1:issue81839, r=estebank

Fix panic in 'remove semicolon' when types are not local

It's not possible to check if removing a semicolon fixes the type error
when checking match arms and one or both of the last arm's and the
current arm's return types are imported "opaque" types. In these cases
we don't generate a "consider removing semicolon" suggestions.

Fixes #81839

---

I'm not sure how to add a test for this. I think the test would need at least two crates. Do we have any existing tests that do this so that I can take a look?

3 years agoRollup merge of #80595 - pthariensflame:patch-1, r=m-ou-se
Guillaume Gomez [Sat, 20 Feb 2021 19:36:54 +0000 (20:36 +0100)]
Rollup merge of #80595 - pthariensflame:patch-1, r=m-ou-se

`impl PartialEq<Punct> for char`; symmetry for #78636

Also fixes the "since" version of the original.

Pinging ``@dtolnay`` and ``@petrochenkov.``

3 years agofn ptr pretty printing: fall back to raw ptr printing
Ralf Jung [Sat, 20 Feb 2021 10:34:35 +0000 (11:34 +0100)]
fn ptr pretty printing: fall back to raw ptr printing

3 years agoAuto merge of #82124 - tmiasko:op-ty-ref, r=oli-obk
bors [Sat, 20 Feb 2021 10:20:42 +0000 (10:20 +0000)]
Auto merge of #82124 - tmiasko:op-ty-ref, r=oli-obk

Pass large interpreter types by reference, not value

r? `@ghost`

3 years agoAuto merge of #81427 - klensy:eat-digits, r=m-ou-se
bors [Sat, 20 Feb 2021 07:31:43 +0000 (07:31 +0000)]
Auto merge of #81427 - klensy:eat-digits, r=m-ou-se

simplify eat_digits

Simplify eat_digits by checking values in iterator, plus decrease function size, by returning unchecked slices.

https://godbolt.org/z/cxjav4

3 years agoAuto merge of #78181 - GuillaumeGomez:sized-trait, r=jyn514
bors [Sat, 20 Feb 2021 04:35:58 +0000 (04:35 +0000)]
Auto merge of #78181 - GuillaumeGomez:sized-trait, r=jyn514

Add Sized trait display when implemented on type

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

I'm not too happy about the hack I had to add in here, however, it seems like the `Sized` trait is **very** special.

cc `@jyn514`
r? `@ollie27`

3 years ago`impl PartialEq<Punct> for char`; symmetry for #78636
Alexander Ronald Altman [Fri, 1 Jan 2021 19:40:00 +0000 (11:40 -0800)]
`impl PartialEq<Punct> for char`; symmetry for #78636

Also fixes the "since" version of the original.

3 years agoAdd tests for !Sized trait display
Guillaume Gomez [Thu, 18 Feb 2021 19:46:34 +0000 (20:46 +0100)]
Add tests for !Sized trait display

3 years agoShow negative implementation of Sized trait
Guillaume Gomez [Thu, 18 Feb 2021 19:46:07 +0000 (20:46 +0100)]
Show negative implementation of Sized trait

3 years agoAuto merge of #82020 - jyn514:mut-passes, r=camelid,GuillaumeGomez
bors [Fri, 19 Feb 2021 16:39:03 +0000 (16:39 +0000)]
Auto merge of #82020 - jyn514:mut-passes, r=camelid,GuillaumeGomez

Make `Clean` take &mut DocContext

- Take `FnMut` in `rustc_trait_selection::find_auto_trait_generics`
- Take `&mut DocContext` in most of `clean`
- Collect the iterator in auto_trait_impls instead of iterating lazily; the lifetimes were really bad.

This combined with https://github.com/rust-lang/rust/pull/82018 should hopefully help with https://github.com/rust-lang/rust/pull/82014 by allowing `cx.cache.exported_traits` to be modified in `register_res`. Previously it had to use interior mutability, which required either adding a RefCell to `cache.exported_traits` on *top* of the existing `RefCell<Cache>` or mixing reads and writes between `cx.exported_traits` and `cx.cache.exported_traits`. I don't currently have that working but I expect it to be reasonably easy to add after this.

3 years agosimplify eat_digits
klensy [Fri, 19 Feb 2021 15:47:22 +0000 (18:47 +0300)]
simplify eat_digits

3 years agoAuto merge of #82281 - Dylan-DPC:rollup-raob2tu, r=Dylan-DPC
bors [Fri, 19 Feb 2021 08:24:01 +0000 (08:24 +0000)]
Auto merge of #82281 - Dylan-DPC:rollup-raob2tu, r=Dylan-DPC

Rollup of 10 pull requests

Successful merges:

 - #79747 (Add explanations and suggestions to `irrefutable_let_patterns` lint)
 - #81496 (name async generators something more human friendly in type error diagnostic)
 - #81873 (Add Mutex::unlock)
 - #82093 (Add tests for Atomic*::fetch_{min,max})
 - #82238 (ast: Keep expansion status for out-of-line module items)
 - #82245 (Do not ICE when evaluating locals' types of invalid `yield`)
 - #82259 (Fix popping singleton paths in when generating E0433)
 - #82261 (rustdoc: Support argument files)
 - #82274 (libtest: Fix unwrap panic on duplicate TestDesc)
 - #82275 (Update cargo)

Failed merges:

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

3 years agoRollup merge of #82275 - ehuss:update-cargo, r=ehuss
Dylan DPC [Fri, 19 Feb 2021 01:49:14 +0000 (02:49 +0100)]
Rollup merge of #82275 - ehuss:update-cargo, r=ehuss

Update cargo

8 commits in ab64d1393b5b77c66b6534ef5023a1b89ee7bf64..bf5a5d5e5d3ae842a63bfce6d070dfd438cf6070
2021-02-10 00:19:10 +0000 to 2021-02-18 15:49:14 +0000
- Propagate `lto=off` harder (rust-lang/cargo#9182)
- refactor: make deref intentions more straightforward (rust-lang/cargo#9183)
- Update link for no_std attribute. (rust-lang/cargo#9174)
- Remove mention of --message-format taking multiple values (rust-lang/cargo#9173)
- Emit warning on env variable case mismatch (rust-lang/cargo#9169)
- Implement Rustdoc versioning checks (rust-lang/cargo#8640)
- Bump to 0.53.0, update changelog (rust-lang/cargo#9168)
- Prevent testsuite from loading config out of sandbox. (rust-lang/cargo#9164)

3 years agoRollup merge of #82274 - andersk:test-unwrap, r=Mark-Simulacrum
Dylan DPC [Fri, 19 Feb 2021 01:49:13 +0000 (02:49 +0100)]
Rollup merge of #82274 - andersk:test-unwrap, r=Mark-Simulacrum

libtest: Fix unwrap panic on duplicate TestDesc

It is possible for different tests to collide to the same `TestDesc` when macros are involved. That is a bug, but it didn’t cause a panic until #81367. For now, change the code to ignore this problem.

Fixes #81852.

This will need to be applied to `beta` too.

3 years agoRollup merge of #82261 - ojeda:rustdoc-argfile, r=jyn514
Dylan DPC [Fri, 19 Feb 2021 01:49:12 +0000 (02:49 +0100)]
Rollup merge of #82261 - ojeda:rustdoc-argfile, r=jyn514

rustdoc: Support argument files

Factors out the `rustc_driver` logic that handles argument files so that rustdoc supports them as well, e.g.:

    rustdoc `@argfile`

This is needed to be able to generate docs for projects that already use argument files when compiling them, e.g. projects that pass a huge number of `--cfg` arguments.

The feature was stabilized for `rustc` in #66172.

3 years agoRollup merge of #82259 - osa1:issue82156, r=petrochenkov
Dylan DPC [Fri, 19 Feb 2021 01:49:11 +0000 (02:49 +0100)]
Rollup merge of #82259 - osa1:issue82156, r=petrochenkov

Fix popping singleton paths in when generating E0433

Fixes #82156

---

This was introduced with #72923, so pinging `@Patryk27` for reviews.

3 years agoRollup merge of #82245 - estebank:issue-78653, r=matthewjasper
Dylan DPC [Fri, 19 Feb 2021 01:49:09 +0000 (02:49 +0100)]
Rollup merge of #82245 - estebank:issue-78653, r=matthewjasper

Do not ICE when evaluating locals' types of invalid `yield`

When a `yield` is outside of a generator, check its value regardless to
avoid an ICE while trying to get all locals' types in writeback.

Fix #78653.

3 years agoRollup merge of #82238 - petrochenkov:nocratemod, r=Aaron1011
Dylan DPC [Fri, 19 Feb 2021 01:49:08 +0000 (02:49 +0100)]
Rollup merge of #82238 - petrochenkov:nocratemod, r=Aaron1011

ast: Keep expansion status for out-of-line module items

I.e. whether a module `mod foo;` is already loaded from a file or not.
This is a pre-requisite to correctly treating inner attributes on such modules (https://github.com/rust-lang/rust/issues/81661).

With this change AST structures for `mod` items diverge even more for AST structure for the crate root, which previously used `ast::Mod`.
Therefore this PR removes `ast::Mod` from `ast::Crate` in the first commit, these two things are sufficiently different from each other, at least at syntactic level.
Customization points for visiting a "`mod` item or crate root" were also removed from AST visitors (`fn visit_mod`).
`ast::Mod` itself was refactored away in the second commit in favor of `ItemKind::Mod(Unsafe, ModKind)`.

3 years agoRollup merge of #82093 - bjorn3:more_atomic_tests, r=kennytm
Dylan DPC [Fri, 19 Feb 2021 01:49:07 +0000 (02:49 +0100)]
Rollup merge of #82093 - bjorn3:more_atomic_tests, r=kennytm

Add tests for Atomic*::fetch_{min,max}

This ensures that all atomic operations except for fences are tested. This has been useful to test my work on using atomic instructions for atomic operations in cg_clif instead of a global lock.

3 years agoRollup merge of #81873 - mark-i-m:unlock, r=m-ou-se
Dylan DPC [Fri, 19 Feb 2021 01:49:06 +0000 (02:49 +0100)]
Rollup merge of #81873 - mark-i-m:unlock, r=m-ou-se

Add Mutex::unlock

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

Discussion: https://github.com/rust-lang/rust/pull/79434#issuecomment-757135874

r? `@m-ou-se`

3 years agoRollup merge of #81496 - guswynn:expected_async_block, r=oli-obk
Dylan DPC [Fri, 19 Feb 2021 01:49:00 +0000 (02:49 +0100)]
Rollup merge of #81496 - guswynn:expected_async_block, r=oli-obk

name async generators something more human friendly in type error diagnostic

fixes #81457

Some details:

1. I opted to load the generator kind from the hir in TyCategory. I also use 1 impl in the hir for the descr
2. I named both the source of the future, in addition to the general type (`future`), not sure what is preferred
3. I am not sure what is required to make sure "generator" is not referred to anywhere. A brief `rg "\"generator\"" showed me that most diagnostics correctly distinguish from generators and async generator, but the `descr` of `DefKind` is pretty general (not sure how thats used)
4. should the descr impl of AsyncGeneratorKind use its display impl instead of copying the string?

3 years agoRollup merge of #79747 - camelid:irrefut-lint-link, r=varkor
Dylan DPC [Fri, 19 Feb 2021 01:48:59 +0000 (02:48 +0100)]
Rollup merge of #79747 - camelid:irrefut-lint-link, r=varkor

Add explanations and suggestions to `irrefutable_let_patterns` lint

Fixes #79716.

3 years agorustdoc: Support argument files
Miguel Ojeda [Thu, 18 Feb 2021 15:15:24 +0000 (16:15 +0100)]
rustdoc: Support argument files

Factors out the `rustc_driver` logic that handles argument files
so that rustdoc supports them as well, e.g.:

    rustdoc @argfile

This is needed to be able to generate docs for projects that
already use argument files when compiling them, e.g. projects
that pass a huge number of `--cfg` arguments.

The feature was stabilized for `rustc` in #66172.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
3 years agoAdd explanations and suggestions to `irrefutable_let_patterns` lint
Camelid [Sat, 5 Dec 2020 21:12:39 +0000 (13:12 -0800)]
Add explanations and suggestions to `irrefutable_let_patterns` lint

3 years agoUpdate cargo
Eric Huss [Thu, 18 Feb 2021 21:04:05 +0000 (13:04 -0800)]
Update cargo

3 years agolibtest: Fix unwrap panic on duplicate TestDesc.
Anders Kaseorg [Thu, 18 Feb 2021 20:41:08 +0000 (12:41 -0800)]
libtest: Fix unwrap panic on duplicate TestDesc.

It is possible for different tests to collide to the same TestDesc
when macros are involved.  That is a bug, but it didn’t cause a panic
until #81367.  For now, change the code to ignore this problem.

Fixes #81852.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
3 years agoAuto merge of #82263 - Dylan-DPC:rollup-cypm2uw, r=Dylan-DPC
bors [Thu, 18 Feb 2021 19:45:42 +0000 (19:45 +0000)]
Auto merge of #82263 - Dylan-DPC:rollup-cypm2uw, r=Dylan-DPC

Rollup of 10 pull requests

Successful merges:

 - #81546 ([libtest] Run the test synchronously when hitting thread limit)
 - #82066 (Ensure valid TraitRefs are created for GATs)
 - #82112 (const_generics: Dont evaluate array length const when handling yet another error )
 - #82194 (In some limited cases, suggest `where` bounds for non-type params)
 - #82215 (Replace if-let and while-let with `if let` and `while let`)
 - #82218 (Make sure pdbs are copied along with exe and dlls when bootstrapping)
 - #82236 (avoid converting types into themselves (clippy::useless_conversion))
 - #82246 (Add long explanation for E0549)
 - #82248 (Optimize counting digits in line numbers during error reporting)
 - #82256 (Print -Ztime-passes (and misc stats/logs) on stderr, not stdout.)

Failed merges:

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

3 years agoadd Mutex::unlock
mark [Mon, 8 Feb 2021 04:50:02 +0000 (22:50 -0600)]
add Mutex::unlock

3 years agoignore file length
Gus Wynn [Thu, 18 Feb 2021 16:17:43 +0000 (08:17 -0800)]
ignore file length

3 years agoFix popping singleton paths in when generating E0433
Ömer Sinan Ağacan [Thu, 18 Feb 2021 14:53:09 +0000 (17:53 +0300)]
Fix popping singleton paths in when generating E0433

Fixes #82156

3 years agoRollup merge of #82256 - eddyb:time-passes-stderr, r=varkor
Dylan DPC [Thu, 18 Feb 2021 15:57:43 +0000 (16:57 +0100)]
Rollup merge of #82256 - eddyb:time-passes-stderr, r=varkor

Print -Ztime-passes (and misc stats/logs) on stderr, not stdout.

I've tried not to change anything that looked similar to `rustc --print`, where people might use automation, and/or any "bulk" prints, such as dumping an entire Graphviz (`dot`) graph on stdout.

The reason I want `-Ztime-passes` to be on stderr like debug logging is I can get a complete (and correctly interleaved) view just by looking at stderr, which is merely a convenience when running `rustc`/Cargo directly, but even more important when it's nested in a build script, as Cargo will split the build script output into stdout (named `output`) and `stderr`.

3 years agoRollup merge of #82248 - nhwn:optimize-counting-digits, r=varkor
Dylan DPC [Thu, 18 Feb 2021 15:57:42 +0000 (16:57 +0100)]
Rollup merge of #82248 - nhwn:optimize-counting-digits, r=varkor

Optimize counting digits in line numbers during error reporting

Replaces `.to_string().len()` with simple loop and integer division, which avoids an unnecessary allocation.

Although I couldn't figure out how to directly profile `rustc`'s error reporting, I ran a microbenchmark on my machine (2.9 GHz Dual-Core Intel Core i5) on the two strategies for `0..100_000`, and the results seem promising:
```
test to_string_len ... bench:  12,124,792 ns/iter (+/- 700,652)
test while_loop    ... bench:      30,333 ns/iter (+/- 562)
```
The x86_64 disassembly reduces integer division to a multiplication + shift, so I don't think there's any problems with using integer division.

For more (micro)optimization, it would be nice if we could avoid the initial check to see if the line number is nonzero, but I don't think `self.get_max_line_num(span, children)` _guarantees_ a nonzero line number.

3 years agoRollup merge of #82246 - jesusprubio:add-long-explanation-e0549, r=GuillaumeGomez
Dylan DPC [Thu, 18 Feb 2021 15:57:41 +0000 (16:57 +0100)]
Rollup merge of #82246 - jesusprubio:add-long-explanation-e0549, r=GuillaumeGomez

Add long explanation for E0549

Helps with #61137

3 years agoRollup merge of #82236 - matthiaskrgr:useless_conv, r=jyn514
Dylan DPC [Thu, 18 Feb 2021 15:57:40 +0000 (16:57 +0100)]
Rollup merge of #82236 - matthiaskrgr:useless_conv, r=jyn514

avoid converting types into themselves (clippy::useless_conversion)

3 years agoRollup merge of #82218 - rylev:copy-pdbs, r=Mark-Simulacrum
Dylan DPC [Thu, 18 Feb 2021 15:57:38 +0000 (16:57 +0100)]
Rollup merge of #82218 - rylev:copy-pdbs, r=Mark-Simulacrum

Make sure pdbs are copied along with exe and dlls when bootstrapping

This makes it easier to find the pdbs when wanting to debug the compiler on Windows.

3 years agoRollup merge of #82215 - TaKO8Ki:replace-if-let-while-let, r=varkor
Dylan DPC [Thu, 18 Feb 2021 15:57:37 +0000 (16:57 +0100)]
Rollup merge of #82215 - TaKO8Ki:replace-if-let-while-let, r=varkor

Replace if-let and while-let with `if let` and `while let`

This pull request replaces if-let and while-let with `if let` and `while let`.

closes https://github.com/rust-lang/rust/issues/82205

3 years agoRollup merge of #82194 - estebank:arbitrary-bounds-suggestion, r=petrochenkov
Dylan DPC [Thu, 18 Feb 2021 15:57:36 +0000 (16:57 +0100)]
Rollup merge of #82194 - estebank:arbitrary-bounds-suggestion, r=petrochenkov

In some limited cases, suggest `where` bounds for non-type params

Partially address #81971.

3 years agoRollup merge of #82112 - BoxyUwU:tumbleweed, r=varkor
Dylan DPC [Thu, 18 Feb 2021 15:57:35 +0000 (16:57 +0100)]
Rollup merge of #82112 - BoxyUwU:tumbleweed, r=varkor

const_generics: Dont evaluate array length const when handling yet another error

Same ICE as #82009 except triggered by a different error.
cc ``@lcnr``
r? ``@varkor``

3 years agoRollup merge of #82066 - matthewjasper:trait-ref-fix, r=jackh726
Dylan DPC [Thu, 18 Feb 2021 15:57:34 +0000 (16:57 +0100)]
Rollup merge of #82066 - matthewjasper:trait-ref-fix, r=jackh726

Ensure valid TraitRefs are created for GATs

This fixes `ProjectionTy::trait_ref` to use the correct substs. Places that need all of the substs have been updated to not use `trait_ref`.

r? ````@jackh726````

3 years agoRollup merge of #81546 - hyd-dev:libtest-run-out-of-threads, r=Mark-Simulacrum
Dylan DPC [Thu, 18 Feb 2021 15:57:33 +0000 (16:57 +0100)]
Rollup merge of #81546 - hyd-dev:libtest-run-out-of-threads, r=Mark-Simulacrum

[libtest] Run the test synchronously when hitting thread limit

libtest currently panics if it hits the thread limit. This often results in spurious test failures (<code>thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 11, kind: WouldBlock, message: "Resource temporarily unavailable" }'</code> ... `error: test failed, to rerun pass '--lib'`). This PR makes it continue to run the test synchronously if it runs out of threads.

Closes #78165.

``@rustbot`` label: A-libtest T-libs

3 years agonhwn: optimize counting digits in line numbers
Nathan Nguyen [Thu, 18 Feb 2021 05:44:37 +0000 (23:44 -0600)]
nhwn: optimize counting digits in line numbers

3 years agoAdd regression test
Ömer Sinan Ağacan [Thu, 18 Feb 2021 13:47:01 +0000 (16:47 +0300)]
Add regression test

3 years agoUpdate 'match-prev-arm-needing-semi'
Ömer Sinan Ağacan [Thu, 11 Feb 2021 17:17:57 +0000 (20:17 +0300)]
Update 'match-prev-arm-needing-semi'

3 years agoCheck opaque type def ids before bailing out
Ömer Sinan Ağacan [Thu, 11 Feb 2021 10:37:00 +0000 (13:37 +0300)]
Check opaque type def ids before bailing out

3 years agoFix panic in 'remove semicolon' when types are not local
Ömer Sinan Ağacan [Thu, 11 Feb 2021 09:53:42 +0000 (12:53 +0300)]
Fix panic in 'remove semicolon' when types are not local

It's not possible to check if removing a semicolon fixes the type error
when checking match arms and one or both of the last arm's and the
current arm's return types are imported "opaque" types. In these cases
we don't generate a "consider removing semicolon" suggestions.

Fixes #81839

3 years agoPrint -Ztime-passes (and misc stats/logs) on stderr, not stdout.
Eduard-Mihai Burtescu [Thu, 18 Feb 2021 12:13:38 +0000 (14:13 +0200)]
Print -Ztime-passes (and misc stats/logs) on stderr, not stdout.

3 years agoAuto merge of #81574 - tmiasko:p, r=oli-obk
bors [Thu, 18 Feb 2021 10:13:36 +0000 (10:13 +0000)]
Auto merge of #81574 - tmiasko:p, r=oli-obk

Precompute ancestors when checking privacy

Precompute ancestors of the old error node set so that check for private
types and traits in public interfaces can in constant time determine if
the current item has any descendants in the old error set.

This removes disparity in compilation time between public and private type
aliases reported in #50614 (from 30 s to 5 s, in an example making extensive use
of private type aliases).

No functional changes intended.

3 years agoast: Keep expansion status for out-of-line module items
Vadim Petrochenkov [Tue, 16 Feb 2021 21:56:07 +0000 (00:56 +0300)]
ast: Keep expansion status for out-of-line module items

Also remove `ast::Mod` which is mostly redundant now

3 years agoast: Stop using `Mod` in `Crate`
Vadim Petrochenkov [Sun, 14 Feb 2021 18:14:12 +0000 (21:14 +0300)]
ast: Stop using `Mod` in `Crate`

Crate root is sufficiently different from `mod` items, at least at syntactic level.

Also remove customization point for "`mod` item or crate root" from AST visitors.

3 years agoUpdate compiler/rustc_error_codes/src/error_codes/E0549.md
Jesús Rubio [Thu, 18 Feb 2021 09:03:01 +0000 (10:03 +0100)]
Update compiler/rustc_error_codes/src/error_codes/E0549.md

Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
3 years agoUpdate compiler/rustc_error_codes/src/error_codes/E0549.md
Jesús Rubio [Thu, 18 Feb 2021 08:38:42 +0000 (09:38 +0100)]
Update compiler/rustc_error_codes/src/error_codes/E0549.md

Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
3 years agoUpdate compiler/rustc_error_codes/src/error_codes/E0549.md
Jesús Rubio [Thu, 18 Feb 2021 08:23:21 +0000 (09:23 +0100)]
Update compiler/rustc_error_codes/src/error_codes/E0549.md

Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
3 years agoAuto merge of #82249 - JohnTitor:rollup-3jbqija, r=JohnTitor
bors [Thu, 18 Feb 2021 07:22:30 +0000 (07:22 +0000)]
Auto merge of #82249 - JohnTitor:rollup-3jbqija, r=JohnTitor

Rollup of 8 pull requests

Successful merges:

 - #82055 (Add diagnostics for specific cases for const/type mismatch err)
 - #82155 (Use !Sync std::lazy::OnceCell in usefulness checking)
 - #82202 (add specs for riscv32/riscv64 musl targets)
 - #82203 (Move some tests to more reasonable directories - 4)
 - #82211 (make `suggest_setup` help messages better)
 - #82212 (Remove redundant rustc_data_structures path component)
 - #82240 (remove useless ?s (clippy::needless_question_marks))
 - #82243 (Add more intra-doc links to std::io)

Failed merges:

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

3 years agoRollup merge of #82243 - pickfire:patch-5, r=jyn514
Yuki Okushi [Thu, 18 Feb 2021 06:57:34 +0000 (15:57 +0900)]
Rollup merge of #82243 - pickfire:patch-5, r=jyn514

Add more intra-doc links to std::io

3 years agoRollup merge of #82240 - matthiaskrgr:qmark, r=Dylan-DPC
Yuki Okushi [Thu, 18 Feb 2021 06:57:33 +0000 (15:57 +0900)]
Rollup merge of #82240 - matthiaskrgr:qmark, r=Dylan-DPC

remove useless ?s (clippy::needless_question_marks)

Example code:
```rust
fn opts() -> Option<String> {
    let s: Option<String> = Some(String::new());
    Some(s?) // this can just be "s"
}
```

3 years agoRollup merge of #82212 - est31:graph_graph_graph, r=oli-obk
Yuki Okushi [Thu, 18 Feb 2021 06:57:32 +0000 (15:57 +0900)]
Rollup merge of #82212 - est31:graph_graph_graph, r=oli-obk

Remove redundant rustc_data_structures path component

3 years agoRollup merge of #82211 - henryboisdequin:make-setup-msgs-better, r=jyn514
Yuki Okushi [Thu, 18 Feb 2021 06:57:30 +0000 (15:57 +0900)]
Rollup merge of #82211 - henryboisdequin:make-setup-msgs-better, r=jyn514

make `suggest_setup` help messages better

When I first built the compiler and didn't create a `config.toml.example`, the following was emitted:

```
help: consider running `x.py setup` or copying `config.toml.example`
```

I ran `x.py setup` but got an error so in this PR I made the help messages a little clearer.

3 years agoRollup merge of #82203 - c410-f3r:tests-tests-tests, r=Dylan-DPC
Yuki Okushi [Thu, 18 Feb 2021 06:57:29 +0000 (15:57 +0900)]
Rollup merge of #82203 - c410-f3r:tests-tests-tests, r=Dylan-DPC

Move some tests to more reasonable directories - 4

cc #81941

3 years agoRollup merge of #82202 - kraj:kraj/riscv-musl, r=estebank
Yuki Okushi [Thu, 18 Feb 2021 06:57:28 +0000 (15:57 +0900)]
Rollup merge of #82202 - kraj:kraj/riscv-musl, r=estebank

add specs for riscv32/riscv64 musl targets

Signed-off-by: Khem Raj <raj.khem@gmail.com>
3 years agoRollup merge of #82155 - tmiasko:once, r=matthewjasper
Yuki Okushi [Thu, 18 Feb 2021 06:57:27 +0000 (15:57 +0900)]
Rollup merge of #82155 - tmiasko:once, r=matthewjasper

Use !Sync std::lazy::OnceCell in usefulness checking

The `rustc_data_structures::sync::OnceCell` is thread-safe when building
a parallel compiler. This is unnecessary for the purposes of pattern
usefulness checking. Use `!Sync` `std::lazy::OnceCell` instead.

3 years agoRollup merge of #82055 - JulianKnodt:ty_where_const, r=estebank
Yuki Okushi [Thu, 18 Feb 2021 06:57:26 +0000 (15:57 +0900)]
Rollup merge of #82055 - JulianKnodt:ty_where_const, r=estebank

Add diagnostics for specific cases for const/type mismatch err

For now, this adds at least more information so better diagnostics can be emitted for const mismatch errors.

I'm not sure what exactly we want to emit, so I've left notes there temporarily, also to see if this is the right approach

r? ```@lcnr```
cc: ```@estebank```

3 years agoAdd long explanation for E0549
Jesus Rubio [Thu, 18 Feb 2021 05:53:01 +0000 (06:53 +0100)]
Add long explanation for E0549

3 years agoDo not ICE when evaluating locals' types of invalid `yield`
Esteban Küber [Thu, 18 Feb 2021 04:44:00 +0000 (20:44 -0800)]
Do not ICE when evaluating locals' types of invalid `yield`

When a `yield` is outside of a generator, check its value regardless to
avoid an ICE while trying to get all locals' types in writeback.

Fix #78653.

3 years agoAuto merge of #81172 - SimonSapin:ptr-metadata, r=oli-obk
bors [Thu, 18 Feb 2021 04:22:16 +0000 (04:22 +0000)]
Auto merge of #81172 - SimonSapin:ptr-metadata, r=oli-obk

Implement RFC 2580: Pointer metadata & VTable

RFC: https://github.com/rust-lang/rfcs/pull/2580

~~Before merging this PR:~~

* [x] Wait for the end of the RFC’s [FCP to merge](https://github.com/rust-lang/rfcs/pull/2580#issuecomment-759145278).
* [x] Open a tracking issue: https://github.com/rust-lang/rust/issues/81513
* [x] Update `#[unstable]` attributes in the PR with the tracking issue number

----

This PR extends the language with a new lang item for the `Pointee` trait which is special-cased in trait resolution to implement it for all types. Even in generic contexts, parameters can be assumed to implement it without a corresponding bound.

For this I mostly imitated what the compiler was already doing for the `DiscriminantKind` trait. I’m very unfamiliar with compiler internals, so careful review is appreciated.

This PR also extends the standard library with new unstable APIs in `core::ptr` and `std::ptr`:

```rust
pub trait Pointee {
    /// One of `()`, `usize`, or `DynMetadata<dyn SomeTrait>`
    type Metadata: Copy + Send + Sync + Ord + Hash + Unpin;
}

pub trait Thin = Pointee<Metadata = ()>;

pub const fn metadata<T: ?Sized>(ptr: *const T) -> <T as Pointee>::Metadata {}

pub const fn from_raw_parts<T: ?Sized>(*const (), <T as Pointee>::Metadata) -> *const T {}
pub const fn from_raw_parts_mut<T: ?Sized>(*mut (),<T as Pointee>::Metadata) -> *mut T {}

impl<T: ?Sized> NonNull<T> {
    pub const fn from_raw_parts(NonNull<()>, <T as Pointee>::Metadata) -> NonNull<T> {}

    /// Convenience for `(ptr.cast(), metadata(ptr))`
    pub const fn to_raw_parts(self) -> (NonNull<()>, <T as Pointee>::Metadata) {}
}

impl<T: ?Sized> *const T {
    pub const fn to_raw_parts(self) -> (*const (), <T as Pointee>::Metadata) {}
}

impl<T: ?Sized> *mut T {
    pub const fn to_raw_parts(self) -> (*mut (), <T as Pointee>::Metadata) {}
}

/// `<dyn SomeTrait as Pointee>::Metadata == DynMetadata<dyn SomeTrait>`
pub struct DynMetadata<Dyn: ?Sized> {
    // Private pointer to vtable
}

impl<Dyn: ?Sized> DynMetadata<Dyn> {
    pub fn size_of(self) -> usize {}
    pub fn align_of(self) -> usize {}
    pub fn layout(self) -> crate::alloc::Layout {}
}

unsafe impl<Dyn: ?Sized> Send for DynMetadata<Dyn> {}
unsafe impl<Dyn: ?Sized> Sync for DynMetadata<Dyn> {}
impl<Dyn: ?Sized> Debug for DynMetadata<Dyn> {}
impl<Dyn: ?Sized> Unpin for DynMetadata<Dyn> {}
impl<Dyn: ?Sized> Copy for DynMetadata<Dyn> {}
impl<Dyn: ?Sized> Clone for DynMetadata<Dyn> {}
impl<Dyn: ?Sized> Eq for DynMetadata<Dyn> {}
impl<Dyn: ?Sized> PartialEq for DynMetadata<Dyn> {}
impl<Dyn: ?Sized> Ord for DynMetadata<Dyn> {}
impl<Dyn: ?Sized> PartialOrd for DynMetadata<Dyn> {}
impl<Dyn: ?Sized> Hash for DynMetadata<Dyn> {}
```

API differences from the RFC, in areas noted as unresolved questions in the RFC:

* Module-level functions instead of associated `from_raw_parts` functions on `*const T` and `*mut T`, following the precedent of `null`, `slice_from_raw_parts`, etc.
* Added `to_raw_parts`

3 years agoAdd missing link from stdio doc
Ivan Tham [Thu, 18 Feb 2021 01:58:15 +0000 (09:58 +0800)]
Add missing link from stdio doc

3 years agoAuto merge of #82241 - Dylan-DPC:rollup-munmzg5, r=Dylan-DPC
bors [Thu, 18 Feb 2021 01:31:10 +0000 (01:31 +0000)]
Auto merge of #82241 - Dylan-DPC:rollup-munmzg5, r=Dylan-DPC

Rollup of 8 pull requests

Successful merges:

 - #77728 (Expose force_quotes on Windows.)
 - #80572 (Add a `Result::into_ok_or_err` method to extract a `T` from `Result<T, T>`)
 - #81860 (Fix SourceMap::start_point)
 - #81869 (Simplify pattern grammar, improve or-pattern diagnostics)
 - #81898 (Fix debug information for function arguments of type &str or slice.)
 - #81972 (Placeholder lifetime error cleanup)
 - #82007 (Implement reborrow for closure captures)
 - #82021 (Spell out nested Self type in lint message)

Failed merges:

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

3 years agoRollup merge of #82021 - csmoe:issue-78600, r=tmandry
Dylan DPC [Wed, 17 Feb 2021 22:51:20 +0000 (23:51 +0100)]
Rollup merge of #82021 - csmoe:issue-78600, r=tmandry

Spell out nested Self type in lint message

Closes #78600
r? `@tmandry`

3 years agoRollup merge of #82007 - sexxi-goose:reborrow, r=nikomatsakis
Dylan DPC [Wed, 17 Feb 2021 22:51:19 +0000 (23:51 +0100)]
Rollup merge of #82007 - sexxi-goose:reborrow, r=nikomatsakis

Implement reborrow for closure captures

The strategy for captures is detailed here with examples: https://hackmd.io/PzxYMPY4RF-B9iH9uj9GTA

Key points:
- We only need to reborrow a capture in case of move closures.
  - If we mutate something via a `&mut` we store it as a `MutBorrow`/`UniqueMuBorrow` of the path containing the `&mut`,
  - Similarly, if it's read via `&` ref we just store it as a `ImmBorrow` of the path containing the `&` ref.
  - If a path doesn't deref a `&mut`, `&`, then that path is captured by Move.
  - If the use of a path results in a move when the closure is called, then that path is truncated before any deref and the truncated path is moved into the closure.

- In the case of non-move closure if a use of a path results in a move, then the path is truncated before any deref and the truncated path is moved into the closure.

Note that the implementation differs a bit from the document to allow for truncated path to be used in the ClosureKind analysis that happens as part of the first capture analysis pass.

Closes: https://github.com/rust-lang/project-rfc-2229/issues/31
r? ````@nikomatsakis````

3 years agoRollup merge of #81972 - matthewjasper:hrtb-error-cleanup, r=nikomatsakis
Dylan DPC [Wed, 17 Feb 2021 22:51:18 +0000 (23:51 +0100)]
Rollup merge of #81972 - matthewjasper:hrtb-error-cleanup, r=nikomatsakis

Placeholder lifetime error cleanup

- Remove note of trait definition
- Avoid repeating the same self type
- Use original region names when possible
- Use this error kind more often
- Print closure signatures when they are suppose to implement `Fn*` traits

Works towards #57374

r? ```@nikomatsakis```

3 years agoRollup merge of #81898 - nanguye2496:nanguye2496/fix_str_and_slice_visualization...
Dylan DPC [Wed, 17 Feb 2021 22:51:17 +0000 (23:51 +0100)]
Rollup merge of #81898 - nanguye2496:nanguye2496/fix_str_and_slice_visualization, r=varkor

Fix debug information for function arguments of type &str or slice.

Issue details:
When lowering MIR to LLVM IR, the compiler decomposes every &str and slice argument into a data pointer and a usize. Then, the original argument is reconstructed from the pointer and the usize arguments in the body of the function that owns it. Since the original argument is declared in the body of a function, it should be marked as a LocalVariable instead of an ArgumentVairable. This confusion causes MSVC debuggers unable to visualize &str and slice arguments correctly. (See https://github.com/rust-lang/rust/issues/81894 for more details).

Fix details:
Making sure that the debug variable for every &str and slice argument is marked as LocalVariable instead of ArgumentVariable in computing_per_local_var_debug_info. This change has been verified on VS Code debugger, VS debugger, WinDbg and LLDB.

3 years agoRollup merge of #81869 - mark-i-m:leading-vert, r=petrochenkov
Dylan DPC [Wed, 17 Feb 2021 22:51:16 +0000 (23:51 +0100)]
Rollup merge of #81869 - mark-i-m:leading-vert, r=petrochenkov

Simplify pattern grammar, improve or-pattern diagnostics

This implements the change under FCP in https://github.com/rust-lang/rust/issues/81415. It allows nested or-patterns to contain a leading `|`, simplifying the [grammar for patterns](https://github.com/rust-lang/reference/pull/957/files?short_path=cc629f1#diff-cc629f15712821139bc706c63b3845ab59a008e2a998e08ffad42e3aebcbcbe2).

Along the way, we also improve the diagnostics around a few specially-handled cases, such as using `||` instead of `|`, using or-patterns in fn params, including the leading `|` in the pattern span, etc.

r? `@petrochenkov`

3 years agoRollup merge of #81860 - osa1:issue81800, r=estebank
Dylan DPC [Wed, 17 Feb 2021 22:51:14 +0000 (23:51 +0100)]
Rollup merge of #81860 - osa1:issue81800, r=estebank

Fix SourceMap::start_point

`start_point` needs to return the *first* character's span, but it would
previously call `find_width_of_character_at_span` which returns the span
of the *last* character. The implementation is now fixed.

Other changes:

- Docs for start_point, end_point, find_width_of_character_at_span
  updated

- Minor simplification in find_width_of_character_at_span code

Fixes #81800

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 #81993 - flip1995:clippyup, r=Manishearth
bors [Wed, 17 Feb 2021 22:37:42 +0000 (22:37 +0000)]
Auto merge of #81993 - flip1995:clippyup, r=Manishearth

Update Clippy

Biweekly Clippy update

r? `@Manishearth`

3 years agoremove useless ?s (clippy::needless_question_marks)
Matthias Krüger [Wed, 17 Feb 2021 22:23:57 +0000 (23:23 +0100)]
remove useless ?s (clippy::needless_question_marks)

Example code:
```
fn opts() -> Option<String> {
    let s: Option<String> = Some(String::new());
    Some(s?) // this can just be "s"
}
```

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 agoavoid converting types into themselves (clippy::useless_conversion)
Matthias Krüger [Wed, 17 Feb 2021 19:37:09 +0000 (20:37 +0100)]
avoid converting types into themselves (clippy::useless_conversion)

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 agoIn some limited cases, suggest `where` bounds for non-type params
Esteban Küber [Tue, 16 Feb 2021 19:02:39 +0000 (11:02 -0800)]
In some limited cases, suggest `where` bounds for non-type params

Partially address #81971.

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 agoMake sure pdbs are copied along with exe and dlls when bootstrapping
Ryan Levick [Wed, 17 Feb 2021 14:07:36 +0000 (15:07 +0100)]
Make sure pdbs are copied along with exe and dlls when bootstrapping

3 years ago[libtest] Run the test synchronously when hitting thread limit
hyd-dev [Fri, 29 Jan 2021 16:23:56 +0000 (00:23 +0800)]
[libtest] Run the test synchronously when hitting thread limit