]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoRollup merge of #87385 - Aaron1011:final-enable-semi, r=petrochenkov
Yuki Okushi [Fri, 30 Jul 2021 19:09:20 +0000 (04:09 +0900)]
Rollup merge of #87385 - Aaron1011:final-enable-semi, r=petrochenkov

Make `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` warn by default

This PR makes the `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` lint warn by default.

To avoid showing a large number of un-actionable warnings to users, we only enable the lint for macros defined in the same crate. This ensures that users will be able to fix the warning by simply removing a semicolon.

In the future, I'd like to enable this lint unconditionally, and eventually make it into a hard error in a future edition. This PR is a step towards that goal.

2 years agoRollup merge of #86072 - MarcusCalhoun-Lopez:llvm_cross, r=nagisa
Yuki Okushi [Fri, 30 Jul 2021 19:09:19 +0000 (04:09 +0900)]
Rollup merge of #86072 - MarcusCalhoun-Lopez:llvm_cross, r=nagisa

Cross compiling rustc_llvm on Darwin requires zlib.

2 years agoAuto merge of #85971 - FabianWolff:issue-85586, r=davidtwco
bors [Fri, 30 Jul 2021 14:38:00 +0000 (14:38 +0000)]
Auto merge of #85971 - FabianWolff:issue-85586, r=davidtwco

Use more precise span for E0282 in cast expressions

This pull request fixes #85586. The example code given there:
```rust
fn main() {
    let a = [1, 2, 3].iter().sum();
    let b = (a + 1) as usize;
}
```
currently produces
```
error[E0282]: type annotations needed
 --> issue-85586.rs:3:13
  |
3 |     let b = (a + 1) as usize;
  |             ^^^^^^^^^^^^^^^^ cannot infer type
  |
  = note: type must be known at this point

error: aborting due to previous error
```
even though the type of the entire cast expression quite clearly should be `usize`. The error is in the cast's left-hand side, which is made explicit by the changes in this PR:
```
error[E0282]: type annotations needed
 --> issue-85586.rs:3:13
  |
3 |     let b = (a + 1) as usize;
  |             ^^^^^^^ cannot infer type
  |
  = note: type must be known at this point

error: aborting due to previous error
```

2 years agoAuto merge of #87237 - jonas-schievink:const-for-and-try, r=oli-obk
bors [Fri, 30 Jul 2021 12:05:48 +0000 (12:05 +0000)]
Auto merge of #87237 - jonas-schievink:const-for-and-try, r=oli-obk

Add feature gates for `for` and `?` in consts

These operations seems *relatively* straightforward to support, and only seem to be blocked on `impl const Trait`.

I have included a working test for `const_try`, but `const_for` is currently unusable without reimplementing *every single* defaulted `Iterator` method, so I didn't do that.

(both features still need tracking issues before this is merged)

2 years agoAuto merge of #87615 - JohnTitor:rollup-t5jpmrg, r=JohnTitor
bors [Fri, 30 Jul 2021 09:43:32 +0000 (09:43 +0000)]
Auto merge of #87615 - JohnTitor:rollup-t5jpmrg, r=JohnTitor

Rollup of 10 pull requests

Successful merges:

 - #87052 (Optimize fmt::PadAdapter::wrap)
 - #87522 (Fix assert in diy_float)
 - #87553 (Fix typo in rustc_driver::version)
 - #87554 (2229: Discr should be read when PatKind is Range)
 - #87564 (min_type_alias_impl_trait is going to be removed in 1.56)
 - #87574 (Update the examples in `String` and `VecDeque::retain`)
 - #87583 (Refactor compression cache in v0 symbol mangler)
 - #87585 (Add missing links for core::char types)
 - #87594 (fs File get_path procfs usage for netbsd same as linux.)
 - #87602 ([backtraces]: look for the `begin` symbol only after seeing `end`)

Failed merges:

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

2 years agoRollup merge of #87602 - wesleywiser:partially_fix_short_backtraces_windows_optimized...
Yuki Okushi [Fri, 30 Jul 2021 07:27:01 +0000 (16:27 +0900)]
Rollup merge of #87602 - wesleywiser:partially_fix_short_backtraces_windows_optimized, r=dtolnay

[backtraces]: look for the `begin` symbol only after seeing `end`

On `x86_64-pc-windows-msvc`, we often get backtraces which look like
    this:

    ```
    10:     0x7ff77e0e9be5 - std::panicking::rust_panic_with_hook
    11:     0x7ff77e0e11b4 - std::sys_common::backtrace::__rust_begin_short_backtrace::h5769736bdb11136c
    12:     0x7ff77e0e116f - std::sys_common::backtrace::__rust_end_short_backtrace::h61c7ecb1b55338ae
    13:     0x7ff77e0f89dd - std::panicking::begin_panic::h8e60ef9f82a41805
    14:     0x7ff77e0e108c - d
    15:     0x7ff77e0e1069 - c
    16:     0x7ff77e0e1059 - b
    17:     0x7ff77e0e1049 - a
    18:     0x7ff77e0e1039 - core::ptr::drop_in_place<std::rt::lang_start<()>::{{closure}}>::h1bfcd14d5e15ba81
    19:     0x7ff77e0e1186 - std::sys_common::backtrace::__rust_begin_short_backtrace::h5769736bdb11136c
    20:     0x7ff77e0e100c - std::rt::lang_start::{{closure}}::ha054184bbf9921e3
    ```

Notice that `__rust_begin_short_backtrace` appears on frame 11 before
    `__rust_end_short_backtrace` on frame 12. This is because in typical
    release binaries without debug symbols, dbghelp.dll, which we use to walk
    and symbolize the stack, does not know where CGU internal functions
    start or end and so the closure invoked by `__rust_end_short_backtrace`
    is incorrectly described as `__rust_begin_short_backtrace` because it
    happens to be near that symbol.

While that can obviously change, this has been happening quite
    consistently since #75048. Since this is a very small change to the std
    and the change makes sense by itself, I think this is worth doing.

This doesn't completely resolve the situation for release binaries on
    Windows, since without debug symbols, the stack printed can still show
    incorrect symbol names (this is why the test uses `#[no_mangle]`) but it
    does slightly improve the situation in that you see the same backtrace
    you would see with `RUST_BACKTRACE=full` or in a debugger (without the
    uninteresting bits at the top and bottom).

Fixes part of #87481

2 years agoRollup merge of #87594 - devnexen:netbsd_fs_getfiledescriptor_path, r=joshtriplett
Yuki Okushi [Fri, 30 Jul 2021 07:27:00 +0000 (16:27 +0900)]
Rollup merge of #87594 - devnexen:netbsd_fs_getfiledescriptor_path, r=joshtriplett

fs File get_path procfs usage for netbsd same as linux.

2 years agoRollup merge of #87585 - GuillaumeGomez:char-types-doc, r=joshtriplett
Yuki Okushi [Fri, 30 Jul 2021 07:26:59 +0000 (16:26 +0900)]
Rollup merge of #87585 - GuillaumeGomez:char-types-doc, r=joshtriplett

Add missing links for core::char types

2 years agoRollup merge of #87583 - tmiasko:compression-cache, r=wesleywiser
Yuki Okushi [Fri, 30 Jul 2021 07:26:58 +0000 (16:26 +0900)]
Rollup merge of #87583 - tmiasko:compression-cache, r=wesleywiser

Refactor compression cache in v0 symbol mangler

* Remove redundant option around compression caches (they are always present).
* Flatten compression caches into symbol mangler to avoid dynamic memory allocation.
* Implement printer for `&mut SymbolMangler` instead of `SymbolMangler` to avoid passing now slightly larger symbol mangler by value.

2 years agoRollup merge of #87574 - cuviper:retain-examples, r=joshtriplett
Yuki Okushi [Fri, 30 Jul 2021 07:26:57 +0000 (16:26 +0900)]
Rollup merge of #87574 - cuviper:retain-examples, r=joshtriplett

Update the examples in `String` and `VecDeque::retain`

The examples added in #60396 used a "clever" post-increment hack,
unrelated to the actual point of the examples. That hack was found
[confusing] in the users forum, and #81811 already changed the `Vec`
example to use a more direct iterator. This commit changes `String` and
`VecDeque` in the same way for consistency.

[confusing]: https://users.rust-lang.org/t/help-understand-strange-expression/62858

2 years agoRollup merge of #87564 - spastorino:adjust-min-tait-removed-version, r=jackh726
Yuki Okushi [Fri, 30 Jul 2021 07:26:56 +0000 (16:26 +0900)]
Rollup merge of #87564 - spastorino:adjust-min-tait-removed-version, r=jackh726

min_type_alias_impl_trait is going to be removed in 1.56

#87501 removed `min_type_alias_impl_trait` but meanwhile that PR was approved in homu queue, a new beta was cut so we need to bump the version because it won't be removed in 1.55.

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

```@bors``` rollup=always

2 years agoRollup merge of #87554 - sexxi-goose:fix-issue-87426, r=nikomatsakis
Yuki Okushi [Fri, 30 Jul 2021 07:26:55 +0000 (16:26 +0900)]
Rollup merge of #87554 - sexxi-goose:fix-issue-87426, r=nikomatsakis

2229: Discr should be read when PatKind is Range

This PR fixes an issue related to pattern matching in closures when Edition 2021 is enabled.

- If any of the patterns the discr is being matched on is `PatKind::Range` then the discr should be read

r? ```@nikomatsakis```

Closes https://github.com/rust-lang/rust/issues/87426

2 years agoRollup merge of #87553 - bjorn3:fix_hotplug_codegen_version, r=wesleywiser
Yuki Okushi [Fri, 30 Jul 2021 07:26:54 +0000 (16:26 +0900)]
Rollup merge of #87553 - bjorn3:fix_hotplug_codegen_version, r=wesleywiser

Fix typo in rustc_driver::version

This caused rustc `-Zcodegen-backend=foo.so -vV` to look for `oo.so` instead of `foo.so`

2 years agoRollup merge of #87522 - frogtd:patch-1, r=yaahc
Yuki Okushi [Fri, 30 Jul 2021 07:26:53 +0000 (16:26 +0900)]
Rollup merge of #87522 - frogtd:patch-1, r=yaahc

Fix assert in diy_float

The shifting should have gone the other way, the current incarnation is always true.

2 years agoRollup merge of #87052 - phlopsi:patch-1, r=jyn514
Yuki Okushi [Fri, 30 Jul 2021 07:26:52 +0000 (16:26 +0900)]
Rollup merge of #87052 - phlopsi:patch-1, r=jyn514

Optimize fmt::PadAdapter::wrap

After adding the first `write!` usage to my project and printing the result to the console, I noticed, that my binary contains the strings "called `Option::unwrap()` on a `None` value`" and more importantly "C:\Users\Patrick Fischer\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\fmt\builders.rs", with my release build being configured as follows:
```
[profile.release]
panic = "abort"
codegen-units = 1
strip = "symbols" # the important bit
lto = true
```
I am in a no_std environment and my custom panic handler is a simple `loop {}`. I did not expect the above information to be preserved. I heavily suspect the edited function to be the culprit. It contains the only direct use of `Option::unwrap` in the entire file and I tracked the symbols in the assembly to be used from the section `_ZN68_$LT$core..fmt..builders..PadAdapter$u20$as$u20$core..fmt..Write$GT$9write_str17ha1d5e5efe167202aE`.

Aside from me suspecting this function to be the culprit, the replaced code performs the same operation as `Option::insert`, but without the `unreachable_unchecked` optimization `Option::insert` provides. Therefore, it makes sense to me to use the more optimized version, instead.

As I don't change any semantics, I hope a simple pull request suffices.

2 years agoAuto merge of #87483 - oli-obk:tait_ice, r=lqd
bors [Fri, 30 Jul 2021 07:02:34 +0000 (07:02 +0000)]
Auto merge of #87483 - oli-obk:tait_ice, r=lqd

Mir borrowck does not generate lifetime variables for 'static lifetimes during opaque type resolution

Fixes #87455

This situation was unreachable before #87287 as we used to just grab the resolved opaque type from typeck and replaced all regions with new inference vars. After #87287 we let the `InferCx` in mir borrowck figure out the opaque type all by itself (which it already did before, but it only used the result to sanity check with the typeck result).

2 years agoAuto merge of #87445 - amalik18:issue-83584-fix, r=kennytm
bors [Fri, 30 Jul 2021 04:34:13 +0000 (04:34 +0000)]
Auto merge of #87445 - amalik18:issue-83584-fix, r=kennytm

Fix may not to appropriate might not or must not

I went through and changed occurrences of `may not` to be more explicit with `might not` and `must not`.

2 years agoAuto merge of #87285 - GuillaumeGomez:intra-doc-span, r=estebank
bors [Thu, 29 Jul 2021 23:33:18 +0000 (23:33 +0000)]
Auto merge of #87285 - GuillaumeGomez:intra-doc-span, r=estebank

Improve intra doc errors display

#87169

`@jyn514` This is what I had in mind to avoid having duplicated backticks. I also gave a try to simply updating the span for the suggestion/help messages but I think this current one is better because less "noisy". Anyway, that allows you to see the result. ;)

2 years agoUpdate error code description
Jonas Schievink [Thu, 29 Jul 2021 22:33:30 +0000 (00:33 +0200)]
Update error code description

2 years agoUpdate tests
Jonas Schievink [Thu, 29 Jul 2021 21:15:53 +0000 (23:15 +0200)]
Update tests

2 years agoAdd tracking issues
Jonas Schievink [Thu, 29 Jul 2021 01:00:52 +0000 (03:00 +0200)]
Add tracking issues

2 years agoAdd `const_for` test
Jonas Schievink [Thu, 29 Jul 2021 00:56:03 +0000 (02:56 +0200)]
Add `const_for` test

2 years agoAdd feature gates for `for` and `?` in consts
Jonas Schievink [Sun, 18 Jul 2021 01:34:50 +0000 (03:34 +0200)]
Add feature gates for `for` and `?` in consts

2 years agoAuto merge of #85901 - ijackson:bufwriter-tweaks, r=joshtriplett
bors [Thu, 29 Jul 2021 20:52:34 +0000 (20:52 +0000)]
Auto merge of #85901 - ijackson:bufwriter-tweaks, r=joshtriplett

Bufwriter disassembly tweaks

In #80690 `@BurntSushi` observed that `WriterPanicked` was erroneously not exported, and suggested renaming `into_raw_parts` to `into_parts`. (More info in my commit messages.)

r? `@BurntSushi`

2 years ago[backtraces]: look for the `begin` symbol only after seeing `end`
Wesley Wiser [Thu, 29 Jul 2021 17:06:37 +0000 (13:06 -0400)]
[backtraces]: look for the `begin` symbol only after seeing `end`

On `x86_64-pc-windows-msvc`, we often get backtraces which look like
this:

```
10:     0x7ff77e0e9be5 - std::panicking::rust_panic_with_hook
11:     0x7ff77e0e11b4 - std::sys_common::backtrace::__rust_begin_short_backtrace::h5769736bdb11136c
12:     0x7ff77e0e116f - std::sys_common::backtrace::__rust_end_short_backtrace::h61c7ecb1b55338ae
13:     0x7ff77e0f89dd - std::panicking::begin_panic::h8e60ef9f82a41805
14:     0x7ff77e0e108c - d
15:     0x7ff77e0e1069 - c
16:     0x7ff77e0e1059 - b
17:     0x7ff77e0e1049 - a
18:     0x7ff77e0e1039 - core::ptr::drop_in_place<std::rt::lang_start<()>::{{closure}}>::h1bfcd14d5e15ba81
19:     0x7ff77e0e1186 - std::sys_common::backtrace::__rust_begin_short_backtrace::h5769736bdb11136c
20:     0x7ff77e0e100c - std::rt::lang_start::{{closure}}::ha054184bbf9921e3
```

Notice that `__rust_begin_short_backtrace` appears on frame 11 before
`__rust_end_short_backtrace` on frame 12. This is because in typical
release binaries without debug symbols, dbghelp.dll, which we use to walk
and symbolize the stack, does not know where CGU internal functions
start or end and so the closure invoked by `__rust_end_short_backtrace`
is incorrectly described as `__rust_begin_short_backtrace` because it
happens to be near that symbol.

While that can obviously change, this has been happening quite
consistently since #75048. Since this is a very small change to the std
and the change makes sense by itself, I think this is worth doing.

This doesn't completely resolve the situation for release binaries on
Windows, since without debug symbols, the stack printed can still show
incorrect symbol names (this is why the test uses `#[no_mangle]`) but it
does slightly improve the situation in that you see the same backtrace
you would see with `RUST_BACKTRACE=full` or in a debugger (without the
uninteresting bits at the top and bottom).

2 years agoAdd regression test
Wesley Wiser [Wed, 28 Jul 2021 15:40:53 +0000 (11:40 -0400)]
Add regression test

2 years agofs File get_path procfs usage for netbsd same as linux.
David Carlier [Thu, 29 Jul 2021 16:49:48 +0000 (17:49 +0100)]
fs File get_path procfs usage for netbsd same as linux.

2 years agoAuto merge of #87579 - flip1995:clippyup, r=Manishearth
bors [Thu, 29 Jul 2021 15:36:52 +0000 (15:36 +0000)]
Auto merge of #87579 - flip1995:clippyup, r=Manishearth

Update Clippy

r? `@Manishearth`

2 years agoUpdate rustdoc-ui tests for intra-doc links errors
Guillaume Gomez [Mon, 19 Jul 2021 15:00:35 +0000 (17:00 +0200)]
Update rustdoc-ui tests for intra-doc links errors

2 years agoRemove unnecessary trailing semicolons from clippy tests
Aaron Hill [Thu, 29 Jul 2021 14:52:35 +0000 (09:52 -0500)]
Remove unnecessary trailing semicolons from clippy tests

2 years agoRename feature gate bufwriter_into_parts from bufwriter_into_raw_parts
Ian Jackson [Mon, 19 Jul 2021 16:33:55 +0000 (17:33 +0100)]
Rename feature gate bufwriter_into_parts from bufwriter_into_raw_parts

As requested
  https://github.com/rust-lang/rust/pull/85901#pullrequestreview-698404772

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoBufWriter: rename `into_parts` from `into_raw_parts`
Ian Jackson [Tue, 1 Jun 2021 15:47:26 +0000 (16:47 +0100)]
BufWriter: rename `into_parts` from `into_raw_parts`

I looked in stdlib and as @BurntSushi thought, `raw` is generally
used for raw pointers, or other hazardous kinds of thing.  stdlib does
not have `into_parts` apart from the one I added to `IntoInnerError`.

I did an ad-hoc search of the rustdocs for my current game project
Otter, which includes quite a large number of dependencies.
`into_parts` seems heavily used for things quite like this.

So change this name.

Suggested-by: Andrew Gallant <jamslam@gmail.com>
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoBufWriter: actually export WriterPanicked error
Ian Jackson [Tue, 1 Jun 2021 15:30:13 +0000 (16:30 +0100)]
BufWriter: actually export WriterPanicked error

I didn't notice the submodule, which means I failed to re-export this
to make it actually-public.

Reported-by: Andrew Gallant <jamslam@gmail.com>
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoAdd missing links for core::char types
Guillaume Gomez [Thu, 29 Jul 2021 12:13:41 +0000 (14:13 +0200)]
Add missing links for core::char types

2 years agoChange span for intra-doc links errors
Guillaume Gomez [Mon, 19 Jul 2021 15:00:21 +0000 (17:00 +0200)]
Change span for intra-doc links errors

2 years agoImplement `Printer` for `&mut SymbolMangler`
Tomasz Miąsko [Thu, 29 Jul 2021 00:00:00 +0000 (00:00 +0000)]
Implement `Printer` for `&mut SymbolMangler`

to avoid passing the symbol mangler by value.

2 years agoFlatten compression caches into symbol mangler
Tomasz Miąsko [Thu, 29 Jul 2021 00:00:00 +0000 (00:00 +0000)]
Flatten compression caches into symbol mangler

The compression caches currently don't have any dedicated functionality
that would benefit from being separated. Incorporating caches directly
into the symbol manger also avoids dynamic memory allocation.

The symbol mangler, which is often passed by value, is now slightly
larger. This aspect will be addressed by a follow-up commit.

2 years agoRemove redundant option around compression caches
Tomasz Miąsko [Tue, 27 Jul 2021 00:00:00 +0000 (00:00 +0000)]
Remove redundant option around compression caches

Compression caches are always present. Remove unnecessary option.

2 years agoUpdate Cargo.lock (Clippy version bump)
flip1995 [Thu, 29 Jul 2021 10:17:29 +0000 (12:17 +0200)]
Update Cargo.lock (Clippy version bump)

2 years agoMerge commit '0cce3f643bfcbb92d5a1bb71858c9cbaff749d6b' into clippyup
flip1995 [Thu, 29 Jul 2021 10:16:06 +0000 (12:16 +0200)]
Merge commit '0cce3f643bfcbb92d5a1bb71858c9cbaff749d6b' into clippyup

2 years agoAuto merge of #7504 - flip1995:rename-lints, r=flip1995
bors [Thu, 29 Jul 2021 10:14:31 +0000 (10:14 +0000)]
Auto merge of #7504 - flip1995:rename-lints, r=flip1995

Rename two lints to comply with our lint naming convention

self_named_constructor -> self_named_constructors
append_instead_of_extend -> extend_with_drain

We don't need to `register_renamed` those lints, since I'll backport them to beta, so the old names won't hit stable.

changelog: none
(I'll adapt the changelog before merging #7498)

2 years agoRename two lints to comply with our lint naming convention
flip1995 [Thu, 29 Jul 2021 10:10:18 +0000 (12:10 +0200)]
Rename two lints to comply with our lint naming convention

self_named_constructor -> self_named_constructors
append_instead_of_extend -> extend_with_drain

2 years agoUse strip_prefix
bjorn3 [Thu, 29 Jul 2021 09:54:39 +0000 (11:54 +0200)]
Use strip_prefix

2 years agoAuto merge of #86664 - m-ou-se:uninit-track-caller, r=JohnTitor
bors [Thu, 29 Jul 2021 09:35:23 +0000 (09:35 +0000)]
Auto merge of #86664 - m-ou-se:uninit-track-caller, r=JohnTitor

Add #[track_caller] for some function in core::mem.

These functions can panic for some types. This makes the panic point to the code that calls e.g. mem::uninitialized(), instead of inside the definition of mem::uninitialized.

2 years agoAuto merge of #7503 - flip1995:rustup, r=flip1995
bors [Thu, 29 Jul 2021 09:35:13 +0000 (09:35 +0000)]
Auto merge of #7503 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

2 years agoBump Clippy Version -> 0.1.56
flip1995 [Thu, 29 Jul 2021 09:15:11 +0000 (11:15 +0200)]
Bump Clippy Version -> 0.1.56

2 years agoBump nightly version -> 2021-07-29
flip1995 [Thu, 29 Jul 2021 09:14:53 +0000 (11:14 +0200)]
Bump nightly version -> 2021-07-29

2 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Thu, 29 Jul 2021 09:14:25 +0000 (11:14 +0200)]
Merge remote-tracking branch 'upstream/master' into rustup

2 years agoAuto merge of #86998 - m-ou-se:const-panic-fmt-as-str, r=oli-obk
bors [Thu, 29 Jul 2021 07:12:07 +0000 (07:12 +0000)]
Auto merge of #86998 - m-ou-se:const-panic-fmt-as-str, r=oli-obk

Make const panic!("..") work in Rust 2021.

During const eval, this replaces calls to core::panicking::panic_fmt and std::panicking::being_panic_fmt with a call to a new const fn: core::panicking::const_panic_fmt. That function uses fmt::Arguments::as_str() to get the str and calls panic_str with that instead.

panic!() invocations with formatting arguments are still not accepted, as the creation of such a fmt::Arguments cannot be done in constant functions right now.

r? `@RalfJung`

2 years agoFix may not to appropriate might not or must not
Ali Malik [Fri, 23 Jul 2021 23:14:28 +0000 (19:14 -0400)]
Fix may not to appropriate might not or must not

2 years agoFix may not to appropriate might not or must not
Ali Malik [Fri, 23 Jul 2021 23:14:28 +0000 (19:14 -0400)]
Fix may not to appropriate might not or must not

2 years agoAuto merge of #87416 - Aaron1011:query-side-effect, r=cjgillot
bors [Thu, 29 Jul 2021 02:51:19 +0000 (02:51 +0000)]
Auto merge of #87416 - Aaron1011:query-side-effect, r=cjgillot

Create `QuerySideEffects` and use it for diagnostics

The code for saving and loading diagnostics during execution is generalized to handle a new `QuerySideEffects` struct. Currently, this struct just holds diagnostics - in a follow-up PR, I plan to add support for storing attriutes marked as used during query execution.

This is a pure refactor, with no intended behavior changes.

2 years agoAuto merge of #85874 - steffahn:fix_unsound_zip_optimization, r=yaahc
bors [Thu, 29 Jul 2021 00:31:07 +0000 (00:31 +0000)]
Auto merge of #85874 - steffahn:fix_unsound_zip_optimization, r=yaahc

Remove unsound TrustedRandomAccess implementations

Removes the implementations that depend on the user-definable trait `Copy`.

Fixes #85873 in the most straightforward way.

<hr>

_Edit:_ This PR now contains additional trait infrastructure to avoid performance regressions around in-place collect, see the discussion in this thread starting from the codegen test failure at https://github.com/rust-lang/rust/pull/85874#issuecomment-872327577.

With this PR, `TrustedRandomAccess` gains additional documentation that specifically allows for and specifies the safety conditions around subtype coercions – those coercions can happen in safe Rust code with the `Zip` API’s usage of `TrustedRandomAccess`. This PR introduces a new supertrait of `TrustedRandomAccess`(currently named `TrustedRandomAccessNoCoerce`) that _doesn’t allow_ such coercions, which means it can be still be useful for optimizing cases such as in-place collect where no iterator is handed out to a user (who could do coercions) after a `get_unchecked` call; the benefit of the supertrait is that it doesn’t come with the additional safety conditions around supertraits either, so it can be implemented for more types than `TrustedRandomAccess`.

The `TrustedRandomAccess` implementations for `vec::IntoIter`, `vec_deque::IntoIter`, and `array::IntoIter` are removed as they don’t conform with the newly documented safety conditions, this way unsoundness is removed. But this PR in turn (re-)adds a `TrustedRandomAccessNoCoerce` implementation for `vec::IntoIter` to avoid performance regressions from stable in a case of in-place collecting of `Vec`s [the above-mentioned codegen test failure]. Re-introducing the (currently nightly+beta-only) impls for `VecDeque`’s and `[T; N]`’s iterators is technically possible, but goes beyond the scope of this PR (i.e. it can happen in a future PR).

2 years agoUpdate the examples in `String` and `VecDeque::retain`
Josh Stone [Wed, 28 Jul 2021 23:35:59 +0000 (16:35 -0700)]
Update the examples in `String` and `VecDeque::retain`

The examples added in #60396 used a "clever" post-increment hack,
unrelated to the actual point of the examples. That hack was found
[confusing] in the users forum, and #81811 already changed the `Vec`
example to use a more direct iterator. This commit changes `String` and
`VecDeque` in the same way for consistency.

[confusing]: https://users.rust-lang.org/t/help-understand-strange-expression/62858

2 years agoAuto merge of #87569 - JohnTitor:rollup-7ydfetw, r=JohnTitor
bors [Wed, 28 Jul 2021 22:06:51 +0000 (22:06 +0000)]
Auto merge of #87569 - JohnTitor:rollup-7ydfetw, r=JohnTitor

Rollup of 10 pull requests

Successful merges:

 - #81050 (Stabilize core::task::ready!)
 - #81363 (Remove P: Unpin bound on impl Future for Pin)
 - #86839 (Add doc aliases to fs.rs)
 - #87435 (fix example code for E0617)
 - #87451 (Add support for tuple struct field documentation)
 - #87491 (Integrate context into the memorial to Anna)
 - #87521 (Add long explanation for E0498)
 - #87527 (Don't run MIR unsafeck at all when using `-Zthir-unsafeck`)
 - #87550 (Add `CI_ONLY_WHEN_CHANNEL` and run `x86_64-gnu-stable` only on nightly)
 - #87565 (Use backticks when referring to `core::future::Ready` in panic message)

Failed merges:

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

2 years agoRollup merge of #87565 - ibraheemdev:patch-7, r=scottmcm
Yuki Okushi [Wed, 28 Jul 2021 21:11:50 +0000 (06:11 +0900)]
Rollup merge of #87565 - ibraheemdev:patch-7, r=scottmcm

Use backticks when referring to `core::future::Ready` in panic message

2 years agoRollup merge of #87550 - pietroalbini:ci-only-when-channel, r=Mark-Simulacrum
Yuki Okushi [Wed, 28 Jul 2021 21:11:49 +0000 (06:11 +0900)]
Rollup merge of #87550 - pietroalbini:ci-only-when-channel, r=Mark-Simulacrum

Add `CI_ONLY_WHEN_CHANNEL` and run `x86_64-gnu-stable` only on nightly

Backporting a commit made on #87508. cc ``@Mark-Simulacrum``

2 years agoRollup merge of #87527 - LeSeulArtichaut:no-mir-unsafeck, r=oli-obk
Yuki Okushi [Wed, 28 Jul 2021 21:11:48 +0000 (06:11 +0900)]
Rollup merge of #87527 - LeSeulArtichaut:no-mir-unsafeck, r=oli-obk

Don't run MIR unsafeck at all when using `-Zthir-unsafeck`

I don't know how I missed this :D
r? ``@oli-obk``

2 years agoRollup merge of #87521 - midgleyc:long-E0498, r=GuillaumeGomez
Yuki Okushi [Wed, 28 Jul 2021 21:11:47 +0000 (06:11 +0900)]
Rollup merge of #87521 - midgleyc:long-E0498, r=GuillaumeGomez

Add long explanation for E0498

Helps with #61137

2 years agoRollup merge of #87491 - jamesmunns:integrate-memorial, r=Mark-Simulacrum
Yuki Okushi [Wed, 28 Jul 2021 21:11:46 +0000 (06:11 +0900)]
Rollup merge of #87491 - jamesmunns:integrate-memorial, r=Mark-Simulacrum

Integrate context into the memorial to Anna

This came up after I reviewed https://github.com/rust-lang/rust/pull/87298, but I didn't propose this in time before that PR was merged.

If y'all feel this is too much churn on the file, no worries, feel free to close, but I felt this was a more fitting integration of the memorial into the test suite.

CC ``@boringcactus.``

2 years agoRollup merge of #87451 - GuillaumeGomez:tuple-struct-field-doc, r=jyn514
Yuki Okushi [Wed, 28 Jul 2021 21:11:45 +0000 (06:11 +0900)]
Rollup merge of #87451 - GuillaumeGomez:tuple-struct-field-doc, r=jyn514

Add support for tuple struct field documentation

Fixes  #42615.
This is #80320 updated to new codebase and with added tests.
Part of https://github.com/rust-lang/rust/issues/83255.

cc ```@camelid``` (since you were involved on the original PR).
r? ```@jyn514```

2 years agoRollup merge of #87435 - ibraheemdev:patch-4, r=JohnTitor
Yuki Okushi [Wed, 28 Jul 2021 21:11:44 +0000 (06:11 +0900)]
Rollup merge of #87435 - ibraheemdev:patch-4, r=JohnTitor

fix example code for E0617

Closes #86908

2 years agoRollup merge of #86839 - D1mon:patch-1, r=JohnTitor
Yuki Okushi [Wed, 28 Jul 2021 21:11:43 +0000 (06:11 +0900)]
Rollup merge of #86839 - D1mon:patch-1, r=JohnTitor

Add doc aliases to fs.rs

Add aliases for create_dir, create_dir_all, remove_dir, remove_dir_all

2 years agoRollup merge of #81363 - jonhoo:no-unpin-in-pin-future-impl, r=m-ou-se
Yuki Okushi [Wed, 28 Jul 2021 21:11:42 +0000 (06:11 +0900)]
Rollup merge of #81363 - jonhoo:no-unpin-in-pin-future-impl, r=m-ou-se

Remove P: Unpin bound on impl Future for Pin

We can safely produce a `Pin<&mut P::Target>` without moving out of the `Pin` by using `Pin::as_mut` directly.

The `Unpin` bound was originally added in #56939 following the recommendation of ``@withoutboats`` in https://github.com/rust-lang/rust/issues/55766#issue-378417538

That comment does not give explicit justification for why the bound should be added. The relevant context was:

> [ ] Remove `impl<P> Unpin for Pin<P>`
>
> This impl is not justified by our standard justification for unpin impls: there is no pointer direction between `Pin<P>` and `P`. Its usefulness is covered by the impls for pointers themselves.
>
> This futures impl (link to the impl changed in this PR) will need to change to add a `P: Unpin` bound.

The decision to remove the unconditional impl of `Unpin for Pin` is sound (these days there is just an auto-impl for when `P: Unpin`). But, I think the decision to also add the `Unpin` bound for `impl Future` may have been unnecessary. Or if that's not the case, I'd be very interested to have the argument for why written down somewhere. The bound _appears_ to not be needed, as demonstrated by the change requiring no unsafe code and by the existence of `Pin::as_mut`.

2 years agoRollup merge of #81050 - yoshuawuyts:stabilize-task-ready, r=m-ou-se
Yuki Okushi [Wed, 28 Jul 2021 21:11:41 +0000 (06:11 +0900)]
Rollup merge of #81050 - yoshuawuyts:stabilize-task-ready, r=m-ou-se

Stabilize core::task::ready!

_Tracking issue: https://github.com/rust-lang/rust/issues/70922_

This PR stabilizes the `task::ready!` macro. Similar to https://github.com/rust-lang/rust/pull/80886, this PR was waiting on https://github.com/rust-lang/rust/issues/74355 to be fixed.

The `task::ready!` API has existed in the futures ecosystem for several years, and was added on nightly last year in https://github.com/rust-lang/rust/pull/70817. The motivation for this macro is the same as it was back then: virtually every single manual future implementation makes use of this; so much so that it's one of the few things included in the [futures-core](https://docs.rs/futures-core/0.3.12/futures_core) library.

r? ``@tmandry``

cc/ ``@rust-lang/wg-async-foundations`` ``@rust-lang/libs``

## Example
```rust
use core::task::{Context, Poll};
use core::future::Future;
use core::pin::Pin;

async fn get_num() -> usize {
    42
}

pub fn do_poll(cx: &mut Context<'_>) -> Poll<()> {
    let mut f = get_num();
    let f = unsafe { Pin::new_unchecked(&mut f) };

    let num = ready!(f.poll(cx));
    // ... use num

    Poll::Ready(())
}
```

2 years agofix example code for E0617
Ibraheem Ahmed [Sat, 24 Jul 2021 17:58:08 +0000 (13:58 -0400)]
fix example code for E0617

2 years agoUse backticks when referring to `core::future::Ready` in panic message
Ibraheem Ahmed [Wed, 28 Jul 2021 20:22:34 +0000 (16:22 -0400)]
Use backticks when referring to `core::future::Ready` in panic message

2 years agomin_type_alias_impl_trait is going to be removed in 1.56
Santiago Pastorino [Wed, 28 Jul 2021 20:04:45 +0000 (17:04 -0300)]
min_type_alias_impl_trait is going to be removed in 1.56

2 years agoAuto merge of #87538 - RalfJung:miri, r=RalfJung
bors [Wed, 28 Jul 2021 19:25:59 +0000 (19:25 +0000)]
Auto merge of #87538 - RalfJung:miri, r=RalfJung

update Miri

Fixes https://github.com/rust-lang/rust/issues/87518
Cc `@rust-lang/miri` r? `@ghost`

2 years agoAdd some doc aliases
D1mon [Sat, 3 Jul 2021 12:31:16 +0000 (15:31 +0300)]
Add some doc aliases

Add `mkdir` to `create_dir`, `rmdir` to `remove_dir`.

2 years agoAuto merge of #87540 - JohnTitor:rollup-8xc6bl5, r=JohnTitor
bors [Wed, 28 Jul 2021 16:59:00 +0000 (16:59 +0000)]
Auto merge of #87540 - JohnTitor:rollup-8xc6bl5, r=JohnTitor

Rollup of 10 pull requests

Successful merges:

 - #87315 (Add docs for raw-dylib to unstable book)
 - #87330 (Use hashbrown's `extend_reserve()` in `HashMap`)
 - #87443 (Don't treat git repos as non-existent when `ignore_git` is set)
 - #87453 (Suggest removing unnecessary &mut as help message)
 - #87500 (Document math behind MIN/MAX consts on integers)
 - #87501 (Remove min_type_alias_impl_trait in favor of type_alias_impl_trait)
 - #87507 (SGX mutex is *not* moveable)
 - #87513 (bootstrap.py: change `git log` option to indicate desired behavior)
 - #87523 (Stop creating a reference then immediately dereferencing it.)
 - #87524 (Fix ICE in `diagnostic_hir_wf_check`)

Failed merges:

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

2 years agofix nit
Roxane [Wed, 28 Jul 2021 16:27:57 +0000 (12:27 -0400)]
fix nit

2 years agoUpdate stable version of ready!() macro.
Mara Bos [Wed, 28 Jul 2021 14:54:53 +0000 (16:54 +0200)]
Update stable version of ready!() macro.

2 years agoRange PatKind implies discr should be read
Roxane [Wed, 28 Jul 2021 14:35:48 +0000 (10:35 -0400)]
Range PatKind implies discr should be read

2 years agoFix typo in rustc_driver::version
bjorn3 [Wed, 28 Jul 2021 14:35:57 +0000 (16:35 +0200)]
Fix typo in rustc_driver::version

This caused rustc -Zcodegen-backend=foo.so -vV to look for oo.so instead of
foo.so

2 years agoExtend documentation of const_format_args!().
Mara Bos [Sat, 10 Jul 2021 16:45:28 +0000 (18:45 +0200)]
Extend documentation of const_format_args!().

2 years agoImprove comments about const panic handling
Mara Bos [Sat, 10 Jul 2021 16:39:25 +0000 (18:39 +0200)]
Improve comments about const panic handling

Co-authored-by: Ralf Jung <post@ralfj.de>
2 years agoCheck that const_panic_fmt is const too.
Mara Bos [Sat, 10 Jul 2021 16:32:27 +0000 (18:32 +0200)]
Check that const_panic_fmt is const too.

2 years agoMake const_fmt_args!() work during bootstrap.
Mara Bos [Fri, 9 Jul 2021 15:39:37 +0000 (17:39 +0200)]
Make const_fmt_args!() work during bootstrap.

2 years agoUse unreachable_unchecked in const_panic_fmt.
Mara Bos [Fri, 9 Jul 2021 15:29:41 +0000 (17:29 +0200)]
Use unreachable_unchecked in const_panic_fmt.

2 years agoAdd new const_format_args!() macro and use it in panics.
Mara Bos [Fri, 9 Jul 2021 14:45:50 +0000 (16:45 +0200)]
Add new const_format_args!() macro and use it in panics.

2 years agoAdd test for const panic in Rust 2021.
Mara Bos [Fri, 9 Jul 2021 13:33:42 +0000 (15:33 +0200)]
Add test for const panic in Rust 2021.

2 years agoUpdate test output for const fmt::Arguments constructor.
Mara Bos [Fri, 9 Jul 2021 12:17:39 +0000 (14:17 +0200)]
Update test output for const fmt::Arguments constructor.

2 years agoMake const panic!("..") work in Rust 2021.
Mara Bos [Tue, 6 Jul 2021 12:38:26 +0000 (12:38 +0000)]
Make const panic!("..") work in Rust 2021.

During const eval, this replaces calls to core::panicking::panic_fmt and
std::panicking::being_panic_fmt with a call to a new const fn:
core::panicking::const_panic_fmt. That function uses
fmt::Arguments::as_str() to get the str and calls panic_str with that
instead.

panic!() invocations with formatting arguments are still not accepted,
as the creation of such a fmt::Arguments cannot be done in constant
functions right now.

2 years agoadd CI_ONLY_WHEN_CHANNEL and run x86_64-gnu-stable only on nightly
Pietro Albini [Wed, 28 Jul 2021 13:18:18 +0000 (15:18 +0200)]
add CI_ONLY_WHEN_CHANNEL and run x86_64-gnu-stable only on nightly

2 years agoAuto merge of #7502 - flip1995:rollup-y3ho3w0, r=flip1995
bors [Wed, 28 Jul 2021 13:15:43 +0000 (13:15 +0000)]
Auto merge of #7502 - flip1995:rollup-y3ho3w0, r=flip1995

Rollup of 3 pull requests

Successful merges:

 - #7279 (Adapting the lint list to Clippy's new metadata format)
 - #7298 (Switch CI to new metadata collection)
 - #7420 (Update lint documentation to use markdown headlines)

Failed merges:

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

changelog: rollup

2 years agoRollup merge of #7420 - xFrednet:7172-update-lint-documentation, r=flip1995
Philipp Krones [Wed, 28 Jul 2021 13:06:27 +0000 (15:06 +0200)]
Rollup merge of #7420 - xFrednet:7172-update-lint-documentation, r=flip1995

Update lint documentation to use markdown headlines

This PR updates all lint documentation to use markdown headlines. It additionally removed the *Known problems* section for lints without any problems. I've double-checked all automatic replacements, but a second pair of eyes is definitely appreciated!

I wasn't sure when you wanted to switch to the new metadata collection tomorrow, I therefore prepared this PR today. And that's it this is a standalone PR to keep the other related PRs reviewable.

changelog:  none

r? `@flip1995`

cc: #7172

Note: This should be merged with the other metadata collection related PRs.

2 years agoRollup merge of #7298 - flip1995:ci-switch-to-monster, r=xFrednet,flip1995
Philipp Krones [Wed, 28 Jul 2021 13:06:26 +0000 (15:06 +0200)]
Rollup merge of #7298 - flip1995:ci-switch-to-monster, r=xFrednet,flip1995

Switch CI to new metadata collection

r? `@xFrednet`

Things we have to keep in mind:

- This removes the template files and the scripts used for deployment from the checkout. This was added in #5517. I don't think we ever needed those there. Not sure though.
- ~~As a result, we can't remove the python scripts yet. We have to wait until this hits a stable Clippy release.~~ I'll just break the next stable deploy and do it by hand once.
- This should be merged together with #7279. Me and `@xFrednet` will coordinate the switch
- ...?

I still have to try out some things:

- [x] Is it worth caching? Yes
- [x] ~~Is it worth to do a release build?~~ Nope
- [x] Does it actually work? With a few changes, yes
- [ ] ...?

changelog: Clippy now uses a lint to generate its documentation :tada:

2 years agoRollup merge of #7279 - xFrednet:7172-adapt-website-to-new-format, r=flip1995
Philipp Krones [Wed, 28 Jul 2021 13:06:26 +0000 (15:06 +0200)]
Rollup merge of #7279 - xFrednet:7172-adapt-website-to-new-format, r=flip1995

Adapting the lint list to Clippy's new metadata format

This is close to the end of a long living project to rewrite the lint metadata collection for Clippy. Progress on this has been tracked in #7172. This PR adds one of the last missing puzzle pieces, the actual display of all the changes that have been done in the background. A preview can be seen here: [Clippy's lint list](https://xfrednet.github.io/rust-clippy/master/index.html)

The styling has been discussed on [zulip](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Styling.20feedback.20for.20Clippy's.20lint.20list/near/239601067) but is still open to suggestion.

Side note: It has been fun working on the website where we don't have unit tests and everything is just tested by playing around. However, it's good that this chaos is contained into this one part of Clippy. :bug:

---

Closes: #1303
Closes: #4310
This actually closes fewer things than I thought it would...

changelog: Reworked Clippy's [website](https://rust-lang.github.io/rust-clippy/master/index.html):
changelog: * Added applicability information about lints
changelog: * Added a link to jump to the specific lint implementation
changelog: * Adapted some styling and improved loading time

r? `@flip1995`

2 years agoRun cargo collect-metadata in cargo dev serve
flip1995 [Wed, 28 Jul 2021 13:05:11 +0000 (15:05 +0200)]
Run cargo collect-metadata in cargo dev serve

2 years agoAdapting the lint list to Clippy's new metadata format
xFrednet [Tue, 18 May 2021 22:08:31 +0000 (00:08 +0200)]
Adapting the lint list to Clippy's new metadata format

Changes included:
    - Minimum adaption to the new `lints.json` format
    - Fixing filtering for the new `lints.json` format; hardcoding the
      lint groups in the index
    - Recreating the original doc styling for the new format
    - Fixed sytax highlighting for rust,ignore code blocks
    - Fixed markdown table extraction in the metadata collector and
      fixed lint level output
    - Adding the additional information row for lints
    - Changed the website title to Clippy's lint list
    - Flexing the website for mobile users
    - Added (?) references for lint levels and groups
    - Making deprecated lints look dead
    - Removed JS code block language extraction in favor of a rust
      implementation `rust-clippy#7352`
    - Added the suspicious lint group to the lint list
    - Remove trailing whitespaces from index.html
    - Fix code highlighting
    - Use default value if the docVersion is empty

Co-authored-by: Philipp Krones <hello@philkrones.com>
2 years agoAdd #[track_caller] for some function in core::mem.
Mara Bos [Sun, 27 Jun 2021 12:41:50 +0000 (12:41 +0000)]
Add #[track_caller] for some function in core::mem.

These functions can panic for some types. This makes the panic point to
the code that calls e.g. mem::uninitialized(), instead of inside the
definition of mem::uninitialized.

2 years agoDocumentation improvements
Frank Steffahn [Thu, 1 Jul 2021 21:01:16 +0000 (23:01 +0200)]
Documentation improvements

2 years agoMake `SpecInPlaceCollect` use `TrustedRandomAccessNoCoerce`
Frank Steffahn [Thu, 1 Jul 2021 17:12:13 +0000 (19:12 +0200)]
Make `SpecInPlaceCollect` use `TrustedRandomAccessNoCoerce`

2 years agoRemove redundant bounds on get_unchecked for vec_deque iterators, and run fmt
Frank Steffahn [Thu, 1 Jul 2021 17:04:50 +0000 (19:04 +0200)]
Remove redundant bounds on get_unchecked for vec_deque iterators, and run fmt

2 years agoAdd back TrustedRandomAccess-specialization for Vec, but only without coercions
Frank Steffahn [Thu, 1 Jul 2021 16:56:50 +0000 (18:56 +0200)]
Add back TrustedRandomAccess-specialization for Vec, but only without coercions

2 years agoChange __iterator_get_unchecked to work with TrustedRandomAccessNoCoerce
Frank Steffahn [Thu, 1 Jul 2021 16:54:02 +0000 (18:54 +0200)]
Change __iterator_get_unchecked to work with TrustedRandomAccessNoCoerce

2 years agoAdd TrustedRandomAccessNoCoerce supertrait without requirements or guarantees about...
Frank Steffahn [Thu, 1 Jul 2021 15:49:47 +0000 (17:49 +0200)]
Add TrustedRandomAccessNoCoerce supertrait without requirements or guarantees about subtype coercions

Update all the TrustedRandomAccess impls to also implement the new supertrait

2 years agoImprove documentation of TrustedRandomAccess
Frank Steffahn [Thu, 3 Jun 2021 13:53:12 +0000 (15:53 +0200)]
Improve documentation of TrustedRandomAccess

Include new details regarding coercions to a subtype.
These conditions also explain why the previously removed implementations
for {array, vec, vec_deque}::IntoIter<T> were unsound, because they introduced
an extra `T: Clone` for the TrustedRandomAccess impl, even though their parameter T
is covariant.

2 years agoRemove unsound TrustedRandomAccess implementations
Frank Steffahn [Tue, 1 Jun 2021 00:21:26 +0000 (02:21 +0200)]
Remove unsound TrustedRandomAccess implementations

Removes the implementations that depend on the user-definable trait `Copy`.