Commit Graph

169614 Commits

Author SHA1 Message Date
Michael Goulet
b7ed860108 recover import instead of use in item 2022-06-07 19:14:03 -07:00
bors
9f7e997c8b Auto merge of #97801 - RalfJung:miri, r=RalfJung
update Miri

Fixes https://github.com/rust-lang/rust/issues/97745
r? `@ghost` Cc `@rust-lang/miri`
Cc `@InfRandomness`
2022-06-07 02:35:19 +00:00
bors
54aa8a7858 Auto merge of #97809 - matthiaskrgr:rollup-ajyvjd3, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #97700 (Add note to documentation of HashSet::intersection)
 - #97792 (More eslint checks)
 - #97794 (Fix typo in redundant_pattern_match.rs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-06-06 23:53:07 +00:00
Matthias Krüger
fece76d7bc
Rollup merge of #97794 - eltociear:patch-13, r=matthiaskrgr
Fix typo in redundant_pattern_match.rs

alway -> always
2022-06-07 01:13:48 +02:00
Matthias Krüger
6be8b9cd77
Rollup merge of #97792 - GuillaumeGomez:eslint-checks, r=Dylan-DPC
More eslint checks

Here is the list of newly added eslint checks:

 * [no-confusing-arrow](https://eslint.org/docs/rules/no-confusing-arrow)
 * [no-div-regex](https://eslint.org/docs/rules/no-div-regex)
 * [no-floating-decimal](https://eslint.org/docs/rules/no-floating-decimal)
 * [no-implicit-globals](https://eslint.org/docs/rules/no-implicit-globals)
 * [no-implied-eval](https://eslint.org/docs/rules/no-implied-eval)
 * [no-label-var](https://eslint.org/docs/rules/no-label-var)

Since you already reviewed the previous ones:

r? `@Dylan-DPC`
2022-06-07 01:13:47 +02:00
Matthias Krüger
c4bfd106e1
Rollup merge of #97700 - nzrq:patch-1, r=dtolnay
Add note to documentation of HashSet::intersection

The functionality of the `std::collections::HashSet::intersection(...)` method was slightly surprising to me so I wanted to take a sec to contribute to the documentation for this method.

I've added a `Note:` section if that is appropriate.
2022-06-07 01:13:46 +02:00
nzrq
7d114c7713
Apply suggestions from code review
Co-authored-by: David Tolnay <dtolnay@gmail.com>
2022-06-06 17:14:58 -04:00
bors
50b00252ae Auto merge of #97730 - flip1995:clippyup, r=Manishearth
Update Clippy

r? `@Manishearth`

This includes a bit bigger `Cargo.lock` update.
2022-06-06 19:40:54 +00:00
Ralf Jung
2e4e3409d7 update Miri 2022-06-06 13:36:21 -04:00
bors
357bc27904 Auto merge of #97795 - Dylan-DPC:rollup-dxilagr, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #97312 (Compute lifetimes in scope at diagnostic time)
 - #97495 (Add E0788 for improper #[no_coverage] usage)
 - #97579 (Avoid creating `SmallVec`s in `global_llvm_features`)
 - #97767 (interpret: do not claim UB until we looked more into variadic functions)
 - #97787 (E0432: rust 2018 -> rust 2018 or later    in --explain message)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-06-06 16:09:54 +00:00
bors
9d20fd1098 Auto merge of #97684 - RalfJung:better-provenance-control, r=oli-obk
interpret: better control over whether we read data with provenance

The resolution in https://github.com/rust-lang/unsafe-code-guidelines/issues/286 seems to be that when we load data at integer type, we implicitly strip provenance. So let's implement that in Miri at least for scalar loads. This makes use of the fact that `Scalar` layouts distinguish pointer-sized integers and pointers -- so I was expecting some wild bugs where layouts set this incorrectly, but so far that does not seem to happen.

This does not entirely implement the solution to https://github.com/rust-lang/unsafe-code-guidelines/issues/286; we still do the wrong thing for integers in larger types: we will `copy_op` them and then do validation, and validation will complain about the provenance. To fix that we need mutating validation; validation needs to strip the provenance rather than complaining about it. This is a larger undertaking (but will also help resolve https://github.com/rust-lang/miri/issues/845 since we can reset padding to `Uninit`).

The reason this is useful is that we can now implement `addr` as a `transmute` from a pointer to an integer, and actually get the desired behavior of stripping provenance without exposing it!
2022-06-06 13:28:58 +00:00
Dylan DPC
99afe26032
Rollup merge of #97787 - matthiaskrgr:e0432_explain, r=Dylan-DPC
E0432: rust 2018 -> rust 2018 or later    in --explain message
2022-06-06 14:34:59 +02:00
Dylan DPC
85617f1c93
Rollup merge of #97767 - RalfJung:variadic, r=davidtwco
interpret: do not claim UB until we looked more into variadic functions

I am not actually sure if this is UB, and anyway for FFI shims, Miri currently does not attempt to distinguish between arguments passed via variadics vs directly. So let's be consistent.
(Programs that ran into this error will anyway immediately fall through to the "unsupported" message on the next line.)
2022-06-06 14:34:58 +02:00
Dylan DPC
6da214c1e2
Rollup merge of #97579 - SparrowLii:target_features, r=nagisa
Avoid creating `SmallVec`s in `global_llvm_features`

This PR made a simple optimization to avoid creating extra `SmallVec`s by adjusting the use of iterator statements.
Also, given the very small size of `tied_target_features`, there is no need to insert each feature into the FxHashMap.
2022-06-06 14:34:57 +02:00
Dylan DPC
cb787bea46
Rollup merge of #97495 - clarfonthey:e0788-no-coverage, r=nagisa
Add E0788 for improper #[no_coverage] usage

Essentially, this adds proper checking for the attribute (tracking issue #84605) and throws errors when it's put in obviously-wrong places, like on struct or const definitions. Most of the code is taken directly from the checks for the `#[inline]` attribute, since it's very similar.

Right now, the code only checks at the function level, but it seems reasonable to allow adding `#[no_coverage]` to individual blocks or expressions, so, for now those just throw `unused_attributes` warnings. Similarly, since there was a lot of desire to eventually allow recursive definitions as well on modules and impl blocks, these also throw `unused_attributes` instead of an error.

I'm not sure if anything has to be done since this error is technically for an unstable feature, but since an error for using unstable features will show up anyway, I think it's okay.

This is the first big piece needed for stabilising this attribute, although I personally would like to explore renaming it to `#[coverage(never)]` on a separate PR, which I will offer soon. There's a lot of discussion still to be had about that, which is why it will be kept separate.

I don't think much is needed besides adding this simple check and a UI test, but let me know if there's something else that should be added to make this happen.
2022-06-06 14:34:56 +02:00
Dylan DPC
a736acc804
Rollup merge of #97312 - cjgillot:no-path-in-scope, r=compiler-errors
Compute lifetimes in scope at diagnostic time

The set of available lifetimes is currently computed during lifetime resolution on HIR.  It is only used for one diagnostic.

In this PR, HIR lifetime resolution just reports whether elided lifetimes are well-defined at the place of use.  The diagnostic code is responsible for building a list of lifetime names if elision is not allowed.

This will allow to remove lifetime resolution on HIR eventually.
2022-06-06 14:34:55 +02:00
Ikko Ashimine
0664bd8b2a
Fix typo in redundant_pattern_match.rs
alway -> always
2022-06-06 21:16:31 +09:00
Guillaume Gomez
cd5e73be3f Add "no-label-var" eslint check 2022-06-06 14:03:26 +02:00
Guillaume Gomez
d0909bdddc Add "no-implied-eval" eslint check 2022-06-06 14:02:37 +02:00
Guillaume Gomez
b827847d19 Add "no-implicit-globals" eslint check 2022-06-06 14:01:52 +02:00
Guillaume Gomez
b48bbd4e2f Add "no-floating-decimal" eslint check 2022-06-06 14:00:43 +02:00
Guillaume Gomez
0e66868138 Add "no-div-regex" eslint check 2022-06-06 13:58:53 +02:00
Guillaume Gomez
116eec247a Add "no-confusing-arrow" eslint check 2022-06-06 13:57:54 +02:00
bors
79b6bad406 Auto merge of #97086 - 5225225:link-section-is-unsafe, r=davidtwco
Report unsafe for overriding link sections

I'm not too sure about the lint wording here, but I couldn't think of anything better.
2022-06-06 10:43:27 +00:00
SparrowLii
b3cd892ae1 Avoid creating SmallVecs in global_llvm_features 2022-06-06 18:05:07 +08:00
Matthias Krüger
343c135e0c E0432: rust 2018 -> rust 2018 or later in --explain message 2022-06-06 11:58:49 +02:00
Philipp Krones
9525e0cb97
Add winnt feature to winapi in rustc-workspace-hack 2022-06-06 11:14:59 +02:00
bors
e70c60d34b Auto merge of #97783 - matthiaskrgr:rollup-14t9htt, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #90905 (Add empty impl blocks if they have documentation)
 - #97683 (Fail gracefully when encountering an HRTB in APIT. )
 - #97721 (Do `suggest_await_before_try` with infer variables in self, and clean up binders)
 - #97752 (typo: `-Zcodegen-backend=llvm -Cpasses=list` should work now)
 - #97759 (Suggest adding `{}` for `'label: non_block_expr`)
 - #97764 (use strict provenance APIs)
 - #97765 (Restore a test that was intended to test `as` cast to ptr)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-06-06 08:02:38 +00:00
Matthias Krüger
1258fa9d9b
Rollup merge of #97765 - RalfJung:restoration, r=Mark-Simulacrum
Restore a test that was intended to test `as` cast to ptr

This test was changed in https://github.com/rust-lang/rust/pull/61864, but the original bug https://github.com/rust-lang/rust/issues/46365 was about casts so I doubt the changed test still even tests what this was intended to test. Let's restore the original test.
2022-06-06 08:37:05 +02:00
Matthias Krüger
1bf1932453
Rollup merge of #97764 - RalfJung:strict, r=dtolnay
use strict provenance APIs

The stdlib was adjusted to avoid bare int2ptr casts, but recently some casts of that sort have sneaked back in. Let's fix that. :)
2022-06-06 08:37:04 +02:00
Matthias Krüger
554674b98c
Rollup merge of #97759 - WaffleLapkin:recover_label_expr, r=compiler-errors
Suggest adding `{}` for `'label: non_block_expr`

Adds suggestions like this:
```text
help: consider enclosing expression in a block
  |
3 |     'l {0};
  |        + +
```

inspired by https://github.com/rust-lang/rust/issues/48594#issuecomment-1146744400

r? ``@compiler-errors``
2022-06-06 08:37:03 +02:00
Matthias Krüger
c9c6c2e7de
Rollup merge of #97752 - klensy:cg-typo, r=bjorn3
typo: `-Zcodegen-backend=llvm -Cpasses=list` should work now

r? ```@bjorn3```
2022-06-06 08:37:02 +02:00
Matthias Krüger
df86d04977
Rollup merge of #97721 - compiler-errors:issue-97704, r=jackh726
Do `suggest_await_before_try` with infer variables in self, and clean up binders

Fixes #97704

Also cleans up binders in this fn, since everything is a `Poly*` and we really shouldn't have stray escaping late-bound regions everywhere. That's why the function changed so much. This isn't necessary, so I can revert if necessary.
2022-06-06 08:37:01 +02:00
Matthias Krüger
f2b3808920
Rollup merge of #97683 - cjgillot:no-apit-hrtb, r=nagisa
Fail gracefully when encountering an HRTB in APIT.

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

~The first commit will be merged as part of https://github.com/rust-lang/rust/pull/97415~
2022-06-06 08:37:00 +02:00
Matthias Krüger
77f0209fde
Rollup merge of #90905 - GuillaumeGomez:empty-impl-blocks, r=jsha
Add empty impl blocks if they have documentation

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

The update for the test script is needed to count the number of impl blocks we have with only the struct. To be noted that with https://github.com/rust-lang/rust/pull/89676 merged, it wouldn't be needed (I don't know what is the status of it btw. cc ```@Mark-Simulacrum).```

It looks like this:

![Screenshot from 2021-11-14 16-51-28](https://user-images.githubusercontent.com/3050060/141689100-e57123c0-bf50-4c42-adf5-d991e169a0e4.png)

cc ```@jyn514```
r? ```@camelid```
2022-06-06 08:36:59 +02:00
bors
6609c6734d Auto merge of #96551 - ferrocene:pa-ignore-paths-when-abbreviating, r=Mark-Simulacrum
[compiletest] Ignore known paths when abbreviating output

To prevent out of memory conditions, compiletest limits the amount of output a test can generate, abbreviating it if the test emits more than a threshold. While the behavior is desirable, it also causes some issues (like #96229, #94322 and #92211).

The latest one happened recently, when the `src/test/ui/numeric/numeric-cast.rs` test started to fail on systems where the path of the rust-lang/rust checkout is too long. This includes my own development machine and [LLVM's CI](https://github.com/rust-lang/rust/issues/96362#issuecomment-1108609893). Rust's CI uses a pretty short directory name for the checkout, which hides these sort of problems until someone runs the test suite on their own computer.

When developing the fix I tried to find the most targeted fix that would prevent this class of failures from happening in the future, deferring the decision on if/how to redesign abbreviation to a later date. The solution I came up with was to ignore known base paths when calculating whether the output exceeds the abbreviation threshold, which removes this kind of nondeterminism.

This PR is best reviewed commit-by-commit.
2022-06-06 05:21:49 +00:00
ltdk
9473e21955 Changes from code review 2022-06-05 22:24:14 -04:00
Michael Goulet
d268b34da4 Do suggest_await_before_try with infer in self, clean up binders 2022-06-05 18:46:48 -07:00
bors
760237ff78 Auto merge of #97710 - RalfJung:ptr-addr, r=thomcc
implement ptr.addr() via transmute

As per the discussion in https://github.com/rust-lang/unsafe-code-guidelines/issues/286, the semantics for ptr-to-int transmutes that we are going with for now is to make them strip provenance without exposing it. That's exactly what `ptr.addr()` does! So we can implement `ptr.addr()` via `transmute`. This also means that once https://github.com/rust-lang/rust/pull/97684 lands, Miri can distinguish `ptr.addr()` from `ptr.expose_addr()`, and the following code will correctly be called out as having UB (if permissive provenance mode is enabled, which will become the default once the [implementation is complete](https://github.com/rust-lang/miri/issues/2133)):

```rust
fn main() {
    let x: i32 = 3;
    let x_ptr = &x as *const i32;

    let x_usize: usize = x_ptr.addr();
    // Cast back an address that did *not* get exposed.
    let ptr = std::ptr::from_exposed_addr::<i32>(x_usize);
    assert_eq!(unsafe { *ptr }, 3); //~ ERROR Undefined Behavior: dereferencing pointer failed
}
```

This completes the Miri implementation of the new distinctions introduced by strict provenance. :)

Cc `@Gankra` -- for now I left in your `FIXME(strict_provenance_magic)` saying these should be intrinsics, but I do not necessarily agree that they should be. Or if we have an intrinsic, I think it should behave exactly like the `transmute` does, which makes one wonder why the intrinsic should be needed.
2022-06-06 01:03:26 +00:00
Waffle Maybe
4f85a73e51 Add spaces before and after expr in add {} suggestion
Co-authored-by: Michael Goulet <michael@errs.io>
2022-06-06 01:40:52 +04:00
Maybe Waffle
f06f051745 Suggest removing label in 'label: non_block_expr 2022-06-05 23:34:11 +04:00
Maybe Waffle
c6e5bb32fb Do not suggest adding labeled block if there are no labeled breaks 2022-06-05 23:12:51 +04:00
Ralf Jung
a6207ec975 interpret: do not claim UB until we looked more into variadic functions 2022-06-05 13:24:24 -04:00
Ralf Jung
e5dd503d61 restore a test 2022-06-05 12:00:43 -04:00
Ralf Jung
4a41c35742 use strict provenance APIs 2022-06-05 11:50:48 -04:00
Ralf Jung
d208f80039 reduce code duplication 2022-06-05 10:13:34 -04:00
Ralf Jung
47d11a8483 interpret: better control over whether we read data with provenance, and implicit provenance stripping where possible 2022-06-05 10:13:34 -04:00
Maybe Waffle
f21c0a274e Suggest adding {} for 'label: non_block_expr 2022-06-05 16:45:29 +04:00
bors
fee3a459dd Auto merge of #97756 - pietroalbini:pa-remove-azure-pipelines, r=Mark-Simulacrum
Remove Azure Pipelines configuration

This PR removes the remaining Azure Pipelines configuration, now that we fully removed all the resources on the Azure side of things.
2022-06-05 12:31:26 +00:00
Pietro Albini
6523ef41da
update comment 2022-06-05 12:32:46 +02:00