]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agofix most compiler/ doctests
Elliot Roberts [Fri, 15 Apr 2022 22:04:34 +0000 (15:04 -0700)]
fix most compiler/ doctests

2 years agoAuto merge of #95362 - scottmcm:calloc-arrays, r=Mark-Simulacrum
bors [Sun, 1 May 2022 00:50:46 +0000 (00:50 +0000)]
Auto merge of #95362 - scottmcm:calloc-arrays, r=Mark-Simulacrum

Support arrays of zeros in Vec's __rust_alloc_zeroed optimization

I happened to notice in https://users.rust-lang.org/t/any-advantage-of-box-u64-16-16-16-over-vec-u64/73500/3?u=scottmcm that the calloc optimization wasn't applying to vectors-of-arrays, so here's the easy fix for that.

2 years agoAuto merge of #93815 - camsteffen:intravisit-docs, r=cjgillot
bors [Sat, 30 Apr 2022 21:24:53 +0000 (21:24 +0000)]
Auto merge of #93815 - camsteffen:intravisit-docs, r=cjgillot

Update intravisit docs

Follow-up to #90986.

r? `@cjgillot`

2 years agoAuto merge of #96347 - estebank:issue-96292, r=compiler-errors
bors [Sat, 30 Apr 2022 18:44:01 +0000 (18:44 +0000)]
Auto merge of #96347 - estebank:issue-96292, r=compiler-errors

Erase type params when suggesting fully qualified path

When suggesting the use of a fully qualified path for a method call that
is ambiguous because it has multiple candidates, erase type params in
the resulting code, as they would result in an error when applied. We
replace them with `_` in the output to rely on inference. There might be
cases where this still produces slighlty incomplete suggestions, but it
otherwise produces many more errors in relatively common cases.

Fix #96292

2 years agoUpdate intravisit docs
Cameron Steffen [Sat, 30 Apr 2022 17:27:01 +0000 (12:27 -0500)]
Update intravisit docs

2 years agoAuto merge of #96348 - overdrivenpotato:inline-location, r=the8472
bors [Sat, 30 Apr 2022 16:33:12 +0000 (16:33 +0000)]
Auto merge of #96348 - overdrivenpotato:inline-location, r=the8472

Inline core::panic::Location methods

This avoids the overhead of a function call when used.

2 years agoAuto merge of #93803 - cjgillot:unify-bounds, r=oli-obk
bors [Sat, 30 Apr 2022 13:52:29 +0000 (13:52 +0000)]
Auto merge of #93803 - cjgillot:unify-bounds, r=oli-obk

Handle generic bounds in a uniform way in HIR

Generic bounds in HIR used to be split between bounds in the parameter definition and bounds in a where clause. This PR attempts to store all of those as where predicates.

This effectively desugars
```rust
fn foo<T: Default, U>(x: impl Copy) where U: Clone
```
into
```rust
fn foo<T, U, _V>(x: _V) where T: Default, U: Clone, _V: Copy
```
(where _V is actually hidden and called "impl Copy").

I managed to make compiler warnings more uniform.
About rustdoc: is making this desugaring user-visible acceptable?
About clippy: I don't understand the subtle logic in the `needless-lifetimes` lint.

r? `@estebank`

2 years agoBless nll tests.
Camille GILLOT [Sat, 30 Apr 2022 08:33:37 +0000 (10:33 +0200)]
Bless nll tests.

2 years agoCorrect comment.
Camille GILLOT [Fri, 29 Apr 2022 16:54:04 +0000 (18:54 +0200)]
Correct comment.

2 years agoSave colon span to suggest bounds.
Camille GILLOT [Thu, 28 Apr 2022 19:59:41 +0000 (21:59 +0200)]
Save colon span to suggest bounds.

2 years agoBless tests.
Camille GILLOT [Mon, 14 Mar 2022 14:56:37 +0000 (15:56 +0100)]
Bless tests.

2 years agoStore all generic bounds as where predicates.
Camille GILLOT [Mon, 7 Feb 2022 21:58:30 +0000 (22:58 +0100)]
Store all generic bounds as where predicates.

2 years agoInline WhereClause into Generics.
Camille GILLOT [Sat, 5 Feb 2022 14:48:02 +0000 (15:48 +0100)]
Inline WhereClause into Generics.

2 years agoBox HIR Generics and Impl.
Camille GILLOT [Sat, 5 Feb 2022 14:26:49 +0000 (15:26 +0100)]
Box HIR Generics and Impl.

2 years agoAuto merge of #95776 - cjgillot:ast-lifetimes-static, r=petrochenkov
bors [Sat, 30 Apr 2022 07:52:18 +0000 (07:52 +0000)]
Auto merge of #95776 - cjgillot:ast-lifetimes-static, r=petrochenkov

Enforce static lifetimes in consts during late resolution

This PR moves the handling of implicitly and explicitly static lifetimes in constants from HIR to the AST.

2 years agoAuto merge of #96500 - SparrowLii:rpo, r=tmiasko
bors [Sat, 30 Apr 2022 05:06:47 +0000 (05:06 +0000)]
Auto merge of #96500 - SparrowLii:rpo, r=tmiasko

Reduce duplication of RPO calculation of mir

Computing the RPO of mir is not a low-cost thing, but it is duplicate in many places. In particular the `iterate_to_fixpoint` method which is called multiple times when computing the data flow.
This PR reduces the number of times the RPO is recalculated as much as possible, which should save some compile time.

2 years agoAuto merge of #90988 - estebank:binding-supposed-to-be-const, r=davidtwco
bors [Sat, 30 Apr 2022 02:41:34 +0000 (02:41 +0000)]
Auto merge of #90988 - estebank:binding-supposed-to-be-const, r=davidtwco

When encountering a binding that could be a const or unit variant, suggest the right path

2 years agoUse newtype `enum`s instead of `bool`
Esteban Kuber [Sat, 30 Apr 2022 02:40:36 +0000 (02:40 +0000)]
Use newtype `enum`s instead of `bool`

2 years agoWhen encountering a binding that could be a const or unit variant, suggest the right...
Esteban Kuber [Wed, 17 Nov 2021 19:37:46 +0000 (19:37 +0000)]
When encountering a binding that could be a const or unit variant, suggest the right path

2 years agoBless tests.
Camille GILLOT [Thu, 31 Mar 2022 18:11:22 +0000 (20:11 +0200)]
Bless tests.

2 years agoBan non-static lifetimes from AnonConst on AST.
Camille GILLOT [Thu, 31 Mar 2022 18:10:37 +0000 (20:10 +0200)]
Ban non-static lifetimes from AnonConst on AST.

The extra diagnostics come from the compiler no longer aborting before
typeck.

2 years agoAuto merge of #96566 - Dylan-DPC:rollup-fo7rd98, r=Dylan-DPC
bors [Fri, 29 Apr 2022 22:27:10 +0000 (22:27 +0000)]
Auto merge of #96566 - Dylan-DPC:rollup-fo7rd98, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #96390 (Switch JS code to ES6 - part 2)
 - #96527 (RustWrapper: explicitly don't handle DXILPointerTyID)
 - #96536 (rustdoc: fix missing method list for primitive deref target)
 - #96559 (Use the correct lifetime binder for elided lifetimes in path.)
 - #96560 (Remove unnecessary environment variable in cf-protection documentation)
 - #96562 (Fix duplicate directory separator in --remap-path-prefix.)

Failed merges:

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

2 years agoRollup merge of #96562 - michaelwoerister:path-remapping-fixes, r=oli-obk
Dylan DPC [Fri, 29 Apr 2022 21:54:43 +0000 (23:54 +0200)]
Rollup merge of #96562 - michaelwoerister:path-remapping-fixes, r=oli-obk

Fix duplicate directory separator in --remap-path-prefix.

The compiler will currently emit duplicate directory separators when `--remap-path-prefix` has an exact match of the working directory and it is invoked with a relative path to the main source file. For example

```bash
rustc src/main.rs -Cdebuginfo=2 --remap-path-prefix="$(pwd)=abc"
```

will produce the path `abc//src/main.rs` in debuginfo. This is because `some_path.join("")` will append a directory separator to `some_path` and then LLVM does not check if the working directory already ends a directory separator before concatenating it with the relative path.

2 years agoRollup merge of #96560 - abrown:update-docs, r=Dylan-DPC
Dylan DPC [Fri, 29 Apr 2022 21:54:42 +0000 (23:54 +0200)]
Rollup merge of #96560 - abrown:update-docs, r=Dylan-DPC

Remove unnecessary environment variable in cf-protection documentation

Before merging the `cf-protection` flag, it was necessary to use a
locally-compiled version of `rustc`. This is no longer the case and the
documentation should reflect this.

2 years agoRollup merge of #96559 - cjgillot:elided-path-fn, r=petrochenkov
Dylan DPC [Fri, 29 Apr 2022 21:54:41 +0000 (23:54 +0200)]
Rollup merge of #96559 - cjgillot:elided-path-fn, r=petrochenkov

Use the correct lifetime binder for elided lifetimes in path.

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

2 years agoRollup merge of #96536 - rust-lang:notriddle/deref-slice-core, r=GuillaumeGomez
Dylan DPC [Fri, 29 Apr 2022 21:54:40 +0000 (23:54 +0200)]
Rollup merge of #96536 - rust-lang:notriddle/deref-slice-core, r=GuillaumeGomez

rustdoc: fix missing method list for primitive deref target

This change makes it so that local impls count when listing primitives that need retained.

Fixes #95325

2 years agoRollup merge of #96527 - durin42:llvm-15-werror-wswitch, r=nikic
Dylan DPC [Fri, 29 Apr 2022 21:54:38 +0000 (23:54 +0200)]
Rollup merge of #96527 - durin42:llvm-15-werror-wswitch, r=nikic

RustWrapper: explicitly don't handle DXILPointerTyID

This new enum entry was introduced in https://reviews.llvm.org/D122268,
and if I'm reading correctly there's no case where we'd ever encounter
it in our uses of LLVM. To preserve the ability to compile this file
with -Werror -Wswitch we add an explicit case for this entry.

r? nikic

2 years agoRollup merge of #96390 - GuillaumeGomez:es6-part2, r=notriddle
Dylan DPC [Fri, 29 Apr 2022 21:54:37 +0000 (23:54 +0200)]
Rollup merge of #96390 - GuillaumeGomez:es6-part2, r=notriddle

Switch JS code to ES6 - part 2

Part of #93058.

It's based on https://github.com/rust-lang/rust/pull/96361 so it needs to wait for it to be merged first.

r? `@notriddle`

2 years agoRemove `error` variable.
Camille GILLOT [Fri, 29 Apr 2022 20:26:22 +0000 (22:26 +0200)]
Remove `error` variable.

2 years agoAuto merge of #95819 - oli-obk:mir_can't_hold_all_these_lifetimes, r=estebank
bors [Fri, 29 Apr 2022 20:00:47 +0000 (20:00 +0000)]
Auto merge of #95819 - oli-obk:mir_can't_hold_all_these_lifetimes, r=estebank

Enforce Copy bounds for repeat elements while considering lifetimes

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

this is a breaking change in order to fix a soundness bug.

Before this PR we only checked whether the repeat element type had an `impl Copy`, but not whether that impl also had the appropriate lifetimes. E.g. if the impl was for `YourType<'static>` and not a general `'a`, then copying any type other than a `'static` one should have been rejected, but wasn't.

r? `@lcnr`

2 years agoEliminate duplication of RPO calculation for mir
SparrowLii [Thu, 28 Apr 2022 03:31:08 +0000 (11:31 +0800)]
Eliminate duplication of RPO calculation for mir

add `postorder_cache` to mir Body

add `ReversePostorderCache` struct

correct struct name and comments

2 years agoFix duplicate directory separator in --remap-path-prefix.
Michael Woerister [Fri, 29 Apr 2022 17:36:02 +0000 (19:36 +0200)]
Fix duplicate directory separator in --remap-path-prefix.

2 years agoRefactor and document the repeat length check
Oli Scherer [Fri, 29 Apr 2022 18:56:57 +0000 (18:56 +0000)]
Refactor and document the repeat length check

2 years agoExtract copy bound check into a function
Oli Scherer [Fri, 29 Apr 2022 18:49:02 +0000 (18:49 +0000)]
Extract copy bound check into a function

2 years agoRemove unnecessary environment variable in cf-protection documentation
Andrew Brown [Fri, 29 Apr 2022 17:32:34 +0000 (10:32 -0700)]
Remove unnecessary environment variable in cf-protection documentation

Before merging the `cf-protection` flag, it was necessary to use a
locally-compiled version of `rustc`. This is no longer the case and the
documentation should reflect this.

2 years agoAuto merge of #96474 - SparrowLii:langcall, r=lcnr
bors [Fri, 29 Apr 2022 17:20:00 +0000 (17:20 +0000)]
Auto merge of #96474 - SparrowLii:langcall, r=lcnr

Eliminate duplication code of building panic langcall during codegen

From the FIXME in the `codegen_panic_intrinsic` func.

2 years agoUse the correct lifetime binder for elided lifetimes in path.
Camille GILLOT [Fri, 29 Apr 2022 16:48:48 +0000 (18:48 +0200)]
Use the correct lifetime binder for elided lifetimes in path.

2 years agorustdoc: prevent B -> C -> B -> C loops from stack overflowing
Michael Howell [Fri, 29 Apr 2022 15:49:14 +0000 (08:49 -0700)]
rustdoc: prevent B -> C -> B -> C loops from stack overflowing

2 years agoBless tests.
Camille GILLOT [Wed, 8 Dec 2021 21:51:39 +0000 (22:51 +0100)]
Bless tests.

2 years agoAuto merge of #96489 - shepmaster:revert-vec-from-array-ref, r=yaahc
bors [Fri, 29 Apr 2022 14:39:14 +0000 (14:39 +0000)]
Auto merge of #96489 - shepmaster:revert-vec-from-array-ref, r=yaahc

Revert "impl From<&[T; N]> and From<&mut [T; N]> for Vec<T>"

This reverts commit 5dd702763ae0e112332a4447171adbed51aeee3d.

2 years agoAuto merge of #96468 - davidtwco:diagnostic-translation-subdiagnostic, r=oli-obk
bors [Fri, 29 Apr 2022 11:58:24 +0000 (11:58 +0000)]
Auto merge of #96468 - davidtwco:diagnostic-translation-subdiagnostic, r=oli-obk

macros: subdiagnostic derive

Add a new macro, `#[derive(SessionSubdiagnostic)]`, which can be applied to structs that represent subdiagnostics, such as labels, notes, helps or suggestions.

`#[derive(SessionSubdiagnostic)]` can be used with the existing `#[derive(SessionDiagnostic)]`. All diagnostics implemented using either derive are translatable, and this new derive should make it easier to port existing diagnostics to using these derives.

For example, consider the following subdiagnostic types...

```rust
#[derive(SessionSubdiagnostic)]
pub enum ExpectedIdentifierLabel<'tcx> {
    #[label(slug = "parser-expected-identifier")]
    WithoutFound {
        #[primary_span]
        span: Span,
    }
    #[label(slug = "parser-expected-identifier-found")]
    WithFound {
        #[primary_span]
        span: Span,
        found: String,
    }
}

#[derive(SessionSubdiagnostic)]
#[suggestion_verbose(slug = "parser-raw-identifier")]
pub struct RawIdentifierSuggestion<'tcx> {
    #[primary_span]
    span: Span,
    #[applicability]
    applicability: Applicability,
    ident: Ident,
}
```

...and the corresponding Fluent messages:

```fluent
parser-expected-identifier = expected identifier

parser-expected-identifier-found = expected identifier, found {$found}

parser-raw-identifier = escape `{$ident}` to use it as an identifier
```

These can be emitted using the new `subdiagnostic` function on `Diagnostic`...

```rust
diag.subdiagnostic(ExpectedIdentifierLabel::WithoutFound { span });
diag.subdiagnostic(RawIdentifierSuggestion { span, applicability, ident });
```

...or as part of a larger `#[derive(SessionDiagnostic)]`:

```rust
#[derive(SessionDiagnostic)]
#[error(slug = "parser-expected-identifier")]
pub struct ExpectedIdentifier {
    #[primary_span]
    span: Span,
    token_descr: String,
    #[subdiagnostic]
    label: ExpectedIdentifierLabel,
    #[subdiagnostic]
    raw_identifier_suggestion: Option<RawIdentifierSuggestion>,
}
```

```rust
sess.emit_err(ExpectedIdentifier { ... });
```

r? `@oli-obk`
cc `@pvdrz`

2 years agoAuto merge of #96548 - Dylan-DPC:rollup-m3xkqxg, r=Dylan-DPC
bors [Fri, 29 Apr 2022 09:33:29 +0000 (09:33 +0000)]
Auto merge of #96548 - Dylan-DPC:rollup-m3xkqxg, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #96477 (Update data layout string for wasm64-unknown-unknown)
 - #96481 (HashMap doc: Don't use monospace font for 'Entry Api')
 - #96492 (Revert "Re-export core::ffi types from std::ffi")
 - #96516 (Revert diagnostic duplication and accidental stabilization)
 - #96523 (Add ``@feat.00`` symbol to symbols.o for COFF)

Failed merges:

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

2 years agoRollup merge of #96523 - nbdd0121:windows, r=petrochenkov
Dylan DPC [Fri, 29 Apr 2022 09:23:16 +0000 (11:23 +0200)]
Rollup merge of #96523 - nbdd0121:windows, r=petrochenkov

Add `@feat.00` symbol to symbols.o for COFF

Fix #96498

This is based on top of #96444.

r? ``@petrochenkov``

2 years agoRollup merge of #96516 - oli-obk:impl_trait_inference_accidental_permitted, r=jackh726
Dylan DPC [Fri, 29 Apr 2022 09:23:15 +0000 (11:23 +0200)]
Rollup merge of #96516 - oli-obk:impl_trait_inference_accidental_permitted, r=jackh726

Revert diagnostic duplication and accidental stabilization

fixes #96460

this is an accidental stabilization that we should put into the beta. I believe it is low-risk, because it was literally what we had before #94081

The effect on tests is massive, but mostly deduplication of diagnostics and some minor span changes.

2 years agoRollup merge of #96492 - joshtriplett:revert-std-ffi-re-export, r=yaahc
Dylan DPC [Fri, 29 Apr 2022 09:23:14 +0000 (11:23 +0200)]
Rollup merge of #96492 - joshtriplett:revert-std-ffi-re-export, r=yaahc

Revert "Re-export core::ffi types from std::ffi"

This reverts commit 9aed829fe6cdf5eaf278c6c3972f7acd0830887d.

Fixes https://github.com/rust-lang/rust/issues/96435 , a regression
in crates doing `use std::ffi::*;` and `use std::os::raw::*;`.

We can re-add this re-export once the `core::ffi` types
are stable, and thus the `std::os::raw` types can become re-exports as
well, which will avoid the conflict. (Type aliases to the same type
still conflict, but re-exports of the same type don't.)

2 years agoRollup merge of #96481 - aDotInTheVoid:hashmap-docs-monospace, r=joshtriplett
Dylan DPC [Fri, 29 Apr 2022 09:23:13 +0000 (11:23 +0200)]
Rollup merge of #96481 - aDotInTheVoid:hashmap-docs-monospace, r=joshtriplett

HashMap doc: Don't use monospace font for 'Entry Api'

2 years agoRollup merge of #96477 - alexcrichton:update-wasm64-data-layout, r=wesleywiser
Dylan DPC [Fri, 29 Apr 2022 09:23:12 +0000 (11:23 +0200)]
Rollup merge of #96477 - alexcrichton:update-wasm64-data-layout, r=wesleywiser

Update data layout string for wasm64-unknown-unknown

Looks like this changed in a recent LLVM update but wasm64 isn't built
on CI so it wasn't caught until now.

Closes #96463

2 years agoAuto merge of #96444 - nbdd0121:used2, r=petrochenkov
bors [Fri, 29 Apr 2022 05:34:29 +0000 (05:34 +0000)]
Auto merge of #96444 - nbdd0121:used2, r=petrochenkov

Use decorated names for linked_symbols on Windows

Fix #96423

r? `@petrochenkov`

2 years agoAuto merge of #96441 - ChrisDenton:sync-pipes, r=m-ou-se
bors [Fri, 29 Apr 2022 03:06:45 +0000 (03:06 +0000)]
Auto merge of #96441 - ChrisDenton:sync-pipes, r=m-ou-se

Windows: Make stdin pipes synchronous

Stdin pipes do not need to be used asynchronously within the standard library. This is a first step in making pipes mostly synchronous.

r? `@m-ou-se`

2 years agomacros: add interop between diagnostic derives
David Wood [Wed, 27 Apr 2022 04:59:48 +0000 (05:59 +0100)]
macros: add interop between diagnostic derives

Add `#[subdiagnostic]` field attribute to the diagnostic derive which
is applied to fields that have types which use the subdiagnostic derive.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agomacros: allow setting applicability in attribute
David Wood [Wed, 27 Apr 2022 04:43:36 +0000 (05:43 +0100)]
macros: allow setting applicability in attribute

In the initial implementation of the `SessionSubdiagnostic`, the
`Applicability` of a suggestion can be set both as a field and as part
of the attribute, this commit adds the same support to the original
`SessionDiagnostic` derive.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agomacros: add more documentation comments
David Wood [Wed, 27 Apr 2022 04:24:31 +0000 (05:24 +0100)]
macros: add more documentation comments

Documentation comments are always good.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agomacros: reuse `SetOnce` trait in diagnostic derive
David Wood [Wed, 27 Apr 2022 03:28:21 +0000 (04:28 +0100)]
macros: reuse `SetOnce` trait in diagnostic derive

`SetOnce` trait was introduced in the subdiagnostic derive to simplify
the code a little bit, re-use it in the diagnostic derive too.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agomacros: add helper functions for invalid attrs
David Wood [Wed, 27 Apr 2022 03:06:13 +0000 (04:06 +0100)]
macros: add helper functions for invalid attrs

Remove some duplicated code between both diagnostic derives by
introducing helper functions for reporting an error in case of a invalid
attribute.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agomacros: split diagnostic derives into modules
David Wood [Wed, 27 Apr 2022 01:57:44 +0000 (02:57 +0100)]
macros: split diagnostic derives into modules

Split `SessionDiagnostic` and `SessionSubdiagnostic` derives and the
various helper functions into multiple modules.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agomacros: subdiagnostic derive
David Wood [Tue, 26 Apr 2022 10:59:45 +0000 (11:59 +0100)]
macros: subdiagnostic derive

Add a new derive, `#[derive(SessionSubdiagnostic)]`, which enables
deriving structs for labels, notes, helps and suggestions.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agotests: move diagnostic derive test to directory
David Wood [Tue, 26 Apr 2022 05:41:31 +0000 (06:41 +0100)]
tests: move diagnostic derive test to directory

Move existing test for session diagnostic derive to a subdirectory.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agoerrors: `span_suggestion` takes `impl ToString`
David Wood [Tue, 26 Apr 2022 05:17:33 +0000 (06:17 +0100)]
errors: `span_suggestion` takes `impl ToString`

Change `span_suggestion` (and variants) to take `impl ToString` rather
than `String` for the suggested code, as this simplifies the
requirements on the diagnostic derive.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agorustdoc: fix missing method list for primitive deref target
Michael Howell [Thu, 28 Apr 2022 23:45:05 +0000 (16:45 -0700)]
rustdoc: fix missing method list for primitive deref target

This change makes it so that local impls count when listing primitives that
need retained.

2 years agoBan non-static in const generics in AST.
Camille GILLOT [Sat, 4 Dec 2021 23:07:21 +0000 (00:07 +0100)]
Ban non-static in const generics in AST.

2 years agoAuto merge of #96393 - joboet:pthread_parker, r=thomcc
bors [Thu, 28 Apr 2022 21:58:08 +0000 (21:58 +0000)]
Auto merge of #96393 - joboet:pthread_parker, r=thomcc

std: directly use pthread in UNIX parker implementation

`Mutex` and `Condvar` are being replaced by more efficient implementations, which need thread parking themselves (see #93740). Therefore we should use the `pthread` synchronization primitives directly. Also, we can avoid allocating the mutex and condition variable because the `Parker` struct is being placed in an `Arc` anyways.

This basically is just a copy of the current `Mutex` and `Condvar` code, which will however be removed (again, see #93740). An alternative implementation could be to use dedicated private `OsMutex` and `OsCondvar` types, but all the other platforms supported by std actually have their own thread parking primitives.

I used `Pin` to guarantee a stable address for the `Parker` struct, while the current implementation does not, rather using extra unsafe declaration. Since the thread struct is shared anyways, I assumed this would not add too much clutter while being clearer.

2 years agoAdd `@feat.00` symbol to symbols.o for COFF
Gary Guo [Thu, 28 Apr 2022 15:22:40 +0000 (16:22 +0100)]
Add `@feat.00` symbol to symbols.o for COFF

2 years agoAuto merge of #96528 - Dylan-DPC:rollup-iedbjli, r=Dylan-DPC
bors [Thu, 28 Apr 2022 19:32:59 +0000 (19:32 +0000)]
Auto merge of #96528 - Dylan-DPC:rollup-iedbjli, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #95312 (Ensure that `'_` and GAT yields errors)
 - #96405 (Migrate ambiguous plus diagnostic to the new derive macro)
 - #96409 (Recover suggestions to introduce named lifetime under NLL)
 - #96433 (rustc_ast: Harmonize delimiter naming with `proc_macro::Delimiter`)
 - #96480 (Fixed grammatical error in example comment)

Failed merges:

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

2 years agoRollup merge of #96480 - user-simon:patch-1, r=Dylan-DPC
Dylan DPC [Thu, 28 Apr 2022 18:13:03 +0000 (20:13 +0200)]
Rollup merge of #96480 - user-simon:patch-1, r=Dylan-DPC

Fixed grammatical error in example comment

Added missing "we" in sentence.

2 years agoRollup merge of #96433 - petrochenkov:delim, r=nnethercote
Dylan DPC [Thu, 28 Apr 2022 18:13:02 +0000 (20:13 +0200)]
Rollup merge of #96433 - petrochenkov:delim, r=nnethercote

rustc_ast: Harmonize delimiter naming with `proc_macro::Delimiter`

Compiler cannot reuse `proc_macro::Delimiter` directly due to extra impls, but can at least use the same naming.

After this PR the only difference between these two enums is that `proc_macro::Delimiter::None` is turned into `token::Delimiter::Invisible`.
It's my mistake that the invisible delimiter is called `None` on stable, during the stabilization I audited the naming and wrote the docs, but missed the fact that the `None` naming gives a wrong and confusing impression about what this thing is.

cc https://github.com/rust-lang/rust/pull/96421
r? ``@nnethercote``

2 years agoRollup merge of #96409 - marmeladema:fix-nll-introduce-named-lifetime-suggestion...
Dylan DPC [Thu, 28 Apr 2022 18:13:01 +0000 (20:13 +0200)]
Rollup merge of #96409 - marmeladema:fix-nll-introduce-named-lifetime-suggestion, r=jackh726

Recover suggestions to introduce named lifetime under NLL

Fixes #96157

r? ```@jackh726```

Built on top of #96385 so only the second commit is relevant

2 years agoRollup merge of #96405 - pvdrz:ambiguous-plus-diagnostic, r=davidtwco
Dylan DPC [Thu, 28 Apr 2022 18:12:59 +0000 (20:12 +0200)]
Rollup merge of #96405 - pvdrz:ambiguous-plus-diagnostic, r=davidtwco

Migrate ambiguous plus diagnostic to the new derive macro

r? ````@davidtwco```` ````@jyn514````

2 years agoRollup merge of #95312 - marmeladema:tests-for-issue-95305, r=jackh726
Dylan DPC [Thu, 28 Apr 2022 18:12:57 +0000 (20:12 +0200)]
Rollup merge of #95312 - marmeladema:tests-for-issue-95305, r=jackh726

Ensure that `'_` and GAT yields errors

Fixes #95305

```@bors``` r? ```@jackh726```

2 years agoRustWrapper: explicitly don't handle DXILPointerTyID
Augie Fackler [Thu, 28 Apr 2022 17:53:52 +0000 (13:53 -0400)]
RustWrapper: explicitly don't handle DXILPointerTyID

This new enum entry was introduced in https://reviews.llvm.org/D122268,
and if I'm reading correctly there's no case where we'd ever encounter
it in our uses of LLVM. To preserve the ability to compile this file
with -Werror -Wswitch we add an explicit case for this entry.

2 years agoAuto merge of #95171 - Kobzol:llvm-ci-update, r=nikic
bors [Thu, 28 Apr 2022 16:27:18 +0000 (16:27 +0000)]
Auto merge of #95171 - Kobzol:llvm-ci-update, r=nikic

Update LLVM used for building rustc in CI for x64

LLVM 14 was tagged. It is needed for building [BOLT](https://github.com/rust-lang/rust/pull/94381), and it also improves max RSS quite [a lot](https://perf.rust-lang.org/compare.html?start=6970f88db3ac2a9cefa9c585228291ae1f18fb04&end=67acb7e3ffcc11d67abfd29c390aac629f3c0e97&stat=max-rss).

GCC was bumped to allow building the new LLVM version. The changes in building LLVM were done to speed up the build a bit by ignoring unused parts and to turn off parts that were problematic to compile even with the bumped GCC.

2 years agoUpdate LLVM submodule
Jakub Beránek [Thu, 28 Apr 2022 14:02:52 +0000 (16:02 +0200)]
Update LLVM submodule

2 years agoUpdate LLVM used for building rustc in CI for x64 to LLVM 14.0.2
Jakub Beránek [Wed, 27 Apr 2022 07:53:38 +0000 (09:53 +0200)]
Update LLVM used for building rustc in CI for x64 to LLVM 14.0.2

2 years agostd: update debuginfo check to match type definition
joboet [Thu, 28 Apr 2022 13:34:43 +0000 (15:34 +0200)]
std: update debuginfo check to match type definition

2 years agoRevert diagnostic duplication and accidental stabilization
Oli Scherer [Thu, 28 Apr 2022 13:25:36 +0000 (13:25 +0000)]
Revert diagnostic duplication and accidental stabilization

2 years agoAuto merge of #95976 - b-naber:valtree-constval-conversion, r=oli-obk
bors [Thu, 28 Apr 2022 13:18:22 +0000 (13:18 +0000)]
Auto merge of #95976 - b-naber:valtree-constval-conversion, r=oli-obk

Implement Valtree to ConstValue conversion

Once we start to use `ValTree`s in the type system we will need to be able to convert them into `ConstValue` instances, which we want to continue to use after MIR construction.

r? `@oli-obk`

cc `@RalfJung`

2 years agouse tcx.require_lang_item() instead
SparrowLii [Thu, 28 Apr 2022 12:18:01 +0000 (20:18 +0800)]
use tcx.require_lang_item() instead

2 years agostd: simplify UNIX parker timeouts
joboet [Wed, 27 Apr 2022 17:28:27 +0000 (19:28 +0200)]
std: simplify UNIX parker timeouts

2 years agoUpdate the diagnostic message to match the new span
Oli Scherer [Thu, 28 Apr 2022 09:40:42 +0000 (09:40 +0000)]
Update the diagnostic message to match the new span

2 years agoAuto merge of #95904 - paolobarbolini:vecdeque-specextend, r=the8472
bors [Thu, 28 Apr 2022 09:27:21 +0000 (09:27 +0000)]
Auto merge of #95904 - paolobarbolini:vecdeque-specextend, r=the8472

Add VecDeque::extend from vec::IntoIter and slice::Iter specializations

Inspired from the [`Vec` `SpecExtend` implementation](https://github.com/rust-lang/rust/blob/027a232755fa9728e9699337267f6675dfd0a8ba/library/alloc/src/vec/spec_extend.rs), but without the specialization for `TrustedLen` which I'll look into in the future.

Should help #95632 and https://github.com/KillingSpark/zstd-rs/pull/17

## Benchmarks

Before

```
test vec_deque::bench_extend_bytes    ... bench:         862 ns/iter (+/- 10)
test vec_deque::bench_extend_vec      ... bench:         883 ns/iter (+/- 19)
```

After

```
test vec_deque::bench_extend_bytes    ... bench:           8 ns/iter (+/- 0)
test vec_deque::bench_extend_vec      ... bench:          24 ns/iter (+/- 1)

```

2 years agoAdd new repeat expr test.
Oli Scherer [Tue, 12 Apr 2022 07:28:07 +0000 (07:28 +0000)]
Add new repeat expr test.

Also add repeat expr test folder and move all related tests to it

2 years agoCheck that repeat expression elements are Copy (ignoring lifetimes) in typeck and...
Oli Scherer [Mon, 11 Apr 2022 16:38:48 +0000 (16:38 +0000)]
Check that repeat expression elements are Copy (ignoring lifetimes) in typeck and that they are Copy (with proper lifetime checks) in borrowck

2 years agorustc_ast: Harmonize delimiter naming with `proc_macro::Delimiter`
Vadim Petrochenkov [Tue, 26 Apr 2022 12:40:14 +0000 (15:40 +0300)]
rustc_ast: Harmonize delimiter naming with `proc_macro::Delimiter`

2 years agoAuto merge of #96503 - ehuss:update-cargo, r=ehuss
bors [Thu, 28 Apr 2022 06:58:54 +0000 (06:58 +0000)]
Auto merge of #96503 - ehuss:update-cargo, r=ehuss

Update cargo

8 commits in edffc4ada3d77799e5a04eeafd9b2f843d29fc23..f63f23ff1f1a12ede8585bbd1bbf0c536e50293d
2022-04-19 17:38:29 +0000 to 2022-04-28 03:15:50 +0000
- move workspace inheritance untable docs to the correct place (rust-lang/cargo#10609)
- Cargo add support for workspace inheritance (rust-lang/cargo#10606)
- chore: Upgrade toml_edit (rust-lang/cargo#10603)
- Mark .cargo/git and .cargo/registry as cache dirs (rust-lang/cargo#10553)
- fix(yank): Use '--version' like install (rust-lang/cargo#10575)
- Disallow setting registry tokens with --config (rust-lang/cargo#10580)
- Set cargo --version git hash length to 9 (rust-lang/cargo#10579)
- Prefer `key.workspace = true` to `key = { workspace = true }` (rust-lang/cargo#10584)

2 years agoUpdate cargo
Eric Huss [Thu, 28 Apr 2022 05:42:54 +0000 (22:42 -0700)]
Update cargo

2 years agoAuto merge of #96085 - jsgf:deny-unused-deps, r=compiler-errors
bors [Thu, 28 Apr 2022 04:17:52 +0000 (04:17 +0000)]
Auto merge of #96085 - jsgf:deny-unused-deps, r=compiler-errors

Make sure `-Dunused-crate-dependencies --json unused-externs` makes rustc exit with error status

This PR:
- fixes compiletest to understand unused extern notifications
- adds tests for `--json unused-externs`
- makes sure that deny-level unused externs notifications are treated as compile errors
  - refactors the `emit_unused_externs` callstack to plumb through the level as an enum as a string, and adds `Level::is_error`

Update: adds `--json unused-externs-silent` with the original behaviour since Cargo needs it. Should address `@est31's` concerns.

Fixes: https://github.com/rust-lang/rust/issues/96068
2 years agoAdd VecDeque::extend from vec::IntoIter and slice::Iter specializations
Paolo Barbolini [Sun, 10 Apr 2022 22:00:03 +0000 (00:00 +0200)]
Add VecDeque::extend from vec::IntoIter and slice::Iter specializations

2 years agoAuto merge of #96495 - Dylan-DPC:rollup-9lm4tpp, r=Dylan-DPC
bors [Thu, 28 Apr 2022 01:37:03 +0000 (01:37 +0000)]
Auto merge of #96495 - Dylan-DPC:rollup-9lm4tpp, r=Dylan-DPC

Rollup of 7 pull requests

Successful merges:

 - #96377 (make `fn() -> _ { .. }` suggestion MachineApplicable)
 - #96397 (Make EncodeWide implement FusedIterator)
 - #96421 (Less `NoDelim`)
 - #96432 (not need `Option` for `dbg_scope`)
 - #96466 (Better error messages when collecting into `[T; n]`)
 - #96471 (replace let else with `?`)
 - #96483 (Add missing `target_feature` to the list of well known cfg names)

Failed merges:

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

2 years agoRollup merge of #96483 - Urgau:check-cfg-target_feature, r=petrochenkov
Dylan DPC [Thu, 28 Apr 2022 00:40:37 +0000 (02:40 +0200)]
Rollup merge of #96483 - Urgau:check-cfg-target_feature, r=petrochenkov

Add missing `target_feature` to the list of well known cfg names

This PR adds the missing `target_feature` cfg name to the list of well known cfg names.

It was notice missing in https://github.com/rust-lang/rust/issues/96472 thanks to `@bjorn3,` the reason being that `--check-cfg=names()` automatically inherit the names passed by `--cfg` (or internal to `rustc`) and is seems that the vast majority of targets have at least one target feature leading to `target_feature` being a well known name in most target but it should always be a well known name so this PR add it unconditionally to list.

r? `@petrochenkov`

2 years agoRollup merge of #96471 - BoxyUwU:let_else_considered_harmful, r=lcnr
Dylan DPC [Thu, 28 Apr 2022 00:40:36 +0000 (02:40 +0200)]
Rollup merge of #96471 - BoxyUwU:let_else_considered_harmful, r=lcnr

replace let else with `?`

r? `@oli-obk`

2 years agoRollup merge of #96466 - compiler-errors:error-collect-array, r=davidtwco
Dylan DPC [Thu, 28 Apr 2022 00:40:35 +0000 (02:40 +0200)]
Rollup merge of #96466 - compiler-errors:error-collect-array, r=davidtwco

Better error messages when collecting into `[T; n]`

Fixes #96461

2 years agoRollup merge of #96432 - SparrowLii:dbg_scope, r=davidtwco
Dylan DPC [Thu, 28 Apr 2022 00:40:34 +0000 (02:40 +0200)]
Rollup merge of #96432 - SparrowLii:dbg_scope, r=davidtwco

not need `Option` for `dbg_scope`

This PR fixes a few FIXME about not using `Option` in `dbg_scope` field of `DebugScope`, during `create_function_debug_context` func in codegen parts.
Added a `BitSet<SourceScope>` parameter to `make_mir_scope` to indicate whether the `DebugScope` has been instantiated.
cc ````@eddyb````

2 years agoRollup merge of #96421 - nnethercote:less-NoDelim, r=petrochenkov
Dylan DPC [Thu, 28 Apr 2022 00:40:34 +0000 (02:40 +0200)]
Rollup merge of #96421 - nnethercote:less-NoDelim, r=petrochenkov

Less `NoDelim`

Currently there are several places where `NoDelim` (which really means "implicit delimiter" or "invisible delimiter") is used to mean "no delimiter". The name `NoDelim` is a bit misleading, and may be a cause.

This PR changes these places, e.g. by changing a `DelimToken` to `Option<DelimToken>` and then using `None` to mean "no delimiter". As a result, the *only* place where `NoDelim` values are now produced is within:
- `Delimiter::to_internal()`, when converting from `Delimiter::None`.
- `FlattenNonterminals::process_token()`, when converting `TokenKind::Interpolated`.

r? ````@petrochenkov````

2 years agoRollup merge of #96397 - AronParker:issue-96368-fix, r=dtolnay
Dylan DPC [Thu, 28 Apr 2022 00:40:33 +0000 (02:40 +0200)]
Rollup merge of #96397 - AronParker:issue-96368-fix, r=dtolnay

Make EncodeWide implement FusedIterator

[`EncodeUtf16`](https://doc.rust-lang.org/std/str/struct.EncodeUtf16.html) and [`EncodeWide`](https://doc.rust-lang.org/std/os/windows/ffi/struct.EncodeWide.html) currently serve similar purposes: They convert from UTF-8 to UTF-16 and WTF-8 to WTF-16, respectively. `EncodeUtf16` wraps a &str, whereas `EncodeWide` wraps an &OsStr.

When Iteration has concluded, these iterators wrap an empty slice, which will forever yield `None` values. Hence, `EncodeUtf16` rightfully implements `FusedIterator`. However, `EncodeWide` in contrast does not, even though it serves an almost identical purpose.

This PR attempts to fix that issue. I consider this change minor and non-controversial, hence why I have not added a RFC/FCP. Please let me know if the stability attribute is wrong or contains a wrong version number. Thanks in advance.

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

2 years agoRollup merge of #96377 - compiler-errors:infer-rustfix, r=petrochenkov
Dylan DPC [Thu, 28 Apr 2022 00:40:32 +0000 (02:40 +0200)]
Rollup merge of #96377 - compiler-errors:infer-rustfix, r=petrochenkov

make `fn() -> _ { .. }` suggestion MachineApplicable

This might not be valid, but it would be nice to promote this to `MachineApplicable` so people can use rustfix here.

Also de65fcf009d07019689cfad7f327667e390a325d is to [restore the suggestion for `issue-77179.rs`](https://github.com/rust-lang/rust/commit/de65fcf009d07019689cfad7f327667e390a325d#diff-12e43fb5d6d12ec7cb5c6b48204a18d113cf5de0e12eb71a358b639bd9aadaf0R8). (though in this case, the code in that issue still doesn't compile, so it's not marked with rustfix).

2 years agoAuto merge of #91557 - cjgillot:ast-lifetimes-named, r=petrochenkov
bors [Wed, 27 Apr 2022 23:13:28 +0000 (23:13 +0000)]
Auto merge of #91557 - cjgillot:ast-lifetimes-named, r=petrochenkov

Perform lifetime resolution on the AST for lowering

Lifetime resolution is currently implemented several times. Once during lowering in order to introduce in-band lifetimes, and once in the resolve_lifetimes query. However, due to the global nature of lifetime resolution and how it interferes with hygiene, it is better suited on the AST.

This PR implements a first draft of lifetime resolution on the AST. For now, we specifically target named lifetimes and everything we need to remove lifetime resolution from lowering. Some diagnostics have already been ported, and sometimes made more precise using available hygiene information. Follow-up PRs will address in particular the resolution of anonymous lifetimes on the AST.

We reuse the rib design of the current resolution framework. Specific `LifetimeRib` and `LifetimeRibKind` types are introduced. The most important variant is `LifetimeRibKind::Generics`, which happens each time we encounter something which may introduce generic lifetime parameters. It can be an item or a `for<...>` binder. The `LifetimeBinderKind` specifies how this rib behaves with respect to in-band lifetimes.

r? `@petrochenkov`

2 years agoEnsure that `'_` and GAT yields errors
marmeladema [Fri, 25 Mar 2022 17:26:55 +0000 (18:26 +0100)]
Ensure that `'_` and GAT yields errors

2 years agoRevert "Re-export core::ffi types from std::ffi"
Josh Triplett [Wed, 27 Apr 2022 20:47:10 +0000 (13:47 -0700)]
Revert "Re-export core::ffi types from std::ffi"

This reverts commit 9aed829fe6cdf5eaf278c6c3972f7acd0830887d.

Fixes https://github.com/rust-lang/rust/issues/96435 , a regression
in crates doing `use std::ffi::*;` and `use std::os::raw::*;`.

We can re-add this re-export once the `core::ffi` types
are stable, and thus the `std::os::raw` types can become re-exports as
well, which will avoid the conflict. (Type aliases to the same type
still conflict, but re-exports of the same type don't.)

2 years agoRemove use of reverted std::ffi::c_char
Josh Triplett [Wed, 27 Apr 2022 21:00:45 +0000 (14:00 -0700)]
Remove use of reverted std::ffi::c_char

2 years agoRecover suggestions to introduce named lifetime under NLL
marmeladema [Mon, 25 Apr 2022 22:17:25 +0000 (00:17 +0200)]
Recover suggestions to introduce named lifetime under NLL

2 years agoCollect extra lifetime parameters during late resolution.
Camille GILLOT [Sun, 24 Apr 2022 13:49:00 +0000 (15:49 +0200)]
Collect extra lifetime parameters during late resolution.