]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoUpdate library/core/src/slice/mod.rs
Dylan DPC [Thu, 7 Apr 2022 02:44:30 +0000 (04:44 +0200)]
Update library/core/src/slice/mod.rs

Co-authored-by: Janusz Marcinkiewicz <virrages@gmail.com>
2 years agoremove exclamation mark
Dylan DPC [Thu, 7 Apr 2022 02:44:11 +0000 (04:44 +0200)]
remove exclamation mark

Co-authored-by: Janusz Marcinkiewicz <virrages@gmail.com>
2 years agoMessage: Chunks cannot have a size of zero.
Marijn Schouten [Wed, 6 Apr 2022 07:54:43 +0000 (09:54 +0200)]
Message: Chunks cannot have a size of zero.

Add a message to the assertion that chunks cannot have a size of zero.

2 years agoAuto merge of #95711 - Dylan-DPC:rollup-ujss3oi, r=Dylan-DPC
bors [Wed, 6 Apr 2022 03:45:36 +0000 (03:45 +0000)]
Auto merge of #95711 - Dylan-DPC:rollup-ujss3oi, r=Dylan-DPC

Rollup of 4 pull requests

Successful merges:

 - #95659 (Rely on #[link] attribute for unwind on Fuchsia.)
 - #95684 (rustdoc: Fix item info display overflow)
 - #95693 (interp: pass TyCtxt to Machine methods that do not take InterpCx)
 - #95699 (fix: Vec leak when capacity is 0)

Failed merges:

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

2 years agoRollup merge of #95699 - SparkyPotato:master, r=dtolnay
Dylan DPC [Wed, 6 Apr 2022 01:39:09 +0000 (03:39 +0200)]
Rollup merge of #95699 - SparkyPotato:master, r=dtolnay

fix: Vec leak when capacity is 0

When `RawVec::with_capacity_in` is called with capacity 0, an allocation of size 0 is allocated.
However, `<RawVec as Drop>::drop` doesn't deallocate, since it only checks if capacity was 0. Fixed by not allocating when capacity is 0.

2 years agoRollup merge of #95693 - RalfJung:more-context, r=oli-obk
Dylan DPC [Wed, 6 Apr 2022 01:39:08 +0000 (03:39 +0200)]
Rollup merge of #95693 - RalfJung:more-context, r=oli-obk

interp: pass TyCtxt to Machine methods that do not take InterpCx

This just seems like something you might need, so let's consistently have it.

One day we might have to add `ParamEnv` as well, though that seems less likely (and in Miri you can always use `reveal_all` anyway). It might make sense to have a type that packages `TyCtxt` and `ParamEnv`, this pairing occurs quite frequently in rustc...

r? `@oli-obk`

2 years agoRollup merge of #95684 - GuillaumeGomez:fix-item-info-overflow, r=notriddle
Dylan DPC [Wed, 6 Apr 2022 01:39:08 +0000 (03:39 +0200)]
Rollup merge of #95684 - GuillaumeGomez:fix-item-info-overflow, r=notriddle

rustdoc: Fix item info display overflow

I came across this issue when reading local `Iterator` docs (reproduced in this screenshot):

![Screenshot from 2022-04-05 17-45-13](https://user-images.githubusercontent.com/3050060/161798150-769ee838-4768-4df8-9d34-b02eb8104eed.png)

The problem comes from the fact that `span` isn't `display: block` by default. Since `item-info` was already present on `<div>` in other places, I moved the last one to `div` as well.

r? `@notriddle`

2 years agoRollup merge of #95659 - anp:remove-link-print, r=tmandry
Dylan DPC [Wed, 6 Apr 2022 01:39:07 +0000 (03:39 +0200)]
Rollup merge of #95659 - anp:remove-link-print, r=tmandry

Rely on #[link] attribute for unwind on Fuchsia.

Closes #95575.

2 years agoAuto merge of #95469 - ChrisDenton:unsound-read-write, r=joshtriplett
bors [Wed, 6 Apr 2022 01:23:08 +0000 (01:23 +0000)]
Auto merge of #95469 - ChrisDenton:unsound-read-write, r=joshtriplett

Fix unsound `File` methods

This is a draft attempt to fix #81357. *EDIT*: this PR now tackles `read()`, `write()`, `read_at()`, `write_at()` and `read_buf`. Still needs more testing though.

cc `@jstarks,` can you confirm the the Windows team is ok with the Rust stdlib using `NtReadFile` and `NtWriteFile`?

~Also, I'm provisionally using `CancelIo` in a last ditch attempt to recover but I'm not sure that this is actually a good idea. Especially as getting into this state would be a programmer error so aborting the process is justified in any case.~ *EDIT*: removed, see comments.

2 years agoAuto merge of #95702 - Dylan-DPC:rollup-793rz6v, r=Dylan-DPC
bors [Tue, 5 Apr 2022 22:42:04 +0000 (22:42 +0000)]
Auto merge of #95702 - Dylan-DPC:rollup-793rz6v, r=Dylan-DPC

Rollup of 8 pull requests

Successful merges:

 - #88025 (ScmCredentials netbsd implementation.)
 - #95473 (track individual proc-macro expansions in the self-profiler)
 - #95547 (caution against ptr-to-int transmutes)
 - #95585 (Explain why `&T` is cloned when `T` is not `Clone`)
 - #95591 (Use revisions to track NLL test output (part 1))
 - #95663 (diagnostics: give a special note for unsafe fn / Fn/FnOnce/FnMut)
 - #95673 (:arrow_up: rust-analyzer)
 - #95681 (resolve: Fix resolution of empty paths passed from rustdoc)

Failed merges:

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

2 years agoRollup merge of #95681 - petrochenkov:doclinkregr2, r=Dylan-DPC
Dylan DPC [Tue, 5 Apr 2022 20:59:01 +0000 (22:59 +0200)]
Rollup merge of #95681 - petrochenkov:doclinkregr2, r=Dylan-DPC

resolve: Fix resolution of empty paths passed from rustdoc

Fixes https://github.com/rust-lang/rust/pull/95337#issuecomment-1088426179

2 years agoRollup merge of #95673 - lnicola:rust-analyzer-2022-04-05, r=lnicola
Dylan DPC [Tue, 5 Apr 2022 20:59:00 +0000 (22:59 +0200)]
Rollup merge of #95673 - lnicola:rust-analyzer-2022-04-05, r=lnicola

:arrow_up: rust-analyzer

r? ``@ghost``

2 years agoRollup merge of #95663 - notriddle:notriddle/unsafe-fn-closure, r=compiler-errors
Dylan DPC [Tue, 5 Apr 2022 20:58:59 +0000 (22:58 +0200)]
Rollup merge of #95663 - notriddle:notriddle/unsafe-fn-closure, r=compiler-errors

diagnostics: give a special note for unsafe fn / Fn/FnOnce/FnMut

Fixes #90073

2 years agoRollup merge of #95591 - jackh726:nll-revisions-1, r=oli-obk
Dylan DPC [Tue, 5 Apr 2022 20:58:58 +0000 (22:58 +0200)]
Rollup merge of #95591 - jackh726:nll-revisions-1, r=oli-obk

Use revisions to track NLL test output (part 1)

The idea here is 2 fold: 1) When we eventually do make NLL default on, that PR should be systematic in "delete revisions and corresponding error annotations" 2) This allows us to look at test NLL outputs in chunks. (Though, I've opted here not to "mark" these tests. There are some tests with NLL revisions *now* that will be missed. I expect we do a second pass once we have all the tests with NLL revisions; these tests should be easy enough to eyeball.)

The actual review here should be "easy", but a bit tedious. I expect we should manually go through each test output and confirm it's okay.

The majority of these are either: 1) Only span change (the one I see most common is highlighting an entire function call, rather than just the function name in that call) 2) "E0308 mismatched types" -> "lifetime does not live long enough" 3) "E0495 cannot infer an appropriate lifetime for lifetime parameter" -> "lifetime does not live long enough" 4) "E0312 lifetime of reference outlives lifetime of borrowed content" -> "lifetime does not live long enough" 5) "E0759 `XXX` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement" -> "lifetime does not live long enough" 6) "E0623 lifetime mismatch" -> "lifetime does not live long enough"

Other than the now lack of an error code, most of these look fine (with most giving more helpful suggestions now).

`rfc1623` output isn't great.

cc ``@marmeladema`` if you want to look through these

Let's r? ``@oli-obk`` since you've commented on the Zulip thread ;)

2 years agoRollup merge of #95585 - compiler-errors:ref-clone, r=estebank
Dylan DPC [Tue, 5 Apr 2022 20:58:57 +0000 (22:58 +0200)]
Rollup merge of #95585 - compiler-errors:ref-clone, r=estebank

Explain why `&T` is cloned when `T` is not `Clone`

Fixes #95535

2 years agoRollup merge of #95547 - RalfJung:ptr-int-transmutes, r=scottmcm
Dylan DPC [Tue, 5 Apr 2022 20:58:56 +0000 (22:58 +0200)]
Rollup merge of #95547 - RalfJung:ptr-int-transmutes, r=scottmcm

caution against ptr-to-int transmutes

I don't know how strong of a statement we want to make here, but I am very concerned that the current docs could be interpreted as saying that ptr-to-int transmutes are just as okay as transmuting `*mut T` into an `&mut T`.

Examples [like this](https://github.com/rust-lang/unsafe-code-guidelines/issues/286#issuecomment-1085144431) show that ptr-to-int transmutes are deeply suspicious -- they are either UB, or they don't round-trip properly, or we have to basically say that `transmute` will actively look for pointers and do all the things a ptr-to-int cast does (which includes a global side-effect of marking the pointed-to allocation as 'exposed').

Another alternative might be to simply not talk about them... but we *do* want people to use casts rather than transmutes for this.

Cc `@rust-lang/lang`

2 years agoRollup merge of #95473 - lqd:macro-expansion, r=petrochenkov
Dylan DPC [Tue, 5 Apr 2022 20:58:55 +0000 (22:58 +0200)]
Rollup merge of #95473 - lqd:macro-expansion, r=petrochenkov

track individual proc-macro expansions in the self-profiler

As described in [this zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Macro.20expansion.20performance.20on.20complex.20macros/near/275063190), users don't currently have a lot of information to diagnose macro expansion performance issues. That comment suggests using the macro names to add further timing information.

This PR starts to do this for proc-macros which have the same issue, and performance problems happening in the wild in [this other zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/247081-t-compiler.2Fperformance/topic/Identifying.20proc-macro.20slowdowns) could be helped by such information.

It uses the available proc-macro name to track their individual expansions with self-profiling events.

r? `@Aaron1011` who mentioned this idea originally

2 years agoRollup merge of #88025 - devnexen:netbsd_scm_creds, r=Amanieu
Dylan DPC [Tue, 5 Apr 2022 20:58:54 +0000 (22:58 +0200)]
Rollup merge of #88025 - devnexen:netbsd_scm_creds, r=Amanieu

ScmCredentials netbsd implementation.

2 years agoAuto merge of #95035 - m-ou-se:futex-locks-on-linux, r=Amanieu
bors [Tue, 5 Apr 2022 20:17:08 +0000 (20:17 +0000)]
Auto merge of #95035 - m-ou-se:futex-locks-on-linux, r=Amanieu

Replace Linux Mutex and Condvar with futex based ones.

Tracking issue: https://github.com/rust-lang/rust/issues/93740

2 years agoformatting
SparkyPotato [Tue, 5 Apr 2022 20:06:46 +0000 (01:36 +0530)]
formatting

2 years agocleanup
SparkyPotato [Tue, 5 Apr 2022 20:06:24 +0000 (01:36 +0530)]
cleanup

2 years agofix Vec leak with 0 capacity
SparkyPotato [Tue, 5 Apr 2022 20:02:26 +0000 (01:32 +0530)]
fix Vec leak with 0 capacity

2 years agodiagnostics: tweak error message to give more rationale to unsafe Fn
Michael Howell [Tue, 5 Apr 2022 18:13:48 +0000 (11:13 -0700)]
diagnostics: tweak error message to give more rationale to unsafe Fn

2 years agointerp: pass TyCtxt to Machine methods that do not take InterpCx
Ralf Jung [Tue, 5 Apr 2022 17:31:51 +0000 (13:31 -0400)]
interp: pass TyCtxt to Machine methods that do not take InterpCx

2 years agoAuto merge of #94527 - oli-obk:undef_scalars, r=nagisa,erikdesjardin
bors [Tue, 5 Apr 2022 16:46:13 +0000 (16:46 +0000)]
Auto merge of #94527 - oli-obk:undef_scalars, r=nagisa,erikdesjardin

Let CTFE to handle partially uninitialized unions without marking the entire value as uninitialized.

follow up to #94411

To fix https://github.com/rust-lang/rust/issues/69488 and by extension fix https://github.com/rust-lang/rust/issues/94371, we should stop treating types like `MaybeUninit<usize>` as something that the `Scalar` type in the interpreter engine can represent. So we add a new field to `abi::Primitive` that records whether the primitive is nested in a union

cc `@RalfJung`

r? `@ghost`

2 years agoExplain why `&T` is cloned when `T` is not `Clone`
Michael Goulet [Sat, 2 Apr 2022 07:23:52 +0000 (00:23 -0700)]
Explain why `&T` is cloned when `T` is not `Clone`

2 years agoUpdate browser-ui-test version to 0.8.5
Guillaume Gomez [Tue, 5 Apr 2022 16:05:12 +0000 (18:05 +0200)]
Update browser-ui-test version to 0.8.5

2 years agoAdd GUI test to ensure that the width of the item-info does not overflow its parent
Guillaume Gomez [Tue, 5 Apr 2022 16:04:16 +0000 (18:04 +0200)]
Add GUI test to ensure that the width of the item-info does not overflow its parent

2 years agoGenerate a <div> instead of a <span> for item-info elements
Guillaume Gomez [Tue, 5 Apr 2022 16:03:30 +0000 (18:03 +0200)]
Generate a <div> instead of a <span> for item-info elements

2 years agounboxed-closures and type-alias-impl-trait nll revisions
Jack Huey [Sat, 2 Apr 2022 15:08:16 +0000 (11:08 -0400)]
unboxed-closures and type-alias-impl-trait nll revisions

2 years agounderscore-lifetime nll revisions
Jack Huey [Sat, 2 Apr 2022 02:29:27 +0000 (22:29 -0400)]
underscore-lifetime nll revisions

2 years agoMore nll revisions
Jack Huey [Sat, 2 Apr 2022 02:12:17 +0000 (22:12 -0400)]
More nll revisions

2 years agoMove some tests with compare-mode=nll output to revisions
Jack Huey [Fri, 1 Apr 2022 23:51:50 +0000 (19:51 -0400)]
Move some tests with compare-mode=nll output to revisions

2 years agoReword comment in futex condvar implementation.
Mara Bos [Tue, 5 Apr 2022 15:08:12 +0000 (17:08 +0200)]
Reword comment in futex condvar implementation.

2 years agoAuto merge of #95680 - Dylan-DPC:rollup-7jldtnz, r=Dylan-DPC
bors [Tue, 5 Apr 2022 14:17:30 +0000 (14:17 +0000)]
Auto merge of #95680 - Dylan-DPC:rollup-7jldtnz, r=Dylan-DPC

Rollup of 4 pull requests

Successful merges:

 - #95525 (Suggest derivable trait on E0277 error)
 - #95654 (diagnostics: use correct span for const generics)
 - #95660 (Update panic docs to make it clearer when to use panic vs Result)
 - #95670 (Refactor: remove unused function parameters)

Failed merges:

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

2 years agoRollup merge of #95670 - TaKO8Ki:remove-unused-function-parameters, r=davidtwco
Dylan DPC [Tue, 5 Apr 2022 13:56:51 +0000 (15:56 +0200)]
Rollup merge of #95670 - TaKO8Ki:remove-unused-function-parameters, r=davidtwco

Refactor: remove unused function parameters

2 years agoRollup merge of #95660 - yaahc:panic-docs-update, r=Dylan-DPC
Dylan DPC [Tue, 5 Apr 2022 13:56:50 +0000 (15:56 +0200)]
Rollup merge of #95660 - yaahc:panic-docs-update, r=Dylan-DPC

Update panic docs to make it clearer when to use panic vs Result

This is based on a question that came up in one of my [error handling office hours](https://twitter.com/yaahc_/status/1506376624509374467?s=20&t=Sp-cEjrx5kpMdNsAGPOo9w) meetings. I had a user who was fairly familiar with error type design, thiserror and anyhow, and rust in general, but who was still confused about when to use panics vs when to use Result and `Error`.

This will also be cross referenced in an error handling FAQ that I will be creating in the https://github.com/rust-lang/project-error-handling repo shortly.

2 years agoRollup merge of #95654 - notriddle:notriddle/issue-95616, r=davidtwco
Dylan DPC [Tue, 5 Apr 2022 13:56:50 +0000 (15:56 +0200)]
Rollup merge of #95654 - notriddle:notriddle/issue-95616, r=davidtwco

diagnostics: use correct span for const generics

Fixes #95616

2 years agoRollup merge of #95525 - ohno418:suggest-derivable-trait-E0277, r=compiler-errors
Dylan DPC [Tue, 5 Apr 2022 13:56:49 +0000 (15:56 +0200)]
Rollup merge of #95525 - ohno418:suggest-derivable-trait-E0277, r=compiler-errors

Suggest derivable trait on E0277 error

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

2 years agoresolve: Fix resolution of empty paths passed from rustdoc
Vadim Petrochenkov [Tue, 5 Apr 2022 12:38:18 +0000 (15:38 +0300)]
resolve: Fix resolution of empty paths passed from rustdoc

2 years agotrack proc-macro expansions in the self-profiler
Rémy Rakic [Wed, 30 Mar 2022 13:14:25 +0000 (15:14 +0200)]
track proc-macro expansions in the self-profiler

Use the proc-macro descr to track their individual expansions with
self-profiling events. This will help diagnose performance issues
with slow proc-macros.

2 years agoUse WrappingRange::full instead of hand-rolling it
Oli Scherer [Tue, 5 Apr 2022 13:13:21 +0000 (13:13 +0000)]
Use WrappingRange::full instead of hand-rolling it

2 years agomir-interpret now treats unions as non-immediate, even if they have scalar layout...
Oli Scherer [Thu, 3 Mar 2022 12:02:52 +0000 (12:02 +0000)]
mir-interpret now treats unions as non-immediate, even if they have scalar layout, allowing partially initializing them

2 years agoMark scalar layout unions so that backends that do not support partially initialized...
Oli Scherer [Thu, 3 Mar 2022 12:02:12 +0000 (12:02 +0000)]
Mark scalar layout unions so that backends that do not support partially initialized scalars can special case them.

2 years agoMark unix::locks::futex::Mutex::new as #[inline].
Mara Bos [Tue, 5 Apr 2022 11:58:10 +0000 (13:58 +0200)]
Mark unix::locks::futex::Mutex::new as #[inline].

2 years ago:arrow_up: rust-analyzer
Laurențiu Nicola [Tue, 5 Apr 2022 11:18:10 +0000 (14:18 +0300)]
:arrow_up: rust-analyzer

2 years agoremove unused function parameters
Takayuki Maeda [Tue, 5 Apr 2022 10:33:22 +0000 (19:33 +0900)]
remove unused function parameters

2 years agoAuto merge of #95667 - Dylan-DPC:rollup-n7xzs3y, r=Dylan-DPC
bors [Tue, 5 Apr 2022 09:47:44 +0000 (09:47 +0000)]
Auto merge of #95667 - Dylan-DPC:rollup-n7xzs3y, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #95234 (bootstrap.py: nixos check in /etc/os-release with quotes)
 - #95449 (Fix `x doc --stage 0 compiler`)
 - #95512 (diagnostics: translation infrastructure)
 - #95607 (Note invariance reason for FnDef types)
 - #95645 (Fix intra doc link ICE when trying to get traits in scope for primitive)

Failed merges:

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

2 years agoFix ui test for nll
ohno418 [Tue, 5 Apr 2022 08:25:38 +0000 (17:25 +0900)]
Fix ui test for nll

2 years agoRollup merge of #95645 - GuillaumeGomez:intra-doc-link-ice-traits-in-scope-primitive...
Dylan DPC [Tue, 5 Apr 2022 07:33:24 +0000 (09:33 +0200)]
Rollup merge of #95645 - GuillaumeGomez:intra-doc-link-ice-traits-in-scope-primitive, r=jyn514

Fix intra doc link ICE when trying to get traits in scope for primitive

Fixes #95633.

I think ``@notriddle`` was the one who worked on this part of the code last so:

r? ``@notriddle``

2 years agoRollup merge of #95607 - compiler-errors:issue-95272, r=Aaron1011
Dylan DPC [Tue, 5 Apr 2022 07:33:23 +0000 (09:33 +0200)]
Rollup merge of #95607 - compiler-errors:issue-95272, r=Aaron1011

Note invariance reason for FnDef types

Fixes #95272. Is it worthwhile even printing a variance explanation here? Or should I try to track down which function parameter is responsible for the invariance?

r? ``@Aaron1011`` since you wrote #89336

2 years agoRollup merge of #95512 - davidtwco:diagnostic-translation, r=oli-obk
Dylan DPC [Tue, 5 Apr 2022 07:33:22 +0000 (09:33 +0200)]
Rollup merge of #95512 - davidtwco:diagnostic-translation, r=oli-obk

diagnostics: translation infrastructure

An implementation of the infrastructure required to have translatable diagnostic messages.

- Introduces a `DiagnosticMessage` type which can represent both the current non-translatable messages and identifiers for [Fluent](https://projectfluent.org/).
- Modifies current diagnostic API so that existing calls still work but `DiagnosticMessage`s can be provided too.
- Adds support for always loading a "fallback bundle" containing the English diagnostic messages, which are used when a `DiagnosticMessage::FluentIdentifier` is used in a diagnostic being emitted.
- Adds support for loading a "primary bundle" which contains the user's preferred language translation, and is used preferentially when it contains a diagnostic message being emitted. Primary bundles are loaded either from the path provided to `-Ztranslate-alternate-ftl` (for testing), or from the sysroot at `$sysroot/locale/$locale/*.ftl` given a locale with `-Ztranslate-lang` (which is parsed as a language identifier).
- Adds "diagnostic args" which enable normally-interpolated variables to be made available as variables for Fluent messages to use.
- Updates `#[derive(SessionDiagnostic)]` so that it can only be used for translatable diagnostics and update the handful of diagnostics which used the derive to be translatable.

For example, the following diagnostic...

```rust
#[derive(SessionDiagnostic)]
#[error = "E0195"]
pub struct LifetimesOrBoundsMismatchOnTrait {
    #[message = "lifetime parameters or bounds on {item_kind} `{ident}` do not match the trait declaration"]
    #[label = "lifetimes do not match {item_kind} in trait"]
    pub span: Span,
    #[label = "lifetimes in impl do not match this {item_kind} in trait"]
    pub generics_span: Option<Span>,
    pub item_kind: &'static str,
    pub ident: Ident,
}
```

...becomes...

```rust
#[derive(SessionDiagnostic)]
#[error(code = "E0195", slug = "typeck-lifetimes-or-bounds-mismatch-on-trait")]
pub struct LifetimesOrBoundsMismatchOnTrait {
    #[primary_span]
    #[label]
    pub span: Span,
    #[label = "generics-label"]
    pub generics_span: Option<Span>,
    pub item_kind: &'static str,
    pub ident: Ident,
}
```

```fluent
typeck-lifetimes-or-bounds-mismatch-on-trait =
    lifetime parameters or bounds on {$item_kind} `{$ident}` do not match the trait declaration
    .label = lifetimes do not match {$item_kind} in trait
    .generics-label = lifetimes in impl do not match this {$item_kind} in trait
```

r? `@estebank`
cc `@oli-obk` `@Manishearth`

2 years agoRollup merge of #95449 - jyn514:doc-stage-0, r=ehuss
Dylan DPC [Tue, 5 Apr 2022 07:33:21 +0000 (09:33 +0200)]
Rollup merge of #95449 - jyn514:doc-stage-0, r=ehuss

Fix `x doc --stage 0 compiler`

Eric figured out the fix to this almost 2 years ago, I just didn't read his comment carefully enough at the timme.
The issue was that fake rustc and fake rustdoc were inconsistent about when they passed `--sysroot` to the real compiler.
Change them to consistently only pass it when `--target` is present.

cc https://github.com/rust-lang/rust/issues/74976#issuecomment-667265945
Fixes https://github.com/rust-lang/rust/issues/79980

r? ``@ehuss``

2 years agoRollup merge of #95234 - ben0x539:nixquotes, r=Dylan-DPC
Dylan DPC [Tue, 5 Apr 2022 07:33:20 +0000 (09:33 +0200)]
Rollup merge of #95234 - ben0x539:nixquotes, r=Dylan-DPC

bootstrap.py: nixos check in /etc/os-release with quotes

Per https://www.freedesktop.org/software/systemd/man/os-release.html,

> Variable assignment values must be enclosed in double or single quotes
> if they include spaces, semicolons or other special characters outside
> of A–Z, a–z, 0–9. (Assignments that do not include these special
> characters may be enclosed in quotes too, but this is optional.)

So, past `ID=nixos`, let's also check for `ID='nixos'` and `ID="nixos"`.

One of these is necessary between nixos/nixpkgs#162168 and
nixos/nixpkgs#164068, but this seems more correct either way.

2 years agoUse rtabort
Chris Denton [Mon, 4 Apr 2022 05:08:41 +0000 (06:08 +0100)]
Use rtabort

2 years agoMake `synchronous_write` safe to call
Chris Denton [Mon, 4 Apr 2022 05:08:16 +0000 (06:08 +0100)]
Make `synchronous_write` safe to call

2 years agoDocument synchronicity
Chris Denton [Wed, 30 Mar 2022 11:36:00 +0000 (12:36 +0100)]
Document synchronicity

2 years agoComplete reads and writes synchronously or abort
Chris Denton [Wed, 30 Mar 2022 09:38:22 +0000 (10:38 +0100)]
Complete reads and writes synchronously or abort

2 years agoCorrect definition of `IO_STATUS_BLOCK`
Chris Denton [Mon, 28 Mar 2022 07:42:59 +0000 (08:42 +0100)]
Correct definition of `IO_STATUS_BLOCK`

2 years agoerrors: support fluent + parallel compiler
David Wood [Sun, 3 Apr 2022 04:32:38 +0000 (05:32 +0100)]
errors: support fluent + parallel compiler

Conditional on the parallel compiler being enabled, use a different
`IntlLangMemoizer` which supports being sent between threads in
`FluentBundle`.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agotidy: add fluent dependencies to whitelist
David Wood [Sun, 3 Apr 2022 04:05:36 +0000 (05:05 +0100)]
tidy: add fluent dependencies to whitelist

Unfortunately, fluent comes with a lot of dependencies and these need to
be added to the whitelist.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agoerrors: use `impl Into<FluentId>`
David Wood [Sun, 3 Apr 2022 03:58:57 +0000 (04:58 +0100)]
errors: use `impl Into<FluentId>`

`FluentId` is the type alias that is used everywhere else so it should
be used here too so that this doesn't need updated if the alias changes.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agosession: opt for enabling directionality markers
David Wood [Sun, 3 Apr 2022 03:53:01 +0000 (04:53 +0100)]
session: opt for enabling directionality markers

Add an option for enabling and disabling Fluent's directionality
isolation markers in output. Disabled by default as these can render in
some terminals and applications.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agoerrors: add links to fluent documentation
David Wood [Sat, 2 Apr 2022 05:21:27 +0000 (06:21 +0100)]
errors: add links to fluent documentation

Add some links to the Fluent documentation to
`DiagnosticMessage::FluentIdentifier` which explain what a Fluent
message and attribute are.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agotypeck: remove now-unnecessary parameter from diag
David Wood [Sat, 2 Apr 2022 05:18:48 +0000 (06:18 +0100)]
typeck: remove now-unnecessary parameter from diag

Removes `expected_pluralize` parameter from diagnostic struct which is
no longer necessary as the Fluent message can determine the correct
pluralization.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agoerrors: don't try load default locale from sysroot
David Wood [Sat, 2 Apr 2022 05:09:43 +0000 (06:09 +0100)]
errors: don't try load default locale from sysroot

If the user requests a diagnostic locale of "en-US" then it doesn't make
sense to try and load that from the `$sysroot` because it is just the
default built-in locale.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agomacros: support translatable suggestions
David Wood [Thu, 31 Mar 2022 12:10:13 +0000 (13:10 +0100)]
macros: support translatable suggestions

Extends support for generating `DiagnosticMessage::FluentIdentifier`
messages from `SessionDiagnostic` derive to `#[suggestion]`.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agomacros: note/help in `SessionDiagnostic` derive
David Wood [Thu, 31 Mar 2022 11:10:00 +0000 (12:10 +0100)]
macros: note/help in `SessionDiagnostic` derive

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agomacros: support translatable labels
David Wood [Thu, 31 Mar 2022 09:24:46 +0000 (10:24 +0100)]
macros: support translatable labels

Extends support for generating `DiagnosticMessage::FluentIdentifier`
messages from `SessionDiagnostic` derive to `#[label]`.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agomacros: optional error codes
David Wood [Thu, 31 Mar 2022 08:21:42 +0000 (09:21 +0100)]
macros: optional error codes

In an effort to make it easier to port diagnostics to
`SessionDiagnostic` (for translation) and since translation slugs could
replace error codes, make error codes optional in the
`SessionDiagnostic` derive.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agomacros: add `#[no_arg]` to skip `set_arg` call
David Wood [Thu, 31 Mar 2022 08:02:31 +0000 (09:02 +0100)]
macros: add `#[no_arg]` to skip `set_arg` call

A call to `set_arg` is generated for every field of a
`SessionDiagnostic` struct without attributes, but not all types support
being an argument, so `#[no_arg]` is introduced to skip these fields.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agomacros: rename `#[message]` to `#[primary_span]`
David Wood [Thu, 31 Mar 2022 07:50:45 +0000 (08:50 +0100)]
macros: rename `#[message]` to `#[primary_span]`

Small commit renaming `#[message]` to `#[primary_span]` as this more
accurately reflects what it does now.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agomacros: translatable struct attrs and warnings
David Wood [Thu, 31 Mar 2022 07:35:17 +0000 (08:35 +0100)]
macros: translatable struct attrs and warnings

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agomacros: update session diagnostic errors
David Wood [Wed, 30 Mar 2022 09:04:03 +0000 (10:04 +0100)]
macros: update session diagnostic errors

Small commit adding backticks around types and annotations in the error
messages from the session diagnostic derive.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agoerrors: disable directionality isolation markers
David Wood [Thu, 31 Mar 2022 09:14:21 +0000 (10:14 +0100)]
errors: disable directionality isolation markers

Fluent diagnostics can insert directionality isolation markers around
interpolated variables indicating that there may be a shift from
right-to-left to left-to-right text (or vice-versa). These are disabled
because they are sometimes visible in the error output, but may be worth
investigating in future (for example: if type names are left-to-right
and the surrounding diagnostic messages are right-to-left, then these
might be helpful).

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agomacros: add args for non-subdiagnostic fields
David Wood [Wed, 30 Mar 2022 08:45:36 +0000 (09:45 +0100)]
macros: add args for non-subdiagnostic fields

Non-subdiagnostic fields (i.e. those that don't have `#[label]`
attributes or similar and are just additional context) have to be added
as arguments for Fluent messages to refer them. This commit extends the
`SessionDiagnostic` derive to do this for all fields that do not have
attributes and introduces an `IntoDiagnosticArg` trait that is
implemented on all types that can be converted to a argument for Fluent.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agomacros: move suggestion type handling to fn
David Wood [Wed, 30 Mar 2022 02:08:58 +0000 (03:08 +0100)]
macros: move suggestion type handling to fn

Move the handling of `Span` or `(Span, Applicability)` types in
`#[suggestion]` attributes to its own function.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agomacros: update comments
David Wood [Wed, 30 Mar 2022 02:00:54 +0000 (03:00 +0100)]
macros: update comments

Various small changes to comments, like wrapping code in backticks,
changing comments to doc comments and adding newlines.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agoerrors: implement sysroot/testing bundle loading
David Wood [Mon, 28 Mar 2022 08:36:20 +0000 (09:36 +0100)]
errors: implement sysroot/testing bundle loading

Extend loading of Fluent bundles so that bundles can be loaded from the
sysroot based on the language requested by the user, or using a nightly
flag.

Sysroot bundles are loaded from `$sysroot/share/locale/$locale/*.ftl`.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agoerrors: implement fallback diagnostic translation
David Wood [Sat, 26 Mar 2022 07:27:43 +0000 (07:27 +0000)]
errors: implement fallback diagnostic translation

This commit updates the signatures of all diagnostic functions to accept
types that can be converted into a `DiagnosticMessage`. This enables
existing diagnostic calls to continue to work as before and Fluent
identifiers to be provided. The `SessionDiagnostic` derive just
generates normal diagnostic calls, so these APIs had to be modified to
accept Fluent identifiers.

In addition, loading of the "fallback" Fluent bundle, which contains the
built-in English messages, has been implemented.

Each diagnostic now has "arguments" which correspond to variables in the
Fluent messages (necessary to render a Fluent message) but no API for
adding arguments has been added yet. Therefore, diagnostics (that do not
require interpolation) can be converted to use Fluent identifiers and
will be output as before.

2 years agospan: move `MultiSpan`
David Wood [Thu, 24 Mar 2022 02:03:04 +0000 (02:03 +0000)]
span: move `MultiSpan`

`MultiSpan` contains labels, which are more complicated with the
introduction of diagnostic translation and will use types from
`rustc_errors` - however, `rustc_errors` depends on `rustc_span` so
`rustc_span` cannot use types like `DiagnosticMessage` without
dependency cycles. Introduce a new `rustc_error_messages` crate that can
contain `DiagnosticMessage` and `MultiSpan`.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agoerrors: introduce `DiagnosticMessage`
David Wood [Wed, 23 Mar 2022 07:34:20 +0000 (07:34 +0000)]
errors: introduce `DiagnosticMessage`

Introduce a `DiagnosticMessage` type that will enable diagnostic
messages to be simple strings or Fluent identifiers.
`DiagnosticMessage` is now used in the implementation of the standard
`DiagnosticBuilder` APIs.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agoAuto merge of #95337 - petrochenkov:doclink3, r=camelid
bors [Tue, 5 Apr 2022 04:39:34 +0000 (04:39 +0000)]
Auto merge of #95337 - petrochenkov:doclink3, r=camelid

rustdoc: Fix resolution of `crate`-relative paths in doc links

Resolve `crate::foo` paths transparently to rustdoc, so their resolution no longer affects diagnostics and modules used for determining traits in scope.

The proper solution is to account for the current `module_id`/`parent_scope` in `fn resolve_crate_root`, but it's a slightly larger compiler changes. This PR moves the code closer to it, but keeps it rustdoc-specific.

Fixes https://github.com/rust-lang/rust/issues/78696
Fixes https://github.com/rust-lang/rust/issues/94924

2 years agoFormat invariance notes with backticks
Michael Goulet [Sat, 2 Apr 2022 22:32:39 +0000 (15:32 -0700)]
Format invariance notes with backticks

2 years agoSuggest only when all fields impl the trait
ohno418 [Sun, 3 Apr 2022 15:08:54 +0000 (00:08 +0900)]
Suggest only when all fields impl the trait

2 years agoHandle reporting invariance of fn pointer
Michael Goulet [Sat, 2 Apr 2022 22:27:14 +0000 (15:27 -0700)]
Handle reporting invariance of fn pointer

2 years agoSuggest only when Rhs for PartialEq and PartialOrd is the same type as self
ohno418 [Fri, 1 Apr 2022 02:28:28 +0000 (11:28 +0900)]
Suggest only when Rhs for PartialEq and PartialOrd is the same type as self

2 years agoAuto merge of #95662 - Dylan-DPC:rollup-fo7jsr6, r=Dylan-DPC
bors [Tue, 5 Apr 2022 02:21:13 +0000 (02:21 +0000)]
Auto merge of #95662 - Dylan-DPC:rollup-fo7jsr6, r=Dylan-DPC

Rollup of 7 pull requests

Successful merges:

 - #91873 (Mention implementers of unsatisfied trait)
 - #95588 (explicitly distinguish pointer::addr and pointer::expose_addr)
 - #95603 (Fix late-bound ICE in `dyn` return type suggestion)
 - #95620 (interpret: remove MemoryExtra in favor of giving access to the Machine)
 - #95630 (Update `NonNull` pointer provenance methods' documentation)
 - #95631 (Refactor: remove unnecessary nested blocks)
 - #95642 (`CandidateSource::XCandidate` -> `CandidateSource::X`)

Failed merges:

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

2 years agoSuggest derivable trait on E0277
ohno418 [Thu, 31 Mar 2022 14:58:45 +0000 (23:58 +0900)]
Suggest derivable trait on E0277

2 years agoFix bogus tidy errors
Michael Howell [Tue, 5 Apr 2022 00:54:20 +0000 (17:54 -0700)]
Fix bogus tidy errors

2 years agodiagnostics: give a special note for unsafe fn / Fn/FnOnce/FnMut
Michael Howell [Tue, 5 Apr 2022 00:37:59 +0000 (17:37 -0700)]
diagnostics: give a special note for unsafe fn / Fn/FnOnce/FnMut

Fixes #90073

2 years agoRollup merge of #95642 - lcnr:probe-smol, r=compiler-errors
Dylan DPC [Mon, 4 Apr 2022 23:53:36 +0000 (01:53 +0200)]
Rollup merge of #95642 - lcnr:probe-smol, r=compiler-errors

`CandidateSource::XCandidate` -> `CandidateSource::X`

2 years agoRollup merge of #95631 - TaKO8Ki:remove-unnecessary-nested-blocks, r=davidtwco
Dylan DPC [Mon, 4 Apr 2022 23:53:35 +0000 (01:53 +0200)]
Rollup merge of #95631 - TaKO8Ki:remove-unnecessary-nested-blocks, r=davidtwco

Refactor: remove unnecessary nested blocks

2 years agoRollup merge of #95630 - declanvk:update-nonnull-doc, r=RalfJung
Dylan DPC [Mon, 4 Apr 2022 23:53:34 +0000 (01:53 +0200)]
Rollup merge of #95630 - declanvk:update-nonnull-doc, r=RalfJung

Update `NonNull` pointer provenance methods' documentation

 - Add links to equivalent methods on raw pointers

2 years agoRollup merge of #95620 - RalfJung:memory-no-extras, r=oli-obk
Dylan DPC [Mon, 4 Apr 2022 23:53:33 +0000 (01:53 +0200)]
Rollup merge of #95620 - RalfJung:memory-no-extras, r=oli-obk

interpret: remove MemoryExtra in favor of giving access to the Machine

The Miri PR for this is upcoming.

r? ``@oli-obk``

2 years agoRollup merge of #95603 - compiler-errors:dyn-return, r=oli-obk
Dylan DPC [Mon, 4 Apr 2022 23:53:32 +0000 (01:53 +0200)]
Rollup merge of #95603 - compiler-errors:dyn-return, r=oli-obk

Fix late-bound ICE in `dyn` return type suggestion

This fixes the root-cause of the attached issues -- the root problem is that we're using the return type from a signature with late-bound instead of early-bound regions. The change on line 1087 (`let Some(liberated_sig) = typeck_results.liberated_fn_sigs().get(fn_hir_id) else { return false; };`) makes sure we're grabbing the _right_ return type for this suggestion to check the `dyn` predicates with.

Fixes #91801
Fixes #91803

This fix also includes some drive-by changes, specifically:

1. Don't suggest boxing when we have `-> dyn Trait` and are already returning `Box<T>` where `T: Trait` (before we always boxed the value).
2. Suggestion applies even when the return type is a type alias (e.g. `type Foo = dyn Trait`). This does cause the suggestion to expand to the aliased type, but I think it's still beneficial.
3. Split up the multipart suggestion because there's a 6-line max in the printed output...

I am open to splitting out the above changes, if we just want to fix the ICE first.

cc: ```@terrarier2111``` and #92289

2 years agoRollup merge of #95588 - RalfJung:strict-provenance, r=scottmcm
Dylan DPC [Mon, 4 Apr 2022 23:53:31 +0000 (01:53 +0200)]
Rollup merge of #95588 - RalfJung:strict-provenance, r=scottmcm

explicitly distinguish pointer::addr and pointer::expose_addr

``@bgeron`` pointed out that the current docs promise that `ptr.addr()` and `ptr as usize` are equivalent. I don't think that is a promise we want to make. (Conceptually, `ptr as usize` might 'escape' the provenance to enable future `usize as ptr` casts, but `ptr.addr()` dertainly does not do that.)

So I propose we word the docs a bit more carefully here. ``@Gankra`` what do you think?

2 years agoRollup merge of #91873 - estebank:mention-impls-for-unsatisfied-trait, r=davidtwco
Dylan DPC [Mon, 4 Apr 2022 23:53:31 +0000 (01:53 +0200)]
Rollup merge of #91873 - estebank:mention-impls-for-unsatisfied-trait, r=davidtwco

Mention implementers of unsatisfied trait

When encountering an unsatisfied trait bound, if there are no other
suggestions, mention all the types that *do* implement that trait:

```
error[E0277]: the trait bound `f32: Foo` is not satisfied
  --> $DIR/impl_wf.rs:22:6
   |
LL | impl Baz<f32> for f32 { }
   |      ^^^^^^^^ the trait `Foo` is not implemented for `f32`
   |
   = help: the trait `Foo` is implemented for `i32`
note: required by a bound in `Baz`
  --> $DIR/impl_wf.rs:18:31
   |
LL | trait Baz<U: ?Sized> where U: Foo { }
   |                               ^^^ required by this bound in `Baz`
```
```
error[E0277]: the trait bound `u32: Foo` is not satisfied
  --> $DIR/associated-types-path-2.rs:29:5
   |
LL |     f1(2u32, 4u32);
   |     ^^ the trait `Foo` is not implemented for `u32`
   |
   = help: the trait `Foo` is implemented for `i32`
note: required by a bound in `f1`
  --> $DIR/associated-types-path-2.rs:13:14
   |
LL | pub fn f1<T: Foo>(a: T, x: T::A) {}
   |              ^^^ required by this bound in `f1`
```

Suggest dereferencing in more cases.

Fix #87437, fix #90970.

2 years agoUpdate panic docs to make it clearer when to use panic vs Result
Jane Lusby [Mon, 4 Apr 2022 23:09:49 +0000 (16:09 -0700)]
Update panic docs to make it clearer when to use panic vs Result

2 years agoRely on #[link] attribute for unwind on Fuchsia.
Adam Perry [Mon, 4 Apr 2022 23:06:12 +0000 (23:06 +0000)]
Rely on #[link] attribute for unwind on Fuchsia.

Closes #95575.