Commit Graph

199666 Commits

Author SHA1 Message Date
Matthias Krüger
a3dda51438
Rollup merge of #101369 - compiler-errors:global-asm-pprint, r=jackh726
Fix `global_asm` macro pretty printing

Fixes #101051
Fixes #101047
2022-09-04 00:20:43 +02:00
Matthias Krüger
037c979a52
Rollup merge of #101349 - notriddle:notriddle/flex-basis, r=GuillaumeGomez
rustdoc: remove `.impl-items { flex-basis }` CSS, not in flex container

Added in 34bd2b845b

For this to actually do anything, [according to MDN] (and Firefox Dev Tools), it must be a "flex item", which only happens if its a direct child of a node with `display: flex` on it. It seems like it could not have worked at the time when this rule was added, because the only items in `rustdoc.css` with `display: flex` active were:

* `#help`

  This should not contain anything like this.

* `.impl-items h4, h4.impl, h3.impl`

  These are all headers, so they shouldn't contain `.impl-items` either.

* `.content .impl-items .method, .content .impl-items > .type, .impl-items > .associatedconstant`

  Associated constants and methods definitely shouldn't contain a list of impl items, and the `.type` class seems to refer to type aliases, which, when shown inside of an impl, only show a link to the aliased type.

[according to MDN]: https://developer.mozilla.org/en-US/docs/Web/CSS/flex-basis

Nowadays, `display: flex` is a lot more prolific, but `.impl-items` still seems to only be used in plain block parents:

* If it's not a trait impl, then it's nested below a `<div>` with an id but no class, added in a5216cf67d. This will be `display: block`, probably. For example, [vec deref]
* Inherent impls also get a `<div>` tag, for example [vec impl], and they are also wrapped by their own non-flexbox `<details>` tag.
* If it's a tait implementation, then it's also nested below a `<details>` container, like [deref cstring].

[vec impl]: https://doc.rust-lang.org/1.63.0/std/vec/struct.Vec.html#impl
[vec deref]: https://doc.rust-lang.org/1.63.0/std/vec/struct.Vec.html#deref-methods-%5BT%5D
[deref cstring]: https://doc.rust-lang.org/1.63.0/std/ops/trait.Deref.html#impl-Deref

Also, this would imply that trait items ought to take up as much space as possible, pushing everything else to the edge of the screen. If this is nested directly below the `.rustdoc` container, which has a row basis, that would be bad.
2022-09-04 00:20:42 +02:00
Matthias Krüger
d085194539
Rollup merge of #100647 - obeis:issue-99875, r=nagisa
Make trait bound not satisfied specify kind

Closes #99875
2022-09-04 00:20:40 +02:00
Matthias Krüger
bd9750fd2a
Rollup merge of #100302 - compiler-errors:deref-path-methods, r=jackh726
Suggest associated method on deref types when path syntax method fails

Fixes #100278
2022-09-04 00:20:39 +02:00
Ben Kimock
563a75b6e3 Add a Machine hook for inline assembly 2022-09-03 18:05:02 -04:00
Christopher Durham
69721defc2
Forbid mixing System with sytem allocator calls 2022-09-03 16:47:12 -05:00
Michael Howell
cee90dd773 rustdoc: remove .impl-items { flex-basis } CSS, not in flex container
Added in 34bd2b845b

For this to actually do anything, [according to MDN] (and Firefox Dev Tools),
it must be a "flex item", which only happens if its a direct child of a node
with `display: flex` on it. It seems like it could not have worked at the time
when this rule was added, because the only items in `rustdoc.css` with
`display: flex` active were:

* `#help`

  This should not contain anything like this.

* `.impl-items h4, h4.impl, h3.impl`

  These are all headers, so they shouldn't contain `.impl-items` either.

* `.content .impl-items .method, .content .impl-items > .type, .impl-items > .associatedconstant`

  Associated constants and methods definitely shouldn't contain a list of impl
  items, and the `.type` class seems to refer to type aliases, which, when
  shown inside of an impl, only show a link to the aliased type.

[according to MDN]: https://developer.mozilla.org/en-US/docs/Web/CSS/flex-basis

Nowadays, `display: flex` is a lot more prolific, but `.impl-items` still
seems to only be used in plain block parents:

* If it's not a trait impl, then it's nested below a `<div>` with an id but no
  class, added in a5216cf67d. This will be
  `display: block`, probably. For example, [vec deref]
* Inherent impls also get a `<div>` tag, for example [vec impl], and they are
  also wrapped by their own non-flexbox `<details>` tag.
* If it's a tait implementation, then it's also nested below a `<details>`
  container, like [deref cstring].

[vec impl]: https://doc.rust-lang.org/1.63.0/std/vec/struct.Vec.html#impl
[vec deref]: https://doc.rust-lang.org/1.63.0/std/vec/struct.Vec.html#deref-methods-%5BT%5D
[deref cstring]: https://doc.rust-lang.org/1.63.0/std/ops/trait.Deref.html#impl-Deref

Also, this would imply that trait items ought to take up as much space as
possible, pushing everything else to the edge of the screen. If this is nested
directly below the `.rustdoc` container, which has a row basis, that would
be bad.
2022-09-03 14:33:31 -07:00
Nixon Enraght-Moony
b76a012be1 Rustdoc-Json: Add enum discriminant 2022-09-03 22:15:26 +01:00
Matthias Krüger
6f4726541e more clippy::perf fixes 2022-09-03 22:57:22 +02:00
bors
84f0c3f79a Auto merge of #101214 - cjgillot:old-no-lt, r=estebank
Do not call object_lifetime_default on lifetime params.

Small cleanup to avoid unnecessary query invocations in trivial cases.
2022-09-03 19:32:41 +00:00
Michael Goulet
771456264b Don't delay invalid lhs bug unless we know it'll be replaced by one in check_overloaded_binop 2022-09-03 19:12:44 +00:00
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