]> git.lizzy.rs Git - rust.git/log
rust.git
21 months agoRevert "Use getentropy when possible on all Apple platforms"
BlackHoleFox [Wed, 5 Oct 2022 05:48:22 +0000 (00:48 -0500)]
Revert "Use getentropy when possible on all Apple platforms"

This reverts commit 3fc35b5b935e390c61ea2bbf744838b2632b2df1.

21 months agoRollup merge of #102686 - cuviper:rls-tool_std, r=jyn514
Michael Howell [Wed, 5 Oct 2022 03:45:14 +0000 (20:45 -0700)]
Rollup merge of #102686 - cuviper:rls-tool_std, r=jyn514

Don't build the compiler before building rls

The rls stub is a simple stable tool, which doesn't need compiler libs.
(Similar to #97511)

21 months agoRollup merge of #102670 - lyming2007:issue-101866-fix, r=compiler-errors
Michael Howell [Wed, 5 Oct 2022 03:45:14 +0000 (20:45 -0700)]
Rollup merge of #102670 - lyming2007:issue-101866-fix, r=compiler-errors

follow-up fix about 101866 to print the self type.

modified:   compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
modified:   src/test/ui/error-codes/E0283.stderr
modified:   src/test/ui/error-codes/E0790.stderr
modified:   src/test/ui/traits/static-method-generic-inference.stderr
modified:   src/test/ui/type/issue-101866.stderr

21 months agoRollup merge of #102662 - notriddle:notriddle/code-header-display-block, r=GuillaumeGomez
Michael Howell [Wed, 5 Oct 2022 03:45:13 +0000 (20:45 -0700)]
Rollup merge of #102662 - notriddle:notriddle/code-header-display-block, r=GuillaumeGomez

rustdoc: remove no-op CSS `.code-header { display: block }`

Since 76a3b609d0b93c5d8da5e4e3db37bd03e5cb1c30 converted code headers to real headers, `display: block` is now the default.

21 months agoRollup merge of #102650 - Rageking8:slightly-improve-no-return-for-returning-function...
Michael Howell [Wed, 5 Oct 2022 03:45:13 +0000 (20:45 -0700)]
Rollup merge of #102650 - Rageking8:slightly-improve-no-return-for-returning-function-error, r=compiler-errors

Slightly improve no return for returning function error

Fixes #100607

The rationale is that absolute beginners will be slightly confused as to why certain lines of code in a function does not require a semicolon. (I have actually witness a beginner having this confusion). Hence, a slight rationale is added "to return this value", which signals to the user that after removing said semicolon the value is returned resolving that error.

However, if this is not desirable, I welcome any other suggestions. Thanks.

21 months agoRollup merge of #102574 - aDotInTheVoid:const_collections_with_hasher, r=oli-obk...
Michael Howell [Wed, 5 Oct 2022 03:45:12 +0000 (20:45 -0700)]
Rollup merge of #102574 - aDotInTheVoid:const_collections_with_hasher, r=oli-obk,fee1-dead

Make Hash{Set,Map}::with_hasher unstably const

Makes  [`HashMap::with_hasher`](https://doc.rust-lang.org/stable/std/collections/hash_map/struct.HashMap.html#method.with_hasher) and [`HashSet::with_hasher`](https://doc.rust-lang.org/stable/std/collections/hash_set/struct.HashSet.html#method.with_hasher) `const`.

This allows

```rust
static GlobalState: Mutex<HashMap<i32, i32, SomeHasher>> = Mutex::new(HashMap::with_hasher(SomeHasher::new()))
```

Tracking issue: #102575

21 months agoSuggest `.into()` when all other coercion suggestions fail
Michael Goulet [Fri, 30 Sep 2022 00:06:19 +0000 (00:06 +0000)]
Suggest `.into()` when all other coercion suggestions fail

21 months agoDon't build the compiler before building rls
Josh Stone [Wed, 5 Oct 2022 02:41:21 +0000 (19:41 -0700)]
Don't build the compiler before building rls

The rls stub is a simple stable tool, which doesn't need compiler libs.

21 months agoAuto merge of #102677 - weihanglo:update-cargo, r=ehuss
bors [Wed, 5 Oct 2022 02:14:13 +0000 (02:14 +0000)]
Auto merge of #102677 - weihanglo:update-cargo, r=ehuss

Update cargo

8 commits in f5fed93ba24607980647962c59863bbabb03ce14..0b84a35c2c7d70df4875a03eb19084b0e7a543ef 2022-09-27 12:03:57 +0000 to 2022-10-03 19:13:21 +0000

- Provide a better error message when mixing dep: with / (rust-lang/cargo#11172)
- Remove lingering unstable flag `-Zfeatures` (rust-lang/cargo#11168)
- Tweak wording (rust-lang/cargo#11164)
- Expose libgit2-sys/vendored feature as vendored-libgit2 (rust-lang/cargo#11162)
- refactor(cli): Upgrade to clap v4 (rust-lang/cargo#11159)
- Expose guide to adding a new edition as rustdoc (rust-lang/cargo#11157)
- Remove `multitarget` from -Zhelp (rust-lang/cargo#11158)
- Remove outdated comments (rust-lang/cargo#11155)

21 months agoTemporarily reinstate doctest=false
reez12g [Wed, 5 Oct 2022 00:53:49 +0000 (09:53 +0900)]
Temporarily reinstate doctest=false

21 months agoAuto merge of #101768 - sunfishcode:sunfishcode/wasi-stdio-lock-asfd, r=joshtriplett
bors [Tue, 4 Oct 2022 23:22:16 +0000 (23:22 +0000)]
Auto merge of #101768 - sunfishcode:sunfishcode/wasi-stdio-lock-asfd, r=joshtriplett

Add `AsFd` implementations for stdio lock types on WASI.

This mirrors the implementations on Unix platforms, and also mirrors the existing `AsRawFd` impls.

This is similar to #100892, but is for the `*Lock` types.

21 months agoUpdate cargo
Weihang Lo [Tue, 4 Oct 2022 20:57:49 +0000 (21:57 +0100)]
Update cargo

8 commits in f5fed93ba24607980647962c59863bbabb03ce14..0b84a35c2c7d70df4875a03eb19084b0e7a543ef
2022-09-27 12:03:57 +0000 to 2022-10-03 19:13:21 +0000

- Provide a better error message when mixing dep: with / (rust-lang/cargo#11172)
- Remove lingering unstable flag `-Zfeatures` (rust-lang/cargo#11168)
- Tweak wording (rust-lang/cargo#11164)
- Expose libgit2-sys/vendored feature as vendored-libgit2 (rust-lang/cargo#11162)
- refactor(cli): Upgrade to clap v4 (rust-lang/cargo#11159)
- Expose guide to adding a new edition as rustdoc (rust-lang/cargo#11157)
- Remove `multitarget` from -Zhelp (rust-lang/cargo#11158)
- Remove outdated comments (rust-lang/cargo#11155)

21 months agofollow-up fix about 101866 to print the self type.
Yiming Lei [Tue, 4 Oct 2022 17:30:25 +0000 (10:30 -0700)]
follow-up fix about 101866 to print the self type.
modified:   compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
modified:   src/test/ui/error-codes/E0283.stderr
modified:   src/test/ui/error-codes/E0790.stderr
modified:   src/test/ui/traits/static-method-generic-inference.stderr
modified:   src/test/ui/type/issue-101866.stderr

21 months agoAuto merge of #102666 - matthiaskrgr:rollup-tuge18t, r=matthiaskrgr
bors [Tue, 4 Oct 2022 16:29:26 +0000 (16:29 +0000)]
Auto merge of #102666 - matthiaskrgr:rollup-tuge18t, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - #102241 (Package `rust-docs-json` into nightly components (take 3))
 - #102488 (Check generic argument compatibility when projecting assoc ty)
 - #102647 (Only allow ~const bounds for traits with #[const_trait])
 - #102648 (Add test for #102605)
 - #102651 (It's not about types or consts, but the lack of regions)
 - #102653 (resolve instance: missing value to `delay_span_bug`)

Failed merges:

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

21 months agoRollup merge of #102653 - lcnr:delay_span_bug, r=fee1-dead
Matthias Krüger [Tue, 4 Oct 2022 16:26:41 +0000 (18:26 +0200)]
Rollup merge of #102653 - lcnr:delay_span_bug, r=fee1-dead

resolve instance: missing value to `delay_span_bug`

21 months agoRollup merge of #102651 - oli-obk:non_region_things, r=lcnr
Matthias Krüger [Tue, 4 Oct 2022 16:26:41 +0000 (18:26 +0200)]
Rollup merge of #102651 - oli-obk:non_region_things, r=lcnr

It's not about types or consts, but the lack of regions

pulled out of https://github.com/rust-lang/rust/pull/101900 which adds a fourth kind of non-lifetime generic parameter, and the naming of these methods would get ridiculous.

21 months agoRollup merge of #102648 - Rageking8:add-test-for-#102605, r=compiler-errors
Matthias Krüger [Tue, 4 Oct 2022 16:26:40 +0000 (18:26 +0200)]
Rollup merge of #102648 - Rageking8:add-test-for-#102605, r=compiler-errors

Add test for #102605

Fixes #102605

21 months agoRollup merge of #102647 - oli-obk:tilde_const_bounds, r=fee1-dead
Matthias Krüger [Tue, 4 Oct 2022 16:26:39 +0000 (18:26 +0200)]
Rollup merge of #102647 - oli-obk:tilde_const_bounds, r=fee1-dead

Only allow ~const bounds for traits with #[const_trait]

r? `@fee1-dead`

21 months agoRollup merge of #102488 - compiler-errors:gat-compatibility, r=oli-obk
Matthias Krüger [Tue, 4 Oct 2022 16:26:39 +0000 (18:26 +0200)]
Rollup merge of #102488 - compiler-errors:gat-compatibility, r=oli-obk

Check generic argument compatibility when projecting assoc ty

Fixes #102114

21 months agoRollup merge of #102241 - jyn514:manifest-json-docs, r=Mark-Simulacrum
Matthias Krüger [Tue, 4 Oct 2022 16:26:38 +0000 (18:26 +0200)]
Rollup merge of #102241 - jyn514:manifest-json-docs, r=Mark-Simulacrum

Package `rust-docs-json` into nightly components (take 3)

`dist` creates a `rust-docs-json.tar.xz` tarfile. But build-manifest expected it to be named `rust-docs-json-preview.tar.xz`. Change build-manifest to allow the name without the `-preview` suffix.

I haven't actually tested this :( build-manifest is a pain to run locally.

21 months agorustdoc: remove no-op CSS `.code-header { display: block }`
Michael Howell [Tue, 4 Oct 2022 15:37:10 +0000 (08:37 -0700)]
rustdoc: remove no-op CSS `.code-header { display: block }`

Since 76a3b609d0b93c5d8da5e4e3db37bd03e5cb1c30 converted code headers to
real headers, `display: block` is now the default.

21 months agomissing value to delay_span_bug
lcnr [Tue, 4 Oct 2022 12:18:11 +0000 (14:18 +0200)]
missing value to delay_span_bug

21 months agotest Miri changes in PR CI; we no longer need xargo
Ralf Jung [Tue, 4 Oct 2022 13:23:57 +0000 (15:23 +0200)]
test Miri changes in PR CI; we no longer need xargo

21 months agoAuto merge of #2566 - saethlin:gc-cleanup, r=oli-obk
bors [Tue, 4 Oct 2022 14:17:17 +0000 (14:17 +0000)]
Auto merge of #2566 - saethlin:gc-cleanup, r=oli-obk

Expand VisitMachineValues to cover more pointers in the interpreter

Follow-on to https://github.com/rust-lang/miri/pull/2559

This is making me want to write a proc macro :thinking:

r? `@RalfJung`

21 months agoIt's not about types or consts, but the lack of regions
Oli Scherer [Tue, 4 Oct 2022 09:43:34 +0000 (09:43 +0000)]
It's not about types or consts, but the lack of regions

21 months agoIt's not about types or consts, but the lack of regions
Oli Scherer [Tue, 4 Oct 2022 09:43:34 +0000 (09:43 +0000)]
It's not about types or consts, but the lack of regions

21 months agore-architect the tag visitor traits
Ralf Jung [Sun, 2 Oct 2022 14:22:53 +0000 (16:22 +0200)]
re-architect the tag visitor traits

21 months agoAuto merge of #2582 - RalfJung:sb-tracking, r=RalfJung
bors [Tue, 4 Oct 2022 13:44:21 +0000 (13:44 +0000)]
Auto merge of #2582 - RalfJung:sb-tracking, r=RalfJung

more details in stacked borrows tag tracking

21 months agoFinish TimeoutCallback
Ben Kimock [Tue, 27 Sep 2022 09:40:12 +0000 (05:40 -0400)]
Finish TimeoutCallback

21 months agoPlease help, where is this lifetime bound coming from
Ben Kimock [Tue, 27 Sep 2022 01:48:18 +0000 (21:48 -0400)]
Please help, where is this lifetime bound coming from

21 months agoUse static dispatch in the visitor
Ben Kimock [Mon, 26 Sep 2022 23:50:50 +0000 (19:50 -0400)]
Use static dispatch in the visitor

21 months agoUse VisitProvenance to factor allocation visiting better
Ben Kimock [Mon, 26 Sep 2022 22:06:20 +0000 (18:06 -0400)]
Use VisitProvenance to factor allocation visiting better

21 months agoA bit of cleanup
Ben Kimock [Mon, 26 Sep 2022 20:07:32 +0000 (16:07 -0400)]
A bit of cleanup

21 months agoExpand VisitMachineValues to cover more pointers in the interpreter
Ben Kimock [Sat, 24 Sep 2022 18:20:22 +0000 (14:20 -0400)]
Expand VisitMachineValues to cover more pointers in the interpreter

21 months agoAuto merge of #102652 - Dylan-DPC:rollup-6ff8ct8, r=Dylan-DPC
bors [Tue, 4 Oct 2022 13:04:57 +0000 (13:04 +0000)]
Auto merge of #102652 - Dylan-DPC:rollup-6ff8ct8, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #101189 (Implement `Ready::into_inner()`)
 - #101642 (Fix in-place collection leak when remaining element destructor panic)
 - #102489 (Normalize substs before resolving instance in `NoopMethodCall` lint)
 - #102559 (Don't ICE when trying to copy unsized value in const prop)
 - #102568 (Lint against nested opaque types that don't satisfy associated type bounds)
 - #102633 (Fix rustdoc ICE in invalid_rust_codeblocks lint)

Failed merges:

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

21 months agomore details on stacked borrows tracking
Ralf Jung [Tue, 4 Oct 2022 11:15:32 +0000 (13:15 +0200)]
more details on stacked borrows tracking

21 months agoresolve error when attempting to link a universal library on macOS
Alex Gaynor [Thu, 30 Jun 2022 19:01:38 +0000 (15:01 -0400)]
resolve error when attempting to link a universal library on macOS

Previously attempting to link universal libraries into libraries (but not binaries) would produce an error that "File too small to be an archive". This works around this by using `object` to extract a library for the target platform when passed a univeral library.

Fixes #55235

21 months agoslightly improve no return for returning function error
Rageking8 [Tue, 4 Oct 2022 08:46:12 +0000 (16:46 +0800)]
slightly improve no return for returning function error

21 months agoAuto merge of #9587 - c410-f3r:arith, r=Alexendoo
bors [Tue, 4 Oct 2022 11:05:24 +0000 (11:05 +0000)]
Auto merge of #9587 - c410-f3r:arith, r=Alexendoo

[arithmetic-side-effects] Do not ignore literal references

To my utter surprise, `rustc` does does not warn stuff like `let n: u8 = &255 + &1` or `let n: u8 = 255 + &1`.

changelog: [arithmetic-side-effects] Do not ignore literal references

21 months agoRollup merge of #102633 - Nilstrieb:rustdoc-lint-🏳️‍⚧️late, r=davidtwco
Dylan DPC [Tue, 4 Oct 2022 10:41:03 +0000 (16:11 +0530)]
Rollup merge of #102633 - Nilstrieb:rustdoc-lint-🏳️‍⚧️late, r=davidtwco

Fix rustdoc ICE in invalid_rust_codeblocks lint

The diagnostic message extraction code didn't handle translations yet.
Fixes #102603
Fixes #102631

r? `@davidtwco`

21 months agoRollup merge of #102568 - compiler-errors:lint-unsatisfied-opaques, r=oli-obk
Dylan DPC [Tue, 4 Oct 2022 10:41:02 +0000 (16:11 +0530)]
Rollup merge of #102568 - compiler-errors:lint-unsatisfied-opaques, r=oli-obk

Lint against nested opaque types that don't satisfy associated type bounds

See the test failures for examples of places where this lint would fire.

r? `@oli-obk`

21 months agoRollup merge of #102559 - compiler-errors:issue-102553, r=oli-obk
Dylan DPC [Tue, 4 Oct 2022 10:41:02 +0000 (16:11 +0530)]
Rollup merge of #102559 - compiler-errors:issue-102553, r=oli-obk

Don't ICE when trying to copy unsized value in const prop

When we have a trivially false where-clause predicate like `Self: Sized` where `Self = dyn Trait`, we sometimes don't throw an error during typeck for an illegal operation such as copying an unsized type.

This, unfortunately, cannot be made into an error (at least not without some migration -- see #95611 for example), but we should at least not ICE, since this function will never actually be reachable from main, for example.

r? `@RalfJung` since I think you added these assertions? but feel free to reassign.

Fixes #102553

21 months agoRollup merge of #102489 - compiler-errors:issue-102074, r=oli-obk
Dylan DPC [Tue, 4 Oct 2022 10:41:01 +0000 (16:11 +0530)]
Rollup merge of #102489 - compiler-errors:issue-102074, r=oli-obk

Normalize substs before resolving instance in `NoopMethodCall` lint

Fixes #102074

r? types

21 months agoRollup merge of #101642 - SkiFire13:fix-inplace-collection-leak, r=the8472
Dylan DPC [Tue, 4 Oct 2022 10:41:01 +0000 (16:11 +0530)]
Rollup merge of #101642 - SkiFire13:fix-inplace-collection-leak, r=the8472

Fix in-place collection leak when remaining element destructor panic

Fixes #101628

cc `@the8472`

I went for the drop guard route, placing it immediately before the `forget_allocation_drop_remaining` call and after the comment, as to signal they are closely related.

I also updated the test to check for the leak, though the only change really needed was removing the leak clean up for miri since now that's no longer leaked.

21 months agoRollup merge of #101189 - daxpedda:ready-into-inner, r=joshtriplett
Dylan DPC [Tue, 4 Oct 2022 10:41:00 +0000 (16:11 +0530)]
Rollup merge of #101189 - daxpedda:ready-into-inner, r=joshtriplett

Implement `Ready::into_inner()`

Tracking issue: #101196.

This implements a method to unwrap the value inside a `Ready` outside an async context.
See https://docs.rs/futures/0.3.24/futures/future/struct.Ready.html#method.into_inner for previous work.

This was discussed in [Zulip beforehand](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/.60Ready.3A.3Ainto_inner.28.29.60):
> An example I'm hitting right now:
I have a cross-platform library that provides a functions that returns a `Future`. The only reason why it returns a `Future` is because the WASM platform requires it, but the native doesn't, to make a cross-platform API that is equal for all I just return a `Ready` on the native targets.
>
> Now I would like to expose native-only functions that aren't async, that users can use to avoid having to deal with async when they are targeting native. With `into_inner` that's easily solvable now.
>
> I want to point out that some internal restructuring could be used to solve that problem too, but in this case it's not that simple, the library uses internal traits that return the `Future` already and playing around with that would introduce unnecessary `cfg` in a lot more places. So it is really only a quality-of-life feature.

21 months agoAuto merge of #102622 - camsteffen:move-layout, r=fee1-dead
bors [Tue, 4 Oct 2022 09:29:07 +0000 (09:29 +0000)]
Auto merge of #102622 - camsteffen:move-layout, r=fee1-dead

Move layout_of and friends from rustc_middle to rustc_ty_utils

Breaks up the very large module that is `rustc_middle::ty::layout` by fork-lifting some queries into `rustc_ty_utils::{abi, layout}`.

This does set back `rustc_ty_utils` to having untranslatable diagnostics. I'd like to leave this as a separate task.

21 months agoMerge the `~const` and `impl const` checks and add some explanatory notes
Oli Scherer [Tue, 4 Oct 2022 08:59:20 +0000 (08:59 +0000)]
Merge the `~const` and `impl const` checks and add some explanatory notes

21 months agoadd test for #102605
Rageking8 [Tue, 4 Oct 2022 08:13:50 +0000 (16:13 +0800)]
add test for #102605

21 months agoOnly allow ~const bounds for traits with #[const_trait]
Oli Scherer [Mon, 3 Oct 2022 17:08:42 +0000 (17:08 +0000)]
Only allow ~const bounds for traits with #[const_trait]

21 months agoAuto merge of #9547 - nyurik:capt, r=flip1995
bors [Tue, 4 Oct 2022 07:20:24 +0000 (07:20 +0000)]
Auto merge of #9547 - nyurik:capt, r=flip1995

fallout: fix tests to allow uninlined_format_args

In order to switch `clippy::uninlined_format_args` from pedantic to style, all existing tests must not raise a warning. I did not want to change the actual tests, so this is a relatively minor change that:

* add `#![allow(clippy::uninlined_format_args)]` where needed
* normalizes all allow/deny/warn attributes
   * all allow attributes are grouped together
   * sorted alphabetically
   * the `clippy::*` attributes are listed separate from the other ones.
   * deny and warn attributes are listed before the allowed ones

See also https://github.com/rust-lang/rust-clippy/pull/9233, https://github.com/rust-lang/rust-clippy/pull/9525, https://github.com/rust-lang/rust-clippy/pull/9527

cc: `@llogiq` `@Alexendoo`

changelog: none

21 months agoAuto merge of #102644 - matthiaskrgr:rollup-rg0sw41, r=matthiaskrgr
bors [Tue, 4 Oct 2022 06:47:21 +0000 (06:47 +0000)]
Auto merge of #102644 - matthiaskrgr:rollup-rg0sw41, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #102441 (Suggest unwrap_or_else when a closure is given)
 - #102547 (Migrate CSS theme for search results)
 - #102567 (Delay evaluating lint primary message until after it would be suppressed)
 - #102624 (rustdoc: remove font family CSS on `.rustdoc-toggle summary::before`)
 - #102628 (Change the parameter name of From::from to `value`)
 - #102637 (Ignore fuchsia on two compiler tests)
 - #102639 (Improve spans when splitting multi-char operator tokens for proc macros.)

Failed merges:

 - #102496 (Suggest `.into()` when all other coercion suggestions fail)

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

21 months agoRollup merge of #102639 - nnethercote:improve-spans-splitting, r=Aaron1011
Matthias Krüger [Tue, 4 Oct 2022 04:14:13 +0000 (06:14 +0200)]
Rollup merge of #102639 - nnethercote:improve-spans-splitting, r=Aaron1011

Improve spans when splitting multi-char operator tokens for proc macros.

When a two-char (or three-char) operator token is split into single-char operator tokens before being passed to a proc macro, the single-char tokens are given the original span of length two (or three). This PR gives them more accurate spans.

r? `@Aaron1011`
cc `@petrochenkov`

21 months agoRollup merge of #102637 - andrewpollack:ignore-fuchsia-two-tests, r=tmandry
Matthias Krüger [Tue, 4 Oct 2022 04:14:12 +0000 (06:14 +0200)]
Rollup merge of #102637 - andrewpollack:ignore-fuchsia-two-tests, r=tmandry

Ignore fuchsia on two compiler tests

Adding `ignore-fuchsia` to two irrelevant compiler tests

cc. `@djkoloski`

r? `@tmandry`

21 months agoRollup merge of #102628 - H4x5:master, r=scottmcm
Matthias Krüger [Tue, 4 Oct 2022 04:14:12 +0000 (06:14 +0200)]
Rollup merge of #102628 - H4x5:master, r=scottmcm

Change the parameter name of From::from to `value`

The `From` trait is currently defined as:
```rust
pub trait From<T>: Sized {
    fn from(_: T) -> Self;
}
```

The name of the argument is `_`. I am proposing to change it to `value`, ie.
```rust
pub trait From<T>: Sized {
    fn from(value: T) -> Self;
}
```

This would be more consistent with the `TryFrom`, which looks like this:
```rust
pub trait TryFrom<T>: Sized {
    type Error;
    fn try_from(value: T) -> Result<Self, Self::Error>;
}
```

The reason for this proposal is twofold:
1. Consistency with the rest of the standard library. The `TryFrom` trait uses `value`, and no `From` implementation uses the default name (as it is quite useless).
2. When generating trait implementations with rust-analyzer/IntelliJ, the parameter name is copied, and it always has to be changed.

Optionally, another name like `x` could be used. I only propose `value` for consistency with `TryFrom`.

Changing parameter names is not a breaking change.

Note: this was originally posted as an internals thread [here](https://internals.rust-lang.org/t/change-the-argument-name-of-from-from/17480)

21 months agoRollup merge of #102624 - notriddle:notriddle/summary-before, r=GuillaumeGomez
Matthias Krüger [Tue, 4 Oct 2022 04:14:11 +0000 (06:14 +0200)]
Rollup merge of #102624 - notriddle:notriddle/summary-before, r=GuillaumeGomez

rustdoc: remove font family CSS on `.rustdoc-toggle summary::before`

This rule became irrelevant since c58246efe47bea09d4f3e70f536e4c9bb7770749 made it so that the `summary::before` pseudo-element contains an SVG instead of text.

21 months agoRollup merge of #102567 - compiler-errors:issue-102561, r=davidtwco
Matthias Krüger [Tue, 4 Oct 2022 04:14:11 +0000 (06:14 +0200)]
Rollup merge of #102567 - compiler-errors:issue-102561, r=davidtwco

Delay evaluating lint primary message until after it would be suppressed

Fixes #102561
Fixes #102572

21 months agoRollup merge of #102547 - GuillaumeGomez:migrate-css-theme-search-result, r=notriddle...
Matthias Krüger [Tue, 4 Oct 2022 04:14:10 +0000 (06:14 +0200)]
Rollup merge of #102547 - GuillaumeGomez:migrate-css-theme-search-result, r=notriddle,jsha

Migrate CSS theme for search results

Part of https://github.com/rust-lang/rust/pull/98460.

Just like https://github.com/rust-lang/rust/pull/102237, I unified theme to how the `ayu` handles this one: only one color for the background when search results are focused or hovered.

You can test it [here](https://rustdoc.crud.net/imperio/migrate-css-theme-search-result/lib2/index.html?search=coo).

cc `@jsha`
r? `@notriddle`

PS: The repetition in GUI tests is getting out of hand so I opened https://github.com/GuillaumeGomez/browser-UI-test/issues/363 to think about adding possibility to declare functions so we can greatly improve this.

21 months agoRollup merge of #102441 - chenyukang:fix-102320-unwrap_or_else, r=compiler-errors
Matthias Krüger [Tue, 4 Oct 2022 04:14:10 +0000 (06:14 +0200)]
Rollup merge of #102441 - chenyukang:fix-102320-unwrap_or_else, r=compiler-errors

Suggest unwrap_or_else when a closure is given

Fixes #102320

r? `@compiler-errors`

21 months agoAuto merge of #102395 - davidtwco:translation-rename-typeck, r=compiler-errors
bors [Tue, 4 Oct 2022 03:57:50 +0000 (03:57 +0000)]
Auto merge of #102395 - davidtwco:translation-rename-typeck, r=compiler-errors

errors: rename `typeck.ftl` to `hir_analysis.ftl`

In #102306, `rustc_typeck` was renamed to `rustc_hir_analysis` but the diagnostic resources were not renamed - which is what this pull request changes.

21 months agoWe are able to resolve methods even if they need subst
Michael Goulet [Tue, 4 Oct 2022 03:22:45 +0000 (03:22 +0000)]
We are able to resolve methods even if they need subst

21 months agouse ci-rustc-sysroot for sysroot when download_rustc
yukang [Tue, 4 Oct 2022 02:48:53 +0000 (10:48 +0800)]
use ci-rustc-sysroot for sysroot when download_rustc

21 months agoNormalize substs before resolving instance in NoopMethodCall lint
Michael Goulet [Thu, 29 Sep 2022 22:03:03 +0000 (22:03 +0000)]
Normalize substs before resolving instance in NoopMethodCall lint

21 months agoAuto merge of #99099 - Stargateur:phantomdata_debug, r=joshtriplett
bors [Tue, 4 Oct 2022 00:56:14 +0000 (00:56 +0000)]
Auto merge of #99099 - Stargateur:phantomdata_debug, r=joshtriplett

Add T to PhantomData impl Debug

This add debug information for `PhantomData`, I believe it's make sense to add this to debug impl of `PhantomData` since `T` is what define what is the `PhantomData` just write `"PhantomData"` is not very useful for debugging.

Alternative:

* `PhantomData::<{}>`
* `PhantomData { t: "str_type" }`

`@rustbot` label +T-libs-api -T-libs

21 months agoDogfood
Caio [Mon, 3 Oct 2022 23:10:00 +0000 (20:10 -0300)]
Dogfood

21 months ago[arithmetic-side-effects] Do not ignore literal references
Caio [Mon, 3 Oct 2022 22:49:03 +0000 (19:49 -0300)]
[arithmetic-side-effects] Do not ignore literal references

21 months agoImprove spans when splitting multi-char operator tokens for proc macros.
Nicholas Nethercote [Mon, 3 Oct 2022 02:57:47 +0000 (13:57 +1100)]
Improve spans when splitting multi-char operator tokens for proc macros.

21 months agoAuto merge of #9559 - c410-f3r:arith, r=Alexendoo
bors [Mon, 3 Oct 2022 21:54:08 +0000 (21:54 +0000)]
Auto merge of #9559 - c410-f3r:arith, r=Alexendoo

Fix #9544

Fix #9544

r? `@Alexendoo`

changelog: [`arithmetic_side_effects`]: Fix false negative for `CustomType / usize`, `CustomType * float` and similar

21 months agoAddress comments
Caio [Mon, 3 Oct 2022 21:36:12 +0000 (18:36 -0300)]
Address comments

21 months agoExtend GUI test to check hover and focus on search results
Guillaume Gomez [Sat, 1 Oct 2022 15:11:33 +0000 (17:11 +0200)]
Extend GUI test to check hover and focus on search results

21 months agoMigrate search results theme style to CSS variables
Guillaume Gomez [Sat, 1 Oct 2022 13:50:47 +0000 (15:50 +0200)]
Migrate search results theme style to CSS variables

21 months agoIgnore fuchsia on two compiler tests
Andrew Pollack [Mon, 3 Oct 2022 21:11:47 +0000 (21:11 +0000)]
Ignore fuchsia on two compiler tests

21 months agoAuto merge of #102632 - matthiaskrgr:rollup-h8s3zmo, r=matthiaskrgr
bors [Mon, 3 Oct 2022 20:22:18 +0000 (20:22 +0000)]
Auto merge of #102632 - matthiaskrgr:rollup-h8s3zmo, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #98218 (Document the conditional existence of `alloc::sync` and `alloc::task`.)
 - #99216 (docs: be less harsh in wording for Vec::from_raw_parts)
 - #99460 (docs: Improve AsRef / AsMut docs on blanket impls)
 - #100470 (Tweak `FpCategory` example order.)
 - #101040 (Fix `#[derive(Default)]` on a generic `#[default]` enum adding unnecessary `Default` bounds)
 - #101308 (introduce `{char, u8}::is_ascii_octdigit`)
 - #102486 (Add diagnostic struct for const eval error in `rustc_middle`)

Failed merges:

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

21 months agoFix rustdoc ICE in invalid_rust_codeblocks lint
Nilstrieb [Mon, 3 Oct 2022 19:01:19 +0000 (21:01 +0200)]
Fix rustdoc ICE in invalid_rust_codeblocks lint

The diagnostic message extraction code didn't handle translations yet.

21 months agoRollup merge of #102486 - pierwill:middle-const-eval-err, r=compiler-errors
Matthias Krüger [Mon, 3 Oct 2022 18:58:56 +0000 (20:58 +0200)]
Rollup merge of #102486 - pierwill:middle-const-eval-err, r=compiler-errors

Add diagnostic struct for const eval error in `rustc_middle`

Part of #100717.

r? `@ghost`

21 months agoRollup merge of #101308 - nerdypepper:feature/is-ascii-octdigit, r=joshtriplett
Matthias Krüger [Mon, 3 Oct 2022 18:58:56 +0000 (20:58 +0200)]
Rollup merge of #101308 - nerdypepper:feature/is-ascii-octdigit, r=joshtriplett

introduce `{char, u8}::is_ascii_octdigit`

This feature adds two new APIs: `char::is_ascii_octdigit` and `u8::is_ascii_octdigit`, under the feature gate `is_ascii_octdigit`. These methods are shorthands for `char::is_digit(self, 8)` and `u8::is_digit(self, 8)`:

```rust
// core::char

impl char {
    pub fn is_ascii_octdigit(self) -> bool;
}

// core::num

impl u8 {
    pub fn is_ascii_octdigit(self) -> bool;
}
```

---

Couple of things I need help understanding:

- `const`ness: have I used the right attribute in this case?
- is there a way to run the tests for `core::char` alone, instead of `./x.py test library/core`?

21 months agoRollup merge of #101040 - danielhenrymantilla:no-bounds-for-default-annotated-derive...
Matthias Krüger [Mon, 3 Oct 2022 18:58:55 +0000 (20:58 +0200)]
Rollup merge of #101040 - danielhenrymantilla:no-bounds-for-default-annotated-derive, r=joshtriplett

Fix `#[derive(Default)]` on a generic `#[default]` enum adding unnecessary `Default` bounds

That is, given something like:

```rs
// #[default] on a generic enum does not add `Default` bounds to the type params.
#[derive(Default)]
enum MyOption<T> {
    #[default]
    None,
    Some(T),
}
```

then `MyOption<T> : Default`_as currently implemented_ only holds when `T : Default`, as reported by ```@5225225``` [over Zulip](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/.23.5Bderive.28Default.29.5D.20for.20enums.20with.20fields).

This is contrary to [what the accepted RFC proposes](https://rust-lang.github.io/rfcs/3107-derive-default-enum.html#generated-bounds) (_i.e._, that `T` be allowed not to be itself `Default`), and indeed seems to be a rather unnecessary limitation.

21 months agoRollup merge of #100470 - reitermarkus:patch-1, r=joshtriplett
Matthias Krüger [Mon, 3 Oct 2022 18:58:55 +0000 (20:58 +0200)]
Rollup merge of #100470 - reitermarkus:patch-1, r=joshtriplett

Tweak `FpCategory` example order.

Follow same order for variable declarations and assertions.

21 months agoRollup merge of #99460 - JanBeh:PR_asref_asmut_docs, r=joshtriplett
Matthias Krüger [Mon, 3 Oct 2022 18:58:54 +0000 (20:58 +0200)]
Rollup merge of #99460 - JanBeh:PR_asref_asmut_docs, r=joshtriplett

docs: Improve AsRef / AsMut docs on blanket impls

There are several issues with the current state of `AsRef` and `AsMut` as [discussed here on IRLO](https://internals.rust-lang.org/t/semantics-of-asref/17016). See also #39397, #45742, #73390, #98905, and the FIXMEs [here](https://github.com/rust-lang/rust/blob/1.62.0/library/core/src/convert/mod.rs#L509-L515) and [here](https://github.com/rust-lang/rust/blob/1.62.0/library/core/src/convert/mod.rs#L530-L536). These issues are difficult to fix. This PR aims to update the documentation to better reflect the status-quo and to give advice on how `AsRef` and `AsMut` should be used.

In particular:

- Explicitly mention that `AsRef` and `AsMut` do not auto-dereference generally for all dereferencable types (but only if inner type is a shared and/or mutable reference)
- Give advice to not use `AsRef` or `AsMut` for the sole purpose of dereferencing
- Suggest providing a transitive `AsRef` or `AsMut` implementation for types which implement `Deref`
- Add new section "Reflexivity" in documentation comments for `AsRef` and `AsMut`
- Provide better example for `AsMut`
- Added heading "Relation to `Borrow`" in `AsRef`'s docs to improve structure

21 months agoRollup merge of #99216 - duarten:master, r=joshtriplett
Matthias Krüger [Mon, 3 Oct 2022 18:58:53 +0000 (20:58 +0200)]
Rollup merge of #99216 - duarten:master, r=joshtriplett

docs: be less harsh in wording for Vec::from_raw_parts

In particular, be clear that it is sound to specify memory not
originating from a previous `Vec` allocation. That is already suggested
in other parts of the documentation about zero-alloc conversions to Box<[T]>.

Incorporate a constraint from `slice::from_raw_parts` that was missing
but needs to be fulfilled, since a `Vec` can be converted into a slice.

Fixes https://github.com/rust-lang/rust/issues/98780.

21 months agoRollup merge of #98218 - kpreid:nostdarc, r=joshtriplett
Matthias Krüger [Mon, 3 Oct 2022 18:58:53 +0000 (20:58 +0200)]
Rollup merge of #98218 - kpreid:nostdarc, r=joshtriplett

Document the conditional existence of `alloc::sync` and `alloc::task`.

`alloc` declares

```rust
#[cfg(target_has_atomic = "ptr")]
pub mod sync;
```

but there is no public documentation of this condition. This PR fixes that, so that users of `alloc` can understand how to make their code compile everywhere `alloc` does, if they are writing a library with impls for `Arc`.

The wording is copied from `std::sync::atomic::AtomicPtr`, with additional advice on how to `#[cfg]` for it.

I feel quite uncertain about whether the paragraph I added to `Arc`'s documentation should actually be there, as it is a distraction for anyone using `std`. On the other hand, maybe more reminders that no_std exists would benefit the ecosystem.

Note: `target_has_atomic` is [stabilized](https://github.com/rust-lang/rust/issues/32976) but [not yet documented in the reference](https://github.com/rust-lang/reference/pull/1171).

21 months agoClarify documentation
Giacomo Stevanato [Sat, 10 Sep 2022 13:00:37 +0000 (15:00 +0200)]
Clarify documentation

21 months agoChange the parameter name of From::from to `value`
H4x5 [Mon, 3 Oct 2022 17:36:57 +0000 (13:36 -0400)]
Change the parameter name of From::from to `value`

21 months agoAuto merge of #102627 - matthiaskrgr:rollup-2xtrqkw, r=matthiaskrgr
bors [Mon, 3 Oct 2022 17:31:45 +0000 (17:31 +0000)]
Auto merge of #102627 - matthiaskrgr:rollup-2xtrqkw, r=matthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - #102439 (rustdoc: re-sugar more cross-crate trait bounds)
 - #102569 (Improve `FromStr` example)
 - #102597 (Avoid ICE in printing RPITIT type)
 - #102607 (Improve documentation of `slice::{from_ptr_range, from_ptr_range_mut}`)
 - #102613 (Fix ICE #101739)
 - #102615 (Cleanup some error code explanations)
 - #102617 (`HirId` for `deferred_transmute_checks`)
 - #102620 (Migrate `.stab` elements style to CSS variables)

Failed merges:

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

21 months agoAdd diagnostic struct for const eval error in `rustc_middle`
pierwill [Sun, 2 Oct 2022 21:02:57 +0000 (16:02 -0500)]
Add diagnostic struct for const eval error in `rustc_middle`

Co-authored-by: Michael Goulet <michael@errs.io>
21 months agoRollup merge of #102620 - GuillaumeGomez:css-stab-migration, r=notriddle
Matthias Krüger [Mon, 3 Oct 2022 17:12:20 +0000 (19:12 +0200)]
Rollup merge of #102620 - GuillaumeGomez:css-stab-migration, r=notriddle

Migrate `.stab` elements style to CSS variables

Part of https://github.com/rust-lang/rust/pull/98460.

There should be no UI changes.

r? `@notriddle`

21 months agoRollup merge of #102617 - lcnr:deferred_transmute_checks, r=compiler-errors
Matthias Krüger [Mon, 3 Oct 2022 17:12:19 +0000 (19:12 +0200)]
Rollup merge of #102617 - lcnr:deferred_transmute_checks, r=compiler-errors

`HirId` for `deferred_transmute_checks`

directly interacting with spans is annoying :sparkles:

21 months agoRollup merge of #102615 - Nilstrieb:there-are-many-error-codes, r=compiler-errors
Matthias Krüger [Mon, 3 Oct 2022 17:12:19 +0000 (19:12 +0200)]
Rollup merge of #102615 - Nilstrieb:there-are-many-error-codes, r=compiler-errors

Cleanup some error code explanations

E0045: Use a stable non-C ABI instead
E0092: Use an atomic intrinsic that actually exists
E0161: Don't use box_syntax
E0579: Format ranges in the rustfmt style
E0622: Use the rustfmt style
E0743: Remove feature gate as it's not needed

21 months agoRollup merge of #102613 - TaKO8Ki:fix-part-of-101739, r=compiler-errors
Matthias Krüger [Mon, 3 Oct 2022 17:12:19 +0000 (19:12 +0200)]
Rollup merge of #102613 - TaKO8Ki:fix-part-of-101739, r=compiler-errors

Fix ICE #101739

Fixes a part of #101739

This cannot cover the following case. It causes `too many args provided` error and obligation does not have references error. I want your advice to solve the following cases as well in this pull request or a follow-up.

```rust
#![crate_type = "lib"]
#![feature(transmutability)]
#![allow(dead_code, incomplete_features, non_camel_case_types)]

mod assert {
    use std::mem::BikeshedIntrinsicFrom;

    pub fn is_transmutable<
        Src,
        Dst,
        Context,
        const ASSUME_ALIGNMENT: bool,
        const ASSUME_LIFETIMES: bool,
        const ASSUME_VALIDITY: bool,
        const ASSUME_VISIBILITY: bool,
    >()
    where
        Dst: BikeshedIntrinsicFrom<
            Src,
            Context,
            ASSUME_ALIGNMENT,
            ASSUME_LIFETIMES,
            ASSUME_VALIDITY,
            ASSUME_VISIBILITY,
        >,
    {}
}

fn via_const() {
    struct Context;
    #[repr(C)] struct Src;
    #[repr(C)] struct Dst;

    const FALSE: bool = false;

    assert::is_transmutable::<Src, Dst, Context, FALSE, FALSE, FALSE, FALSE>();
}
```

21 months agoRollup merge of #102607 - WaffleLapkin:docky_docky_slice_from_ptr_range, r=joshtriplett
Matthias Krüger [Mon, 3 Oct 2022 17:12:18 +0000 (19:12 +0200)]
Rollup merge of #102607 - WaffleLapkin:docky_docky_slice_from_ptr_range, r=joshtriplett

Improve documentation of `slice::{from_ptr_range, from_ptr_range_mut}`

Document panic conditions (`T` is a ZST) and sync docs of shared/unique version.

cc `@wx-csy`

21 months agoRollup merge of #102597 - compiler-errors:issue-102571, r=davidtwco
Matthias Krüger [Mon, 3 Oct 2022 17:12:18 +0000 (19:12 +0200)]
Rollup merge of #102597 - compiler-errors:issue-102571, r=davidtwco

Avoid ICE in printing RPITIT type

Fixes #102571

21 months agoRollup merge of #102569 - eduardosm:from_str-example, r=joshtriplett
Matthias Krüger [Mon, 3 Oct 2022 17:12:17 +0000 (19:12 +0200)]
Rollup merge of #102569 - eduardosm:from_str-example, r=joshtriplett

Improve `FromStr` example

The `from_str` implementation from the example had an `unwrap` that would make it panic on invalid input strings. Instead of panicking, it nows returns an error to better reflect the intented behavior of the `FromStr` trait.

21 months agoRollup merge of #102439 - fmease:rustdoc-simplify-cross-crate-trait-bounds, r=Guillau...
Matthias Krüger [Mon, 3 Oct 2022 17:12:17 +0000 (19:12 +0200)]
Rollup merge of #102439 - fmease:rustdoc-simplify-cross-crate-trait-bounds, r=GuillaumeGomez

rustdoc: re-sugar more cross-crate trait bounds

Previously, we would only ever re-sugar cross-crate predicates like `Type: Trait, <Type as Trait>::Name == Rhs` to `Type: Trait<Name = Rhs>` if the `Type` was a generic parameter like `Self` or `T`. With this PR, `Type` can be any type.

Most notably, this means that we now re-sugar predicates involving associated types (where `Type` is of the form `Self::Name`) which are then picked up by the pre-existing logic that re-sugars them into bounds. As a result of that, the associated type `IntoIter` of `std`'s `IntoIterator` trait (re-exported from `core`) is no longer rendered as:

```rust
type IntoIter: Iterator
where
    <Self::IntoIter as Iterator>::Item == Self::Item;
```

but as one would expect: `type IntoIter: Iterator<Item = Self::Item>;`.

Cross-crate closure bounds like `F: Fn(i32) -> bool` are now also rendered properly (previously, the return type (`Self::Output`) would not be rendered and we would show the underlying equality predicate).

Fixes #77763.
Fixes #84579.
Fixes #102142.

`@rustbot` label T-rustdoc A-cross-crate-reexports
r? rustdoc

21 months agoAuto merge of #9581 - ebobrow:mul-add-negative, r=Manishearth
bors [Mon, 3 Oct 2022 17:12:10 +0000 (17:12 +0000)]
Auto merge of #9581 - ebobrow:mul-add-negative, r=Manishearth

`suboptimal_flops` lint for multiply and subtract

fixes #9526

changelog: [`suboptimal_flops`] lint for multiply and subtract

21 months agorustdoc: remove font family CSS on `.rustdoc-toggle summary::before`
Michael Howell [Mon, 3 Oct 2022 16:29:26 +0000 (09:29 -0700)]
rustdoc: remove font family CSS on `.rustdoc-toggle summary::before`

This rule became irrelevant since c58246efe47bea09d4f3e70f536e4c9bb7770749
made it so that the `summary::before` pseudo-element contains an SVG instead
of text.

21 months agoAdd SAFETY comments for AsFd implementations on stdin/stdout/stderr
Josh Triplett [Mon, 3 Oct 2022 11:58:00 +0000 (12:58 +0100)]
Add SAFETY comments for AsFd implementations on stdin/stdout/stderr

21 months agoAdd stability attributes.
Dan Gohman [Thu, 22 Sep 2022 23:14:14 +0000 (16:14 -0700)]
Add stability attributes.

21 months agoAuto merge of #102610 - dawnofmidnight:git-commit-hash, r=Mark-Simulacrum
bors [Mon, 3 Oct 2022 14:20:32 +0000 (14:20 +0000)]
Auto merge of #102610 - dawnofmidnight:git-commit-hash, r=Mark-Simulacrum

re-add git-commit-hash file to tarballs

rust-lang/rust#100557 removed the `git-commit-hash` file and replaced it with `git-commit-info`. However, build-manifest relies on the `git-commit-hash` file being present, so this adds it back.

r? `@Mark-Simulacrum`

21 months agoMove utils from rustc_middle to rustc_ty_utils
Cameron Steffen [Mon, 3 Oct 2022 00:06:14 +0000 (19:06 -0500)]
Move utils from rustc_middle to rustc_ty_utils

21 months agoMigrate stab elements style to CSS variables
Guillaume Gomez [Mon, 3 Oct 2022 13:31:59 +0000 (15:31 +0200)]
Migrate stab elements style to CSS variables

21 months agoerrors: rename `typeck.ftl` to `hir_analysis.ftl`
David Wood [Wed, 28 Sep 2022 09:21:33 +0000 (10:21 +0100)]
errors: rename `typeck.ftl` to `hir_analysis.ftl`

In #102306, `rustc_typeck` was renamed to `rustc_hir_analysis` but the
diagnostic resources were not renamed - which is what this commit
changes.

Signed-off-by: David Wood <david.wood@huawei.com>