]> git.lizzy.rs Git - rust.git/log
rust.git
20 months agoAuto merge of #102080 - yanchen4791:issue-99824-fix, r=cjgillot
bors [Sun, 16 Oct 2022 07:40:56 +0000 (07:40 +0000)]
Auto merge of #102080 - yanchen4791:issue-99824-fix, r=cjgillot

Fix missing explanation of where the borrowed reference is used when the same borrow occurs multiple times due to loop iterations

Fix #99824.

Problem of the issue:
If a borrow occurs in a loop, the borrowed reference could be invalidated at the same place at next iteration of the loop. When this happens, the point where the borrow occurs is the same as the intervening point that might invalidate the reference in the loop. This causes a problem for the current code finding the point where the resulting reference is used, so that the explanation of the cause will be missing. As the second point of "explain all errors in terms of three points" (see [leveraging intuition framing errors in terms of points"](https://rust-lang.github.io/rfcs/2094-nll.html#leveraging-intuition-framing-errors-in-terms-of-points), this explanation is very helpful for user to understand the error.

In the current implementation, the searching region for finding the location where the borrowed reference is used is limited to between the place where the borrow occurs and the place where the reference is invalidated. If those two places happen to be the same, which indicates that the borrow and invalidation occur at the same place in a loop, the search will fail.

One solution to the problem is when these two places are the same,  find the terminator of the loop, and then use the location of the loop terminator instead of the location of the borrow for the region to find the place where the borrowed reference is used.

20 months agoAuto merge of #103105 - JohnTitor:rollup-x4ivrix, r=JohnTitor
bors [Sun, 16 Oct 2022 04:54:29 +0000 (04:54 +0000)]
Auto merge of #103105 - JohnTitor:rollup-x4ivrix, r=JohnTitor

Rollup of 6 pull requests

Successful merges:

 - #101717 (Add documentation about the memory layout of `UnsafeCell<T>`)
 - #102023 (Add MaybeUninit array transpose From impls)
 - #103033 (Update pkg-config)
 - #103080 (pretty: fix to print some lifetimes on HIR pretty-print)
 - #103082 (Surround type with backticks)
 - #103088 (Fix settings page)

Failed merges:

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

20 months agoRollup merge of #103088 - GuillaumeGomez:fix-settings-page, r=notriddle
Yuki Okushi [Sun, 16 Oct 2022 02:41:14 +0000 (11:41 +0900)]
Rollup merge of #103088 - GuillaumeGomez:fix-settings-page, r=notriddle

Fix settings page

Thanks to https://github.com/rust-lang/rust/pull/103060, I discovered that the settings page was badly rendered. This PR fixes it.

Before:
![Screenshot from 2022-10-15 16-02-41](https://user-images.githubusercontent.com/3050060/195990668-42e0b16b-3146-4864-b822-6f6a80fb77a5.png)

After:
![Screenshot from 2022-10-15 16-02-31](https://user-images.githubusercontent.com/3050060/195990664-20f967df-8989-4336-bca9-be52baab8e81.png)

r? ```@notriddle```

20 months agoRollup merge of #103082 - gimbles:patch-1, r=cjgillo
Yuki Okushi [Sun, 16 Oct 2022 02:41:14 +0000 (11:41 +0900)]
Rollup merge of #103082 - gimbles:patch-1, r=cjgillo

Surround type with backticks

Very smol PR. :)

20 months agoRollup merge of #103080 - ohno418:fix-hir-pretty-print-lifetimes, r=cjgillot
Yuki Okushi [Sun, 16 Oct 2022 02:41:13 +0000 (11:41 +0900)]
Rollup merge of #103080 - ohno418:fix-hir-pretty-print-lifetimes, r=cjgillot

pretty: fix to print some lifetimes on HIR pretty-print

HIR pretty-printer doesn't seem to print some lifetimes in types. This PR fixes that.

Closes https://github.com/rust-lang/rust/issues/85089

20 months agoRollup merge of #103033 - alyssais:pkg-config, r=joshtriplett
Yuki Okushi [Sun, 16 Oct 2022 02:41:13 +0000 (11:41 +0900)]
Rollup merge of #103033 - alyssais:pkg-config, r=joshtriplett

Update pkg-config

I'd like to be able to cross-compile rustc in a scenario where it'd be really helpful to have https://github.com/rust-lang/pkg-config-rs/commit/cd3ccca7c3b89644e74b0217ef93c632efd8ed2a.  I've done some test builds of the compiler on x86_64 linux, targeting x86_64 linux and aarch64 linux.

20 months agoRollup merge of #102023 - SUPERCILEX:maybeuninit-transpose, r=scottmcm
Yuki Okushi [Sun, 16 Oct 2022 02:41:12 +0000 (11:41 +0900)]
Rollup merge of #102023 - SUPERCILEX:maybeuninit-transpose, r=scottmcm

Add MaybeUninit array transpose From impls

See discussion in https://github.com/rust-lang/rust/pull/101179 and https://github.com/rust-lang/rust/issues/96097. I believe this solution offers the simplest implementation with minimal future API regret.

`@RalfJung` mind doing a correctness review?

20 months agoRollup merge of #101717 - Pointerbender:unsafecell-memory-layout, r=Amanieu
Yuki Okushi [Sun, 16 Oct 2022 02:41:12 +0000 (11:41 +0900)]
Rollup merge of #101717 - Pointerbender:unsafecell-memory-layout, r=Amanieu

Add documentation about the memory layout of `UnsafeCell<T>`

The documentation for `UnsafeCell<T>` currently does not make any promises about its memory layout. This PR adds this documentation, namely that the memory layout of `UnsafeCell<T>` is the same as the memory layout of its inner `T`.

# Use case
Without this layout promise, the following cast would not be legally possible:

```rust
fn example<T>(ptr: *mut T) -> *const UnsafeCell<T> {
  ptr as *const UnsafeCell<T>
}
```

A use case where this can come up involves FFI. If Rust receives a pointer over a FFI boundary which provides shared read-write access (with some form of custom synchronization), and this pointer is managed by some Rust struct with lifetime `'a`, then it would greatly simplify its (internal) API and safety contract if a `&'a UnsafeCell<T>` can be created from a raw FFI pointer `*mut T`. A lot of safety checks can be done when receiving the pointer for the first time through FFI (non-nullness, alignment, initialize uninit bytes, etc.) and these properties can then be encoded into the `&UnsafeCell<T>` type. Without this documentation guarantee, this is not legal today outside of the standard library.

# Caveats
Casting in the opposite direction is still not valid, even with this documentation change:

```rust
fn example2<T>(ptr: &UnsafeCell<T>) -> &mut T {
  let t = ptr as *const UnsafeCell<T> as *mut T;
  unsafe { &mut *t }
}
```

This is because the only legal way to obtain a mutable pointer to the contents of the shared reference is through [`UnsafeCell::get`](https://doc.rust-lang.org/std/cell/struct.UnsafeCell.html#method.get) and [`UnsafeCell::raw_get`](https://doc.rust-lang.org/std/cell/struct.UnsafeCell.html#method.raw_get). Although there might be a desire to also make this legal at some point in the future, that part is outside the scope of this PR. Also see this relevant [Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/136281-t-lang.2Fwg-unsafe-code-guidelines/topic/transmuting.20.26.20-.3E.20.26mut).

# Alternatives
Instead of adding a new documentation promise, it's also possible to add a new method to `UnsafeCell<T>` with signature `pub fn from_ptr_bikeshed(ptr: *mut T) -> *const UnsafeCell<T>` which indirectly only allows one-way casting to `*const UnsafeCell<T>`.

20 months agoAuto merge of #102931 - camsteffen:inline-overlapping-impls, r=cjgillot
bors [Sun, 16 Oct 2022 02:05:30 +0000 (02:05 +0000)]
Auto merge of #102931 - camsteffen:inline-overlapping-impls, r=cjgillot

Make `overlapping_impls` not generic

Trying to win back perf from #101632.

20 months agoAdd MaybeUninit array transpose impls
Alex Saveau [Sat, 15 Oct 2022 22:57:19 +0000 (15:57 -0700)]
Add MaybeUninit array transpose impls

Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
20 months agoAuto merge of #100579 - joboet:sync_mutex_everywhere, r=thomcc
bors [Sat, 15 Oct 2022 22:49:30 +0000 (22:49 +0000)]
Auto merge of #100579 - joboet:sync_mutex_everywhere, r=thomcc

std: use `sync::Mutex` for internal statics

Since `sync::Mutex` is now `const`-constructible, it can be used for internal statics, removing the need for `sys_common::StaticMutex`. This adds some extra allocations on platforms which need to box their mutexes (currently SGX and some UNIX), but these will become unnecessary with the lock improvements tracked in #93740.

I changed the program argument implementation on Hermit, it does not need `Mutex` but can use atomics like some UNIX systems (ping `@mkroening` `@stlankes).`

20 months agopretty: fix to print some lifetimes on HIR pretty-print
Yutaro Ohno [Fri, 14 Oct 2022 08:53:09 +0000 (17:53 +0900)]
pretty: fix to print some lifetimes on HIR pretty-print

20 months agoAdd more GUI tests for settings page
Guillaume Gomez [Sat, 15 Oct 2022 13:59:11 +0000 (15:59 +0200)]
Add more GUI tests for settings page

20 months agoFix display of settings page
Guillaume Gomez [Sat, 15 Oct 2022 13:59:00 +0000 (15:59 +0200)]
Fix display of settings page

20 months agoAuto merge of #102895 - Nilstrieb:query-cleanups, r=cjgillot
bors [Sat, 15 Oct 2022 13:30:15 +0000 (13:30 +0000)]
Auto merge of #102895 - Nilstrieb:query-cleanups, r=cjgillot

Get rid of `rustc_query_description!`

**I am not entirely sure whether this is an improvement and would like to get your feedback on it.**

Helps with #96524.

Queries can provide an arbitrary expression for their description and their caching behavior. Before, these expressions where stored in a `rustc_query_description` macro emitted by the `rustc_queries` macro, and then used in `rustc_query_impl` to fill out the methods for the `QueryDescription` trait.

Instead, we now emit two new modules from `rustc_queries` containing the functions with the expressions. `rustc_query_impl` calls these functions now instead of invoking the macro.

Since we are now defining some of the functions in `rustc_middle::query`, we now need all the imports for the key types mthere as well.

r? `@cjgillot`

20 months agoAuto merge of #103083 - Dylan-DPC:rollup-97cvwdv, r=Dylan-DPC
bors [Sat, 15 Oct 2022 10:45:36 +0000 (10:45 +0000)]
Auto merge of #103083 - Dylan-DPC:rollup-97cvwdv, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #102773 (Use semaphores for thread parking on Apple platforms)
 - #102884 (resolve: Some cleanup, asserts and tests for lifetime ribs)
 - #102954 (Add missing checks for `doc(cfg_hide(...))`)
 - #102998 (Drop temporaries created in a condition, even if it's a let chain)
 - #103003 (Fix `suggest_floating_point_literal` ICE)
 - #103041 (Update cargo)

Failed merges:

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

20 months agoRollup merge of #103041 - weihanglo:update-cargo, r=ehuss
Dylan DPC [Sat, 15 Oct 2022 10:15:33 +0000 (15:45 +0530)]
Rollup merge of #103041 - weihanglo:update-cargo, r=ehuss

Update cargo

12 commits in b8f30cb23c4e5f20854a4f683325782b7cff9837..b332991a57c9d055f1864de1eed93e2178d49440 2022-10-10 19:16:06 +0000 to 2022-10-13 22:05:28 +0000
- Differentiate the warning when an alias (built-in or user-defined) shadows an external subcommand (rust-lang/cargo#11170)
- chore: Update tests for latest clap (rust-lang/cargo#11235)
- feat(publish): Support 'publish.timeout' config behind '-Zpublish-timeout' (rust-lang/cargo#11230)
- Add missing edition (rust-lang/cargo#11231)
- doc(profiles): add module level doc (rust-lang/cargo#11219)
- refactor(publish): Clarify which SourceId is being used (rust-lang/cargo#11216)
- Add new SourceKind::SparseRegistry to differentiate sparse registries (rust-lang/cargo#11209)
- Fix deadlock when build scripts are waiting for input on stdin (rust-lang/cargo#11205)
- refactor: New variant `FeaturesFor::ArtifactDep` (rust-lang/cargo#11184)
- Fix rustdoc warning about unclosed HTML tag (rust-lang/cargo#11221)
- refactor(tests): Prepare for wait-for-publish test changes (rust-lang/cargo#11210)
- Add configuration option for controlling crates.io protocol (rust-lang/cargo#11215)

20 months agoRollup merge of #103003 - TaKO8Ki:fix-102989, r=compiler-errors
Dylan DPC [Sat, 15 Oct 2022 10:15:33 +0000 (15:45 +0530)]
Rollup merge of #103003 - TaKO8Ki:fix-102989, r=compiler-errors

Fix `suggest_floating_point_literal` ICE

Fixes #102989

20 months agoRollup merge of #102998 - nathanwhit:let-chains-drop-order, r=eholk
Dylan DPC [Sat, 15 Oct 2022 10:15:32 +0000 (15:45 +0530)]
Rollup merge of #102998 - nathanwhit:let-chains-drop-order, r=eholk

Drop temporaries created in a condition, even if it's a let chain

Fixes #100513.

During the lowering from AST to HIR we wrap expressions acting as conditions in a `DropTemps` expression so that any temporaries created in the condition are dropped after the condition is executed. Effectively this means we transform

```rust
if Some(1).is_some() { .. }
```

into (roughly)

```rust
if { let _t = Some(1).is_some(); _t } { .. }
```

so that if we create any temporaries, they're lifted into the new scope surrounding the condition, so for example something along the lines of

```rust
if { let temp = Some(1); let _t = temp.is_some(); _t }.
```

Before this PR, if the condition contained any let expressions we would not introduce that new scope, instead leaving the condition alone. This meant that in a let-chain like

```rust
if get_drop("first").is_some() && let None = get_drop("last") {
        println!("second");
} else { .. }
```

the temporary created for `get_drop("first")` would be lifted into the _surrounding block_, which caused it to be dropped after the execution of the entire `if` expression.

After this PR, we wrap everything but the `let` expression in terminating scopes. The upside to this solution is that it's minimally invasive, but the downside is that in the worst case, an expression with `let` exprs interspersed like

```rust
if get_drop("first").is_some()
    && let Some(_a) = get_drop("fifth")
    && get_drop("second").is_some()
    && let Some(_b) = get_drop("fourth") { .. }
```

gets _multiple_ new scopes, roughly

```rust
if { let _t = get_drop("first").is_some(); _t }
    && let Some(_a) = get_drop("fifth")
    && { let _t = get_drop("second").is_some(); _t }
    && let Some(_b) = get_drop("fourth") { .. }
```

so instead of all of the temporaries being dropped at the end of the entire condition, they will be dropped right after they're evaluated (before the subsequent `let` expr). So while I'd say the drop behavior around let-chains is _less_ surprising after this PR, it still might not exactly match what people might expect.

For tests, I've just extended the drop order tests added in #100526. I'm not sure if that's the best way to go about it, though, so suggestions are welcome.

20 months agoRollup merge of #102954 - GuillaumeGomez:cfg-hide-attr-checks, r=Manishearth
Dylan DPC [Sat, 15 Oct 2022 10:15:32 +0000 (15:45 +0530)]
Rollup merge of #102954 - GuillaumeGomez:cfg-hide-attr-checks, r=Manishearth

Add missing checks for `doc(cfg_hide(...))`

Part of  #43781.

The `doc(cfg_hide(...))` attribute can only be used at the crate level and takes a list of attributes as argument.

r? ```@Manishearth```

20 months agoRollup merge of #102884 - petrochenkov:liferib, r=cjgillot
Dylan DPC [Sat, 15 Oct 2022 10:15:31 +0000 (15:45 +0530)]
Rollup merge of #102884 - petrochenkov:liferib, r=cjgillot

resolve: Some cleanup, asserts and tests for lifetime ribs

Follow up to https://github.com/rust-lang/rust/pull/98279 and friends.
r? ``@cjgillot``

20 months agoRollup merge of #102773 - joboet:apple_parker, r=thomcc
Dylan DPC [Sat, 15 Oct 2022 10:15:30 +0000 (15:45 +0530)]
Rollup merge of #102773 - joboet:apple_parker, r=thomcc

Use semaphores for thread parking on Apple platforms

Currently we use a mutex-condvar pair for thread parking on Apple systems. Unfortunately, `pthread_cond_timedwait` uses the real-time clock for measuring time, which causes problems when the system time changes. The parking implementation in this PR uses a semaphore instead, which measures monotonic time by default, avoiding these issues. As a further benefit, this has the potential to improve performance a bit, since `unpark` does not need to wait for a lock to be released.

Since the Mach semaphores are poorly documented (I could not find availability or stability guarantees for instance), this uses a [dispatch semaphore](https://developer.apple.com/documentation/dispatch/dispatch_semaphore?language=objc) instead. While it adds a layer of indirection (it uses Mach semaphores internally), the overhead is probably negligible.

Tested on macOS 12.5.

r? ``````@thomcc``````

20 months agoSurround type with backticks
Gimgim [Sat, 15 Oct 2022 09:58:29 +0000 (15:28 +0530)]
Surround type with backticks

20 months agoAuto merge of #101832 - compiler-errors:dyn-star-plus, r=eholk
bors [Sat, 15 Oct 2022 07:36:38 +0000 (07:36 +0000)]
Auto merge of #101832 - compiler-errors:dyn-star-plus, r=eholk

Make `dyn*` casts into a coercion, allow `dyn*` upcasting

I know that `dyn*` is likely not going to be a feature exposed to surface Rust, but this makes it slightly more ergonomic to write tests for these types anyways. ... and this was just fun to implement anyways.

1. Make `dyn*` into a coercion instead of a cast
2. Enable `dyn*` upcasting since we basically get it for free
3. Simplify some of the cast checking code since we're using the coercion path now

r? `@eholk` but feel free to reassign
cc `@nikomatsakis` and `@tmandry` who might care about making `dyn*` casts into a coercion

20 months agoAuto merge of #99292 - Aaron1011:stability-use-tree, r=cjgillot
bors [Sat, 15 Oct 2022 04:27:15 +0000 (04:27 +0000)]
Auto merge of #99292 - Aaron1011:stability-use-tree, r=cjgillot

Correctly handle path stability for 'use tree' items

PR #95956 started checking the stability of path segments.
However, this was not applied to 'use tree' items
(e.g. 'use some::path::{ItemOne, ItemTwo}') due to the way
that we desugar these items in HIR lowering.

This PR modifies 'use tree' lowering to preserve resolution
information, which is needed by stability checking.

20 months agoAuto merge of #98033 - joshtriplett:is-terminal-fd-handle, r=thomcc
bors [Sat, 15 Oct 2022 01:42:28 +0000 (01:42 +0000)]
Auto merge of #98033 - joshtriplett:is-terminal-fd-handle, r=thomcc

Add `IsTerminal` trait to determine if a descriptor or handle is a terminal

The UNIX implementation uses `isatty`. The Windows implementation uses
the same logic the `atty` crate uses, including the hack needed to
detect msys terminals.

Implement this trait for `Stdin`/`Stdout`/`Stderr`/`File` on all
platforms. On Unix, implement it for `BorrowedFd`/`OwnedFd`. On Windows,
implement it for `BorrowedHandle`/`OwnedHandle`.

Based on https://github.com/rust-lang/rust/pull/91121

Co-authored-by: Matt Wilkinson <mattwilki17@gmail.com>
20 months agoUse Align8 to avoid misalignment if the allocator or Vec doesn't align allocations
Josh Triplett [Fri, 9 Sep 2022 13:01:26 +0000 (15:01 +0200)]
Use Align8 to avoid misalignment if the allocator or Vec doesn't align allocations

20 months agoRewrite FILE_NAME_INFO handling to avoid enlarging slice reference
Josh Triplett [Wed, 24 Aug 2022 13:32:16 +0000 (15:32 +0200)]
Rewrite FILE_NAME_INFO handling to avoid enlarging slice reference

Rather than referencing a slice's pointer and then creating a new slice
with a longer length, offset from the base structure pointer instead.
This makes some choices of Rust semantics happier.

20 months agoMake is_terminal fail fast if a process has no console at all
Josh Triplett [Mon, 20 Jun 2022 01:11:39 +0000 (18:11 -0700)]
Make is_terminal fail fast if a process has no console at all

If a process has no console, it'll have NULL in place of a console
handle, so return early with `false` in that case without making any OS
calls.

20 months agoAdd `IsTerminal` trait to determine if a descriptor or handle is a terminal
Josh Triplett [Sun, 12 Jun 2022 21:10:18 +0000 (14:10 -0700)]
Add `IsTerminal` trait to determine if a descriptor or handle is a terminal

The UNIX and WASI implementations use `isatty`. The Windows
implementation uses the same logic the `atty` crate uses, including the
hack needed to detect msys terminals.

Implement this trait for `File` and for `Stdin`/`Stdout`/`Stderr` and
their locked counterparts on all platforms. On UNIX and WASI, implement
it for `BorrowedFd`/`OwnedFd`. On Windows, implement it for
`BorrowedHandle`/`OwnedHandle`.

Based on https://github.com/rust-lang/rust/pull/91121

Co-authored-by: Matt Wilkinson <mattwilki17@gmail.com>
20 months agoAuto merge of #103069 - matthiaskrgr:rollup-xxsx6sk, r=matthiaskrgr
bors [Fri, 14 Oct 2022 22:56:53 +0000 (22:56 +0000)]
Auto merge of #103069 - matthiaskrgr:rollup-xxsx6sk, r=matthiaskrgr

Rollup of 9 pull requests

Successful merges:

 - #102092 (refactor: use grep -E/-F instead of fgrep/egrep)
 - #102781 (Improved documentation for `std::io::Error`)
 - #103017 (Avoid dropping TLS Key on sgx)
 - #103039 (checktools: fix comments)
 - #103045 (Remove leading newlines from integer primitive doc examples)
 - #103047 (Update browser-ui-test version to fix some flaky tests)
 - #103054 (Clean up rust-logo rustdoc GUI test)
 - #103059 (Fix `Duration::{try_,}from_secs_f{32,64}(-0.0)`)
 - #103067 (More alphabetical sorting)

Failed merges:

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

20 months agoRollup merge of #103067 - Nilstrieb:tidy-likes-the-alphabet, r=jackh726
Matthias Krüger [Fri, 14 Oct 2022 21:43:46 +0000 (23:43 +0200)]
Rollup merge of #103067 - Nilstrieb:tidy-likes-the-alphabet, r=jackh726

More alphabetical sorting

Sort and enforce a few more things. The biggest change here is sorting all target features.

20 months agoRollup merge of #103059 - beetrees:duration-from-negative-zero, r=thomcc
Matthias Krüger [Fri, 14 Oct 2022 21:43:46 +0000 (23:43 +0200)]
Rollup merge of #103059 - beetrees:duration-from-negative-zero, r=thomcc

Fix `Duration::{try_,}from_secs_f{32,64}(-0.0)`

Make `Duration::{try_,}from_secs_f{32,64}(-0.0)` return `Duration::ZERO` (as they did before #90247) instead of erroring/panicking.

I'll update this PR to remove the `#![feature(duration_checked_float)]` if #102271 is merged before this PR.

Tracking issue for `try_from_secs_f{32,64}`: #83400

20 months agoRollup merge of #103054 - GuillaumeGomez:cleanup-rust-logo-test, r=notriddle
Matthias Krüger [Fri, 14 Oct 2022 21:43:45 +0000 (23:43 +0200)]
Rollup merge of #103054 - GuillaumeGomez:cleanup-rust-logo-test, r=notriddle

Clean up rust-logo rustdoc GUI test

r? `@notriddle`

20 months agoRollup merge of #103047 - GuillaumeGomez:update-browser-ui-test, r=notriddle
Matthias Krüger [Fri, 14 Oct 2022 21:43:45 +0000 (23:43 +0200)]
Rollup merge of #103047 - GuillaumeGomez:update-browser-ui-test, r=notriddle

Update browser-ui-test version to fix some flaky tests

Part of #93784.

It should fix the new spurious failure found in https://github.com/rust-lang/rust/pull/102744.

r? ``@notriddle``

20 months agoRollup merge of #103045 - lukas-code:blank-lines, r=GuillaumeGomez
Matthias Krüger [Fri, 14 Oct 2022 21:43:44 +0000 (23:43 +0200)]
Rollup merge of #103045 - lukas-code:blank-lines, r=GuillaumeGomez

Remove leading newlines from integer primitive doc examples

fixes https://github.com/rust-lang/rust/issues/103043

```@rustbot``` label +A-docs

20 months agoRollup merge of #103039 - RalfJung:checktools, r=Dylan-DPC
Matthias Krüger [Fri, 14 Oct 2022 21:43:44 +0000 (23:43 +0200)]
Rollup merge of #103039 - RalfJung:checktools, r=Dylan-DPC

checktools: fix comments

This bothers me each time I see it, time to fix it. ;)
r? ```@Mark-Simulacrum```

20 months agoRollup merge of #103017 - fortanix:raoul/sgx_tls_fix, r=ChrisDenton
Matthias Krüger [Fri, 14 Oct 2022 21:43:43 +0000 (23:43 +0200)]
Rollup merge of #103017 - fortanix:raoul/sgx_tls_fix, r=ChrisDenton

Avoid dropping TLS Key on sgx

#102655 reenabled dropping thread local `Key` on every platform ([library/std/src/sys_common/thread_local_key.rs](https://github.com/rust-lang-ci/rust/commit/fa0ca783f89a83046e6ce0383385ba5b28296435#diff-5cb9acf9e243f35c975fa9fbac4885519dc104626bc03610dfa7a20bc79641ceL237-R215)). That's causing problems at least for sgx.

cc: `@jethrogb` `@ChrisDenton`

20 months agoRollup merge of #102781 - StackOverflowExcept1on:master, r=joshtriplett
Matthias Krüger [Fri, 14 Oct 2022 21:43:43 +0000 (23:43 +0200)]
Rollup merge of #102781 - StackOverflowExcept1on:master, r=joshtriplett

Improved documentation for `std::io::Error`

20 months agoRollup merge of #102092 - kxxt:patch-1, r=joshtriplett
Matthias Krüger [Fri, 14 Oct 2022 21:43:42 +0000 (23:43 +0200)]
Rollup merge of #102092 - kxxt:patch-1, r=joshtriplett

refactor: use grep -E/-F instead of fgrep/egrep

`egrep` and `fgrep` are obsolescent now. This PR updates  all `egrep` and `fgrep` commands to `grep -E` and `grep -F`.

Running egrep/fgrep command with grep v3.8 will output the following warning to stderr:

```
egrep: warning: egrep is obsolescent; using grep -E
```

- https://www.phoronix.com/news/GNU-Grep-3.8-Stop-egrep-fgrep
- https://lists.gnu.org/archive/html/info-gnu/2022-09/msg00001.html

20 months agoRemove the `describe` method from the `QueryDescription` trait
nils [Thu, 13 Oct 2022 19:18:36 +0000 (21:18 +0200)]
Remove the `describe` method from the `QueryDescription` trait

It was called directly already, but now it's even more useless since it
just forwards to the free function. Call it directly.

20 months agoGet rid of `rustc_query_description!`
Nilstrieb [Mon, 10 Oct 2022 18:03:19 +0000 (20:03 +0200)]
Get rid of `rustc_query_description!`

Queries can provide an arbitrary expression for their description and
their caching behavior. Before, these expressions where stored in a
`rustc_query_description` macro emitted by the `rustc_queries` macro,
and then used in `rustc_query_impl` to fill out the methods for the
`QueryDescription` trait.

Instead, we now emit two new modules from `rustc_queries` containing the
functions with the expressions. `rustc_query_impl` calls these functions
now instead of invoking the macro.

Since we are now defining some of the functions in
`rustc_middle::query`, we now need all the imports for the key types
there as well.

20 months agoRemove unsued variable in query macro
Nilstrieb [Mon, 10 Oct 2022 16:11:53 +0000 (18:11 +0200)]
Remove unsued variable in query macro

20 months agoAuto merge of #101030 - woppopo:const_location, r=scottmcm
bors [Fri, 14 Oct 2022 20:15:51 +0000 (20:15 +0000)]
Auto merge of #101030 - woppopo:const_location, r=scottmcm

Constify `Location` methods

Tracking issue: #102911

Example: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=4789884c2f16ec4fb0e0405d86b794f5

20 months agoSort target features alphabetically
nils [Fri, 14 Oct 2022 20:01:18 +0000 (22:01 +0200)]
Sort target features alphabetically

20 months agoAlso run alphabetical check in src and library
nils [Fri, 14 Oct 2022 20:00:44 +0000 (22:00 +0200)]
Also run alphabetical check in src and library

20 months agoAdd some tidy-alphabetical
nils [Fri, 14 Oct 2022 19:18:03 +0000 (21:18 +0200)]
Add some tidy-alphabetical

20 months agoremove no_core feature
Takayuki Maeda [Fri, 14 Oct 2022 17:45:11 +0000 (02:45 +0900)]
remove no_core feature

20 months agoAuto merge of #102783 - RalfJung:tls, r=thomcc
bors [Fri, 14 Oct 2022 16:43:46 +0000 (16:43 +0000)]
Auto merge of #102783 - RalfJung:tls, r=thomcc

sync thread_local key conditions exactly with what the macro uses

This makes the `cfg` in `mod.rs` syntactically the same as those in `local.rs`.

I don't think this should actually change anything, but seems better to be consistent?
I looked into this due to https://github.com/rust-lang/rust/issues/102549, but this PR would make it *less* likely that `__OsLocalKeyInner` is going to get provided, so this cannot help with that issue.

r? `@thomcc`

20 months agoBugfix: keep TLS data in sync
Raoul Strackx [Thu, 13 Oct 2022 16:58:25 +0000 (18:58 +0200)]
Bugfix: keep TLS data in sync

20 months agoFix `Duration::{try_,}from_secs_f{32,64}(-0.0)`
beetrees [Fri, 14 Oct 2022 14:51:20 +0000 (15:51 +0100)]
Fix `Duration::{try_,}from_secs_f{32,64}(-0.0)`

20 months agoAuto merge of #102529 - colinba:master, r=joshtriplett
bors [Fri, 14 Oct 2022 13:41:40 +0000 (13:41 +0000)]
Auto merge of #102529 - colinba:master, r=joshtriplett

Detect and reject out-of-range integers in format string literals

Until now out-of-range integers in format string literals were silently ignored. They wrapped around to zero at usize::MAX, producing unexpected results.

When using debug builds of rustc, such integers in format string literals even cause an 'attempt to add with overflow' panic in rustc.

Fix this by producing an error diagnostic for integers in format string literals which do not fit into usize.

Fixes #102528

20 months agoClean up rust-logo rustdoc GUI test
Guillaume Gomez [Fri, 14 Oct 2022 12:55:11 +0000 (14:55 +0200)]
Clean up rust-logo rustdoc GUI test

20 months agoTweak grammar
Josh Triplett [Fri, 14 Oct 2022 11:17:07 +0000 (12:17 +0100)]
Tweak grammar

20 months agoAuto merge of #103048 - Dylan-DPC:rollup-47r62js, r=Dylan-DPC
bors [Fri, 14 Oct 2022 10:54:32 +0000 (10:54 +0000)]
Auto merge of #103048 - Dylan-DPC:rollup-47r62js, r=Dylan-DPC

Rollup of 8 pull requests

Successful merges:

 - #102847 (impl AsFd and AsRawFd for io::{Stdin, Stdout, Stderr}, not the sys versions)
 - #102856 (Only test duplicate inherent impl items in a single place)
 - #102914 (Migrate css highlight without change)
 - #102938 (Move some tests to more reasonable directories)
 - #103015 (fix a typo)
 - #103018 (More dupe word typos)
 - #103025 (rustdoc: remove unused CSS `.search-container > *`)
 - #103031 (Suppress irrefutable let patterns lint for prefixes in match guards)

Failed merges:

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

20 months agoRollup merge of #103031 - est31:match_guard_irrefutable_let, r=oli-obk
Dylan DPC [Fri, 14 Oct 2022 10:49:16 +0000 (16:19 +0530)]
Rollup merge of #103031 - est31:match_guard_irrefutable_let, r=oli-obk

Suppress irrefutable let patterns lint for prefixes in match guards

In match guards, irrefutable prefixes might use the bindings created by the match pattern. Ideally, we check for this, but we can do the next best thing and just not lint for irrefutable prefixes in match guards.

Fixes #98361

20 months agoRollup merge of #103025 - notriddle:notriddle/search-container-star, r=GuillaumeGomez
Dylan DPC [Fri, 14 Oct 2022 10:49:16 +0000 (16:19 +0530)]
Rollup merge of #103025 - notriddle:notriddle/search-container-star, r=GuillaumeGomez

rustdoc: remove unused CSS `.search-container > *`

The two items it was really intended to target were the buttons, and those both need to have the style set directly on them anyway because the buttons are both child elements of wrappers.

https://github.com/rust-lang/rust/blob/6b3ede3f7bc502eba7bbd202b4b9312d812adcd7/src/librustdoc/html/static/css/rustdoc.css#L1406-L1411

20 months agoRollup merge of #103018 - Rageking8:more-dupe-word-typos, r=TaKO8Ki
Dylan DPC [Fri, 14 Oct 2022 10:49:15 +0000 (16:19 +0530)]
Rollup merge of #103018 - Rageking8:more-dupe-word-typos, r=TaKO8Ki

More dupe word typos

I only picked those changes (from the regex search) that I am pretty certain doesn't change meaning and is just a typo fix. Do correct me if any fix is undesirable and I can revert those. Thanks.

20 months agoRollup merge of #103015 - whentojump:patch, r=compiler-errors
Dylan DPC [Fri, 14 Oct 2022 10:49:15 +0000 (16:19 +0530)]
Rollup merge of #103015 - whentojump:patch, r=compiler-errors

fix a typo

20 months agoRollup merge of #102938 - c410-f3r:here-we-go-again, r=petrochenkov
Dylan DPC [Fri, 14 Oct 2022 10:49:13 +0000 (16:19 +0530)]
Rollup merge of #102938 - c410-f3r:here-we-go-again, r=petrochenkov

Move some tests to more reasonable directories

r? ``@petrochenkov``

20 months agoRollup merge of #102914 - GuillaumeGomez:migrate-css-highlight-without-change, r...
Dylan DPC [Fri, 14 Oct 2022 10:49:13 +0000 (16:19 +0530)]
Rollup merge of #102914 - GuillaumeGomez:migrate-css-highlight-without-change, r=notriddle

Migrate css highlight without change

This is a "previous" version of https://github.com/rust-lang/rust/pull/102663: only migrating to CSS variables, no changes. It's a bit more verbose because rules are not coherent between themes.

r? ``@notriddle``

20 months agoRollup merge of #102856 - cjgillot:impl-single-check, r=petrochenkov
Dylan DPC [Fri, 14 Oct 2022 10:49:12 +0000 (16:19 +0530)]
Rollup merge of #102856 - cjgillot:impl-single-check, r=petrochenkov

Only test duplicate inherent impl items in a single place

Based on https://github.com/rust-lang/rust/pull/100387

r? ``@petrochenkov``

20 months agoRollup merge of #102847 - joshtriplett:bugfix-impl-fd-traits-for-io-types, r=m-ou-se
Dylan DPC [Fri, 14 Oct 2022 10:49:12 +0000 (16:19 +0530)]
Rollup merge of #102847 - joshtriplett:bugfix-impl-fd-traits-for-io-types, r=m-ou-se

impl AsFd and AsRawFd for io::{Stdin, Stdout, Stderr}, not the sys versions

https://github.com/rust-lang/rust/pull/100892 implemented AsFd for the
sys versions, rather than for the public types. Change the
implementations to apply to the public types.

20 months agoUpdate browser-ui-test version to fix some flaky tests
Guillaume Gomez [Fri, 14 Oct 2022 10:43:42 +0000 (12:43 +0200)]
Update browser-ui-test version to fix some flaky tests

20 months agoremove leading newlines from integer primitive doc examples
Lukas Markeffsky [Fri, 14 Oct 2022 10:14:29 +0000 (12:14 +0200)]
remove leading newlines from integer primitive doc examples

20 months agoAdd UI test for invalid `doc(cfg_hide(...))` attributes
Guillaume Gomez [Wed, 12 Oct 2022 09:32:26 +0000 (11:32 +0200)]
Add UI test for invalid `doc(cfg_hide(...))` attributes

20 months agoAdd missing checks for `doc(cfg_hide(...))` attribute
Guillaume Gomez [Wed, 12 Oct 2022 09:32:00 +0000 (11:32 +0200)]
Add missing checks for `doc(cfg_hide(...))` attribute

20 months agoUpdate cargo
Weihang Lo [Fri, 14 Oct 2022 08:58:48 +0000 (09:58 +0100)]
Update cargo

12 commits in b8f30cb23c4e5f20854a4f683325782b7cff9837..b332991a57c9d055f1864de1eed93e2178d49440
2022-10-10 19:16:06 +0000 to 2022-10-13 22:05:28 +0000
- Differentiate the warning when an alias (built-in or user-defined) shadows an external subcommand (rust-lang/cargo#11170)
- chore: Update tests for latest clap (rust-lang/cargo#11235)
- feat(publish): Support 'publish.timeout' config behind '-Zpublish-timeout' (rust-lang/cargo#11230)
- Add missing edition (rust-lang/cargo#11231)
- doc(profiles): add module level doc (rust-lang/cargo#11219)
- refactor(publish): Clarify which SourceId is being used (rust-lang/cargo#11216)
- Add new SourceKind::SparseRegistry to differentiate sparse registries (rust-lang/cargo#11209)
- Fix deadlock when build scripts are waiting for input on stdin (rust-lang/cargo#11205)
- refactor: New variant `FeaturesFor::ArtifactDep` (rust-lang/cargo#11184)
- Fix rustdoc warning about unclosed HTML tag (rust-lang/cargo#11221)
- refactor(tests): Prepare for wait-for-publish test changes (rust-lang/cargo#11210)
- Add configuration option for controlling crates.io protocol (rust-lang/cargo#11215)

20 months agowasm-ignore some tests that access thread-local private details
Ralf Jung [Fri, 14 Oct 2022 06:27:12 +0000 (08:27 +0200)]
wasm-ignore some tests that access thread-local private details

20 months agoAuto merge of #102695 - compiler-errors:int-and-float-trivial-copy, r=lcnr
bors [Fri, 14 Oct 2022 07:41:55 +0000 (07:41 +0000)]
Auto merge of #102695 - compiler-errors:int-and-float-trivial-copy, r=lcnr

Int and float inference variables are trivially copy

Fixes #102645

20 months agochecktools: fix comments
Ralf Jung [Fri, 14 Oct 2022 06:40:55 +0000 (08:40 +0200)]
checktools: fix comments

20 months agoAddress nits, add test for implicit dyn-star coercion without feature gate
Michael Goulet [Fri, 14 Oct 2022 04:55:07 +0000 (04:55 +0000)]
Address nits, add test for implicit dyn-star coercion without feature gate

20 months agoRemove CastCheckResult since it's unused
Michael Goulet [Wed, 14 Sep 2022 23:42:25 +0000 (23:42 +0000)]
Remove CastCheckResult since it's unused

20 months agoAdd test
Michael Goulet [Wed, 5 Oct 2022 03:35:50 +0000 (03:35 +0000)]
Add test

20 months agofloat and int vars are trivially copy
Michael Goulet [Wed, 5 Oct 2022 03:13:32 +0000 (03:13 +0000)]
float and int vars are trivially copy

20 months agomore dupe word typos
Rageking8 [Thu, 13 Oct 2022 16:25:34 +0000 (00:25 +0800)]
more dupe word typos

20 months agoAllow dyn* upcasting
Michael Goulet [Wed, 14 Sep 2022 23:28:14 +0000 (23:28 +0000)]
Allow dyn* upcasting

20 months agoAuto merge of #102684 - JhonnyBillM:delete-target-data-layout-errors-wrapper, r=davidtwco
bors [Fri, 14 Oct 2022 04:35:22 +0000 (04:35 +0000)]
Auto merge of #102684 - JhonnyBillM:delete-target-data-layout-errors-wrapper, r=davidtwco

Move `IntoDiagnostic` conformance for `TargetDataLayoutErrors` into `rustc_errors`

Addressed this suggestion https://github.com/rust-lang/rust/pull/101558#issuecomment-1243830009.

This way we comply with the Coherence rule given that `IntoDiagnostic` trait is defined in `rustc_errors`, and almost all other crates depend on it.

20 months agonormalize stderr
Takayuki Maeda [Thu, 13 Oct 2022 06:07:39 +0000 (15:07 +0900)]
normalize stderr

20 months agocheck if the self type is `ty::Float` before getting second substs
Takayuki Maeda [Thu, 13 Oct 2022 04:07:56 +0000 (13:07 +0900)]
check if the self type is `ty::Float` before getting second substs

20 months agoMake dyn* cast into a coercion
Michael Goulet [Wed, 14 Sep 2022 23:20:03 +0000 (23:20 +0000)]
Make dyn* cast into a coercion

20 months agoUpdate pkg-config
Alyssa Ross [Fri, 14 Oct 2022 01:42:23 +0000 (01:42 +0000)]
Update pkg-config

20 months agoValidate MIR in the `drop_order` test
Nathan Whitaker [Fri, 14 Oct 2022 01:29:25 +0000 (18:29 -0700)]
Validate MIR in the `drop_order` test

20 months agoAuto merge of #103026 - matthiaskrgr:rollup-gfmlfkt, r=matthiaskrgr
bors [Fri, 14 Oct 2022 01:28:06 +0000 (01:28 +0000)]
Auto merge of #103026 - matthiaskrgr:rollup-gfmlfkt, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #103000 (Add suggestion to the "missing native library" error)
 - #103006 (rustdoc: don't ICE on `TyKind::Typeof`)
 - #103008 (replace ReErased with fresh region vars in opaque types)
 - #103011 (Improve rustdoc `unsafe-fn` GUI test)
 - #103013 (Add new bootstrap entrypoints to triagebot)
 - #103016 (Ensure enum cast moves)
 - #103021 (Add links to relevant pages to find constraint information)

Failed merges:

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

20 months agoLower condition directly from AST to HIR
Nathan Whitaker [Fri, 14 Oct 2022 01:20:39 +0000 (18:20 -0700)]
Lower condition directly from AST to HIR

20 months agoSuppress irrefutable let patterns lint for prefixes in match guards
est31 [Thu, 13 Oct 2022 23:46:24 +0000 (01:46 +0200)]
Suppress irrefutable let patterns lint for prefixes in match guards

In match guards, irrefutable prefixes might use the bindings created
by the match pattern. Ideally, we check for this, but we can do the
next best thing and just not lint for irrefutable prefixes in match
guards.

20 months agoRollup merge of #103021 - GuillaumeGomez:constraint-pages, r=Amanieu
Matthias Krüger [Thu, 13 Oct 2022 22:45:20 +0000 (00:45 +0200)]
Rollup merge of #103021 - GuillaumeGomez:constraint-pages, r=Amanieu

Add links to relevant pages to find constraint information

I think it can be quite helpful to find this information more quickly.

r? `@Amanieu`

20 months agoRollup merge of #103016 - nbdd0121:enum, r=pnkfelix
Matthias Krüger [Thu, 13 Oct 2022 22:45:19 +0000 (00:45 +0200)]
Rollup merge of #103016 - nbdd0121:enum, r=pnkfelix

Ensure enum cast moves

Fix #102389

r? ``@pnkfelix``

20 months agoRollup merge of #103013 - Nilstrieb:patch-1, r=jyn514
Matthias Krüger [Thu, 13 Oct 2022 22:45:19 +0000 (00:45 +0200)]
Rollup merge of #103013 - Nilstrieb:patch-1, r=jyn514

Add new bootstrap entrypoints to triagebot

They haven't been added yet, as seen in #103007.

r? ``@jyn514``

20 months agoRollup merge of #103011 - GuillaumeGomez:improve-unsafe-fn-gui-test, r=notriddle
Matthias Krüger [Thu, 13 Oct 2022 22:45:18 +0000 (00:45 +0200)]
Rollup merge of #103011 - GuillaumeGomez:improve-unsafe-fn-gui-test, r=notriddle

Improve rustdoc `unsafe-fn` GUI test

r? ``@notriddle``

20 months agoRollup merge of #103008 - aliemjay:opaque-parent-substs, r=oli-obk
Matthias Krüger [Thu, 13 Oct 2022 22:45:18 +0000 (00:45 +0200)]
Rollup merge of #103008 - aliemjay:opaque-parent-substs, r=oli-obk

replace ReErased with fresh region vars in opaque types

See inline comments.

Prior art #102943. cc ``@compiler-errors`` ``@oli-obk``

Fixes #100267
Fixes #101940
Fixes #102649
Fixes #102510

20 months agoRollup merge of #103006 - WaffleLapkin:rustdoc_dont, r=compiler-errors
Matthias Krüger [Thu, 13 Oct 2022 22:45:17 +0000 (00:45 +0200)]
Rollup merge of #103006 - WaffleLapkin:rustdoc_dont, r=compiler-errors

rustdoc: don't ICE on `TyKind::Typeof`

Fixes #102986

I'm not sure why rustdoc started seeing `TyKind::Typeof` all of a sudden (the code being editted was last touched 3 months ago), probably something to do with error recovery? idk.

20 months agoRollup merge of #103000 - wesleywiser:suggest_libname, r=compiler-errors
Matthias Krüger [Thu, 13 Oct 2022 22:45:17 +0000 (00:45 +0200)]
Rollup merge of #103000 - wesleywiser:suggest_libname, r=compiler-errors

Add suggestion to the "missing native library" error

If we fail to locate a native library that we are linking with, it could be the case the user entered a complete file name like `foo.lib` or `libfoo.a` when we expect them to simply provide `foo`.

In this situation, we now detect that case and suggest the user only provide the library name itself.

20 months agoAuto merge of #102700 - oli-obk:0xDEAD_TAIT, r=compiler-errors
bors [Thu, 13 Oct 2022 22:39:05 +0000 (22:39 +0000)]
Auto merge of #102700 - oli-obk:0xDEAD_TAIT, r=compiler-errors

Check hidden types in dead code

fixes #99490

r? `@compiler-errors`

best reviewed commit by commit

20 months agorustdoc: remove unused CSS `.search-container > *`
Michael Howell [Thu, 13 Oct 2022 21:53:57 +0000 (14:53 -0700)]
rustdoc: remove unused CSS `.search-container > *`

The two items it was really intended to target were the buttons, and those
both need to have the style set directly on them anyway because the buttons
are both child elements of wrappers.

20 months agoAdd links to relevant pages to find constraint information
Guillaume Gomez [Thu, 13 Oct 2022 20:05:24 +0000 (22:05 +0200)]
Add links to relevant pages to find constraint information

20 months agoMake overlapping_impls non-generic
Cameron Steffen [Tue, 11 Oct 2022 20:37:11 +0000 (15:37 -0500)]
Make overlapping_impls non-generic

This improves perf

20 months agoReport duplicate definition in impls with overlap check.
Camille GILLOT [Sat, 13 Aug 2022 10:32:01 +0000 (12:32 +0200)]
Report duplicate definition in impls with overlap check.

20 months agoFix test
Gary Guo [Thu, 13 Oct 2022 16:46:33 +0000 (17:46 +0100)]
Fix test

20 months agoBless tests
Gary Guo [Thu, 13 Oct 2022 16:24:27 +0000 (17:24 +0100)]
Bless tests