]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoRollup merge of #90117 - calebsander:fix/rsplit-clone, r=yaahc
Matthias Krüger [Sat, 23 Oct 2021 03:28:26 +0000 (05:28 +0200)]
Rollup merge of #90117 - calebsander:fix/rsplit-clone, r=yaahc

Make RSplit<T, P>: Clone not require T: Clone

This addresses a TODO comment. The behavior of `#[derive(Clone)]` *does* result in a `T: Clone` requirement. Playground example:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=a8b1a9581ff8893baf401d624a53d35b

Add a manual `Clone` implementation, mirroring `Split` and `SplitInclusive`.
`(R)?SplitN(Mut)?` don't have any `Clone` implementations, but I'll leave that for its own pull request.

2 years agoRollup merge of #90087 - calebcartwright:rustfmt-subtree, r=calebcartwright
Matthias Krüger [Sat, 23 Oct 2021 03:28:25 +0000 (05:28 +0200)]
Rollup merge of #90087 - calebcartwright:rustfmt-subtree, r=calebcartwright

Sync rustfmt subtree

There's a large number of small fixes and new features, but nothing too big. Detailed changelog for those interested can be found in https://github.com/rust-lang/rustfmt/blob/master/CHANGELOG.md#1438-2021-10-20

2 years agoRollup merge of #90070 - llogiq:compiletest-config-edition, r=Mark-Simulacrum
Matthias Krüger [Sat, 23 Oct 2021 03:28:24 +0000 (05:28 +0200)]
Rollup merge of #90070 - llogiq:compiletest-config-edition, r=Mark-Simulacrum

Add edition configuration to compiletest

This allows the compiletest configuration to set a default edition that can still be overridden with header annotations. Doing this will make it far easier for clippy to get our tests to the newest edition.

r? ```@Manishearth```

2 years agoRollup merge of #89920 - hudson-ayers:location-detail-control, r=davidtwco
Matthias Krüger [Sat, 23 Oct 2021 03:28:23 +0000 (05:28 +0200)]
Rollup merge of #89920 - hudson-ayers:location-detail-control, r=davidtwco

Implement -Z location-detail flag

This PR implements the `-Z location-detail` flag as described in https://github.com/rust-lang/rfcs/pull/2091 .

`-Z location-detail=val` controls what location details are tracked when using `caller_location`. This allows users to control what location details are printed as part of panic messages, by allowing them to exclude any combination of filenames, line numbers, and column numbers. This option is intended to provide users with a way to mitigate the size impact of `#[track_caller]`.

Some measurements of the savings of this approach on an embedded binary can be found here: https://github.com/rust-lang/rust/issues/70579#issuecomment-942556822 .

Closes #70580 (unless people want to leave that open as a place for discussion of further improvements).

This is my first real PR to rust, so any help correcting mistakes / understanding side effects / improving my tests is appreciated :)

I have one question: RFC 2091 specified this as a debugging option (I think that is what -Z implies?). Does that mean this can never be stabilized without a separate MCP? If so, do I need to submit an MCP now, or is the initial RFC specifying this option sufficient for this to be merged as is, and then an MCP would be needed for eventual stabilization?

2 years agoRollup merge of #89730 - crlf0710:type_changing_feature, r=jackh726
Matthias Krüger [Sat, 23 Oct 2021 03:28:22 +0000 (05:28 +0200)]
Rollup merge of #89730 - crlf0710:type_changing_feature, r=jackh726

add feature flag for `type_changing_struct_update`

This implements the PR0 part of the mentoring notes within #86618.

overrides the previous inactive #86646 pr.

r? ```@nikomatsakis```

2 years agoRollup merge of #89468 - FabianWolff:issue-89358, r=jackh726
Matthias Krüger [Sat, 23 Oct 2021 03:28:22 +0000 (05:28 +0200)]
Rollup merge of #89468 - FabianWolff:issue-89358, r=jackh726

Report fatal lexer errors in `--cfg` command line arguments

Fixes #89358. The erroneous behavior was apparently introduced by `@Mark-Simulacrum` in https://github.com/rust-lang/rust/commit/a678e3191197f145451c97c6cc884e15cae38186; the idea is to silence individual parser errors and instead emit one catch-all error message after parsing. However, for the example in #89358, a fatal lexer error is created here:
https://github.com/rust-lang/rust/blob/edebf77e0090195bf80c0d8cda821e1bf9d03053/compiler/rustc_parse/src/lexer/mod.rs#L340-L349

This fatal error aborts the compilation, and so the call to `new_parser_from_source_str()` never returns and the catch-all error message is never emitted. I have therefore changed the `SilentEmitter` to silence only non-fatal errors; with my changes, for the rustc invocation described in #89358:
```sh
rustc --cfg "abc\""
```
I get the following output:
```
error[E0765]: unterminated double quote string
  |
  = note: this error occurred on the command line: `--cfg=abc"`
```

2 years agoRollup merge of #89416 - notriddle:notriddle/do-not-elide-lifetimes-in-region-errors...
Matthias Krüger [Sat, 23 Oct 2021 03:28:21 +0000 (05:28 +0200)]
Rollup merge of #89416 - notriddle:notriddle/do-not-elide-lifetimes-in-region-errors, r=jackh726

nice_region_error: Include lifetime placeholders in error output

As you can see in src/test/ui/traits/self-without-lifetime-constraint.stderr
you can get very confusing type names if you don't have this.

Fixes #87763

2 years agoRollup merge of #88300 - ijackson:exitstatusext-methods, r=yaahc
Matthias Krüger [Sat, 23 Oct 2021 03:28:20 +0000 (05:28 +0200)]
Rollup merge of #88300 - ijackson:exitstatusext-methods, r=yaahc

Stabilise unix_process_wait_more, extra ExitStatusExt methods

This stabilises the feature `unix_process_wait_more`.  Tracking issue #80695, FCP needed.

This was implemented in #79982 and merged in January.

2 years agoRollup merge of #83233 - jethrogb:split_array, r=yaahc
Matthias Krüger [Sat, 23 Oct 2021 03:28:19 +0000 (05:28 +0200)]
Rollup merge of #83233 - jethrogb:split_array, r=yaahc

Implement split_array and split_array_mut

This implements `[T]::split_array::<const N>() -> (&[T; N], &[T])` and `[T; N]::split_array::<const M>() -> (&[T; M], &[T])` and their mutable equivalents. These are another few “missing” array implementations now that const generics are a thing, similar to #74373, #75026, etc. Fixes #74674.

This implements `[T; N]::split_array` returning an array and a slice. Ultimately, this is probably not what we want, we would want the second return value to be an array of length N-M, which will likely be possible with future const generics enhancements. We need to implement the array method now though, to immediately shadow the slice method. This way, when the slice methods get stabilized, calling them on an array will not be automatic through coercion, so we won't have trouble stabilizing the array methods later (cf. into_iter debacle).

An unchecked version of `[T]::split_array` could also be added as in #76014. This would not be needed for `[T; N]::split_array` as that can be compile-time checked. Edit: actually, since split_at_unchecked is internal-only it could be changed to be split_array-only.

2 years agonice_region_error: Include lifetime placeholders in error output
Michael Howell [Fri, 1 Oct 2021 05:47:41 +0000 (22:47 -0700)]
nice_region_error: Include lifetime placeholders in error output

As you can see in src/test/ui/traits/self-without-lifetime-constraint.stderr
you can get very confusing type names if you don't have this.

Fixes #87763

2 years agoAuto merge of #90007 - xfix:inline-cstr-from-str, r=kennytm
bors [Fri, 22 Oct 2021 21:01:59 +0000 (21:01 +0000)]
Auto merge of #90007 - xfix:inline-cstr-from-str, r=kennytm

Inline CStr::from_ptr

Inlining this function is valuable, as it allows LLVM to apply `strlen`-specific optimizations without having to enable LTO.

For instance, the following function:

```rust
pub fn f(p: *const c_char) -> Option<u8> {
    unsafe { CStr::from_ptr(p) }.to_bytes().get(0).copied()
}
```

Looks like this if `CStr::from_ptr` is allowed to be inlined.

```asm
before:
        push    rax
        call    qword ptr [rip + std::ffi::c_str::CStr::from_ptr@GOTPCREL]
        mov     rcx, rax
        cmp     rdx, 1
        sete    dl
        test    rax, rax
        sete    al
        or      al, dl
        jne     .LBB1_2
        mov     dl, byte ptr [rcx]
.LBB1_2:
        xor     al, 1
        pop     rcx
        ret

after:
        mov     dl, byte ptr [rdi]
        test    dl, dl
        setne   al
        ret
```

Note that optimization turned this from O(N) to O(1) in terms of performance, as LLVM knows that it doesn't really need to call `strlen` to determine whether a string is empty or not.

2 years agoApply suggestions from code review
Jane Lusby [Fri, 22 Oct 2021 17:47:34 +0000 (10:47 -0700)]
Apply suggestions from code review

2 years agoAuto merge of #89893 - camsteffen:redundant-dump-enabled, r=matthewjasper
bors [Fri, 22 Oct 2021 17:32:20 +0000 (17:32 +0000)]
Auto merge of #89893 - camsteffen:redundant-dump-enabled, r=matthewjasper

Remove redundant dump_enabled check

2 years agoadd feature flag for `type_changing_struct_update`
Charles Lew [Sun, 10 Oct 2021 06:50:39 +0000 (14:50 +0800)]
add feature flag for `type_changing_struct_update`

2 years agoAuto merge of #90161 - JohnTitor:rollup-1j2qc8m, r=JohnTitor
bors [Fri, 22 Oct 2021 14:25:23 +0000 (14:25 +0000)]
Auto merge of #90161 - JohnTitor:rollup-1j2qc8m, r=JohnTitor

Rollup of 14 pull requests

Successful merges:

 - #87537 (Clarify undefined behaviour in binary heap, btree and hashset docs)
 - #88624 (Stabilize feature `saturating_div` for rust 1.58.0)
 - #89257 (Give better error for `macro_rules name`)
 - #89665 (Ensure that pushing empty path works as before on verbatim paths)
 - #89895 (Don't mark for loop iter expression as desugared)
 - #89922 (Update E0637 description to mention `&` w/o an explicit lifetime name)
 - #89944 (Change `Duration::[try_]from_secs_{f32, f64}` underflow error)
 - #89991 (rustc_ast: Turn `MutVisitor::token_visiting_enabled` into a constant)
 - #90028 (Reject closures in patterns)
 - #90069 (Fix const qualification when executed after promotion)
 - #90078 (Add a regression test for issue-83479)
 - #90114 (Add some tests for const_generics_defaults)
 - #90115 (Add test for issue #78561)
 - #90129 (triagebot: Treat `I-*nominated` like `I-nominated`)

Failed merges:

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

2 years agoRollup merge of #90129 - joshtriplett:triagebot-nominated, r=Mark-Simulacrum
Yuki Okushi [Fri, 22 Oct 2021 10:42:53 +0000 (19:42 +0900)]
Rollup merge of #90129 - joshtriplett:triagebot-nominated, r=Mark-Simulacrum

triagebot: Treat `I-*nominated` like `I-nominated`

rustbot doesn't allow unauthenticated users to set `I-nominated`; apply the same permissions to the new `I-*nominated` labels.

2 years agoRollup merge of #90115 - samlich:test-issue-78561, r=oli-obk
Yuki Okushi [Fri, 22 Oct 2021 10:42:52 +0000 (19:42 +0900)]
Rollup merge of #90115 - samlich:test-issue-78561, r=oli-obk

Add test for issue #78561

Adds test for and closes #78561 which previously crashed compiler.

2 years agoRollup merge of #90114 - BoxyUwU:cg_defaults_tests, r=lcnr
Yuki Okushi [Fri, 22 Oct 2021 10:42:51 +0000 (19:42 +0900)]
Rollup merge of #90114 - BoxyUwU:cg_defaults_tests, r=lcnr

Add some tests for const_generics_defaults

I think this covers some of the stuff required for stabilisation report, some of these tests are probably covering stuff we already have but it can't hurt to have more :)

r? ````@lcnr````

2 years agoRollup merge of #90078 - JohnTitor:test-83479, r=Mark-Simulacrum
Yuki Okushi [Fri, 22 Oct 2021 10:42:50 +0000 (19:42 +0900)]
Rollup merge of #90078 - JohnTitor:test-83479, r=Mark-Simulacrum

Add a regression test for issue-83479

Add a regression test for https://github.com/rust-lang/rust/issues/83479#issue-841147340, but not close the issue, see https://github.com/rust-lang/rust/issues/83479#issuecomment-947255641.

2 years agoRollup merge of #90069 - tmiasko:promoted-const-qualif, r=oli-obk
Yuki Okushi [Fri, 22 Oct 2021 10:42:49 +0000 (19:42 +0900)]
Rollup merge of #90069 - tmiasko:promoted-const-qualif, r=oli-obk

Fix const qualification when executed after promotion

The const qualification was so far performed before the promotion and
the implementation assumed that it will never encounter a promoted.

With `const_precise_live_drops` feature, checking for live drops is
delayed until after drop elaboration, which in turn runs after
promotion. so the assumption is no longer true. When evaluating
`NeedsNonConstDrop` it is now possible to encounter promoteds.

Use type base qualification for the promoted. It is a sound
approximation in general, and in the specific case of promoteds and
`NeedsNonConstDrop` it is precise.

Fixes #89938.

2 years agoRollup merge of #90028 - tmiasko:structural-match-closure, r=spastorino
Yuki Okushi [Fri, 22 Oct 2021 10:42:48 +0000 (19:42 +0900)]
Rollup merge of #90028 - tmiasko:structural-match-closure, r=spastorino

Reject closures in patterns

Fixes #90013.

2 years agoRollup merge of #89991 - petrochenkov:visitok2, r=jackh726
Yuki Okushi [Fri, 22 Oct 2021 10:42:48 +0000 (19:42 +0900)]
Rollup merge of #89991 - petrochenkov:visitok2, r=jackh726

rustc_ast: Turn `MutVisitor::token_visiting_enabled` into a constant

It's a visitor property rather than something that needs to be determined at runtime

2 years agoRollup merge of #89944 - mbartlett21:patch-2, r=Mark-Simulacrum
Yuki Okushi [Fri, 22 Oct 2021 10:42:47 +0000 (19:42 +0900)]
Rollup merge of #89944 - mbartlett21:patch-2, r=Mark-Simulacrum

Change `Duration::[try_]from_secs_{f32, f64}` underflow error

The error message now says that it was a negative value.

Fixes #89913.

2 years agoRollup merge of #89922 - JohnTitor:update-e0637, r=jackh726
Yuki Okushi [Fri, 22 Oct 2021 10:42:46 +0000 (19:42 +0900)]
Rollup merge of #89922 - JohnTitor:update-e0637, r=jackh726

Update E0637 description to mention `&` w/o an explicit lifetime name

Deal with https://github.com/rust-lang/rust/issues/89824#issuecomment-941598647. Another solution would be splitting the error code into two as (I think) it's a bit unclear to users why they have the same error code.

2 years agoRollup merge of #89895 - camsteffen:for-loop-head-span, r=davidtwco
Yuki Okushi [Fri, 22 Oct 2021 10:42:45 +0000 (19:42 +0900)]
Rollup merge of #89895 - camsteffen:for-loop-head-span, r=davidtwco

Don't mark for loop iter expression as desugared

We typically don't mark spans of lowered things as desugared. This helps Clippy rightly discern when code is (not) from expansion. This was discovered by ``@flip1995`` at https://github.com/rust-lang/rust-clippy/pull/7789#issuecomment-939289501.

2 years agoRollup merge of #89665 - seanyoung:push-empty, r=m-ou-se
Yuki Okushi [Fri, 22 Oct 2021 10:42:43 +0000 (19:42 +0900)]
Rollup merge of #89665 - seanyoung:push-empty, r=m-ou-se

Ensure that pushing empty path works as before on verbatim paths

Fixes: https://github.com/rust-lang/rust/issues/89658
Signed-off-by: Sean Young <sean@mess.org>
2 years agoRollup merge of #89257 - aDotInTheVoid:macro-error-2, r=estebank
Yuki Okushi [Fri, 22 Oct 2021 10:42:43 +0000 (19:42 +0900)]
Rollup merge of #89257 - aDotInTheVoid:macro-error-2, r=estebank

Give better error for `macro_rules name`

follow up to #89221

r? ``@estebank``

``@rustbot`` modify labels: +A-diagnostics +A-parser

2 years agoRollup merge of #88624 - kellerkindt:master, r=JohnTitor
Yuki Okushi [Fri, 22 Oct 2021 10:42:42 +0000 (19:42 +0900)]
Rollup merge of #88624 - kellerkindt:master, r=JohnTitor

Stabilize feature `saturating_div` for rust 1.58.0

The tracking issue is #89381

This seems like a reasonable simple change(?). The feature `saturating_div` was added as part of the ongoing effort to implement a `Saturating` integer type (see #87921). The implementation has been discussed [here](https://github.com/rust-lang/rust/pull/87921#issuecomment-899357720) and [here](https://github.com/rust-lang/rust/pull/87921#discussion_r691888556). It extends the list of saturating operations on integer types (like `saturating_add`, `saturating_sub`, `saturating_mul`, ...) by the function `fn saturating_div(self, rhs: Self) -> Self`.

The stabilization of the feature `saturating_int_impl` (for the `Saturating` type) needs to have this stabilized first.

Closes #89381

2 years agoRollup merge of #87537 - Wilfred:improve-min-heap-docs, r=Mark-Simulacrum
Yuki Okushi [Fri, 22 Oct 2021 10:42:41 +0000 (19:42 +0900)]
Rollup merge of #87537 - Wilfred:improve-min-heap-docs, r=Mark-Simulacrum

Clarify undefined behaviour in binary heap, btree and hashset docs

Previously, it wasn't clear whether "This could include" was referring to logic errors, or undefined behaviour. Tweak wording to clarify this sentence does not relate to UB.

2 years agoImplement split_array and split_array_mut
Jethro Beekman [Wed, 17 Mar 2021 16:23:09 +0000 (17:23 +0100)]
Implement split_array and split_array_mut

2 years agoMake RSplit<T, P>: Clone not require T: Clone
Caleb Sander [Thu, 21 Oct 2021 00:04:01 +0000 (17:04 -0700)]
Make RSplit<T, P>: Clone not require T: Clone

This addresses a TODO comment. The behavior of #[derive(Clone)]
*does* result in a T: Clone requirement.

Add a manual Clone implementation, matching Split and SplitInclusive.

2 years agoAuto merge of #90126 - flip1995:clippyup, r=Manishearth
bors [Thu, 21 Oct 2021 23:31:13 +0000 (23:31 +0000)]
Auto merge of #90126 - flip1995:clippyup, r=Manishearth

Update Clippy

r? `@Manishearth`

This adds a new dep to Clippy: [indoc](https://crates.io/crates/indoc)

And transitively: [unindent](https://crates.io/crates/unindent)

2 years agofix doc issue in rustfmt
Caleb Cartwright [Thu, 21 Oct 2021 22:22:54 +0000 (17:22 -0500)]
fix doc issue in rustfmt

2 years agoadd tests for -Zlocation-detail
Hudson Ayers [Fri, 15 Oct 2021 15:58:28 +0000 (08:58 -0700)]
add tests for -Zlocation-detail

2 years agodocument the unstable location-detail flag
Hudson Ayers [Thu, 14 Oct 2021 17:46:07 +0000 (10:46 -0700)]
document the unstable location-detail flag

2 years agoConfigure saved panic locations based on location-detail flag
Hudson Ayers [Thu, 14 Oct 2021 16:20:32 +0000 (09:20 -0700)]
Configure saved panic locations based on location-detail flag

2 years agoStabilize feature saturating_div for rust 1.58
Michael Watzko [Thu, 21 Oct 2021 16:08:03 +0000 (18:08 +0200)]
Stabilize feature saturating_div for rust 1.58

2 years agoAuto merge of #90130 - Mark-Simulacrum:revert-namebinding, r=oli-obk
bors [Thu, 21 Oct 2021 15:45:00 +0000 (15:45 +0000)]
Auto merge of #90130 - Mark-Simulacrum:revert-namebinding, r=oli-obk

Revert "resolve: Use NameBinding for local variables and generic parameters"

This reverts commit 6162529a01473bbb2427fa27354cbafc3c514eee, that is, PR #89100.

Reverting per performance regression noted post-merge on that PR (https://github.com/rust-lang/rust/pull/89100#issuecomment-948065457).

2 years agoClarify undefined behaviour for binary heap, btree and hashset
Wilfred Hughes [Wed, 28 Jul 2021 06:13:42 +0000 (23:13 -0700)]
Clarify undefined behaviour for binary heap, btree and hashset

Previously, it wasn't clear whether "This could include" was referring
to logic errors, or undefined behaviour. Tweak wording to clarify this
sentence does not relate to UB.

2 years agoRevert "Auto merge of #89100 - petrochenkov:localbind, r=cjgillot"
Mark Rousskov [Thu, 21 Oct 2021 13:09:24 +0000 (09:09 -0400)]
Revert "Auto merge of #89100 - petrochenkov:localbind, r=cjgillot"

This reverts commit 6162529a01473bbb2427fa27354cbafc3c514eee.

2 years agotriagebot: Treat `I-*nominated` like `I-nominated`
Josh Triplett [Thu, 21 Oct 2021 13:07:36 +0000 (15:07 +0200)]
triagebot: Treat `I-*nominated` like `I-nominated`

rustbot doesn't allow unauthenticated users to set `I-nominated`; apply
the same permissions to the new `I-*nominated` labels.

2 years agoUpdate Cargo.lock
flip1995 [Thu, 21 Oct 2021 11:13:17 +0000 (13:13 +0200)]
Update Cargo.lock

2 years agoMerge commit '91496c2ac6abf6454c413bb23e8becf6b6dc20ea' into clippyup
flip1995 [Thu, 21 Oct 2021 11:11:36 +0000 (13:11 +0200)]
Merge commit '91496c2ac6abf6454c413bb23e8becf6b6dc20ea' into clippyup

2 years agoAuto merge of #7853 - flip1995:rustup, r=flip1995
bors [Thu, 21 Oct 2021 10:23:11 +0000 (10:23 +0000)]
Auto merge of #7853 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

2 years agoBump nightly version -> 2021-10-21
flip1995 [Thu, 21 Oct 2021 10:19:46 +0000 (12:19 +0200)]
Bump nightly version -> 2021-10-21

2 years agoBump Clippy Version -> 0.1.58
flip1995 [Thu, 21 Oct 2021 10:19:32 +0000 (12:19 +0200)]
Bump Clippy Version -> 0.1.58

2 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Thu, 21 Oct 2021 10:18:12 +0000 (12:18 +0200)]
Merge remote-tracking branch 'upstream/master' into rustup

2 years agoAdd test for issue #78561
samlich [Wed, 20 Oct 2021 22:51:31 +0000 (22:51 +0000)]
Add test for issue #78561

2 years agoVerify that only NeedsNonConstDrop expects promoteds
Tomasz Miąsko [Thu, 21 Oct 2021 00:00:00 +0000 (00:00 +0000)]
Verify that only NeedsNonConstDrop expects promoteds

2 years agoAuto merge of #7852 - surechen:fix_typo, r=xFrednet
bors [Thu, 21 Oct 2021 09:08:22 +0000 (09:08 +0000)]
Auto merge of #7852 - surechen:fix_typo, r=xFrednet

Fix typo for invalid_null_ptr_usage and missing_inline_in_public_items.

Fix typo for invalid_null_ptr_usage and missing_inline_in_public_items.

changelog: none

2 years agoAuto merge of #90119 - JohnTitor:rollup-e5t6khz, r=JohnTitor
bors [Thu, 21 Oct 2021 08:04:19 +0000 (08:04 +0000)]
Auto merge of #90119 - JohnTitor:rollup-e5t6khz, r=JohnTitor

Rollup of 14 pull requests

Successful merges:

 - #86984 (Reject octal zeros in IPv4 addresses)
 - #87440 (Remove unnecessary condition in Barrier::wait())
 - #88644 (`AbstractConst` private fields)
 - #89292 (Stabilize CString::from_vec_with_nul[_unchecked])
 - #90010 (Avoid overflow in `VecDeque::with_capacity_in()`.)
 - #90029 (Add test for debug logging during incremental compilation)
 - #90031 (config: add the option to enable LLVM tests)
 - #90048 (Add test for line-number setting)
 - #90071 (Remove hir::map::blocks and use FnKind instead)
 - #90074 (2229 migrations small cleanup)
 - #90077 (Make `From` impls of NonZero integer const.)
 - #90097 (Add test for duplicated sidebar entries for reexported macro)
 - #90098 (Add test to ensure that the missing_doc_code_examples is not triggered on foreign trait implementations)
 - #90099 (Fix MIRI UB in `Vec::swap_remove`)

Failed merges:

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

2 years agoFix typo for INVALID_NULL_PTR_USAGE and MISSING_INLINE_IN_PUBLIC_ITEMS.
surechen [Thu, 21 Oct 2021 06:33:43 +0000 (14:33 +0800)]
Fix typo for INVALID_NULL_PTR_USAGE and MISSING_INLINE_IN_PUBLIC_ITEMS.

2 years agoRollup merge of #90099 - SkiFire13:fix-vec-swap-remove, r=dtolnay
Yuki Okushi [Thu, 21 Oct 2021 05:11:13 +0000 (14:11 +0900)]
Rollup merge of #90099 - SkiFire13:fix-vec-swap-remove, r=dtolnay

Fix MIRI UB in `Vec::swap_remove`

Fixes #90055

I find it weird that `Vec::swap_remove` read the last element to the stack just to immediately put it back in the `Vec` in place of the one at index `index`. It seems much more natural to me to just read the element at position `index` and then move the last element in its place. I guess this might also slightly improve codegen.

2 years agoRollup merge of #90098 - GuillaumeGomez:add-test-foreign-impl-missing-doc-code-exampl...
Yuki Okushi [Thu, 21 Oct 2021 05:11:12 +0000 (14:11 +0900)]
Rollup merge of #90098 - GuillaumeGomez:add-test-foreign-impl-missing-doc-code-examples, r=jyn514

Add test to ensure that the missing_doc_code_examples is not triggered on foreign trait implementations

Fixes #76450.

r? ````@jyn514````

2 years agoRollup merge of #90097 - GuillaumeGomez:duplicated-sidebar-entry-reexported-macro...
Yuki Okushi [Thu, 21 Oct 2021 05:11:11 +0000 (14:11 +0900)]
Rollup merge of #90097 - GuillaumeGomez:duplicated-sidebar-entry-reexported-macro, r=notriddle

Add test for duplicated sidebar entries for reexported macro

Fixes #90015.

r? ````@notriddle````

2 years agoRollup merge of #90077 - woppopo:const_nonzero_from, r=oli-obk
Yuki Okushi [Thu, 21 Oct 2021 05:11:10 +0000 (14:11 +0900)]
Rollup merge of #90077 - woppopo:const_nonzero_from, r=oli-obk

Make `From` impls of NonZero integer const.

I also changed the feature gate added to `From` impls of Atomic integer to `const_num_from_num` from `const_convert`.

Tracking issue: #87852

2 years agoRollup merge of #90074 - klensy:upvar-all, r=wesleywiser
Yuki Okushi [Thu, 21 Oct 2021 05:11:09 +0000 (14:11 +0900)]
Rollup merge of #90074 - klensy:upvar-all, r=wesleywiser

2229 migrations small cleanup

This removes needless `format!`'ing of empty string and replaces `vec!` with const strings with const array.

2 years agoRollup merge of #90071 - cjgillot:no-blocks, r=oli-obk
Yuki Okushi [Thu, 21 Oct 2021 05:11:08 +0000 (14:11 +0900)]
Rollup merge of #90071 - cjgillot:no-blocks, r=oli-obk

Remove hir::map::blocks and use FnKind instead

The principal tool is `FnLikeNode`, which is not often used and can be easily implemented using `rustc_hir::intravisit::FnKind`.

2 years agoRollup merge of #90048 - GuillaumeGomez:line-number-setting, r=jsha
Yuki Okushi [Thu, 21 Oct 2021 05:11:08 +0000 (14:11 +0900)]
Rollup merge of #90048 - GuillaumeGomez:line-number-setting, r=jsha

Add test for line-number setting

The first commit updates the version of the package to be able to have multi-line commands (which looks much nicer for this test).

r? ````@jsha````

2 years agoRollup merge of #90031 - durin42:allow-llvm-tests, r=Mark-Simulacrum
Yuki Okushi [Thu, 21 Oct 2021 05:11:07 +0000 (14:11 +0900)]
Rollup merge of #90031 - durin42:allow-llvm-tests, r=Mark-Simulacrum

config: add the option to enable LLVM tests

I'm working on some LLVM patches in concert with a Rust patch, and it's
helping me quite a bit to have this as an option. It doesn't seem that
hard, so I figured I'd formalize it in x.py and send it upstream.

2 years agoRollup merge of #90029 - tgnottingham:incr-debug-logging-test, r=Mark-Simulacrum
Yuki Okushi [Thu, 21 Oct 2021 05:11:06 +0000 (14:11 +0900)]
Rollup merge of #90029 - tgnottingham:incr-debug-logging-test, r=Mark-Simulacrum

Add test for debug logging during incremental compilation

Debug logging during incremental compilation had been broken for some
time, until #89343 fixed it (among other things). Add a test so this is
less likely to break without being noticed. This test is nearly a copy
of the `src/test/ui/rustc-rust-log.rs` test, but tests debug logging in
the incremental compliation code paths.

2 years agoRollup merge of #90010 - rusticstuff:vecdeque_with_capacity_in_overflow, r=m-ou-se
Yuki Okushi [Thu, 21 Oct 2021 05:11:05 +0000 (14:11 +0900)]
Rollup merge of #90010 - rusticstuff:vecdeque_with_capacity_in_overflow, r=m-ou-se

Avoid overflow in `VecDeque::with_capacity_in()`.

The overflow only happens if alloc is compiled with overflow checks enabled and the passed capacity is greater or equal 2^(usize::BITS-1). The overflow shadows the expected "capacity overflow" panic leading to a test failure if overflow checks are enabled for std in the CI.

Unblocks [CI: Enable overflow checks for test (non-dist) builds #89776](https://github.com/rust-lang/rust/pull/89776).

For some reason the overflow is only observable with optimization turned off, but that is a separate issue.

2 years agoRollup merge of #89292 - CleanCut:stabilize-cstring_from_vec_with_nul, r=JohnTitor
Yuki Okushi [Thu, 21 Oct 2021 05:11:04 +0000 (14:11 +0900)]
Rollup merge of #89292 - CleanCut:stabilize-cstring_from_vec_with_nul, r=JohnTitor

Stabilize CString::from_vec_with_nul[_unchecked]

Closes the tracking issue #73179. I am keeping this in _draft_ mode until the FCP has ended.

This is my first time stabilizing a feature, so I would appreciate any guidance on things I should do differently.

Closes #73179

2 years agoRollup merge of #88644 - eopb:abstractconst_leaf_subst, r=lcnr
Yuki Okushi [Thu, 21 Oct 2021 05:11:03 +0000 (14:11 +0900)]
Rollup merge of #88644 - eopb:abstractconst_leaf_subst, r=lcnr

`AbstractConst` private fields

Calls `subst` in `AbstractConst::root` when `Node` is `Leaf`.

r? ``@lcnr``

2 years agoRollup merge of #87440 - twetzel59:fix-barrier-no-op, r=yaahc
Yuki Okushi [Thu, 21 Oct 2021 05:11:02 +0000 (14:11 +0900)]
Rollup merge of #87440 - twetzel59:fix-barrier-no-op, r=yaahc

Remove unnecessary condition in Barrier::wait()

This is my first pull request for Rust, so feel free to call me out if anything is amiss.

After some examination, I realized that the second condition of the "spurious-wakeup-handler" loop in ``std::sync::Barrier::wait()`` should always evaluate to ``true``, making it redundant in the ``&&`` expression.

Here is the affected function before the fix:
```rust
#[stable(feature = "rust1", since = "1.0.0")]
pub fn wait(&self) -> BarrierWaitResult {
    let mut lock = self.lock.lock().unwrap();
    let local_gen = lock.generation_id;
    lock.count += 1;
    if lock.count < self.num_threads {
        // We need a while loop to guard against spurious wakeups.
        // https://en.wikipedia.org/wiki/Spurious_wakeup
        while local_gen == lock.generation_id && lock.count < self.num_threads { // fixme
            lock = self.cvar.wait(lock).unwrap();
        }
        BarrierWaitResult(false)
    } else {
        lock.count = 0;
        lock.generation_id = lock.generation_id.wrapping_add(1);
        self.cvar.notify_all();
        BarrierWaitResult(true)
    }
}
```

At first glance, it seems that the check that ``lock.count < self.num_threads`` would be necessary in order for a thread A to detect when another thread B has caused the barrier to reach its thread count, making thread B the "leader".

However, the control flow implicitly results in an invariant that makes observing ``!(lock.count < self.num_threads)``, i.e. ``lock.count >= self.num_threads`` impossible from thread A.

When thread B, which will be the leader, calls ``.wait()`` on this shared instance of the ``Barrier``, it locks the mutex in the first line and saves the ``MutexGuard`` in the ``lock`` variable. It then increments the value of ``lock.count``. However, it then proceeds to check if ``lock.count < self.num_threads``. Since it is the leader, it is the case that (after the increment of ``lock.count``), the lock count is *equal* to the number of threads. Thus, the second branch is immediately taken and ``lock.count`` is zeroed. Additionally, the generation ID is incremented (with wrap). Then, the condition variable is signalled. But, the other threads are waiting at the line ``lock = self.cvar.wait(lock).unwrap();``, so they cannot resume until thread B's call to ``Barrier::wait()`` returns, which drops the ``MutexGuard`` acquired in the first ``let`` statement and unlocks the mutex.

The order of events is thus:
1. A thread A calls `.wait()`
2. `.wait()` acquires the mutex, increments `lock.count`, and takes the first branch
3. Thread A enters the ``while`` loop since the generation ID has not changed and the count is less than the number of threads for the ``Barrier``
3. Spurious wakeups occur, but both conditions hold, so the thread A waits on the condition variable
4. This process repeats for N - 2 additional times for non-leader threads A'
5. *Meanwhile*, Thread B calls ``Barrier::wait()`` on the same barrier that threads A, A', A'', etc. are waiting on. The thread count reaches the number of threads for the ``Barrier``, so all threads should now proceed, with B being the leader. B acquires the mutex and increments the value ``lock.count`` only to find that it is not less than ``self.num_threads``. Thus, it immediately clamps ``self.num_threads`` back down to 0 and increments the generation. Then, it signals the condvar to tell the A (prime) threads that they may continue.
6. The A, A', A''... threads wake up and attempt to re-acquire the ``lock`` as per the internal operation of a condition variable. When each A has exclusive access to the mutex, it finds that ``lock.generation_id`` no longer matches ``local_generation`` **and the ``&&`` expression short-circuits -- and even if it were to evaluate it, ``self.count`` is definitely less than ``self.num_threads`` because it has been reset to ``0`` by thread B *before* B dropped its ``MutexGuard``**.

Therefore, it my understanding that it would be impossible for the non-leader threads to ever see the second boolean expression evaluate to anything other than ``true``. This PR simply removes that condition.

Any input would be appreciated. Sorry if this is terribly verbose. I'm new to the Rust community and concurrency can be hard to explain in words. Thanks!

2 years agoRollup merge of #86984 - Smittyvb:ipv4-octal-zero, r=m-ou-se
Yuki Okushi [Thu, 21 Oct 2021 05:11:01 +0000 (14:11 +0900)]
Rollup merge of #86984 - Smittyvb:ipv4-octal-zero, r=m-ou-se

Reject octal zeros in IPv4 addresses

This fixes #86964 by rejecting octal zeros in IP addresses, such that `192.168.00.00000000` is rejected with a parse error, since having leading zeros in front of another zero indicates it is a zero written in octal notation, which is not allowed in the strict mode specified by RFC 6943 3.1.1. Octal rejection was implemented in #83652, but due to the way it was implemented octal zeros were still allowed.

2 years agoAuto merge of #90072 - ehuss:empty-rmeta-no-warn, r=Mark-Simulacrum
bors [Thu, 21 Oct 2021 05:04:39 +0000 (05:04 +0000)]
Auto merge of #90072 - ehuss:empty-rmeta-no-warn, r=Mark-Simulacrum

Don't emit a warning for empty rmeta files.

This avoids displaying a warning when attempting to load an empty rmeta file. Warnings were enabled via #89634 which can cause a lot of noise (for example, running `./x.py check`).  rustc generates empty rmeta files for things like binaries, which can happen when checking libraries as unittests.

Closes #89795

2 years agoAuto merge of #89998 - camelid:box-default, r=jyn514
bors [Thu, 21 Oct 2021 01:38:55 +0000 (01:38 +0000)]
Auto merge of #89998 - camelid:box-default, r=jyn514

rustdoc: Box some fields of `GenericParamDefKind` to reduce size

This change shrinks `GenericParamDef` from 120 to 56 bytes. `GenericParamDef` is
used a lot, so the extra indirection should hopefully be worth the size savings.

r? `@ghost`

2 years ago*dust dust*
Ellen [Wed, 20 Oct 2021 23:16:49 +0000 (00:16 +0100)]
*dust dust*

2 years agoOrdering
Ellen [Wed, 20 Oct 2021 22:44:50 +0000 (23:44 +0100)]
Ordering

2 years agoadd fixme
Ellen [Wed, 20 Oct 2021 22:37:36 +0000 (23:37 +0100)]
add fixme

2 years agoInference
Ellen [Wed, 20 Oct 2021 22:36:50 +0000 (23:36 +0100)]
Inference

2 years agoWfness
Ellen [Wed, 20 Oct 2021 22:31:08 +0000 (23:31 +0100)]
Wfness

2 years agoReturn pos impl trait
Ellen [Wed, 20 Oct 2021 22:18:26 +0000 (23:18 +0100)]
Return pos impl trait

2 years agoTrait objects
Ellen [Wed, 20 Oct 2021 21:56:42 +0000 (22:56 +0100)]
Trait objects

2 years agofix 'since' version number
Nathan Stocks [Wed, 20 Oct 2021 21:36:55 +0000 (15:36 -0600)]
fix 'since' version number

Co-authored-by: Yuki Okushi <jtitor@2k36.org>
2 years agoAuto merge of #7838 - nhamovitz:trailing_zs_arr_wo_repr, r=Manishearth
bors [Wed, 20 Oct 2021 20:35:58 +0000 (20:35 +0000)]
Auto merge of #7838 - nhamovitz:trailing_zs_arr_wo_repr, r=Manishearth

Warn on structs with a trailing zero-sized array but no `repr` attribute

Closes #2868

changelog: Implement ``[`trailing_empty_array`]``, which warns if a struct is defined where the last field is a zero-sized array but there are no `repr` attributes. Zero-sized arrays aren't very useful in Rust itself, so such a struct is likely being created to pass to C code or in some other situation where control over memory layout matters. Either way, a `repr` attribute is needed.

2 years agostabilize CString::from_vec_with_nul[_unchecked]
Nathan Stocks [Sun, 26 Sep 2021 21:38:51 +0000 (15:38 -0600)]
stabilize CString::from_vec_with_nul[_unchecked]

2 years agoAdd edition configuration to compiletest
Andre Bogus [Tue, 19 Oct 2021 21:06:19 +0000 (23:06 +0200)]
Add edition configuration to compiletest

2 years agoAuto merge of #89978 - cjgillot:qarray, r=Mark-Simulacrum
bors [Wed, 20 Oct 2021 17:57:35 +0000 (17:57 +0000)]
Auto merge of #89978 - cjgillot:qarray, r=Mark-Simulacrum

Merge the two depkind vtables

Knowledge of `DepKind`s is managed using two arrays containing flags (is_anon, eval_always, fingerprint_style), and function pointers (forcing and loading code).

This PR aims at merging the two arrays so as to reduce unneeded indirect calls and (hopefully) increase code locality.
r? `@ghost`

2 years agoAddress review.
Camille GILLOT [Tue, 19 Oct 2021 17:17:33 +0000 (19:17 +0200)]
Address review.

2 years agoAuto merge of #7849 - ThibsG:SafetyDoc, r=llogiq
bors [Wed, 20 Oct 2021 16:46:38 +0000 (16:46 +0000)]
Auto merge of #7849 - ThibsG:SafetyDoc, r=llogiq

FIx FP in `missing_safety_doc` lint

Fix FP where lint souldn't fire if any parent has `#[doc(hidden)]` attribute

fixes: #7347

changelog: [`missing_safety_doc`] Fix FP if any parent has `#[doc(hidden)]` attribute

2 years agoInline DepNodeParams methods.
Camille GILLOT [Sun, 17 Oct 2021 09:49:30 +0000 (11:49 +0200)]
Inline DepNodeParams methods.

2 years agoCompute query vtable manually.
Camille GILLOT [Sun, 11 Jul 2021 18:08:17 +0000 (20:08 +0200)]
Compute query vtable manually.

2 years agoStore node_intern_event_id in CurrentDepGraph.
Camille GILLOT [Thu, 7 Oct 2021 17:20:41 +0000 (19:20 +0200)]
Store node_intern_event_id in CurrentDepGraph.

2 years agoBuild jump table at runtime.
Camille GILLOT [Sat, 16 Oct 2021 19:12:34 +0000 (21:12 +0200)]
Build jump table at runtime.

2 years agoInvoke callbacks from rustc_middle.
Camille GILLOT [Sat, 16 Oct 2021 18:24:08 +0000 (20:24 +0200)]
Invoke callbacks from rustc_middle.

2 years agoMerge two query callbacks arrays.
Camille GILLOT [Sat, 16 Oct 2021 18:10:23 +0000 (20:10 +0200)]
Merge two query callbacks arrays.

2 years agoDrop has_params.
Camille GILLOT [Sat, 16 Oct 2021 19:24:10 +0000 (21:24 +0200)]
Drop has_params.

2 years agoMake hash_result an Option.
Camille GILLOT [Sat, 16 Oct 2021 20:31:48 +0000 (22:31 +0200)]
Make hash_result an Option.

2 years agoMove def_path_hash_to_def_id to rustc_middle.
Camille GILLOT [Sat, 16 Oct 2021 15:13:02 +0000 (17:13 +0200)]
Move def_path_hash_to_def_id to rustc_middle.

2 years agoAvoid trivial lambdas.
Camille GILLOT [Tue, 24 Aug 2021 18:12:17 +0000 (20:12 +0200)]
Avoid trivial lambdas.

2 years agoDo not lint if any parent has hidden attribute
ThibsG [Thu, 14 Oct 2021 10:16:35 +0000 (12:16 +0200)]
Do not lint if any parent has hidden attribute

2 years agoensure cargo-fmt tests are excluded from root workspace
Caleb Cartwright [Wed, 20 Oct 2021 15:12:22 +0000 (10:12 -0500)]
ensure cargo-fmt tests are excluded from root workspace

2 years agoAdd test to ensure that the missing_doc_code_examples is not triggered on foreign...
Guillaume Gomez [Wed, 20 Oct 2021 13:57:44 +0000 (15:57 +0200)]
Add test to ensure that the missing_doc_code_examples is not triggered on foreign trait implementations

2 years agoAuto merge of #90050 - michaelwoerister:fix-vtable-debug-name-crash-90019, r=wesleywiser
bors [Wed, 20 Oct 2021 14:37:48 +0000 (14:37 +0000)]
Auto merge of #90050 - michaelwoerister:fix-vtable-debug-name-crash-90019, r=wesleywiser

Erase late-bound regions before computing vtable debuginfo name.

Fixes #90019.

The `msvc_enum_fallback()` for computing enum type names needs to access the memory layout of niche enums in order to determine the type name. `compute_debuginfo_vtable_name()` did not properly erase regions before computing type names which made memory layout computation ICE when encountering un-erased regions.

r? `@wesleywiser`

2 years agoAdd test for duplicated sidebar entries for reexported macro
Guillaume Gomez [Wed, 20 Oct 2021 13:44:16 +0000 (15:44 +0200)]
Add test for duplicated sidebar entries for reexported macro

2 years agoPrevent invalid values from existing in Vec::swap_remove
Giacomo Stevanato [Wed, 20 Oct 2021 13:42:54 +0000 (15:42 +0200)]
Prevent invalid values from existing in Vec::swap_remove

2 years agoAuto merge of #7848 - Veykril:patch-1, r=xFrednet
bors [Wed, 20 Oct 2021 12:02:32 +0000 (12:02 +0000)]
Auto merge of #7848 - Veykril:patch-1, r=xFrednet

Fix doc heading of `transmute_num_to_bytes`

changelog: none

2 years agoFix doc heading of TRANSMUTE_NUM_TO_BYTES
Lukas Wirth [Wed, 20 Oct 2021 11:46:12 +0000 (13:46 +0200)]
Fix doc heading of TRANSMUTE_NUM_TO_BYTES