]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agodoc/platform-support: Add documentation for m68k-unknown-linux-gnu
John Paul Adrian Glaubitz [Mon, 30 Aug 2021 18:36:39 +0000 (18:36 +0000)]
doc/platform-support: Add documentation for m68k-unknown-linux-gnu

2 years agodoc/platform-support.md: Add m68k-unknown-linux-gnu as Tier 3 target
John Paul Adrian Glaubitz [Thu, 26 Aug 2021 11:02:04 +0000 (11:02 +0000)]
doc/platform-support.md: Add m68k-unknown-linux-gnu as Tier 3 target

2 years agolibrary/std/env: Add 'm68k' to comment on ARCH constant
John Paul Adrian Glaubitz [Wed, 25 Aug 2021 07:51:34 +0000 (07:51 +0000)]
library/std/env: Add 'm68k' to comment on ARCH constant

2 years agocompiler/rustc_llvm: Enable M68k LLVM target
John Paul Adrian Glaubitz [Wed, 25 Aug 2021 07:49:17 +0000 (07:49 +0000)]
compiler/rustc_llvm: Enable M68k LLVM target

2 years agolibstd: Add m68k for raw type definitions on Linux
John Paul Adrian Glaubitz [Wed, 25 Aug 2021 07:48:23 +0000 (07:48 +0000)]
libstd: Add m68k for raw type definitions on Linux

2 years agorustdoc: Add human-readable cfg string for m68k
John Paul Adrian Glaubitz [Wed, 25 Aug 2021 07:47:50 +0000 (07:47 +0000)]
rustdoc: Add human-readable cfg string for m68k

2 years agocompiletest: Add m68k to ARCH_TABLE
John Paul Adrian Glaubitz [Wed, 25 Aug 2021 07:47:23 +0000 (07:47 +0000)]
compiletest: Add m68k to ARCH_TABLE

2 years agoci: Add Dockerfile for dist-m68k-linux
John Paul Adrian Glaubitz [Wed, 25 Aug 2021 07:46:46 +0000 (07:46 +0000)]
ci: Add Dockerfile for dist-m68k-linux

2 years agobuild-manifest: Add m68k-unknown-linux-gnu target
John Paul Adrian Glaubitz [Wed, 25 Aug 2021 07:45:58 +0000 (07:45 +0000)]
build-manifest: Add m68k-unknown-linux-gnu target

2 years agocompiler/rustc_target: Add support for m68k-linux-gnu
John Paul Adrian Glaubitz [Wed, 25 Aug 2021 07:45:06 +0000 (07:45 +0000)]
compiler/rustc_target: Add support for m68k-linux-gnu

2 years agobootstrap: Add LLVM target matching for M68k
John Paul Adrian Glaubitz [Wed, 25 Aug 2021 07:43:42 +0000 (07:43 +0000)]
bootstrap: Add LLVM target matching for M68k

2 years agobootstrap: Add cputype matching for m68k
John Paul Adrian Glaubitz [Wed, 25 Aug 2021 07:43:20 +0000 (07:43 +0000)]
bootstrap: Add cputype matching for m68k

2 years agoUpdate odht to 0.2.1
Michael Woerister [Fri, 10 Sep 2021 12:12:30 +0000 (14:12 +0200)]
Update odht to 0.2.1

2 years agoCorrectly handle "--open" option when building compiler docs
Guillaume Gomez [Sun, 5 Sep 2021 15:24:09 +0000 (17:24 +0200)]
Correctly handle "--open" option when building compiler docs

2 years agoAllow to pass "compiler" arguments to doc subcommand
Guillaume Gomez [Sun, 5 Sep 2021 15:20:37 +0000 (17:20 +0200)]
Allow to pass "compiler" arguments to doc subcommand

2 years agoAuto merge of #88945 - Aaron1011:no-projection-completion, r=wesleywiser,jackh726
bors [Fri, 17 Sep 2021 09:44:28 +0000 (09:44 +0000)]
Auto merge of #88945 - Aaron1011:no-projection-completion, r=wesleywiser,jackh726

Remove concept of 'completion' from the projection cache

Fixes #88910

When we initially store a `NormalizedTy` in the projection cache,
we discard all obligations that we can (while ensuring that we
don't cause any issues with incremental compilation).

Marking a projection cache entry as 'completed' discards all
obligations associated with it. This can only cause problems,
since any obligations stored in the cache are there for a reason
(e.g. they evaluate to `EvaluatedToOkModuloRegions`).

This commit removes `complete` and `complete_normalized` entirely.

2 years agoAuto merge of #89037 - JohnTitor:rollup-rd9btbs, r=JohnTitor
bors [Fri, 17 Sep 2021 06:47:35 +0000 (06:47 +0000)]
Auto merge of #89037 - JohnTitor:rollup-rd9btbs, r=JohnTitor

Rollup of 10 pull requests

Successful merges:

 - #86382 (Make diagnostics clearer for `?` operators)
 - #87529 (Fix ICE in `improper_ctypes_definitions` lint with all-ZST transparent types)
 - #88339 (Add TcpListener::into_incoming and IntoIncoming)
 - #88735 (Don't lint about missing code examples in derived traits)
 - #88751 (Couple of changes to FileSearch and SearchPath)
 - #88883 (Move some tests to more reasonable directories - 7)
 - #88887 (Const Deref)
 - #88911 (Improve error message for type mismatch in generator arguments)
 - #89014 (PassWrapper: handle separate Module*SanitizerPass)
 - #89033 (Set the library path in sysroot-crates-are-unstable)

Failed merges:

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

2 years agoApply review comments
Yuki Okushi [Fri, 17 Sep 2021 05:10:41 +0000 (14:10 +0900)]
Apply review comments

2 years agoRollup merge of #89033 - cuviper:sysroot-lib-path, r=Mark-Simulacrum
Yuki Okushi [Fri, 17 Sep 2021 05:09:51 +0000 (14:09 +0900)]
Rollup merge of #89033 - cuviper:sysroot-lib-path, r=Mark-Simulacrum

Set the library path in sysroot-crates-are-unstable

Most of the `run-make-fulldeps` tests use a make-driven rustc command
that includes `HOST_RPATH_DIR` in the library path, but this particular
test runs from python instead. When the toolchain is built without
`rpath` enabled, we need that library path in the environment so it can
find its own libraries.

2 years agoRollup merge of #89014 - durin42:llvm-14-module-pass-manager, r=nikic
Yuki Okushi [Fri, 17 Sep 2021 05:09:50 +0000 (14:09 +0900)]
Rollup merge of #89014 - durin42:llvm-14-module-pass-manager, r=nikic

PassWrapper: handle separate Module*SanitizerPass

Change ab41eef9aca3 in LLVM split MemorySanitizerPass into
MemorySanitizerPass for functions and ModuleMemorySanitizerPass for
modules. There's a related change for ThreadSanitizerPass, and in here
since we're using a ModulePassManager I only add the module flavor of
the pass on LLVM 14.

r? `@nikic` cc `@nagisa`

2 years agoRollup merge of #88911 - FabianWolff:issue-88653, r=petrochenkov
Yuki Okushi [Fri, 17 Sep 2021 05:09:49 +0000 (14:09 +0900)]
Rollup merge of #88911 - FabianWolff:issue-88653, r=petrochenkov

Improve error message for type mismatch in generator arguments

Fixes #88653. The code example given there is invalid because the `Generator` trait (unlike the `Fn` traits) does not take the generator arguments in tupled-up form (because there can only be one argument, from my understanding). Hence, the type error in the example in #88653 is correct, because the given generator takes a `bool` argument, whereas the function's return type talks about a generator with a `(bool,)` argument.

The error message is both confusing and wrong, though: It is wrong because it displays the wrong "expected signature", and it is confusing because both the "expected" and "found" notes point at the same span. With my changes, I get the following, more helpful output:
```
error[E0631]: type mismatch in generator arguments
 --> test.rs:5:22
  |
5 | fn foo(bar: bool) -> impl Generator<(bool,)> {
  |                      ^^^^^^^^^^^^^^^^^^^^^^^ expected signature of `fn((bool,)) -> _`
6 |     |bar| {
  |     ----- found signature of `fn(bool) -> _`
```

2 years agoRollup merge of #88887 - fee1-dead:const-deref, r=oli-obk
Yuki Okushi [Fri, 17 Sep 2021 05:09:48 +0000 (14:09 +0900)]
Rollup merge of #88887 - fee1-dead:const-deref, r=oli-obk

Const Deref

Implements `const Deref`/`const DerefMut` for `&mut T`, `&T`, `Cow<'_, B>` and `ManuallyDrop<T>`

2 years agoRollup merge of #88883 - c410-f3r:tests, r=petrochenkov
Yuki Okushi [Fri, 17 Sep 2021 05:09:48 +0000 (14:09 +0900)]
Rollup merge of #88883 - c410-f3r:tests, r=petrochenkov

Move some tests to more reasonable directories - 7

cc #73494
r? ``@petrochenkov``

2 years agoRollup merge of #88751 - bjorn3:move_filesearch, r=oli-obk
Yuki Okushi [Fri, 17 Sep 2021 05:09:47 +0000 (14:09 +0900)]
Rollup merge of #88751 - bjorn3:move_filesearch, r=oli-obk

Couple of changes to FileSearch and SearchPath

* Turn a couple of regular comments into doc comments
* Move `get_tools_search_paths` from `FileSearch` to `Session`
* Use Lrc instead of Option to avoid duplication of a `SearchPath`

2 years agoRollup merge of #88735 - hnj2:patch-1, r=GuillaumeGomez
Yuki Okushi [Fri, 17 Sep 2021 05:09:46 +0000 (14:09 +0900)]
Rollup merge of #88735 - hnj2:patch-1, r=GuillaumeGomez

Don't lint about missing code examples in derived traits

When the `missing_doc_code_examples` lint is performed it also requires that derived Trait implementations have a code example for each member etc., which causes undesirable behavior.

# Examples

With `missing_doc_code_examples` enable we are not able to use the `Clone` derive macro due to the generated code not being documented:
```rust
#[deny(rustdoc::missing_doc_code_examples)]

/// docs
/// ```
/// let s = SomeStruct;
/// ```
#[derive(Clone)]
pub struct SomeStruct;
```
yields:
```
 Documenting testt v0.1.0 (<redacted>)
error: missing code example in this documentation
 --> src/lib.rs:7:10
  |
7 | #[derive(Clone)]
  |          ^^^^^
  |
note: the lint level is defined here
 --> src/lib.rs:1:8
  |
1 | #[deny(rustdoc::missing_doc_code_examples)]
  |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: missing code example in this documentation
 --> src/lib.rs:7:10
  |
7 | #[derive(Clone)]
  |          ^^^^^

error: could not document `testt`

Caused by:
  process didn't exit successfully: `rustdoc ...
```

closes #81775

2 years agoRollup merge of #88339 - piegamesde:master, r=joshtriplett
Yuki Okushi [Fri, 17 Sep 2021 05:09:45 +0000 (14:09 +0900)]
Rollup merge of #88339 - piegamesde:master, r=joshtriplett

Add TcpListener::into_incoming and IntoIncoming

The `incoming` method is really useful, however for some use cases the borrow
this introduces is needlessly restricting. Thus, an owned variant is added.

r? ``@joshtriplett``

2 years agoRollup merge of #87529 - FabianWolff:issue-87496, r=nikomatsakis
Yuki Okushi [Fri, 17 Sep 2021 05:09:44 +0000 (14:09 +0900)]
Rollup merge of #87529 - FabianWolff:issue-87496, r=nikomatsakis

Fix ICE in `improper_ctypes_definitions` lint with all-ZST transparent types

Fixes #87496. There is also another function in the same file that looks fishy, but I haven't been able to produce an ICE there, and in any case, it's not related to #87496:
https://github.com/rust-lang/rust/blob/fd853c00e255559255885aadff9e93a1760c8728/compiler/rustc_lint/src/types.rs#L720-L734

r? ```@JohnTitor```

2 years agoRollup merge of #86382 - JohnTitor:try-desugar, r=estebank
Yuki Okushi [Fri, 17 Sep 2021 05:09:43 +0000 (14:09 +0900)]
Rollup merge of #86382 - JohnTitor:try-desugar, r=estebank

Make diagnostics clearer for `?` operators

Re-submission of #75029, fixes #71309
This also revives the `content` methods removed by #83185.
r? `@estebank`

2 years agoRecover invalid assoc type bounds using `==`
Yuki Okushi [Wed, 28 Jul 2021 20:49:56 +0000 (05:49 +0900)]
Recover invalid assoc type bounds using `==`

2 years agoUse `multipart_suggestion`
Yuki Okushi [Fri, 17 Sep 2021 04:39:26 +0000 (13:39 +0900)]
Use `multipart_suggestion`

2 years agoEmit clearer diagnostics for parens around `for` loop heads
Yuki Okushi [Fri, 18 Jun 2021 01:22:23 +0000 (10:22 +0900)]
Emit clearer diagnostics for parens around `for` loop heads

2 years agoMake diagnostics clearer for `?` operators
Yuki Okushi [Wed, 16 Jun 2021 21:35:42 +0000 (06:35 +0900)]
Make diagnostics clearer for `?` operators

2 years agoAuto merge of #88934 - tmiasko:trace-log, r=davidtwco
bors [Fri, 17 Sep 2021 03:47:23 +0000 (03:47 +0000)]
Auto merge of #88934 - tmiasko:trace-log, r=davidtwco

Avoid unnecessary formatting when trace log level is disabled

2 years agoAuto merge of #88832 - pcwalton:debug-unit-variant-fast-path, r=oli-obk
bors [Fri, 17 Sep 2021 01:00:11 +0000 (01:00 +0000)]
Auto merge of #88832 - pcwalton:debug-unit-variant-fast-path, r=oli-obk

Introduce a fast path that avoids the `debug_tuple` abstraction when deriving Debug for unit-like enum variants.

The intent here is to allow LLVM to remove the switch entirely in favor of an
indexed load from a table of constant strings, which is likely what the
programmer would write in C. Unfortunately, LLVM currently doesn't perform this
optimization due to a bug, but there is [a
patch](https://reviews.llvm.org/D109565) that fixes this issue. I've verified
that, with that patch applied on top of this commit, Debug for unit-like tuple
variants becomes a load, reducing the O(n) code bloat to O(1).

Note that inlining `DebugTuple::finish()` wasn't enough to allow LLVM to
optimize the code properly; I had to avoid the abstraction entirely. Not using
the abstraction is likely better for compile time anyway.

Part of #88793.

r? `@oli-obk`

2 years agoSet the library path in sysroot-crates-are-unstable
Josh Stone [Fri, 17 Sep 2021 00:30:36 +0000 (17:30 -0700)]
Set the library path in sysroot-crates-are-unstable

Most of the `run-make-fulldeps` tests use a make-driven rustc command
that includes `HOST_RPATH_DIR` in the library path, but this particular
test runs from python instead. When the toolchain is built without
`rpath` enabled, we need that library path in the environment so it can
find its own libraries.

2 years agoDon't lint about missing code examples in derived traits
Hans [Tue, 7 Sep 2021 23:09:15 +0000 (01:09 +0200)]
Don't lint about missing code examples in derived traits

Fixes #81775

2 years agoDon't inline OnceCell initialization closures
The8472 [Thu, 16 Sep 2021 22:24:36 +0000 (00:24 +0200)]
Don't inline OnceCell initialization closures

2 years agoAuto merge of #88719 - estebank:point-at-arg-for-obligation, r=nagisa
bors [Thu, 16 Sep 2021 22:17:33 +0000 (22:17 +0000)]
Auto merge of #88719 - estebank:point-at-arg-for-obligation, r=nagisa

Point at argument instead of call for their obligations

When an obligation is introduced by a specific `fn` argument, point at
the argument instead of the `fn` call if the obligation fails to be
fulfilled.

Move the information about pointing at the call argument expression in
an unmet obligation span from the `FulfillmentError` to a new
`ObligationCauseCode`.

When giving an error about an obligation introduced by a function call
that an argument doesn't fulfill, and that argument is a block, add a
span_label pointing at the innermost tail expression.

Current output:

```
error[E0425]: cannot find value `x` in this scope
 --> f10.rs:4:14
  |
4 |         Some(x * 2)
  |              ^ not found in this scope

error[E0277]: expected a `FnOnce<({integer},)>` closure, found `Option<_>`
 --> f10.rs:2:31
  |
2 |       let p = Some(45).and_then({
  |  ______________________--------_^
  | |                      |
  | |                      required by a bound introduced by this call
3 | |         |x| println!("doubling {}", x);
4 | |         Some(x * 2)
  | |         -----------
5 | |     });
  | |_____^ expected an `FnOnce<({integer},)>` closure, found `Option<_>`
  |
  = help: the trait `FnOnce<({integer},)>` is not implemented for `Option<_>`
```

Previous output:

```
error[E0425]: cannot find value `x` in this scope
 --> f10.rs:4:14
  |
4 |         Some(x * 2)
  |              ^ not found in this scope

error[E0277]: expected a `FnOnce<({integer},)>` closure, found `Option<_>`
 --> f10.rs:2:22
  |
2 |     let p = Some(45).and_then({
  |                      ^^^^^^^^ expected an `FnOnce<({integer},)>` closure, found `Option<_>`
  |
  = help: the trait `FnOnce<({integer},)>` is not implemented for `Option<_>`
```

Partially address #27300. Will require rebasing on top of #88546.

2 years agoPropagate coercion cause into `try_coerce`
Aaron Hill [Thu, 16 Sep 2021 21:53:40 +0000 (16:53 -0500)]
Propagate coercion cause into `try_coerce`

Currently, `coerce_inner` discards its `ObligationCause`
when calling `try_coerce`. This interfers with other
diagnostc improvements I'm working on, since we will lose
the original span by the time the actual coercion occurs.

Additionally, we now use the span of the trailing expression
(rather than the span of the entire function) when performing
a coercion in `check_return_expr`. This currently has no visible
effect on any of the unit tests, but will unblock future
diagnostic improvements.

2 years agoAuto merge of #89019 - Manishearth:rollup-5qp8a5s, r=Manishearth
bors [Thu, 16 Sep 2021 19:33:39 +0000 (19:33 +0000)]
Auto merge of #89019 - Manishearth:rollup-5qp8a5s, r=Manishearth

Rollup of 10 pull requests

Successful merges:

 - #88292 (Enable --generate-link-to-definition for rustc's docs)
 - #88729 (Recover from `Foo(a: 1, b: 2)`)
 - #88875 (cleanup(rustc_trait_selection): remove vestigial code from rustc_on_unimplemented)
 - #88892 (Move object safety suggestions to the end of the error)
 - #88928 (Document the closure arguments for `reduce`.)
 - #88976 (Clean up and add doc comments for CStr)
 - #88983 (Allow calling `get_body_with_borrowck_facts` without `-Z polonius`)
 - #88985 (Update clobber_abi list to include k[1-7] regs)
 - #88986 (Update the backtrace crate)
 - #89009 (Fix typo in `break` docs)

Failed merges:

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

2 years agoPassWrapper: these two lines shouldn't have been ifdef'd
Augie Fackler [Thu, 16 Sep 2021 19:04:18 +0000 (15:04 -0400)]
PassWrapper: these two lines shouldn't have been ifdef'd

2 years agoAdd a separate error for `dyn Trait` in `const fn`
Waffle [Thu, 16 Sep 2021 17:57:12 +0000 (20:57 +0300)]
Add a separate error for `dyn Trait` in `const fn`

Previously "trait bounds other than `Sized` on const fn parameters are unstable"
error was used for both trait bounds (<T: Trait>) and trait objects (dyn Trait).
This was pretty confusing.

This patch adds a separeta error for trait objects: "trait objects in const fn
are unstable". The error for trait bounds is otherwise intact.

2 years agodelay error for enabling unstable lib features
Vishad Goyal [Thu, 16 Sep 2021 13:58:03 +0000 (19:28 +0530)]
delay error for enabling unstable lib features

If #![feature] is used outside the nightly channel for only lib
features, the check will be delayed to the stability pass after
parsing. This is done so that appropriate help messages can be shown if
the #![feature] has been used needlessly

2 years agoRollup merge of #89009 - tatami4:master, r=Mark-Simulacrum
Manish Goregaokar [Thu, 16 Sep 2021 17:57:25 +0000 (10:57 -0700)]
Rollup merge of #89009 - tatami4:master, r=Mark-Simulacrum

Fix typo in `break` docs

2 years agoRollup merge of #88986 - hargoniX:master, r=Mark-Simulacrum
Manish Goregaokar [Thu, 16 Sep 2021 17:57:24 +0000 (10:57 -0700)]
Rollup merge of #88986 - hargoniX:master, r=Mark-Simulacrum

Update the backtrace crate

https://github.com/rust-lang/backtrace-rs/pull/437 fixed backtraces in
OpenBSD -> update it here as well so OpenBSD Rust code can produce
proper backtraces.

2 years agoRollup merge of #88985 - Commeownist:patch-1, r=Amanieu
Manish Goregaokar [Thu, 16 Sep 2021 17:57:23 +0000 (10:57 -0700)]
Rollup merge of #88985 - Commeownist:patch-1, r=Amanieu

Update clobber_abi list to include k[1-7] regs

2 years agoRollup merge of #88983 - willcrichton:allow-single-polonius-call, r=ecstatic-morse
Manish Goregaokar [Thu, 16 Sep 2021 17:57:22 +0000 (10:57 -0700)]
Rollup merge of #88983 - willcrichton:allow-single-polonius-call, r=ecstatic-morse

Allow calling `get_body_with_borrowck_facts` without `-Z polonius`

For my [static analysis tool](https://github.com/willcrichton/flowistry), I need to access the set of outlives-constraints. Recently, #86977 merged a way to access these facts via Polonius. However, the merged implementation requires `-Z polonius` to be provided to use this feature. This uses Polonius for borrow checking on the entire crate, which as described [here](https://rust-lang.zulipchat.com/#narrow/stream/186049-t-compiler.2Fwg-polonius/topic/Polonius.20performance.20in.20a.20rustc.20plugin/near/251301631), is very slow.

This PR allows `get_body_with_borrowck_facts` to be called without `-Z polonius`. This is essential for my tool to run in a sensible length of time. This is a temporary patch as the Polonius-related APIs develop -- I can update my code as future changes happen.

Additionally, this PR also makes public two APIs that were previously public but then became private after `rustc_mir` got broken up: `rustc_mir_dataflow::framework::graphviz` and `rustc_mir_transform::MirPass`. I need both of these for my analysis tool. (I can break this change into a separate PR if necessary.)

2 years agoRollup merge of #88976 - notriddle:notriddle/cow-from-cstr-docs, r=Mark-Simulacrum
Manish Goregaokar [Thu, 16 Sep 2021 17:57:21 +0000 (10:57 -0700)]
Rollup merge of #88976 - notriddle:notriddle/cow-from-cstr-docs, r=Mark-Simulacrum

Clean up and add doc comments for CStr

CC #51430

2 years agoRollup merge of #88928 - lefth:master, r=Mark-Simulacrum
Manish Goregaokar [Thu, 16 Sep 2021 17:57:20 +0000 (10:57 -0700)]
Rollup merge of #88928 - lefth:master, r=Mark-Simulacrum

Document the closure arguments for `reduce`.

See issue #88927.

2 years agoRollup merge of #88892 - estebank:trait-objects, r=petrochenkov
Manish Goregaokar [Thu, 16 Sep 2021 17:57:20 +0000 (10:57 -0700)]
Rollup merge of #88892 - estebank:trait-objects, r=petrochenkov

Move object safety suggestions to the end of the error

2 years agoRollup merge of #88875 - notriddle:notriddle/cleanup-unused-trait-selection, r=Mark...
Manish Goregaokar [Thu, 16 Sep 2021 17:57:19 +0000 (10:57 -0700)]
Rollup merge of #88875 - notriddle:notriddle/cleanup-unused-trait-selection, r=Mark-Simulacrum

cleanup(rustc_trait_selection): remove vestigial code from rustc_on_unimplemented

This isn't allowed by the validator, and seems to be unused.
When it was added in ed10a3faae1fd1176b2edf4a61438e0542c103b9,
it was used on `Sized`, and that usage is gone.

2 years agoRollup merge of #88729 - estebank:struct-literal-using-parens, r=oli-obk
Manish Goregaokar [Thu, 16 Sep 2021 17:57:18 +0000 (10:57 -0700)]
Rollup merge of #88729 - estebank:struct-literal-using-parens, r=oli-obk

Recover from `Foo(a: 1, b: 2)`

Detect likely `struct` literal using parentheses as delimiters and emit
targeted suggestion instead of type ascription parse error.

Fix #61326.

2 years agoRollup merge of #88292 - SkiFire13:enable-rustdoc-links, r=jyn514
Manish Goregaokar [Thu, 16 Sep 2021 17:57:17 +0000 (10:57 -0700)]
Rollup merge of #88292 - SkiFire13:enable-rustdoc-links, r=jyn514

Enable --generate-link-to-definition for rustc's docs

cc `@jyn514`

2 years agoAdd `ConstraintCategory::Usage` for handling aggregate construction
Aaron Hill [Mon, 6 Sep 2021 21:59:24 +0000 (16:59 -0500)]
Add `ConstraintCategory::Usage` for handling aggregate construction

In some cases, we emit borrowcheck diagnostics pointing
at a particular field expression in a struct expression
(e.g. `MyStruct { field: my_expr }`). However, this
behavior currently relies on us choosing the
`ConstraintCategory::Boring` with the 'correct' span.
When adding additional variants to `ConstraintCategory`,
(or changing existing usages away from `ConstraintCategory::Boring`),
the current behavior can easily get broken, since a non-boring
constraint will get chosen over a boring one.

To make the diagnostic output less fragile, this commit
adds a `ConstraintCategory::Usage` variant. We use this variant
for the temporary assignments created for each field of
an aggregate we are constructing.

Using this new variant, we can emit a message mentioning
"this usage", emphasizing the fact that the error message
is related to the specific use site (in the struct expression).

This is preparation for additional work on improving NLL error messages
(see #57374)

2 years agoAuto merge of #88979 - tmiasko:no-remove-zsts-in-generators, r=oli-obk
bors [Thu, 16 Sep 2021 16:46:02 +0000 (16:46 +0000)]
Auto merge of #88979 - tmiasko:no-remove-zsts-in-generators, r=oli-obk

Disable RemoveZsts in generators to avoid query cycles

Querying layout of a generator requires its optimized MIR. Thus
computing layout during MIR optimization of a generator might create a
query cycle. Disable RemoveZsts in generators to avoid the issue
(similar approach is used in ConstProp transform already).

Fixes #88972.

2 years agofix potential race in AtomicU64 time monotonizer
The8472 [Thu, 16 Sep 2021 16:32:28 +0000 (18:32 +0200)]
fix potential race in AtomicU64 time monotonizer

2 years agoPassWrapper: handle separate Module*SanitizerPass
Augie Fackler [Thu, 16 Sep 2021 15:45:38 +0000 (11:45 -0400)]
PassWrapper: handle separate Module*SanitizerPass

Change ab41eef9aca3 in LLVM split MemorySanitizerPass into
MemorySanitizerPass for functions and ModuleMemorySanitizerPass for
modules. There's a related change for ThreadSanitizerPass, and in here
since we're using a ModulePassManager I only add the module flavor of
the pass on LLVM 14.

r? @nikic cc @nagisa

2 years agofix rebase
Esteban Kuber [Thu, 16 Sep 2021 14:01:37 +0000 (14:01 +0000)]
fix rebase

2 years agoAuto merge of #88219 - jyn514:parallel-io, r=GuillaumeGomez
bors [Thu, 16 Sep 2021 13:47:55 +0000 (13:47 +0000)]
Auto merge of #88219 - jyn514:parallel-io, r=GuillaumeGomez

rustdoc: reduce number of copies when using parallel IO

This is Windows-only for now; I was getting really bad slowdowns from this on linux for some reason.

Helps with https://github.com/rust-lang/rust/issues/82741. Follow-up to https://github.com/rust-lang/rust/pull/60971.

2 years agoPoint at argument when evaluating `Path`'s bounds
Esteban Kuber [Tue, 14 Sep 2021 10:52:36 +0000 (10:52 +0000)]
Point at argument when evaluating `Path`'s bounds

When evaluating an `ExprKind::Call`, we first have to `check_expr` on it's
callee. When this one is a `ExprKind::Path`, we had to evaluate the bounds
introduced for its arguments, but by the time we evaluated them we no
longer had access to the argument spans. Now we special case this so
that we can point at the right place on unsatisfied bounds. This also
allows the E0277 deduplication to kick in correctly, so we now emit
fewer errors.

2 years agoFix rebase
Esteban Kuber [Sun, 12 Sep 2021 20:36:58 +0000 (20:36 +0000)]
Fix rebase

2 years agoRemove unnecessary label
Esteban Kuber [Tue, 7 Sep 2021 14:25:40 +0000 (14:25 +0000)]
Remove unnecessary label

2 years agofix rebase
Esteban Kuber [Tue, 7 Sep 2021 14:05:08 +0000 (14:05 +0000)]
fix rebase

2 years agofix `clone` call
Esteban Kuber [Tue, 7 Sep 2021 13:23:39 +0000 (13:23 +0000)]
fix `clone` call

2 years agoAccount for blocks in arguments
Esteban Kuber [Tue, 7 Sep 2021 11:57:01 +0000 (11:57 +0000)]
Account for blocks in arguments

When giving an error about an obligation introduced by a function call
that an argument doesn't fulfill, and that argument is a block, add a
span_label pointing at the innermost tail expression.

2 years agoPoint at call span that introduced obligation for the arg
Esteban Kuber [Tue, 7 Sep 2021 11:30:53 +0000 (11:30 +0000)]
Point at call span that introduced obligation for the arg

2 years agoRefactor `FulfillmentError` to track less data
Esteban Kuber [Tue, 7 Sep 2021 11:19:57 +0000 (11:19 +0000)]
Refactor `FulfillmentError` to track less data

Move the information about pointing at the call argument expression in
an unmet obligation span from the `FulfillmentError` to a new
`ObligationCauseCode`.

2 years agoPoint at argument instead of call for their obligations
Esteban Kuber [Tue, 7 Sep 2021 07:42:44 +0000 (07:42 +0000)]
Point at argument instead of call for their obligations

When an obligation is introduced by a specific `fn` argument, point at
the argument instead of the `fn` call if the obligation fails to be
fulfilled.

2 years agoFix typo in `break` docs
tatami4 [Thu, 16 Sep 2021 11:51:14 +0000 (14:51 +0300)]
Fix typo in `break` docs

2 years agoEnable rustdoc's --generate-link-to-definition for rustc docs
Giacomo Stevanato [Tue, 24 Aug 2021 15:23:20 +0000 (17:23 +0200)]
Enable rustdoc's --generate-link-to-definition for rustc docs

2 years agoAuto merge of #86809 - DevinR528:reachable-pat, r=Nadrieril
bors [Thu, 16 Sep 2021 05:29:22 +0000 (05:29 +0000)]
Auto merge of #86809 - DevinR528:reachable-pat, r=Nadrieril

Add non_exhaustive_omitted_patterns lint related to rfc-2008-non_exhaustive

Fixes: #84332
This PR adds `non_exhaustive_omitted_patterns`, an allow by default lint that is triggered when a `non_exhaustive` type is missing explicit patterns. The warning or deny attribute can be put above the wildcard `_` pattern on enums or on the expression for enums or structs. The lint is capable of warning about multiple types within the same pattern. This lint will not be triggered for `if let ..` patterns.

```rust
// crate A
#[non_exhaustive]
pub struct Foo {
    a: u8,
    b: usize,
}
#[non_exhaustive]
pub enum Bar {
    A(Foo),
    B,
}

// crate B
#[deny(non_exhaustive_omitted_patterns)] // here
match Bar::B {
    Bar::B => {}
    #[deny(non_exhaustive_omitted_patterns)] // or here
    _ => {}
}

#[warn(non_exhaustive_omitted_patterns)] // only here
let Foo { a, .. } = Foo::default();

#[deny(non_exhaustive_omitted_patterns)]
match Bar::B {
    // triggers for Bar::B, and Foo.b
    Bar::A(Foo { a, .. }) => {}
    // if the attribute was here only Bar::B would cause a warning
    _ => {}
}
```

2 years agoFix shuffle index constant not being monomorphized.
Caleb Zulawski [Thu, 16 Sep 2021 02:59:49 +0000 (02:59 +0000)]
Fix shuffle index constant not being monomorphized.

2 years agoReuse existing shared Lrc for MatchImpl parent
Mark Rousskov [Thu, 16 Sep 2021 02:58:40 +0000 (22:58 -0400)]
Reuse existing shared Lrc for MatchImpl parent

This is hopefully a small performance win for the hot path.

2 years agoAuto merge of #88992 - Manishearth:rollup-k9hijii, r=Manishearth
bors [Thu, 16 Sep 2021 02:00:08 +0000 (02:00 +0000)]
Auto merge of #88992 - Manishearth:rollup-k9hijii, r=Manishearth

Rollup of 8 pull requests

Successful merges:

 - #87320 (Introduce -Z remap-cwd-prefix switch)
 - #88690 (Accept `m!{ .. }.method()` and `m!{ .. }?` statements. )
 - #88775 (Revert anon union parsing)
 - #88841 (feat(rustc_typeck): suggest removing bad parens in `(recv.method)()`)
 - #88907 (Highlight the `const fn` if error happened because of a bound on the impl block)
 - #88915 (`Wrapping<T>` has the same layout and ABI as `T`)
 - #88933 (Remove implementation of `min_align_of` intrinsic)
 - #88951 (Update books)

Failed merges:

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

2 years agoAvoid codegen for Result::into_ok in lang_start
Mark Rousskov [Wed, 15 Sep 2021 18:58:53 +0000 (14:58 -0400)]
Avoid codegen for Result::into_ok in lang_start

Otherwise, we end up pulling in an extra module as part of codegen, and that
costs us a sizeable amount of work (both in LLVM and outside).

2 years agoFix linting when trailing macro expands to a trailing semi
Aaron Hill [Thu, 16 Sep 2021 00:32:03 +0000 (19:32 -0500)]
Fix linting when trailing macro expands to a trailing semi

When a macro is used in the trailing expression position of a block
(e.g. `fn foo() { my_macro!() }`), we currently parse it as an
expression, rather than a statement. As a result, we ended up
using the `NodeId` of the containing statement as our `lint_node_id`,
even though we don't normally do this for macro calls.

If such a macro expands to an expression with a `#[cfg]` attribute,
then the trailing statement can get removed entirely. This lead to
an ICE, since we were usng the `NodeId` of the expression to emit
a lint.

Ths commit makes us skip updating `lint_node_id` when handling
a macro in trailing expression position. This will cause us to
lint at the closest parent of the macro call.

2 years agoDisable the evaluation cache when in intercrate mode
Aaron Hill [Wed, 15 Sep 2021 23:17:38 +0000 (18:17 -0500)]
Disable the evaluation cache when in intercrate mode

It's possible to use the same `InferCtxt` with both
an intercrate and non-intercrate `SelectionContext`. However,
the local (inferctxt) evaluation cache is not aware of this
distinction, so this kind of `InferCtxt` re-use will pollute
the cache wth bad results.

This commit avoids the issue by disabling the evaluation cache
entirely during intercrate mode.

2 years agoAuto merge of #88977 - ehuss:disable-validate-maintainers, r=Mark-Simulacrum
bors [Wed, 15 Sep 2021 23:02:02 +0000 (23:02 +0000)]
Auto merge of #88977 - ehuss:disable-validate-maintainers, r=Mark-Simulacrum

Disable validate_maintainers.

The validate_maintainers check has started to fail with the error:

```
HTTPError: HTTP Error 403: Forbidden
b'{"message":"Must have admin access to view repository collaborators.","documentation_url":"https://docs.github.com/rest/reference/repos#list-repository-collaborators"}'
```

Apparently GitHub has restricted the collaborators API to admins.  For now, this just disables the check to get CI working again.  Eventually, I think we'll just need to remove the check since we will unlikely use an admin token, and I don't see a workaround.  The `MAINTAINERS` list doesn't change often, so we may just need to put a sternly worded comment near the list.

2 years agoDisable debuginfo test on Windows that fails in new cdb version.
Eric Huss [Wed, 15 Sep 2021 22:59:48 +0000 (15:59 -0700)]
Disable debuginfo test on Windows that fails in new cdb version.

2 years agoRollup merge of #88951 - ehuss:update-books, r=ehuss
Manish Goregaokar [Wed, 15 Sep 2021 21:57:04 +0000 (14:57 -0700)]
Rollup merge of #88951 - ehuss:update-books, r=ehuss

Update books

## rust-by-example

1 commits in 04f489c889235fe3b6dfe678ae5410d07deda958..9d4132b56c4999cd3ce1aeca5f1b2f2cb0d11c24
2021-08-17 08:01:20 -0300 to 2021-09-14 06:56:00 -0300
- Fix link to "integration testing" page (rust-lang/rust-by-example#1458)

## rustc-dev-guide

17 commits in 95f1acf9a39d6f402f654e917e2c1dfdb779c5fc..9198465b6ca8bed669df0cbb67c0e6d0b140803c
2021-08-31 12:38:30 -0500 to 2021-09-12 11:50:44 -0500
- Clarify difference of a help vs note diagnostic.
- remove ctag section
- Update suggested.md
- Update SUMMARY.md
- Move ctag section to "Suggested Workflow"
- Delete ctags.md
- Clarify paragraph in "Keeping things up to date"
- Docs: added section on rustdoc
- Docs: made suggested fix
- Docs: deleted copy
- Docs: added section discussing core ideas
- Docs: delete redundant use of correctness
- Docs: consolidated parallelism information
- Add links to overview.md (rust-lang/rustc-dev-guide#1202)
- Spelling change intermidiate to intermediate
- Fix a typo (rust-lang/rustc-dev-guide#1200)
- Documenting diagnostic items with their usage and naming conventions (rust-lang/rustc-dev-guide#1192)

## embedded-book

1 commits in c3a51e23859554369e6bbb5128dcef0e4f159fb5..4c76da9ddb4650203c129fceffdea95a3466c205
2021-08-26 07:04:58 +0000 to 2021-09-12 12:43:03 +0000
- 2.1(QEMU): update app name for git project init  (rust-embedded/book#301)

2 years agoRollup merge of #88933 - tmiasko:remove-min-align-of, r=oli-obk
Manish Goregaokar [Wed, 15 Sep 2021 21:57:03 +0000 (14:57 -0700)]
Rollup merge of #88933 - tmiasko:remove-min-align-of, r=oli-obk

Remove implementation of `min_align_of` intrinsic

Since #88839 `min_align_of` is lowered to AlignOf operator.

2 years agoRollup merge of #88915 - joshlf:patch-4, r=kennytm
Manish Goregaokar [Wed, 15 Sep 2021 21:57:02 +0000 (14:57 -0700)]
Rollup merge of #88915 - joshlf:patch-4, r=kennytm

`Wrapping<T>` has the same layout and ABI as `T`

2 years agoRollup merge of #88907 - WaffleLapkin:targeted_const_fn_with_a_bound_in_impl_block_er...
Manish Goregaokar [Wed, 15 Sep 2021 21:57:01 +0000 (14:57 -0700)]
Rollup merge of #88907 - WaffleLapkin:targeted_const_fn_with_a_bound_in_impl_block_error, r=estebank

Highlight the `const fn` if error happened because of a bound on the impl block

Currently, for the following code, the compiler produces the errors like the
following:
```rust
struct Type<T>(T);

impl<T: Clone> Type<T> {
    const fn f() {}
}
```
```text
error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable
 --> ./test.rs:3:6
  |
3 | impl<T: Clone> Type<T> {
  |      ^
  |
  = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
  = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable
```

This can be confusing (especially to newcomers) since the error mentions "const fn parameters", but highlights only the impl.

This PR adds function highlighting, changing the error to the following:

```text
error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable
 --> ./test.rs:3:6
  |
3 | impl<T: Clone> Type<T> {
  |      ^
4 |     pub const fn f() {}
  |     ---------------- function declared as const here
  |
  = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
  = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable
```

---

I've originally wanted to point directly to `const` token, but couldn't find a way to get it's span. It seems like this span is lost during the AST -> HIR lowering.

Also, since the errors for object casts in `const fn`s (`&T` -> `&dyn Trait`) seem to trigger the same error, this PR accidentally changes these errors too. Not sure if it's desired or how to fix this.

P.S. it's my first time contributing to diagnostics, so feedback is very appreciated!

---

r? ```@estebank```

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

2 years agoRollup merge of #88841 - notriddle:notriddle/method-parens, r=estebank
Manish Goregaokar [Wed, 15 Sep 2021 21:56:59 +0000 (14:56 -0700)]
Rollup merge of #88841 - notriddle:notriddle/method-parens, r=estebank

feat(rustc_typeck): suggest removing bad parens in `(recv.method)()`

Fixes #88803

2 years agoRollup merge of #88775 - pnkfelix:revert-anon-union-parsing, r=davidtwco
Manish Goregaokar [Wed, 15 Sep 2021 21:56:58 +0000 (14:56 -0700)]
Rollup merge of #88775 - pnkfelix:revert-anon-union-parsing, r=davidtwco

Revert anon union parsing

Revert PR #84571 and #85515, which implemented anonymous union parsing in a manner that broke the context-sensitivity for the `union` keyword and thus broke stable Rust code.

Fix #88583.

2 years agoRollup merge of #88690 - m-ou-se:macro-braces-dot-question-expr-parse, r=nagisa
Manish Goregaokar [Wed, 15 Sep 2021 21:56:57 +0000 (14:56 -0700)]
Rollup merge of #88690 - m-ou-se:macro-braces-dot-question-expr-parse, r=nagisa

Accept `m!{ .. }.method()` and `m!{ .. }?` statements.

This PR fixes something that I keep running into when using `quote!{}.into()` in a proc macro to convert the `proc_macro2::TokenStream` to a `proc_macro::TokenStream`:

Before:

```
error: expected expression, found `.`
 --> src/lib.rs:6:6
  |
4 |     quote! {
5 |         ...
6 |     }.into()
  |      ^ expected expression
```

After:
```
```
(No output, compiles fine.)

---

Context:

For expressions like `{ 1 }` and `if true { 1 } else { 2 }`, we accept them as full statements without a trailing `;`, which means the following is not accepted:

```rust
{ 1 } - 1 // error
```

since that is parsed as two statements: `{ 1 }` and `-1`. Syntactically correct, but the type of `{ 1 }` should be `()` as there is no `;`.

However, for specifically `.` and `?` after the `}`, we do [continue parsing it as an expression](https://github.com/rust-lang/rust/blob/13db8440bbbe42870bc828d4ec3e965b38670277/compiler/rustc_parse/src/parser/expr.rs#L864-L876):

```rust
{ "abc" }.len(); // ok
```

For braced macro invocations, we do not do this:

```rust
vec![1, 2, 3].len(); // ok
vec!{1, 2, 3}.len(); // error
```

(It parses `vec!{1, 2, 3}` as a full statement, and then complains about `.len()` not being a valid expression.)

This PR changes this to also look for a `.` and `?` after a braced macro invocation. We can be sure the macro is an expression and not a full statement in those cases, since no statement can start with a `.` or `?`.

2 years agoRollup merge of #87320 - danakj:debug-compilation-dir, r=michaelwoerister
Manish Goregaokar [Wed, 15 Sep 2021 21:56:56 +0000 (14:56 -0700)]
Rollup merge of #87320 - danakj:debug-compilation-dir, r=michaelwoerister

Introduce -Z remap-cwd-prefix switch

This switch remaps any absolute paths rooted under the current
working directory to a new value. This includes remapping the
debug info in `DW_AT_comp_dir` and `DW_AT_decl_file`.

Importantly, this flag does not require passing the current working
directory to the compiler, such that the command line can be
run on any machine (with the same input files) and produce the
same results. This is critical property for debugging compiler
issues that crop up on remote machines.

This is based on adetaylor's https://github.com/rust-lang/rust/commit/dbc4ae7cba0ba8d650b91ddd459b86a02a2d05c5

Major Change Proposal: https://github.com/rust-lang/compiler-team/issues/450
Discussed on #38322. Would resolve issue #87325.

2 years agoAllow `panic!("{}", computed_str)` in const fn.
Gary Guo [Tue, 14 Sep 2021 18:14:37 +0000 (19:14 +0100)]
Allow `panic!("{}", computed_str)` in const fn.

2 years agoAdd tracking issue for unix_chown
Josh Triplett [Wed, 15 Sep 2021 20:09:54 +0000 (13:09 -0700)]
Add tracking issue for unix_chown

2 years agoAllow call to get_body_with_borrowck_facts without -Z polonius
Will Crichton [Wed, 15 Sep 2021 18:45:31 +0000 (11:45 -0700)]
Allow call to get_body_with_borrowck_facts without -Z polonius

2 years agoMake rustc_mir_dataflow::framework::graphviz and rustc_mir_transform::MirPass public
Will Crichton [Wed, 15 Sep 2021 18:41:37 +0000 (11:41 -0700)]
Make rustc_mir_dataflow::framework::graphviz and rustc_mir_transform::MirPass public

2 years agoUpdate the backtrace crate
Henrik Böving [Wed, 15 Sep 2021 18:32:35 +0000 (20:32 +0200)]
Update the backtrace crate

https://github.com/rust-lang/backtrace-rs/pull/437 fixed backtraces in
OpenBSD -> update it here as well so OpenBSD Rust code can produce
proper backtraces.

2 years agoUpdate clobber_abi list to include k[1-7] regs
Commeownist [Wed, 15 Sep 2021 18:31:59 +0000 (21:31 +0300)]
Update clobber_abi list to include k[1-7] regs

2 years agoDisable both reproducible-build tests for crate-type=bin
danakj [Wed, 15 Sep 2021 17:37:22 +0000 (13:37 -0400)]
Disable both reproducible-build tests for crate-type=bin

These tests fail on Windows, as the build is not deterministic there for
bin targets.

Issue https://github.com/rust-lang/rust/issues/88982 is filed for this
problem.

2 years agoMove some tests to more reasonable directories
Caio [Wed, 15 Sep 2021 17:03:27 +0000 (14:03 -0300)]
Move some tests to more reasonable directories

2 years agoUse explicit log level in tracing instrument macro
Tomasz Miąsko [Mon, 6 Sep 2021 00:00:00 +0000 (00:00 +0000)]
Use explicit log level in tracing instrument macro

Specify a log level in tracing instrument macro explicitly.

Additionally reduce the used log level from a default info level to a
debug level (all of those appear to be developer oriented logs, so there
should be no need to include them in release builds).

2 years agoDisable RemoveZsts in generators to avoid query cycles
Tomasz Miąsko [Wed, 15 Sep 2021 00:00:00 +0000 (00:00 +0000)]
Disable RemoveZsts in generators to avoid query cycles

Querying layout of a generator requires its optimized MIR. Thus
computing layout during MIR optimization of a generator might create a
query cycle. Disable RemoveZsts in generators to avoid the issue
(similar approach is used in ConstProp transform already).

2 years agoMake two functions private
bjorn3 [Wed, 15 Sep 2021 16:44:31 +0000 (18:44 +0200)]
Make two functions private

2 years agoInline with_interner
bjorn3 [Wed, 15 Sep 2021 16:44:17 +0000 (18:44 +0200)]
Inline with_interner

2 years agoMove the Lock into symbol::Interner
bjorn3 [Wed, 15 Sep 2021 16:33:41 +0000 (18:33 +0200)]
Move the Lock into symbol::Interner

This makes it easier to make the symbol interner (near) lock free in
case of concurrent accesses in the future.