Commit Graph

168925 Commits

Author SHA1 Message Date
bors
e52e7115c7 Auto merge of #96515 - lcnr:user-types-in-pat, r=nikomatsakis
correctly deal with user type ascriptions in pat

supersedes #93856

`thir::PatKind::AscribeUserType` previously resulted in `CanonicalUserTypeAnnotations` where the inferred type already had a subtyping relation according to `variance` to the `user_ty`.

The bug can pretty much be summarized as follows:

- during mir building
  - `user_ty -> inferred_ty`: considers variance
  - `StatementKind::AscribeUserType`: `inferred_ty` is the type of the place, so no variance needed
- during mir borrowck
  - `user_ty -> inferred_ty`: does not consider variance
  - `StatementKind::AscribeUserType`: applies variance

This mostly worked fine. The lifetimes in `inferred_ty` were only bound by its relation to `user_ty` and to the `place` of `StatementKind::AscribeUserType`, so it doesn't matter where exactly the subtyping happens.

It does however matter when having higher ranked subtying. At this point the place where the subtyping happens is forced, causing this mismatch between building and borrowck to result in unintended errors.

cc #96514 which is pretty much the same issue

r? `@nikomatsakis`
2022-05-21 23:34:30 +00:00
Joshua Nelson
0c92d1c7f3 Fix typo in Mir phase docs 2022-05-21 16:21:44 -05:00
Jacob Pratt
7b987e34c0
Merge crate and restricted visibilities 2022-05-21 17:02:55 -04:00
bors
9257f5aad0 Auto merge of #94530 - tmiasko:alignment-impls, r=dtolnay
Implement Copy, Clone, PartialEq and Eq for core::fmt::Alignment

Alignment is a fieldless exhaustive enum, so it is already possible to
clone and compare it by matching, but it is inconvenient to do so. For
example, if one would like to create a struct describing a formatter
configuration and provide a clone implementation:

```rust
pub struct Format {
    fill: char,
    width: Option<usize>,
    align: fmt::Alignment,
}

impl Clone for Format {
    fn clone(&self) -> Self {
        Format {
            align: match self.align {
                fmt::Alignment::Left => fmt::Alignment::Left,
                fmt::Alignment::Right => fmt::Alignment::Right,
                fmt::Alignment::Center => fmt::Alignment::Center,
            },
            .. *self
        }
    }
}
```

Derive Copy, Clone, PartialEq, and Eq for Alignment for convenience.
2022-05-21 19:49:51 +00:00
Jacob Pratt
8cece636b2
Remove feature: crate visibility modifier 2022-05-21 14:22:06 -04:00
bors
bb4781aa27 Auto merge of #97248 - xFrednet:clippyup, r=Manishearth
Clippyup

This direction was simpler. All test Clippy pass locally 🙃

r? `@Manishearth`
2022-05-21 17:25:49 +00:00
Michael Howell
3657d0936f Extend substs_to_args into a perfectly-sized Vec almost every time 2022-05-21 07:55:14 -07:00
Michael Howell
08237d8a6d Shrink GenericArgs/PathSegment with boxed slices 2022-05-21 07:55:13 -07:00
Michael Howell
855e320fe2 Remove unused Hash impl from DocFragmentKind 2022-05-21 07:54:21 -07:00
Michael Howell
98b98ac11e Fix broken intra-doc link 2022-05-21 07:53:45 -07:00
bors
74b13691aa Auto merge of #97247 - RalfJung:miri, r=RalfJung
update Miri

Fixes https://github.com/rust-lang/rust/issues/97204
r? `@ghost`
2022-05-21 14:09:31 +00:00
Vadim Petrochenkov
3f21c31bf4 rustdoc: Some link resolution caching cleanup 2022-05-21 15:38:23 +03:00
Vadim Petrochenkov
c5449f57c1 rustdoc: Stop using write! in UrlFragment::render 2022-05-21 15:21:53 +03:00
Vadim Petrochenkov
f7521db243 rustdoc: Remove ItemFragment(Kind) 2022-05-21 15:08:55 +03:00
lcnr
76370084fa update nll tests 2022-05-21 14:01:04 +02:00
xFrednet
6e87c2490e
Fix lint registration 2022-05-21 13:50:11 +02:00
bors
3b9cf893d0 Auto merge of #97246 - GuillaumeGomez:rollup-btcok8x, r=GuillaumeGomez
Rollup of 7 pull requests

Successful merges:

 - #97190 (Add implicit call to from_str via parse in documentation)
 - #97218 (Add eslint checks)
 - #97219 (make ptr::invalid not the same as a regular int2ptr cast)
 - #97223 (Remove quadratic behaviour from -Zunpretty=hir-tree.)
 - #97232 (typo)
 - #97237 (Add some more weird-exprs)
 - #97238 (Bump LLVM fetched from CI to fix run-make)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-05-21 11:28:48 +00:00
xFrednet
13cc27b445
Merge 'rust-clippy/master' into clippyup 2022-05-21 13:24:00 +02:00
Guillaume Gomez
d803caec71 Strenghten strip-enum-variant.rs test 2022-05-21 13:21:12 +02:00
Guillaume Gomez
6092cbb17c Remove fields_stripped fields (and equivalents) 2022-05-21 13:21:12 +02:00
Ralf Jung
cb4d79a304 update Miri 2022-05-21 11:58:36 +02:00
Guillaume Gomez
28730acdbe
Rollup merge of #97238 - Mark-Simulacrum:bump-ci-llvm, r=jyn514
Bump LLVM fetched from CI to fix run-make

cc `@yaahc,` who found this while testing locally

Ideally we'd detect this in CI and catch it, but at least we have a comment now which should hopefully prevent this from happening in the future.

r? `@pietroalbini` or `@jyn514`
2022-05-21 11:39:54 +02:00
Guillaume Gomez
b659266b88
Rollup merge of #97237 - oberien:patch-1, r=Dylan-DPC
Add some more weird-exprs

Continuing from https://github.com/rust-lang/rust/pull/86713 (which stalled due to a thinking emoji), I'd like to "improve" the `weird-exprs.rs`-file (as I can't reopen that PR).
2022-05-21 11:39:53 +02:00
Guillaume Gomez
85dfd065b1
Rollup merge of #97232 - tshepang:typo, r=Dylan-DPC
typo
2022-05-21 11:39:52 +02:00
Guillaume Gomez
54e36ef1b3
Rollup merge of #97223 - cjgillot:linear-hir-tree, r=jackh726
Remove quadratic behaviour from -Zunpretty=hir-tree.

Closes https://github.com/rust-lang/rust/issues/97115
2022-05-21 11:39:51 +02:00
Guillaume Gomez
6fef5f1e24
Rollup merge of #97219 - RalfJung:ptr-invalid, r=thomcc
make ptr::invalid not the same as a regular int2ptr cast

In Miri, we would like to distinguish `ptr::invalid` from `ptr::from_exposed_provenance`, so that we can provide better diagnostics issues like https://github.com/rust-lang/miri/issues/2134, and so that we can detect the UB in programs like
```rust
fn main() {
    let x = 0u8;
    let original_ptr = &x as *const u8;
    let addr = original_ptr.expose_addr();
    let new_ptr: *const u8 = core::ptr::invalid(addr);
    unsafe {
        dbg!(*new_ptr);
    }
}
```

To achieve that, the two functions need to have different implementations. Currently, both are just `as` casts. We *could* add an intrinsic for this, but it turns out `transmute` already has the right behavior, at least as far as Miri is concerned. So I propose we just use that.

Cc `@Gankra`
2022-05-21 11:39:50 +02:00
Guillaume Gomez
e5c7b21f39
Rollup merge of #97218 - GuillaumeGomez:eslint-checks, r=notriddle
Add eslint checks

The first check is to ensure that `=>` is always surrounded with whitespaces.

The second is to ensure that the dict objects looks like this: `{"a": 2}` and not `{"a" : 2}` or `{"a":2}`.

r? ``@notriddle``
2022-05-21 11:39:49 +02:00
Guillaume Gomez
1210b50dbb
Rollup merge of #97190 - SylvainDe:master, r=Dylan-DPC
Add implicit call to from_str via parse in documentation

The documentation mentions "FromStr’s from_str method is often used implicitly,
through str’s parse method. See parse’s documentation for examples.".

It may be nicer to show that in the code example as well.
2022-05-21 11:39:48 +02:00
Mara Bos
3b70c29103 Fix typo in futex RwLock::write_contended.
I wrote `state` where I should've used `s`.

This removes the unnecessary `s` variable to prevent that mistake.

Fortunately, this typo didn't affect the correctness of the lock, as the
second half of the condition (!has_writers_waiting) is enough for
correctness, which explains why this mistake didn't show up during
testing.
2022-05-21 11:15:28 +02:00
bors
5f33adce1b Auto merge of #93963 - GuillaumeGomez:reduce-clean-type-size, r=notriddle
rustdoc: Reduce clean::Type size

There is no need to keep the `DefId` around since it's allow used to compute if we should show a cast or not. As such, we can simply directly store the boolean.

I think it's not what you had in mind `@camelid` but I guess it's still an improvement? 😉

It was discussed in https://github.com/rust-lang/rust/pull/93941.

r? `@camelid`
2022-05-21 09:04:05 +00:00
Camille GILLOT
075429f76b Recover when resolution did not resolve lifetimes. 2022-05-21 09:39:41 +02:00
bors
4f372b14de Auto merge of #97239 - jhpratt:remove-crate-vis, r=joshtriplett
Remove `crate` visibility modifier

FCP to remove this syntax is just about complete in #53120. Once it completes, this should be merged ASAP to avoid merge conflicts.

The first two commits remove usage of the feature in this repository, while the last removes the feature itself.
2022-05-21 06:38:49 +00:00
lcnr
1fcbf0c368 update mir dumps 2022-05-21 08:13:17 +02:00
lcnr
db11c1939c update mir user type printing and apparently fix an ICE 2022-05-21 08:13:17 +02:00
lcnr
39a03779f8 correctly deal with user type ascriptions in pat 2022-05-21 08:13:17 +02:00
Jacob Pratt
6970246886
Remove crate visibility modifier in libs, tests 2022-05-21 00:32:47 -04:00
bors
3b64fe953c Auto merge of #96923 - eholk:fix-fake-read, r=nikomatsakis
Drop Tracking: Implement `fake_read` callback

This PR updates drop tracking's use of `ExprUseVisitor` so that we treat `fake_read` events as borrows. Without doing this, we were not handling match expressions correctly, which showed up as a breakage in the `addassign-yield.rs` test. We did not previously notice this because we still had rather large temporary scopes that we held borrows for, which changed in #94309.

This PR also includes a variant of the `addassign-yield.rs` test case to make sure we continue to have correct behavior here with drop tracking.

r? `@nikomatsakis`
2022-05-21 04:21:38 +00:00
Takayuki Maeda
42e9f2daf3 typo suggestion for a variable with a name similar to struct fields 2022-05-21 12:55:37 +09:00
bors
4a86c7907b Auto merge of #96605 - Urgau:string-retain-codegen, r=thomcc
Improve codegen of String::retain method

This pull-request improve the codegen of the `String::retain` method.

Using `unwrap_unchecked` helps the optimizer to not generate a panicking path that will never be taken for valid UTF-8 like string.

Using `encode_utf8` saves us from an expensive call to `memcpy`, as the optimizer is unable to realize that `ch_len <= 4` and so can generate much better assembly code.

https://rust.godbolt.org/z/z73ohenfc
2022-05-21 01:56:51 +00:00
Jacob Pratt
49c82f31a8
Remove crate visibility usage in compiler 2022-05-20 20:04:54 -04:00
bors
e57884b6e9 Auto merge of #95824 - zx2c4-forks:grnd_insecure, r=thomcc
Use GRND_INSECURE instead of /dev/urandom when possible

From reading the source code, it appears like the desired semantic of
std::unix::rand is to always provide some bytes and never block. For
that reason GRND_NONBLOCK is checked before calling getrandom(0), so
that getrandom(0) won't block. If it would block, then the function
falls back to using /dev/urandom, which for the time being doesn't
block. There are some drawbacks to using /dev/urandom, however, and so
getrandom(GRND_INSECURE) was created as a replacement for this exact
circumstance.

getrandom(GRND_INSECURE) is the same as /dev/urandom, except:

- It won't leave a warning in dmesg if used at early boot time, which is
  a common occurance (and the reason why I found this issue);

- It won't introduce a tiny delay at early boot on newer kernels when
  /dev/urandom tries to opportunistically create jitter entropy;

- It only requires 1 syscall, rather than 3.

Other than that, it returns the same "quality" of randomness as
/dev/urandom, and never blocks.

It's only available on kernels ≥5.6, so we try to use it, cache the
result of that attempt, and fall back to to the previous code if it
didn't work.
2022-05-20 23:11:12 +00:00
Mark Rousskov
7501995977 Bump LLVM fetched from CI to fix run-make 2022-05-20 18:56:21 -04:00
oberien
6491eb1e6c Add back thinking emoji 2022-05-21 00:38:37 +02:00
Jaro Fietz
d85ba01ecb Add a function returning itself to weird-exprs 2022-05-21 00:19:53 +02:00
Jaro Fietz
df0b0d4ae3 Add unicode identifier to weird-exprs
Use unicode identifiers and a unicode emoji in weird-exprs.rs
2022-05-21 00:18:36 +02:00
Jaro Fietz
51730fb171 Make the most special expression even more special
Add or-pattern syntax in argument position
2022-05-21 00:17:48 +02:00
Jason A. Donenfeld
18a9d58266 Use GRND_INSECURE instead of /dev/urandom when possible
From reading the source code, it appears like the desired semantic of
std::unix::rand is to always provide some bytes and never block. For
that reason GRND_NONBLOCK is checked before calling getrandom(0), so
that getrandom(0) won't block. If it would block, then the function
falls back to using /dev/urandom, which for the time being doesn't
block. There are some drawbacks to using /dev/urandom, however, and so
getrandom(GRND_INSECURE) was created as a replacement for this exact
circumstance.

getrandom(GRND_INSECURE) is the same as /dev/urandom, except:

- It won't leave a warning in dmesg if used at early boot time, which is
  a common occurance (and the reason why I found this issue);

- It won't introduce a tiny delay at early boot on newer kernels when
  /dev/urandom tries to opportunistically create jitter entropy;

- It only requires 1 syscall, rather than 3.

Other than that, it returns the same "quality" of randomness as
/dev/urandom, and never blocks.

It's only available on kernels ≥5.6, so we try to use it, cache the
result of that attempt, and fall back to to the previous code if it
didn't work.
2022-05-21 00:02:20 +02:00
Jason A. Donenfeld
204da52c34 Update libc dependency of std to 0.2.126
This is required for the next commit, which uses libc::GRND_INSECURE.
2022-05-21 00:02:20 +02:00
bors
b312ad7d0c Auto merge of #8856 - xFrednet:rustup, r=Manishearth,Alexendoo
Rustup

`@rust-lang/clippy,` `@Jarcho,` `@dswij,` `@Alexendoo.` Could someone review this? It should be pretty straight forward since it's just a sync. I think it's also fine if either one of `@Jarcho,` `@dswij,` `@Alexendoo` approves this, as these are usually not reviewed. I just want to make sure that I didn't break something obvious 🙃

It should be enough to look at the merge commit 🙃

changelog: none
changelog: move [`significant_drop_in_scrutinee`] to `suspicious`
2022-05-20 21:35:14 +00:00
xFrednet
7842dbc4f5
Remove duplicated code and ignore deadlock test 2022-05-20 23:32:58 +02:00