]> git.lizzy.rs Git - rust.git/log
rust.git
20 months agoRollup merge of #98204 - Kixiron:stable-unzip, r=thomcc
Dylan DPC [Tue, 25 Oct 2022 09:13:13 +0000 (14:43 +0530)]
Rollup merge of #98204 - Kixiron:stable-unzip, r=thomcc

Stabilize `Option::unzip()`

Stabilizes `Option::unzip()`, closes #87800

```@rustbot``` modify labels: +T-libs-api

20 months agoAuto merge of #102988 - dpaoliello:inlinerawdylib, r=dpaoliello
bors [Tue, 25 Oct 2022 04:57:51 +0000 (04:57 +0000)]
Auto merge of #102988 - dpaoliello:inlinerawdylib, r=dpaoliello

Support raw-dylib functions being used inside inlined functions

Fixes #102714

Issue Details:
When generating the import library for `raw-dylib` symbols, we currently only use the functions and variables declared within the current crate. This works fine if all crates are static libraries or `rlib`s as the generated import library will be contained in the static library or `rlib` itself, but if a dependency is a dynamic library AND the use of a `raw-dylib` function or variable is inlined or part of a generic instantiation then the current crate won't see its dependency's import library and so linking will fail.

Fix Details:
Instead, when we generate the import library for a `dylib` or `bin` crate, we will now generate it for the symbols both for the current crate and all upstream crates. We do this in two steps so that the import library for the current crate is passed into the linker first, thus it is preferred if there are any ambiguous symbols.

20 months agoAuto merge of #103502 - JohnTitor:rollup-o6mhyzq, r=JohnTitor
bors [Tue, 25 Oct 2022 02:16:57 +0000 (02:16 +0000)]
Auto merge of #103502 - JohnTitor:rollup-o6mhyzq, r=JohnTitor

Rollup of 11 pull requests

Successful merges:

 - #103333 (Fix assertion failed for break_last_token and trailing token)
 - #103350 (Change terminology for assoc method suggestions when they are not called)
 - #103382 (Don't ICE when reporting borrowck errors involving regions from `anonymous_lifetime_in_impl_trait`)
 - #103409 (Delay span bug when we can't map lifetimes back in `collect_trait_impl_trait_tys`)
 - #103410 (-Z docs: Add link to unstable book)
 - #103462 (rustdoc: remove no-op CSS `.source pre.rust { white-space: pre }`)
 - #103465 (E0210 explanation: remove redundant sentence)
 - #103486 (Use functions in highlight-colors rustdoc GUI test)
 - #103493 (rustdoc: remove unused `.sidebar-logo` DOM on source pages)
 - #103494 (rustdoc: remove redundant CSS `a.test-arrow:hover`)
 - #103495 (rustdoc: Use `unix_sigpipe` instead of `rustc_driver::set_sigpipe_handler`)

Failed merges:

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

20 months agoSupport raw-dylib functions being used inside inlined functions
Daniel Paoliello [Wed, 12 Oct 2022 21:44:01 +0000 (14:44 -0700)]
Support raw-dylib functions being used inside inlined functions

20 months agoRollup merge of #103495 - Enselic:rustdoc-unix_sigpipe, r=notriddle
Yuki Okushi [Mon, 24 Oct 2022 23:01:31 +0000 (08:01 +0900)]
Rollup merge of #103495 - Enselic:rustdoc-unix_sigpipe, r=notriddle

rustdoc: Use `unix_sigpipe` instead of `rustc_driver::set_sigpipe_handler`

Do what was already done for `rustc` in #102587, namely start using `unix_sigpipe` instead of `rustc_driver::set_sigpipe_handler`.

After this has been merged, we can completely remove `rustc_driver::set_sigpipe_handler`.

PR that added `set_sigpipe_handler`: https://github.com/rust-lang/rust/pull/49606

Tracking issue for `unix_sigpipe`: #97889

Verification of this change
---------------------------

1. Remove `#[unix_sigpipe = "sig_dfl"]`
1. Run `./x.py build`
1. Run `./build/aarch64-apple-darwin/stage1/bin/rustdoc --help | false`
1. Observe ICE
1. Add back `#[unix_sigpipe = "sig_dfl"]`
1. Run `./x.py build`
1. Run `./build/aarch64-apple-darwin/stage1/bin/rustdoc --help | false`
1. Observe ICE fixed

``@rustbot`` labels +T-rustdoc

20 months agoRollup merge of #103494 - notriddle:notriddle/test-arrow-hover, r=GuillaumeGomez
Yuki Okushi [Mon, 24 Oct 2022 23:01:31 +0000 (08:01 +0900)]
Rollup merge of #103494 - notriddle:notriddle/test-arrow-hover, r=GuillaumeGomez

rustdoc: remove redundant CSS `a.test-arrow:hover`

In 4b402dbe690dd00f567542ca9e41042826a168b5, when this rule was added, it was overriding a rule that made all links in docblock get an underline when hovered. This became redundant when, after reordering the rules, 7585632052298f9c84cc12ac5afcb23786ae1d3d changed the pro-underline rule to exclude the test-arrow link anyway.

20 months agoRollup merge of #103493 - notriddle:notriddle/source-sidebar-logo, r=GuillaumeGomez
Yuki Okushi [Mon, 24 Oct 2022 23:01:30 +0000 (08:01 +0900)]
Rollup merge of #103493 - notriddle:notriddle/source-sidebar-logo, r=GuillaumeGomez

rustdoc: remove unused `.sidebar-logo` DOM on source pages

20 months agoRollup merge of #103486 - GuillaumeGomez:cleanup-rustdoc-gui-highlight-colors, r...
Yuki Okushi [Mon, 24 Oct 2022 23:01:30 +0000 (08:01 +0900)]
Rollup merge of #103486 - GuillaumeGomez:cleanup-rustdoc-gui-highlight-colors, r=notriddle

Use functions in highlight-colors rustdoc GUI test

r? ``@notriddle``

20 months agoRollup merge of #103465 - jruderman:patch-1, r=compiler-errors
Yuki Okushi [Mon, 24 Oct 2022 23:01:30 +0000 (08:01 +0900)]
Rollup merge of #103465 - jruderman:patch-1, r=compiler-errors

E0210 explanation: remove redundant sentence

20 months agoRollup merge of #103462 - notriddle:notriddle/source-pre-rust-white-space, r=Dylan-DPC
Yuki Okushi [Mon, 24 Oct 2022 23:01:29 +0000 (08:01 +0900)]
Rollup merge of #103462 - notriddle:notriddle/source-pre-rust-white-space, r=Dylan-DPC

rustdoc: remove no-op CSS `.source pre.rust { white-space: pre }`

This rule, added in 49e6db7f3510a99ab3d3723b2430add985629c39, overrode a rule in normalize.css.

https://github.com/rust-lang/rust/blob/49e6db7f3510a99ab3d3723b2430add985629c39/src/librustdoc/html/static/normalize.css#L169-L175

When normalize.css was updated, this rule went away.

https://github.com/necolas/normalize.css/commit/a8edd0c5aa06b905e8e1550fd6a5c01e46375194

20 months agoRollup merge of #103410 - camsteffen:link-unstable-book, r=JohnTitor
Yuki Okushi [Mon, 24 Oct 2022 23:01:28 +0000 (08:01 +0900)]
Rollup merge of #103410 - camsteffen:link-unstable-book, r=JohnTitor

-Z docs: Add link to unstable book

20 months agoRollup merge of #103409 - compiler-errors:rpitit-signature-mismatch, r=lcnr
Yuki Okushi [Mon, 24 Oct 2022 23:01:28 +0000 (08:01 +0900)]
Rollup merge of #103409 - compiler-errors:rpitit-signature-mismatch, r=lcnr

Delay span bug when we can't map lifetimes back in `collect_trait_impl_trait_tys`

When a lifetime is late-bound in a trait signature, but early-bound in an impl signature, we already emit an error -- however, we also ICE in `collect_trait_impl_trait_tys`, so just delay a bug here.

Fixes #103407

20 months agoRollup merge of #103382 - compiler-errors:anon-apit-lt-region-ice, r=cjgillot
Yuki Okushi [Mon, 24 Oct 2022 23:01:28 +0000 (08:01 +0900)]
Rollup merge of #103382 - compiler-errors:anon-apit-lt-region-ice, r=cjgillot

Don't ICE when reporting borrowck errors involving regions from `anonymous_lifetime_in_impl_trait`

The issue here is that when we have:

```
trait Trait<'a> { .. }

fn foo(arg: impl Trait) { .. }
```

The anonymous lifetime `'_` that we generate for `arg: impl Trait` doesn't end up in the argument type (which is a param) but in a where-clause of the function, in a predicate whose self type is that param ty.

Fixes #101660

r? ``@cjgillot``

20 months agoRollup merge of #103350 - clubby789:refer-to-assoc-method, r=wesleywiser
Yuki Okushi [Mon, 24 Oct 2022 23:01:27 +0000 (08:01 +0900)]
Rollup merge of #103350 - clubby789:refer-to-assoc-method, r=wesleywiser

Change terminology for assoc method suggestions when they are not called

Fixes #103325

```@rustbot``` label +A-diagnostics

20 months agoRollup merge of #103333 - chenyukang:yukang/fix-103143, r=wesleywiser
Yuki Okushi [Mon, 24 Oct 2022 23:01:27 +0000 (08:01 +0900)]
Rollup merge of #103333 - chenyukang:yukang/fix-103143, r=wesleywiser

Fix assertion failed for break_last_token and trailing token

Fixes #103143

20 months agoDelay span bug when we can't map lifetimes back in collect_trait_impl_trait_tys
Michael Goulet [Mon, 24 Oct 2022 18:45:50 +0000 (18:45 +0000)]
Delay span bug when we can't map lifetimes back in collect_trait_impl_trait_tys

20 months agorustdoc: Use `unix_sigpipe` instead of `rustc_driver::set_sigpipe_handler`
Martin Nordholts [Mon, 24 Oct 2022 18:14:28 +0000 (20:14 +0200)]
rustdoc: Use `unix_sigpipe` instead of `rustc_driver::set_sigpipe_handler`

Start using `unix_sigpipe` instead of
`rustc_driver::set_sigpipe_handler`.

After this has been merged, we can completely remove
`rustc_driver::set_sigpipe_handler`.

Verification of this change
---------------------------

1. Remove `#[unix_sigpipe = "sig_dfl"]`
1. Run `./x.py build`
1. Run `./build/aarch64-apple-darwin/stage1/bin/rustdoc --help | false`
1. Observe ICE
1. Add back `#[unix_sigpipe = "sig_dfl"]`
1. Run `./x.py build`
1. Run `./build/aarch64-apple-darwin/stage1/bin/rustdoc --help | false`
1. Observe ICE fixed

20 months agorustdoc: remove redundant CSS `a.test-arrow:hover`
Michael Howell [Mon, 24 Oct 2022 18:39:19 +0000 (11:39 -0700)]
rustdoc: remove redundant CSS `a.test-arrow:hover`

In 4b402dbe690dd00f567542ca9e41042826a168b5, when this rule was added, it
was overriding a rule that made all links in docblock get an underline when
hovered. This became redundant when, after reordering the rules,
7585632052298f9c84cc12ac5afcb23786ae1d3d changed the pro-underline rule to
exclude the test-arrow link anyway.

20 months agorustdoc: remove unused `.sidebar-logo` DOM on source pages
Michael Howell [Mon, 24 Oct 2022 17:47:24 +0000 (10:47 -0700)]
rustdoc: remove unused `.sidebar-logo` DOM on source pages

20 months agoAuto merge of #103337 - flip1995:clippyup, r=Manishearth
bors [Mon, 24 Oct 2022 16:50:15 +0000 (16:50 +0000)]
Auto merge of #103337 - flip1995:clippyup, r=Manishearth

Update Clippy

r? `@Manishearth`

20 months agoUse functions in highlight-colors rustdoc GUI test
Guillaume Gomez [Mon, 24 Oct 2022 15:44:17 +0000 (17:44 +0200)]
Use functions in highlight-colors rustdoc GUI test

20 months agoDocument link to unstable book
Cameron Steffen [Sat, 22 Oct 2022 18:29:10 +0000 (13:29 -0500)]
Document link to unstable book

20 months agoAuto merge of #94063 - Aaron1011:pretty-print-rental, r=lcnr
bors [Mon, 24 Oct 2022 13:35:48 +0000 (13:35 +0000)]
Auto merge of #94063 - Aaron1011:pretty-print-rental, r=lcnr

Only apply `ProceduralMasquerade` hack to older versions of `rental`

The latest version of `rental` (v0.5.6) contains a fix that allows it to
compile without relying on the pretty-print back-compat hack.

Hopefully, there are no longer any crates relying on the affected
versions of the (much less popular) `procedural-masquerade` crate. This
should allow us to target the pretty-print back-compat hack specifically
to older versions of `rental`, and specifically mention upgrading to
`rental` v0.5.6 in the lint message.

20 months agoAuto merge of #103471 - JohnTitor:rollup-tfmy6ab, r=JohnTitor
bors [Mon, 24 Oct 2022 10:54:40 +0000 (10:54 +0000)]
Auto merge of #103471 - JohnTitor:rollup-tfmy6ab, r=JohnTitor

Rollup of 7 pull requests

Successful merges:

 - #99578 (Remove redundant lifetime bound from `impl Borrow for Cow`)
 - #99939 (Sort tests at compile time, not at startup)
 - #102271 (Stabilize `duration_checked_float`)
 - #102766 (Don't link to `libresolv` in libstd on Darwin)
 - #103277 (Update libstd's libc to 0.2.135 (to make `libstd` no longer pull in `libiconv.dylib` on Darwin))
 - #103437 (Sync rustc_codegen_cranelift)
 - #103466 (Fix grammar in docs for std::io::Read)

Failed merges:

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

20 months agoRollup merge of #103466 - jruderman:patch-2, r=Dylan-DPC
Yuki Okushi [Mon, 24 Oct 2022 10:32:29 +0000 (19:32 +0900)]
Rollup merge of #103466 - jruderman:patch-2, r=Dylan-DPC

Fix grammar in docs for std::io::Read

Two independent clauses were incorrectly joined by a bare comma. The simplest fix would be to switch to a semicolon, but I think it's slightly better to keep the comma and use the coordinating conjunction "so".

20 months agoRollup merge of #103437 - bjorn3:sync_cg_clif-2022-10-23, r=bjorn3
Yuki Okushi [Mon, 24 Oct 2022 10:32:28 +0000 (19:32 +0900)]
Rollup merge of #103437 - bjorn3:sync_cg_clif-2022-10-23, r=bjorn3

Sync rustc_codegen_cranelift

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler

20 months agoRollup merge of #103277 - thomcc:bump-libc-135, r=Mark-Simulacrum
Yuki Okushi [Mon, 24 Oct 2022 10:32:27 +0000 (19:32 +0900)]
Rollup merge of #103277 - thomcc:bump-libc-135, r=Mark-Simulacrum

Update libstd's libc to 0.2.135 (to make `libstd` no longer pull in `libiconv.dylib` on Darwin)

This is to pull in https://github.com/rust-lang/libc/pull/2944.

It's related to https://github.com/rust-lang/rust/pull/102766, in that they both remove unused dylibs from libstd on Darwin platforms. As a result, I'm marking this as relnotes since everybody agreed it was good to add it to the other as well. (The note should be about no longer linking against libiconv -- the libc update is irrelevant).

Might as well have the same reviewer too.

r? `@Mark-Simulacrum`

20 months agoRollup merge of #102766 - thomcc:remove-resolv, r=Mark-Simulacrum
Yuki Okushi [Mon, 24 Oct 2022 10:32:27 +0000 (19:32 +0900)]
Rollup merge of #102766 - thomcc:remove-resolv, r=Mark-Simulacrum

Don't link to `libresolv` in libstd on Darwin

Currently we link `libresolv` into every Rust program on apple targets despite never using it (as of https://github.com/rust-lang/rust/pull/44965). I had thought we needed this for `getaddrinfo` or something, but we do not / cannot safely use it.

I'd like to fix this for `libiconv` too (the other library we pull in. that's harder since it's coming in through `libc`, which is https://github.com/rust-lang/libc/pull/2944)).

---

This may warrant release notes. I'm not sure but I've added the flag regardless -- It's a change to the list of dylibs every Rust program pulls in, so it's worth mentioning.

It's pretty unlikely anybody was relying on this being pulled in, and `std` does not guarantee that it will link (and thus transitively provide access to) any particular system library -- anybody relying on that behavior would already be broken when dynamically linking std. That is, there's an outside chance something will fail to link on macOS and iOS because it was accidentally relying on our unnecessary dependency.

(If that *does* happen, that project could be easily fixed by linking libresolv explicitly on those platforms, probably via `#[link(name = "resolv")] extern {}`,` -Crustc-link-lib=resolv`, `println!("cargo:rustc-link-lib=resolv")`, or one of several places in `.config/cargo.toml`)

---

I'm also going to preemptively add the nomination for discussing this in the libs meeting. Basically: Do we care about programs that assume we will bring libraries in that we do not use. `libresolv` and `libiconv` on macOS/iOS are in this camp (`libresolv` because we used to use it, and `libiconv` because the `libc` crate was unintentionally(?) pulling it in to every Rust program).

I'd like to remove them both, but this may cause link issues programs that are relying on `std` to depend on them transitively. (Relying on std for this does not work in all build configurations, so this seems very fragile, and like a use case we should not support).

More generally, IMO we should not guarantee the specific set of system-provided libraries we use (beyond what is implied by an OS version requirement), which means we'd be free to remove this cruft.

20 months agoRollup merge of #102271 - lopopolo:lopopolo/stabilize-duration-try-from-secs-float...
Yuki Okushi [Mon, 24 Oct 2022 10:32:26 +0000 (19:32 +0900)]
Rollup merge of #102271 - lopopolo:lopopolo/stabilize-duration-try-from-secs-float, r=dtolnay

Stabilize `duration_checked_float`

## Stabilization Report

This stabilization report is for a stabilization of `duration_checked_float`, tracking issue: https://github.com/rust-lang/rust/issues/83400.

### Implementation History

- https://github.com/rust-lang/rust/pull/82179
- https://github.com/rust-lang/rust/pull/90247
- https://github.com/rust-lang/rust/pull/96051
- Changed error type to `FromFloatSecsError` in https://github.com/rust-lang/rust/pull/90247
- https://github.com/rust-lang/rust/pull/96051 changes the rounding mode to round-to-nearest instead of truncate.

## API Summary

This stabilization report proposes the following API to be stabilized in `core`, along with their re-exports in `std`:

```rust
// core::time

impl Duration {
    pub const fn try_from_secs_f32(secs: f32) -> Result<Duration, TryFromFloatSecsError>;
    pub const fn try_from_secs_f64(secs: f64) -> Result<Duration, TryFromFloatSecsError>;
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct TryFromFloatSecsError { ... }

impl core::fmt::Display for TryFromFloatSecsError { ... }
impl core::error::Error for TryFromFloatSecsError { ... }
```

These functions are made const unstable under `duration_consts_float`, tracking issue #72440.

There is an open question in the tracking issue around what the error type should be called which I was hoping to resolve in the context of an FCP.

In this stabilization PR, I have altered the name of the error type to `TryFromFloatSecsError`. In my opinion, the error type shares the name of the method (adjusted to accommodate both types of floats), which is consistent with other error types in `core`, `alloc` and `std` like `TryReserveError` and `TryFromIntError`.

## Experience Report

Code such as this is ready to be converted to a checked API to ensure it is panic free:

```rust
impl Time {
    pub fn checked_add_f64(&self, seconds: f64) -> Result<Self, TimeError> {
        // Fail safely during `f64` conversion to duration
        if seconds.is_nan() || seconds.is_infinite() {
            return Err(TzOutOfRangeError::new().into());
        }

        if seconds.is_sign_positive() {
            self.checked_add(Duration::from_secs_f64(seconds))
        } else {
            self.checked_sub(Duration::from_secs_f64(-seconds))
        }
    }
}
```

See: https://github.com/artichoke/artichoke/issues/2194.

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

cc `@mbartlett21`

20 months agoRollup merge of #99939 - saethlin:pre-sort-tests, r=thomcc,jackh726
Yuki Okushi [Mon, 24 Oct 2022 10:32:25 +0000 (19:32 +0900)]
Rollup merge of #99939 - saethlin:pre-sort-tests, r=thomcc,jackh726

Sort tests at compile time, not at startup

Recently, another Miri user was trying to run `cargo miri test` on the crate `iced-x86` with `--features=code_asm,mvex`. This configuration has a startup time of ~18 minutes. That's ~18 minutes before any tests even start to run. The fact that this crate has over 26,000 tests and Miri is slow makes a lot of code which is otherwise a bit sloppy but fine into a huge runtime issue.

Sorting the tests when the test harness is created instead of at startup time knocks just under 4 minutes out of those ~18 minutes. I have ways to remove most of the rest of the startup time, but this change requires coordinating changes of both the compiler and libtest, so I'm sending it separately.

(except for doctests, because there is no compile-time harness)

20 months agoRollup merge of #99578 - steffahn:remove_redundant_bound, r=thomcc
Yuki Okushi [Mon, 24 Oct 2022 10:32:24 +0000 (19:32 +0900)]
Rollup merge of #99578 - steffahn:remove_redundant_bound, r=thomcc

Remove redundant lifetime bound from `impl Borrow for Cow`

The lifetime bound `B::Owned: 'a` is redundant and doesn't make a difference,
because `Cow<'a, B>` comes with an implicit `B: 'a`, and associated types
will outlive lifetimes outlived by the `Self` type (and all the trait's
generic parameters, of which there are none in this case), so the implicit `B: 'a`
implies `B::Owned: 'a` anyway.

The explicit lifetime bound here does however [end up in documentation](https://doc.rust-lang.org/std/borrow/enum.Cow.html#impl-Borrow%3CB%3E),
and that's confusing in my opinion, so let's remove it ^^

_(Documentation right now, compare to `AsRef`, too:)_
![Screenshot_20220722_014055](https://user-images.githubusercontent.com/3986214/180332665-424d0c05-afb3-40d8-a330-a57a2c9a494b.png)

20 months agoFix grammar in docs for std::io::Read
Jesse Ruderman [Mon, 24 Oct 2022 08:06:34 +0000 (01:06 -0700)]
Fix grammar in docs for std::io::Read

20 months agoRemove redundant sentence
Jesse Ruderman [Mon, 24 Oct 2022 07:52:26 +0000 (00:52 -0700)]
Remove redundant sentence

20 months agoAuto merge of #102536 - scottmcm:lookup_line-tweak, r=jackh726
bors [Mon, 24 Oct 2022 07:24:45 +0000 (07:24 +0000)]
Auto merge of #102536 - scottmcm:lookup_line-tweak, r=jackh726

Shorten the `lookup_line` code slightly

The `match` looks like it's exactly the same as `checked_sub(1)`, so we might as well see if perf says we can just do that to save a couple lines.

20 months agorustdoc: remove no-op CSS `.source pre.rust { white-space: pre }`
Michael Howell [Mon, 24 Oct 2022 05:16:13 +0000 (22:16 -0700)]
rustdoc: remove no-op CSS `.source pre.rust { white-space: pre }`

This rule, added in 49e6db7f3510a99ab3d3723b2430add985629c39, overrode a
rule in normalize.css.

https://github.com/rust-lang/rust/blob/49e6db7f3510a99ab3d3723b2430add985629c39/src/librustdoc/html/static/normalize.css#L169-L175

When normalize.css was updated, this rule went away.

https://github.com/necolas/normalize.css/commit/a8edd0c5aa06b905e8e1550fd6a5c01e46375194

20 months agoAuto merge of #100848 - xfix:use-metadata-for-slice-len, r=thomcc
bors [Mon, 24 Oct 2022 04:14:46 +0000 (04:14 +0000)]
Auto merge of #100848 - xfix:use-metadata-for-slice-len, r=thomcc

Use ptr::metadata in <[T]>::len implementation

This avoids duplication of ptr::metadata code.

I believe this is acceptable as the previous approach essentially duplicated `ptr::metadata` because back then `rustc_allow_const_fn_unstable` annotation did not exist.

I would like somebody to ping `@rust-lang/wg-const-eval` as the documentation says:

> Always ping `@rust-lang/wg-const-eval` if you are adding more rustc_allow_const_fn_unstable attributes to any const fn.

20 months agoOverride linker in cargotest on windows
Aaron Hill [Mon, 24 Oct 2022 00:32:33 +0000 (19:32 -0500)]
Override linker in cargotest on windows

20 months agoAuto merge of #103452 - notriddle:rollup-peewevm, r=notriddle
bors [Mon, 24 Oct 2022 00:29:51 +0000 (00:29 +0000)]
Auto merge of #103452 - notriddle:rollup-peewevm, r=notriddle

Rollup of 11 pull requests

Successful merges:

 - #100462 (Clarify `array::from_fn` documentation)
 - #101644 (Document surprising and dangerous fs::Permissions behaviour on Unix)
 - #103005 (kmc-solid: Handle errors returned by `SOLID_FS_ReadDir`)
 - #103140 (Add diagnostic for calling a function with the same name with unresolved Macro)
 - #103254 (rustdoc: do not filter out cross-crate `Self: Sized` bounds)
 - #103347 (bootstrap: also create rustc-src component in sysroot)
 - #103402 (Fix wrapped valid-range handling in ty_find_init_error)
 - #103414 (Pretty print lifetimes captured by RPIT)
 - #103424 (rustdoc: remove no-op CSS `.code-header { border-bottom: none }`)
 - #103434 (Use functions for jump-to-def-background rustdoc GUI test)
 - #103447 (`MaybeUninit`: use `assume_init_drop()` in the partially initialized array example)

Failed merges:

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

20 months agoRollup merge of #103447 - ajtribick:maybe_uninit_doc_update, r=scottmcm
Michael Howell [Sun, 23 Oct 2022 21:48:19 +0000 (14:48 -0700)]
Rollup merge of #103447 - ajtribick:maybe_uninit_doc_update, r=scottmcm

`MaybeUninit`: use `assume_init_drop()` in the partially initialized array example

The `assume_init_drop()` method does the same thing as the pointer conversion, and makes the example more straightforward.

20 months agoRollup merge of #103434 - GuillaumeGomez:gui-test-jump-to-def-background-cleanup...
Michael Howell [Sun, 23 Oct 2022 21:48:18 +0000 (14:48 -0700)]
Rollup merge of #103434 - GuillaumeGomez:gui-test-jump-to-def-background-cleanup, r=notriddle

Use functions for jump-to-def-background rustdoc GUI test

r? `@notriddle`

20 months agoRollup merge of #103424 - notriddle:notriddle/code-header-border-bottom-none, r=Guill...
Michael Howell [Sun, 23 Oct 2022 21:48:18 +0000 (14:48 -0700)]
Rollup merge of #103424 - notriddle:notriddle/code-header-border-bottom-none, r=GuillaumeGomez

rustdoc: remove no-op CSS `.code-header { border-bottom: none }`

The code headers are always h3 or h4, which don't have border-bottom by default anyway.

20 months agoRollup merge of #103414 - compiler-errors:rpit-print-lt, r=cjgillot
Michael Howell [Sun, 23 Oct 2022 21:48:17 +0000 (14:48 -0700)]
Rollup merge of #103414 - compiler-errors:rpit-print-lt, r=cjgillot

Pretty print lifetimes captured by RPIT

This specifically makes the output in #103409 change from:

```diff
  error: `impl` item signature doesn't match `trait` item signature
    --> $DIR/signature-mismatch.rs:15:5
     |
  LL |     fn async_fn(&self, buff: &[u8]) -> impl Future<Output = Vec<u8>>;
     |     ----------------------------------------------------------------- expected `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>>`
  ...
  LL |     fn async_fn<'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>> + 'a {
-  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>>`
+  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '2`
     |
     = note: expected `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>>`
-               found `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>>`
+               found `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '2`
     = help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
     = help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output

  error: aborting due to previous error
```

Along with the UI tests in this PR, which I think are all improvements!

r? `@oli-obk` though feel free to re-roll

20 months agoRollup merge of #103402 - joshtriplett:niche-wrap-fix, r=oli-obk
Michael Howell [Sun, 23 Oct 2022 21:48:17 +0000 (14:48 -0700)]
Rollup merge of #103402 - joshtriplett:niche-wrap-fix, r=oli-obk

Fix wrapped valid-range handling in ty_find_init_error

Rust's niche handling allows for wrapping valid ranges with end < start;
for instance, a valid range with start=43 and end=41 means a niche of
42. Most places in the compiler handle this correctly, but
`ty_find_init_error` assumed that `lo > 0` means the type cannot contain a
zero.

Fix it to handle wrapping ranges.

20 months agoRollup merge of #103347 - RalfJung:rustc-src, r=Mark-Simulacrum
Michael Howell [Sun, 23 Oct 2022 21:48:16 +0000 (14:48 -0700)]
Rollup merge of #103347 - RalfJung:rustc-src, r=Mark-Simulacrum

bootstrap: also create rustc-src component in sysroot

Fixes https://github.com/rust-lang/rust-analyzer/issues/12926

20 months agoRollup merge of #103254 - fmease:fix-24183, r=GuillaumeGomez
Michael Howell [Sun, 23 Oct 2022 21:48:16 +0000 (14:48 -0700)]
Rollup merge of #103254 - fmease:fix-24183, r=GuillaumeGomez

rustdoc: do not filter out cross-crate `Self: Sized` bounds

All type parameters **except `Self`** are implicitly `Sized` ([via](https://doc.rust-lang.org/nightly/std/marker/trait.Sized.html)). Previously, we disregarded the exception of `Self` and omitted cross-crate `Sized` bounds of *any* type parameter *including* `Self` when rendering.
From now on, we *do* render cross-crate `Self: Sized` bounds.

Most notably, in `std` we now finally properly render the `Sized` bound of the `Clone` trait as well as the `Self: Sized` bound on `Iterator::map`.

Fixes #24183.

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

20 months agoRollup merge of #103140 - chenyukang:yukang/fix-103112, r=estebank
Michael Howell [Sun, 23 Oct 2022 21:48:15 +0000 (14:48 -0700)]
Rollup merge of #103140 - chenyukang:yukang/fix-103112, r=estebank

Add diagnostic for calling a function with the same name with unresolved Macro

Fixes #103112

20 months agoRollup merge of #103005 - solid-rs:patch/kmc-solid/readdir-terminator, r=m-ou-se
Michael Howell [Sun, 23 Oct 2022 21:48:15 +0000 (14:48 -0700)]
Rollup merge of #103005 - solid-rs:patch/kmc-solid/readdir-terminator, r=m-ou-se

kmc-solid: Handle errors returned by `SOLID_FS_ReadDir`

Fixes the issue where the `std::fs::ReadDir` implementaton of the [`*-kmc-solid_*`](https://doc.rust-lang.org/nightly/rustc/platform-support/kmc-solid.html) Tier 3 targets silently suppressed errors returned by the underlying `SOLID_FS_ReadDir` system function. The new implementation correctly handles all cases:

- `SOLID_ERR_NOTFOUND` indicates the end of directory stream.
- `SOLID_ERR_OK` + non-empty `d_name` indicates success.
- Some old filesystem drivers may return `SOLID_ERR_OK` + empty `d_name` to indicate the end of directory stream.
- Any other negative values (per ITRON convention) represent an error.

20 months agoRollup merge of #101644 - Timmmm:file_permissions_docs, r=thomcc
Michael Howell [Sun, 23 Oct 2022 21:48:14 +0000 (14:48 -0700)]
Rollup merge of #101644 - Timmmm:file_permissions_docs, r=thomcc

Document surprising and dangerous fs::Permissions behaviour on Unix

This documents the very surprising behaviour that `set_readonly(false)` will make a file *world writable* on Unix. I would go so far as to say that this function should be deprecated on Unix, or maybe even entirely. But documenting the bad behaviour is a good first step.

Fixes #74895

20 months agoRollup merge of #100462 - zohnannor:master, r=thomcc
Michael Howell [Sun, 23 Oct 2022 21:48:13 +0000 (14:48 -0700)]
Rollup merge of #100462 - zohnannor:master, r=thomcc

Clarify `array::from_fn` documentation

I've seen quite a few of people on social media confused of where the length of array is coming from in the newly stabilized `array::from_fn` example.

This PR tries to clarify the documentation on this.

20 months agoAuto merge of #103062 - cuviper:dist-mips, r=Mark-Simulacrum
bors [Sun, 23 Oct 2022 21:38:43 +0000 (21:38 +0000)]
Auto merge of #103062 - cuviper:dist-mips, r=Mark-Simulacrum

Upgrade dist-mips*-linux to ubuntu:22.04 + crosstool-ng

These have no change in compatibility, still Linux 4.4 and glibc 2.23.

The main motivation for upgrading is that LLVM 16 will require at least GCC 7.1. Using crosstool-ng lets us choose our own toolchain versions, and then the Ubuntu version doesn't matter so much, just for the host compilation while we cross-compile.

20 months agoAuto merge of #103137 - dtolnay:readdir, r=Mark-Simulacrum
bors [Sun, 23 Oct 2022 18:55:40 +0000 (18:55 +0000)]
Auto merge of #103137 - dtolnay:readdir, r=Mark-Simulacrum

Eliminate 280-byte memset from ReadDir iterator

This guy:

https://github.com/rust-lang/rust/blob/1536ab1b383f21b38f8d49230a2aecc51daffa3d/library/std/src/sys/unix/fs.rs#L589

It turns out `libc::dirent64` is quite big&mdash;https://docs.rs/libc/0.2.135/libc/struct.dirent64.html. In #103135 this memset accounted for 0.9% of the runtime of iterating a big directory.

Almost none of the big zeroed value is ever used. We memcpy a tiny prefix (19 bytes) into it, and then read just 9 bytes (`d_ino` and `d_type`) back out. We can read exactly those 9 bytes we need directly from the original entry_ptr instead.

## History

This code got added in #93459 and tweaked in #94272 and #94750.

Prior to #93459, there was no memset but a full 280 bytes were being copied from the entry_ptr.

<table><tr><td>copy 280 bytes</td></tr></table>

This was not legal because not all of those bytes might be initialized, or even allocated, depending on the length of the directory entry's name, leading to a segfault. That PR fixed the segfault by creating a new zeroed dirent64 and copying just the guaranteed initialized prefix into it.

<table><tr><td>memset 280 bytes</td><td>copy 19 bytes</td></tr></table>

However this was still buggy because it used `addr_of!((*entry_ptr).d_name)`, which is considered UB by Miri in the case that the full extent of entry_ptr is not in bounds of the same allocation. (Arguably this shouldn't be a requirement, but here we are.)

The UB got fixed by #94272 by replacing `addr_of` with some pointer manipulation based on `offset_from`, but still fundamentally the same operation.

<table><tr><td>memset 280 bytes</td><td>copy 19 bytes</td></tr></table>

Then #94750 noticed that only 9 of those 19 bytes were even being used, so we could pick out only those 9 to put in the ReadDir value.

<table><tr><td>memset 280 bytes</td><td>copy 19 bytes</td><td>copy 9 bytes</td></tr></table>

After my PR we just grab the 9 needed bytes directly from entry_ptr.

<table><tr><td>copy 9 bytes</td></tr></table>

The resulting code is more complex but I believe still worthwhile to land for the following reason. This is an extremely straightforward thing to accomplish in C and clearly libc assumes that; literally just `entry_ptr->d_name`. The extra work in comparison to accomplish it in Rust is not an example of any actual safety being provided by Rust. I believe it's useful to have uncovered that and think about what could be done in the standard library or language to support this obvious operation better.

## References

- https://man7.org/linux/man-pages/man3/readdir.3.html

20 months agoAnnotate static lifetimes too
Michael Goulet [Sun, 23 Oct 2022 17:21:43 +0000 (17:21 +0000)]
Annotate static lifetimes too

20 months agoMaybeUninit: use assume_init_drop() in the partially initialized array example
Andrew Tribick [Sun, 23 Oct 2022 16:59:24 +0000 (18:59 +0200)]
MaybeUninit: use assume_init_drop() in the partially initialized array example

20 months agoAuto merge of #101403 - bjorn3:dylib_lto, r=Mark-Simulacrum
bors [Sun, 23 Oct 2022 15:00:31 +0000 (15:00 +0000)]
Auto merge of #101403 - bjorn3:dylib_lto, r=Mark-Simulacrum

Enable LTO for rustc_driver.so

Alternative to https://github.com/rust-lang/rust/pull/97154

This enables LTO'ing dylibs behind a feature flag and uses this feature for compiling rustc_driver.so.

20 months agoRustfmt cg_clif's build system
bjorn3 [Sun, 23 Oct 2022 14:43:48 +0000 (16:43 +0200)]
Rustfmt cg_clif's build system

20 months agoUpdate list of allowed cranelift dependencies
bjorn3 [Sun, 23 Oct 2022 14:43:29 +0000 (16:43 +0200)]
Update list of allowed cranelift dependencies

20 months agoMerge commit '266e96785ab71834b917bf474f130a6d8fdecd4b' into sync_cg_clif-2022-10-23
bjorn3 [Sun, 23 Oct 2022 14:22:55 +0000 (16:22 +0200)]
Merge commit '266e96785ab71834b917bf474f130a6d8fdecd4b' into sync_cg_clif-2022-10-23

20 months agoRevert "Update to Cranelift 0.89.0"
bjorn3 [Sun, 23 Oct 2022 14:14:08 +0000 (16:14 +0200)]
Revert "Update to Cranelift 0.89.0"

It added a lot of extra dependencies. I opened bytecodealliance/wasmtime#5101
to remove those dependencies again.

This reverts commit da770abea31e25514af65387ea93a755242610b7.

20 months agoRevert "Stop using a depracated function"
bjorn3 [Sun, 23 Oct 2022 14:16:50 +0000 (16:16 +0200)]
Revert "Stop using a depracated function"

This reverts commit b1791eef6add9563c1b750e88ec02e681a9a4ad7.

20 months agoUse functions for jump-to-def-background rustodoc GUI test
Guillaume Gomez [Sun, 23 Oct 2022 13:40:56 +0000 (15:40 +0200)]
Use functions for jump-to-def-background rustodoc GUI test

20 months agoMerge commit '4f142aa1058f14f153f8bfd2d82f04ddb9982388' into clippyup
flip1995 [Sun, 23 Oct 2022 13:18:45 +0000 (15:18 +0200)]
Merge commit '4f142aa1058f14f153f8bfd2d82f04ddb9982388' into clippyup

20 months agoFix drop for dyn*
bjorn3 [Sun, 23 Oct 2022 13:09:28 +0000 (15:09 +0200)]
Fix drop for dyn*

20 months agoAllow dyn* upcasting
bjorn3 [Sun, 23 Oct 2022 13:09:11 +0000 (15:09 +0200)]
Allow dyn* upcasting

20 months agoUpdate rustc test suite failure list
bjorn3 [Sun, 23 Oct 2022 12:14:35 +0000 (14:14 +0200)]
Update rustc test suite failure list

20 months agoRustup to rustc 1.66.0-nightly (6e95b6da8 2022-10-22)
bjorn3 [Sun, 23 Oct 2022 11:50:51 +0000 (13:50 +0200)]
Rustup to rustc 1.66.0-nightly (6e95b6da8 2022-10-22)

20 months agoUpdate LLVM submodule
bjorn3 [Tue, 18 Oct 2022 12:27:45 +0000 (12:27 +0000)]
Update LLVM submodule

20 months agoIntroduce dedicated `-Zdylib-lto` flag for enabling LTO on `dylib`s
Jakub Beránek [Thu, 29 Sep 2022 14:31:03 +0000 (16:31 +0200)]
Introduce dedicated `-Zdylib-lto` flag for enabling LTO on `dylib`s

20 months agoSync from rust e64f1110c062f61746f222059439529a43ccf6dc
bjorn3 [Sun, 23 Oct 2022 11:44:16 +0000 (13:44 +0200)]
Sync from rust e64f1110c062f61746f222059439529a43ccf6dc

20 months agoAdd `rust.lto` config option
Jakub Beránek [Thu, 29 Sep 2022 14:28:57 +0000 (16:28 +0200)]
Add `rust.lto` config option

20 months agoAllow LTO for dylibs
bjorn3 [Sun, 4 Sep 2022 09:26:04 +0000 (09:26 +0000)]
Allow LTO for dylibs

20 months agoAdd missing export for the oom strategy symbol
bjorn3 [Sun, 4 Sep 2022 09:24:26 +0000 (09:24 +0000)]
Add missing export for the oom strategy symbol

20 months agoAuto merge of #103431 - Dylan-DPC:rollup-oozfo89, r=Dylan-DPC
bors [Sun, 23 Oct 2022 11:33:18 +0000 (11:33 +0000)]
Auto merge of #103431 - Dylan-DPC:rollup-oozfo89, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #101293 (Recover when unclosed char literal is parsed as a lifetime in some positions)
 - #101908 (Suggest let for assignment, and some code refactor)
 - #103192 (rustdoc: Eliminate uses of `EarlyDocLinkResolver::all_traits`)
 - #103226 (Check `needs_infer` before `needs_drop` during HIR generator analysis)
 - #103249 (resolve: Revert "Set effective visibilities for imports more precisely")
 - #103305 (Move some tests to more reasonable places)

Failed merges:

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

20 months agoAuto merge of #9622 - llogiq:box-dyn-default, r=Alexendoo
bors [Sun, 23 Oct 2022 11:15:19 +0000 (11:15 +0000)]
Auto merge of #9622 - llogiq:box-dyn-default, r=Alexendoo

fix `box-default` ignoring trait objects' types

This avoids removing the turbofish when the `Box` type is a `dyn` or `impl _`.

This fixes #9621.

---

changelog: none

20 months agoRollup merge of #103305 - c410-f3r:moar-errors, r=petrochenkov
Dylan DPC [Sun, 23 Oct 2022 09:50:20 +0000 (15:20 +0530)]
Rollup merge of #103305 - c410-f3r:moar-errors, r=petrochenkov

Move some tests to more reasonable places

r? `@petrochenkov`

20 months agoRollup merge of #103249 - petrochenkov:revaddids, r=oli-obk
Dylan DPC [Sun, 23 Oct 2022 09:50:18 +0000 (15:20 +0530)]
Rollup merge of #103249 - petrochenkov:revaddids, r=oli-obk

resolve: Revert "Set effective visibilities for imports more precisely"

In theory the change was correct, but in practice the use of import items in HIR is limited and hacky, and it expects that (effective) visibilities for all (up to) 3 IDs of the import are set to the value reflecting (effective) visibility of the whole syntactic `use` item rather than its individual components.

Fixes https://github.com/rust-lang/rust/issues/102352
r? `@oli-obk`

20 months agoRollup merge of #103226 - compiler-errors:delay-if-need-infer, r=lcnr
Dylan DPC [Sun, 23 Oct 2022 09:50:17 +0000 (15:20 +0530)]
Rollup merge of #103226 - compiler-errors:delay-if-need-infer, r=lcnr

Check `needs_infer` before `needs_drop` during HIR generator analysis

This is kinda a revival of #103036, but with the understanding that after fallback, a generator-interior type will only have `needs_infer` true if there's an error that prevented int or float variable fallback to occur (modulo region variables, which are erased).

Therefore the best choice here is to delay a bug and skip the `needs_drop` call altogether.

r? `@lcnr` feel free to reassign though

20 months agoRollup merge of #103192 - petrochenkov:noalltraits, r=jyn514
Dylan DPC [Sun, 23 Oct 2022 09:50:17 +0000 (15:20 +0530)]
Rollup merge of #103192 - petrochenkov:noalltraits, r=jyn514

rustdoc: Eliminate uses of `EarlyDocLinkResolver::all_traits`

Another step to https://github.com/rust-lang/rust/pull/94857.

20 months agoRollup merge of #101908 - chenyukang:fix-101880, r=estebank
Dylan DPC [Sun, 23 Oct 2022 09:50:16 +0000 (15:20 +0530)]
Rollup merge of #101908 - chenyukang:fix-101880, r=estebank

Suggest let for assignment, and some code refactor

Fixes #101880

20 months agoRollup merge of #101293 - compiler-errors:lt-is-actually-char, r=estebank
Dylan DPC [Sun, 23 Oct 2022 09:50:16 +0000 (15:20 +0530)]
Rollup merge of #101293 - compiler-errors:lt-is-actually-char, r=estebank

Recover when unclosed char literal is parsed as a lifetime in some positions

Fixes #101278

20 months agoAuto merge of #103345 - Nilstrieb:diag-flat, r=compiler-errors
bors [Sun, 23 Oct 2022 09:06:39 +0000 (09:06 +0000)]
Auto merge of #103345 - Nilstrieb:diag-flat, r=compiler-errors

Flatten diagnostic slug modules

This makes it easier to grep for the slugs in the code.

See https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Localization.20infra.20interferes.20with.20grepping.20for.20error for more discussion about it.

This was mostly done with a few regexes and a bunch of manual work. This also exposes a pretty annoying inconsistency for the extra labels. Some of the extra labels are defined as additional properties in the fluent message (which makes them not prefixed with the crate name) and some of them are new fluent messages themselves (which makes them prefixed with the crate name). I don't know whether we want to clean this up at some point but it's useful to know.

r? `@davidtwco`

20 months agoUpdate translation tests
Nilstrieb [Sat, 22 Oct 2022 09:08:09 +0000 (11:08 +0200)]
Update translation tests

20 months agoMigrate all diagnostics
Nilstrieb [Sat, 22 Oct 2022 09:07:54 +0000 (11:07 +0200)]
Migrate all diagnostics

20 months agoGenerate fluent message constant in a flat module for all crates
Nilstrieb [Fri, 21 Oct 2022 10:25:25 +0000 (12:25 +0200)]
Generate fluent message constant in a flat module for all crates

This will make it easier to grep for fluent message names.

20 months agoAuto merge of #103426 - matthiaskrgr:rollup-n6dqdy8, r=matthiaskrgr
bors [Sun, 23 Oct 2022 06:20:24 +0000 (06:20 +0000)]
Auto merge of #103426 - matthiaskrgr:rollup-n6dqdy8, r=matthiaskrgr

Rollup of 9 pull requests

Successful merges:

 - #103123 (Introduce `subst_iter` and `subst_iter_copied` on `EarlyBinder` )
 - #103328 (Do not suggest trivially false const predicates)
 - #103354 (Escape string literals when fixing overlong char literal)
 - #103355 (Handle return-position `impl Trait` in traits properly in `register_hidden_type`)
 - #103368 (Delay ambiguity span bug in normalize query iff not rustdoc)
 - #103388 (rustdoc: remove unused CSS class `.result-description`)
 - #103399 (Change `unknown_lint` applicability to `MaybeIncorrect`)
 - #103401 (Use functions for headings rustdoc GUI test)
 - #103412 (Fix typo in docs of `String::leak`.)

Failed merges:

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

20 months agoRollup merge of #103412 - finnbear:fix_docs_typo_string_leak, r=thomcc
Matthias Krüger [Sun, 23 Oct 2022 06:14:34 +0000 (08:14 +0200)]
Rollup merge of #103412 - finnbear:fix_docs_typo_string_leak, r=thomcc

Fix typo in docs of `String::leak`.

I introduced a typo in #103280, this PR fixes it.

See https://github.com/rust-lang/rust/pull/103280#discussion_r1002538265

20 months agoRollup merge of #103401 - GuillaumeGomez:gui-test-headings-cleanup, r=notriddle
Matthias Krüger [Sun, 23 Oct 2022 06:14:33 +0000 (08:14 +0200)]
Rollup merge of #103401 - GuillaumeGomez:gui-test-headings-cleanup, r=notriddle

Use functions for headings rustdoc GUI test

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

20 months agoRollup merge of #103399 - smoelius:unknown-lint-maybe-incorrect, r=fee1-dead
Matthias Krüger [Sun, 23 Oct 2022 06:14:33 +0000 (08:14 +0200)]
Rollup merge of #103399 - smoelius:unknown-lint-maybe-incorrect, r=fee1-dead

Change `unknown_lint` applicability to `MaybeIncorrect`

This small PR changes the applicability of `unknown_lint` to `MaybeIncorrect`, because the suggested lint might not be the correct one.

Here is one example where the current applicability causes a problem. Clippy has a set of internal lints guarded by a feature called `internal`. If the feature is not enabled, then the internal lints are "unknown." In that case, running `cargo clippy --fix ...` on `clippy_utils` causes lines such as the followig
https://github.com/rust-lang/rust/blob/26c96e341639102afacbbcad0dc18ad0ac71ab18/src/tools/clippy/clippy_utils/src/paths.rs#L51-L52
to be changed to
```rust
 #[expect(clippy::invalid_regex)] // internal lints do not know about all external crates
 pub const FUTURES_IO_ASYNCREADEXT: [&str; 3] = ["futures_util", "io", "AsyncReadExt"];
```
which is not correct.

20 months agoRollup merge of #103388 - notriddle:notriddle/result-description, r=GuillaumeGomez
Matthias Krüger [Sun, 23 Oct 2022 06:14:32 +0000 (08:14 +0200)]
Rollup merge of #103388 - notriddle:notriddle/result-description, r=GuillaumeGomez

rustdoc: remove unused CSS class `.result-description`

It was added to the CSS in d8de2b4c338471aacaf0e8a096f9a7148b146ab4, but was never actually used in that PR.

20 months agoRollup merge of #103368 - compiler-errors:normalization-ambiguity-bug, r=oli-obk
Matthias Krüger [Sun, 23 Oct 2022 06:14:32 +0000 (08:14 +0200)]
Rollup merge of #103368 - compiler-errors:normalization-ambiguity-bug, r=oli-obk

Delay ambiguity span bug in normalize query iff not rustdoc

Oli and I decided that the compiler debt of adding another usage of `tcx.sess.opts.actually_rustdoc` is fine, because we don't really want to add more complexity to the normalize query, and moving rustdoc to use fulfill normalization (`fully_normalize`, i.e. not use the normalize query) is unnecessary overhead given that it's skipping binders and stuff.

r? oli-obk

Fixes #102827
Fixes #103181

20 months agoRollup merge of #103355 - compiler-errors:rpitit-default-check, r=oli-obk
Matthias Krüger [Sun, 23 Oct 2022 06:14:31 +0000 (08:14 +0200)]
Rollup merge of #103355 - compiler-errors:rpitit-default-check, r=oli-obk

Handle return-position `impl Trait` in traits properly in `register_hidden_type`

The bounds that we get by calling `bound_explicit_item_bounds` from an RPITIT have projections, not opaques, but when we're *registering* an opaque, we want to treat it like an opaque.

Coincidentally fixes #102688 as well, which makes sense, since that was failing because we were inferring an opaque type to be equal to itself (opaque cycle error => "cannot resolve opaque type").

Fixes #103352

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

20 months agoRollup merge of #103354 - clubby789:escape-string-literals, r=compiler-errors
Matthias Krüger [Sun, 23 Oct 2022 06:14:31 +0000 (08:14 +0200)]
Rollup merge of #103354 - clubby789:escape-string-literals, r=compiler-errors

Escape string literals when fixing overlong char literal

Fixes #103323

````@rustbot```` label +A-diagnostics +A-suggestion-diagnostics

20 months agoRollup merge of #103328 - compiler-errors:trivial-false-const-sugg, r=jackh726
Matthias Krüger [Sun, 23 Oct 2022 06:14:30 +0000 (08:14 +0200)]
Rollup merge of #103328 - compiler-errors:trivial-false-const-sugg, r=jackh726

Do not suggest trivially false const predicates

Pass through constness to `predicate_can_apply` and don't suggest other impls if it's satisfied but not const.

Fixes #103267

20 months agoRollup merge of #103123 - compiler-errors:early-binder-iter, r=cjgillot
Matthias Krüger [Sun, 23 Oct 2022 06:14:30 +0000 (08:14 +0200)]
Rollup merge of #103123 - compiler-errors:early-binder-iter, r=cjgillot

Introduce `subst_iter` and `subst_iter_copied` on `EarlyBinder`

Makes working with bounds lists a bit easier, which I seem to do a lot.

Specifically, means that we don't need to do `.transpose_iter().map(|(pred, _)| *pred)` every time we want to iterate through an `EarlyBinder<&'tcx [(Predicate, Span)]>` (and even then, still have to call `subst` later), which was a very awkward idiom imo.

20 months agoAuto merge of #9688 - Alexendoo:msrv-tests, r=Manishearth
bors [Sun, 23 Oct 2022 05:05:23 +0000 (05:05 +0000)]
Auto merge of #9688 - Alexendoo:msrv-tests, r=Manishearth

Move MSRV tests into the lint specific test files

There are currently two ways MSRV tests are done in the ui test suite, adding a case to the `#![clippy::msrv = "1.0"]` `tests/ui/min_rust_version_attr.rs` or adding the two `msrv_1_xx` functions to the test file of the lint in question

This updates the clippy book to suggest the `msrv_1_xx` style, and replaces the tests in `tests/ui/min_rust_version_attr.rs` with ones of that style

Almost the entire diff is just moving stuff around as a result, I made sure to check the line numbers the lints are emitted at correspond with the right `msrv` case, so feel free to only skim that part

changelog: none

20 months agorustdoc: remove no-op CSS `.code-header { border-bottom: none }`
Michael Howell [Sun, 23 Oct 2022 04:28:53 +0000 (21:28 -0700)]
rustdoc: remove no-op CSS `.code-header { border-bottom: none }`

The code headers are always h3 or h4, which don't have border-bottom by
default anyway.

20 months agoAuto merge of #102660 - camsteffen:uninhabited-perf, r=oli-obk
bors [Sun, 23 Oct 2022 03:39:43 +0000 (03:39 +0000)]
Auto merge of #102660 - camsteffen:uninhabited-perf, r=oli-obk

Remove ParamEnv from uninhabited query

20 months agoFix wrapped valid-range handling in ty_find_init_error
Josh Triplett [Sat, 22 Oct 2022 14:37:46 +0000 (15:37 +0100)]
Fix wrapped valid-range handling in ty_find_init_error

Rust's niche handling allows for wrapping valid ranges with end < start;
for instance, a valid range with start=43 and end=41 means a niche of
42. Most places in the compiler handle this correctly, but
ty_find_init_error assumed that `lo > 0` means the type cannot contain a
zero.

Fix it to handle wrapping ranges.

Add a test to cover this case.

20 months agoBump cargotest servo to 785a344e32db58d4e631fd3cae17fd1f29a721ab
Aaron Hill [Sat, 22 Oct 2022 22:11:37 +0000 (17:11 -0500)]
Bump cargotest servo to 785a344e32db58d4e631fd3cae17fd1f29a721ab

This updates the 'cssparser' and 'procedural-masquerade' deps
to versions that no longer depend on the proc-macro back-compat
hack.

20 months agoPretty print lifetimes captured by RPIT
Michael Goulet [Sat, 22 Oct 2022 20:18:16 +0000 (20:18 +0000)]
Pretty print lifetimes captured by RPIT

20 months agoFix typo in docs of `String::leak`.
Finn Bear [Sat, 22 Oct 2022 19:26:47 +0000 (12:26 -0700)]
Fix typo in docs of `String::leak`.