Commit Graph

199708 Commits

Author SHA1 Message Date
Camille GILLOT
e7164267a2 Do not call object_lifetime_default on lifetime params. 2022-09-03 21:11:42 +02:00
Bart Massey
3afbc115f7 updated description of File struct in std::fs 2022-09-03 11:09:06 -07:00
bors
dec689432f Auto merge of #101342 - saethlin:update-backtrace, r=Mark-Simulacrum
Update backtrace

Most notably, this pulls in ebc9a85466, which is both a bugfix and a significant performance improvement for Miri, since fixing the bug makes `RUST_BACKTRACE=1` backtraces much smaller: https://github.com/rust-lang/miri/issues/2273, https://github.com/rust-lang/miri-test-libstd/issues/8

This also pulls in other commits which turn the backtrace-rs CI green. That's nice.
2022-09-03 17:12:17 +00:00
bors
8ddb8b7e8e Auto merge of #13183 - Veykril:break-break, r=Veykril
Fix nested break expressions, expecting unknown types
2022-09-03 15:33:21 +00:00
Lukas Wirth
020f6895e5 Fix nested break expressions, expecting unknown types 2022-09-03 17:32:21 +02:00
Michael Wright
750a2d57bd Fix unnecessary_to_owned false positive
Fixes #9351.

Note that this commit reworks that fix for #9317. The change
is to check that the type implements `AsRef<str>` before regarding
`to_string` as an equivalent of `to_owned`. This was suggested
by Jarcho in the #9317 issue comments.

The benefit of this is that it moves some complexity out of
`check_other_call_arg` and simplifies the module as a whole.
2022-09-03 17:00:44 +02:00
bors
ae0030beb0 Auto merge of #101378 - matthiaskrgr:rollup-s1awa47, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #101335 (rustdoc: remove old CSS selector that causes weird spacing)
 - #101347 (ffx component run should provide a collection)
 - #101364 (Shrink suggestion span of argument mismatch error)
 - #101365 (remove redundant clones)

Failed merges:

 - #101349 (rustdoc: remove `.impl-items { flex-basis }` CSS, not in flex container)

r? `@ghost`
`@rustbot` modify labels: rollup
2022-09-03 14:23:58 +00:00
Matthias Krüger
01da61a9bf
Rollup merge of #101365 - matthiaskrgr:clones2, r=fee1-dead
remove redundant clones
2022-09-03 14:20:53 +02:00
Matthias Krüger
3c2780cf16
Rollup merge of #101364 - compiler-errors:arg-suggestion-spans, r=wesleywiser
Shrink suggestion span of argument mismatch error

This doesn't really help with #101242, but I wanted to put this up while I work on other fixes.
2022-09-03 14:20:52 +02:00
Matthias Krüger
525e386822
Rollup merge of #101347 - diminishedprime:patch-4, r=tmandry
ffx component run should provide a collection

In the future,`ffx component run` will not default to the using the `/core/ffx-laboratory` collection. Updated the run commands to include this.
2022-09-03 14:20:51 +02:00
Matthias Krüger
5e34b79c29
Rollup merge of #101335 - notriddle:notriddle/methods-stability, r=notriddle
rustdoc: remove old CSS selector that causes weird spacing

It was added with e08a84a0c1 (actually, it was called `.methods > .stability` at the time) and was directly nested that way.

**EDIT**: It is technically reachable code still, but it seems wrong.

## With the old CSS rule still present

https://notriddle.com/notriddle-rustdoc-test/weird-spacing/lib/struct.Foo.html

![image](https://user-images.githubusercontent.com/1593513/188216226-c667c560-d33d-494f-a492-4e0ec3ac0009.png)

## Version 2 (an older version of this PR)

https://notriddle.com/notriddle-rustdoc-test/normal-spacing-2/lib/struct.Foo.html

![image](https://user-images.githubusercontent.com/1593513/188216418-9fcd3109-f1b2-425d-b4fc-0c6b3b54e48e.png)

## Version 3 (with alignment fix for mobile)

https://notriddle.com/notriddle-rustdoc-test/normal-spacing-3/lib/struct.Foo.html

![image](https://user-images.githubusercontent.com/1593513/188223161-0e1ebce7-842f-41cb-8a0c-ae43aedcfccc.png)
2022-09-03 14:20:49 +02:00
joboet
8c37fdf2d7
std: make ReentrantMutex movable and const; simplify Stdout initialization 2022-09-03 14:05:28 +02:00
bors
47d1cdb0bc Auto merge of #100574 - Urgau:check-cfg-warn-cfg, r=petrochenkov
Add warning against unexpected --cfg with --check-cfg

This PR adds a warning when an unexpected `--cfg` is specified but not in the specified list of `--check-cfg`.

This is the follow-up PR I mentioned in https://github.com/rust-lang/rust/pull/99519.

r? `@petrochenkov`
2022-09-03 12:02:14 +00:00
bors
06b72b06a2 Auto merge of #101154 - RalfJung:validation-perf, r=oli-obk
interpret: fix unnecessary allocation in validation visitor

Should fix the perf regression introduced by https://github.com/rust-lang/rust/pull/100043.

r? `@oli-obk`
2022-09-03 09:20:54 +00:00
Michael Goulet
be53bd8380 Include enum path in variant suggestion 2022-09-03 08:11:17 +00:00
Michael Goulet
e9b01c745d Fix global_asm macro pretty printing 2022-09-03 08:06:35 +00:00
bors
99ab5fe53a Auto merge of #9400 - lukaslueg:approx_large_enum, r=llogiq
Use `approx_ty_size` for `large_enum_variant`

This builds upon #9373 to use the approximate size of each variant for `large_enum_variant`. This allows us to lint in situations where an `enum` contains generics but is still guaranteed to have a large variant on an at-least basis, e.g. with `(T, [u8; 512])`.

* I've changed the wording from "is ... bytes" to "contains at least" because
  * the size is now an approximate lower bound (e.g. `512` in the example above). The actual size is larger due to `T`, including due to `T`'s memory layout.
  * the discriminant is not taken into account in the message. This comes up with variants like `A(T)`, which are "is at least 0 bytes" otherwise, which may be misleading.
* If the second-largest variant has no fields, there is a special case "carries no data" instead of "is at least 0 bytes".
* A variant like `A(T)` is "at least 0 bytes", which is technically true, yet we don't distinguish between "indeterminate" and truly "ZST".
* The generics-tests that were there before now lint while they didn't lint before. AFAICS this is correct.

I guess the above is correct-ish. However, I use the `SubstsRef` that I got via `cx.tcx.type_of(item.def_id)` to solve for generics in the variants. Is this even applicable, since we start from an - [ ] `ItemKind`?

changelog: none
2022-09-03 07:34:42 +00:00
Michael Goulet
fdbede7ad8 Suggest copied or cloned 2022-09-03 07:30:30 +00:00
Michael Goulet
12a4952369 Suggest associated method on deref types 2022-09-03 07:24:55 +00:00
bors
92086258e3 Auto merge of #101361 - Dylan-DPC:rollup-xj1syld, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #99736 (Partially stabilize `bound_as_ref` by stabilizing `Bound::as_ref`)
 - #100928 (Migrate rustc_metadata to SessionDiagnostics)
 - #101217 ([drop tracking] Use parent expression for scope, not parent node )
 - #101325 (Windows RNG: Use `BCRYPT_RNG_ALG_HANDLE` by default)
 - #101330 (Fix `std::collections::HashSet::drain` documentation)
 - #101338 (Fix unsupported syntax in .manifest file)
 - #101348 (Cleanup css theme)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-09-03 07:00:07 +00:00
Chris Denton
0fe54d4650
Restore old behaviour on broken UNC paths 2022-09-03 07:56:38 +01:00
Matthias Krüger
57198b549f remove redundant clones 2022-09-03 07:58:41 +02:00
Michael Goulet
b0f3a551f2 Shrink suggestion span of argument mismatch error 2022-09-03 05:54:13 +00:00
Michael Goulet
91674cc56c Suggest removing unnecessary prefix let in patterns 2022-09-03 05:39:46 +00:00
Dylan DPC
7eed25b200
Rollup merge of #101348 - GuillaumeGomez:cleanup-css-theme, r=notriddle
Cleanup css theme

Follow-up of https://github.com/rust-lang/rust/pull/100494.

The change for the border color of the search input in the dark mode was actually a weird case: the search input border was unique, it didn't share the same variable with other items with borders. This weird case being unique to the dark theme, I removed it, hence the modification in the GUI test.

Live demo is [here](https://rustdoc.crud.net/imperio/cleanup-css-theme/std/index.html).

cc `@jsha`
r? `@notriddle`
2022-09-03 10:33:09 +05:30
Dylan DPC
9ed2deb0de
Rollup merge of #101338 - diminishedprime:patch-2, r=tmandry
Fix unsupported syntax in .manifest file

Fuchsia .manifest files do not support a `#` comment syntax. Because of this, if you copy and paste the current example code for this file, and then remove the line you don't need, you still see an error. To make this a bit easier to follow, split this into two code blocks, one for rustc, and one for cargo.
2022-09-03 10:33:08 +05:30
Dylan DPC
414d79d567
Rollup merge of #101330 - wkordalski:hashset-drain-doc, r=jyn514
Fix `std::collections::HashSet::drain` documentation

Hi!

`std::collections::HashSet::drain` contains small typo in the docstring.

I didn't read too much about the model of contributing to Rust, so merge this PR or close and fix the typo the right way :)

Thanks for Rust!
2022-09-03 10:33:07 +05:30
Dylan DPC
c42df986da
Rollup merge of #101325 - ChrisDenton:BCRYPT_RNG_ALG_HANDLE, r=thomcc
Windows RNG: Use `BCRYPT_RNG_ALG_HANDLE` by default

This only changes a small amount of actual code, the rest is documentation outlining the history of this module as I feel it will be relevant to any future issues that might crop up.

The code change is to use the `BCRYPT_RNG_ALG_HANDLE` [pseudo-handle](https://docs.microsoft.com/en-us/windows/win32/seccng/cng-algorithm-pseudo-handles) by default, which simply uses the default RNG. Previously we used `BCRYPT_USE_SYSTEM_PREFERRED_RNG` which has to load the system configuration and then find and load that RNG. I suspect this was the cause of failures on some systems (e.g. due to corrupted config). However, this is admittedly speculation as I can't reproduce the issue myself (and it does seem quite rare even in the wild). Still, removing a possible point of failure is likely worthwhile in any case.

r? libs
2022-09-03 10:33:06 +05:30
Dylan DPC
dc8fe633d5
Rollup merge of #101217 - eholk:drop-tracking-73137, r=jyn514
[drop tracking] Use parent expression for scope, not parent node

Previously we were just using the parent node as the scope for a temporary value, but it turns out this is too narrow. For example, in an expression like

    Foo {
        b: &42,
        a: async { 0 }.await,
    }

the scope for the &42 was set to the ExprField node for `b: &42`, when we actually want to use the Foo struct expression.

We fix this by recursively searching through parent nodes until we find a Node::Expr. It may be that we don't find one, and if so that's okay, we will just fall back on the enclosing temporary scope which is always sufficient.

Helps with #97331

r? ``@jyn514``
2022-09-03 10:33:06 +05:30
Dylan DPC
a0056795da
Rollup merge of #100928 - CleanCut:rustc_metadata_diagnostics, r=davidtwco
Migrate rustc_metadata to SessionDiagnostics

Migrate rustc_metadata to SessionDiagnostics.

Part of https://github.com/rust-lang/rust/issues/100717
2022-09-03 10:33:05 +05:30
Dylan DPC
2ed716a81d
Rollup merge of #99736 - lopopolo:lopopolo/gh-80996-partial-stabilization-bounds-as-ref, r=dtolnay
Partially stabilize `bound_as_ref` by stabilizing `Bound::as_ref`

Stabilizing `Bound::as_ref` will simplify the implementation for `RangeBounds<usize>` for custom range types:

```rust
impl RangeBounds<usize> for Region {
    fn start_bound(&self) -> Bound<&usize> {
        // TODO: Use `self.start.as_ref()` when upstream `std` stabilizes:
        // https://github.com/rust-lang/rust/issues/80996
        match self.start {
            Bound::Included(ref bound) => Bound::Included(bound),
            Bound::Excluded(ref bound) => Bound::Excluded(bound),
            Bound::Unbounded => Bound::Unbounded,
        }
    }

    fn end_bound(&self) -> Bound<&usize> {
        // TODO: Use `self.end.as_ref()` when upstream `std` stabilizes:
        // https://github.com/rust-lang/rust/issues/80996
        match self.end {
            Bound::Included(ref bound) => Bound::Included(bound),
            Bound::Excluded(ref bound) => Bound::Excluded(bound),
            Bound::Unbounded => Bound::Unbounded,
        }
    }
}
```

See:

- #80996
- https://github.com/rust-lang/rust/issues/80996#issuecomment-1194575470

cc `@yaahc` who suggested partial stabilization.
2022-09-03 10:33:04 +05:30
bors
0421444f8f Auto merge of #101139 - nnethercote:shrink-thir-Pat, r=cjgillot
Shrink `thir::Pat`

r? `@cjgillot`
2022-09-03 04:19:00 +00:00
bors
0209485578 Auto merge of #100966 - compiler-errors:revert-remove-deferred-sized-checks, r=pnkfelix
Revert "Remove deferred sized checks"

cc: https://github.com/rust-lang/rust/pull/100652#issuecomment-1225798572

I'm okay with reverting this for now, and I will look into the diagnostic regressions.

This reverts commit 33212bf7f5.

r? `@pnkfelix`

----

EDIT: This _also_ fixes #101066, a regression in method selection logic/coercion(?) due to the early registering of a `Sized` bound.
2022-09-03 00:02:41 +00:00
asquared31415
80e035c9e4 implement IsZero for Saturating and Wrapping 2022-09-02 19:55:01 -04:00
Matt Hamrick
c528f70325
ffx component run should provide a collection
In the future,`ffx component run` will not default to the using the `/core/ffx-laboratory` collection. Updated the run commands to include this.
2022-09-02 15:16:51 -07:00
Lukas Lueg
584000a792 Use approx_ty_size for large_enum_variant 2022-09-03 00:16:28 +02:00
Guillaume Gomez
30bdf54827 Update rustdoc-gui tests for search-input border color on dark theme 2022-09-03 00:16:10 +02:00
Guillaume Gomez
7fb0a89bec Clean up themes CSS 2022-09-03 00:16:09 +02:00
bors
8c6ce6b91b Auto merge of #97802 - Enselic:add-no_ignore_sigkill-feature, r=joshtriplett
Support `#[unix_sigpipe = "inherit|sig_dfl"]` on `fn main()` to prevent ignoring `SIGPIPE`

When enabled, programs don't have to explicitly handle `ErrorKind::BrokenPipe` any longer. Currently, the program

```rust
fn main() { loop { println!("hello world"); } }
```

will print an error if used with a short-lived pipe, e.g.

    % ./main | head -n 1
    hello world
    thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', library/std/src/io/stdio.rs:1016:9
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

by enabling `#[unix_sigpipe = "sig_dfl"]` like this

```rust
#![feature(unix_sigpipe)]
#[unix_sigpipe = "sig_dfl"]
fn main() { loop { println!("hello world"); } }
```

there is no error, because `SIGPIPE` will not be ignored and thus the program will be killed appropriately:

    % ./main | head -n 1
    hello world

The current libstd behaviour of ignoring `SIGPIPE` before `fn main()` can be explicitly requested by using `#[unix_sigpipe = "sig_ign"]`.

With `#[unix_sigpipe = "inherit"]`, no change at all is made to `SIGPIPE`, which typically means the behaviour will be the same as `#[unix_sigpipe = "sig_dfl"]`.

See https://github.com/rust-lang/rust/issues/62569 and referenced issues for discussions regarding the `SIGPIPE` problem itself

See the [this](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Proposal.3A.20First.20step.20towards.20solving.20the.20SIGPIPE.20problem) Zulip topic for more discussions, including about this PR.

Tracking issue: https://github.com/rust-lang/rust/issues/97889
2022-09-02 21:08:08 +00:00
Matt Hamrick
dd89792715
Add -api-level to pm command
As of ~Aug 30th, `pm build` commands require an `api-level` flag. This flag should match the fuchsia api-level that's being targeted by the code. Since this is dependent on the version of the SDK that's being used, we may want to change this to something a bit more robust in the future.
2022-09-02 13:47:00 -07:00
bors
30e4532153 Auto merge of #8952 - rust-lang:explain, r=xFredNet
add `--explain` subcommand

This closes #8291.

---

changelog: add `cargo clippy -- --explain <lintname>` subcommand
2022-09-02 20:27:42 +00:00
Andre Bogus
ad72aee93c add --explain subcommand 2022-09-02 22:17:39 +02:00
Michael Howell
0f29824760 rustdoc: put in rule to get alignment in desktop and mobile layouts 2022-09-02 13:13:22 -07:00
Ben Kimock
a7b4f189d8 Update backtrace 2022-09-02 16:09:58 -04:00
bors
c36696ac02 Auto merge of #9418 - lukaslueg:issue9415, r=llogiq
Fix `mut_mutex_lock` when Mutex is behind immutable deref

I *think* the problem here is the `if let ty::Ref(_, _, Mutability::Mut) = cx.typeck_results().expr_ty(recv).kind()` line tries to check if the `Mutex` can be mutably borrowed (there already is a test for `Arc<Mutex<_>>`), but gets bamboozled by the `&mut Arc` indirection. And I *think* checking the deref-adjustment to filter immutable-adjust (the deref through the `Arc`, starting from `&mut Arc`) is the correct fix.

Fixes #9415

changelog: Fix `mut_mutex_lock` when Mutex is behind immutable deref
2022-09-02 18:54:06 +00:00
Michael Howell
6f95c89c4d rustdoc: remove incorrect CSS rule causing misaligned item-info 2022-09-02 11:50:19 -07:00
Michael Howell
df0904750d rustdoc: remove unused CSS selector .methods > .item-info
It was added with e08a84a0c1
(actually, it was called `.methods > .stability` at the time) and was
directly nested that way.

But with the switch to `<details>`, the code has changed drastically out from
under it, to the point where you have to go out of your way to actually get
it to render this way, and the result looks overly-tight and weird alongside
the normal version where this code is not reachable.
2022-09-02 11:45:16 -07:00
bors
9ba169a73a Auto merge of #101333 - matthiaskrgr:rollup-qpf1otj, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #100121 (Try normalizing types without RevealAll in ParamEnv in MIR validation)
 - #100200 (Change implementation of `-Z gcc-ld` and `lld-wrapper` again)
 - #100814 ( Porting 'compiler/rustc_trait_selection' to translatable diagnostics - Part 1)
 - #101215 (Also replace the version placeholder in rustc_attr)
 - #101260 (Use `FILE_ATTRIBUTE_TAG_INFO` to get reparse tag)
 - #101323 (Remove unused .toggle-label CSS rule)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-09-02 18:40:21 +00:00
Lukas Lueg
ffc75af4cd Fix mut_mutex_lock for Mutex behind imm deref
Fixes #9415
2022-09-02 20:39:47 +02:00
Matt Hamrick
6fbc4d9165
Fix unsupported syntax in .manifest file
Fuchsia .manifest files do not support a `#` comment syntax. Because of this, if you copy and paste the current example code for this file, and then remove the line you don't need, you still see an error. To make this a bit easier to follow, split this into two code blocks, one for rustc, and one for cargo.
2022-09-02 11:14:22 -07:00