]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoAdd negative example for `Result::and_then`
cyqsimon [Fri, 11 Feb 2022 01:55:47 +0000 (09:55 +0800)]
Add negative example for `Result::and_then`

2 years agoMore practical examples for `Result::and_then`
cyqsimon [Thu, 10 Feb 2022 09:59:46 +0000 (17:59 +0800)]
More practical examples for `Result::and_then`

2 years agoUse 0-based idx for array content
cyqsimon [Thu, 10 Feb 2022 08:32:53 +0000 (16:32 +0800)]
Use 0-based idx for array content

2 years agoMore practical examples for `Option::and_then`
cyqsimon [Thu, 10 Feb 2022 08:09:49 +0000 (16:09 +0800)]
More practical examples for `Option::and_then`

2 years agoAuto merge of #93836 - matthiaskrgr:rollup-d1ssiwl, r=matthiaskrgr
bors [Thu, 10 Feb 2022 02:27:43 +0000 (02:27 +0000)]
Auto merge of #93836 - matthiaskrgr:rollup-d1ssiwl, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - #91443 (Better suggestions when user tries to collect into an unsized `[_]`)
 - #91504 (`#[used(linker)]` attribute)
 - #93503 (debuginfo: Fix DW_AT_containing_type vtable debuginfo regression)
 - #93753 (Complete removal of #[main] attribute from compiler)
 - #93799 (Fix typo in `std::fmt` docs)
 - #93813 (Make a few cleanup MIR passes public)

Failed merges:

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

2 years agoRollup merge of #93813 - xldenis:public-mir-passes, r=wesleywiser
Matthias Krüger [Wed, 9 Feb 2022 22:29:59 +0000 (23:29 +0100)]
Rollup merge of #93813 - xldenis:public-mir-passes, r=wesleywiser

Make a few cleanup MIR passes public

Zulip Discussion: https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Making.20passes.20public.20again

This makes a few passes which used to be public, public again. I'd like to use these to clean up MIR code for my external rustc driver. The other option would be to make them all public, but I don't know if that's warranted / useful.

r? `@wesleywiser`

2 years agoRollup merge of #93799 - wooorm:patch-1, r=dtolnay
Matthias Krüger [Wed, 9 Feb 2022 22:29:58 +0000 (23:29 +0100)]
Rollup merge of #93799 - wooorm:patch-1, r=dtolnay

Fix typo in `std::fmt` docs

Hey!

Reading the docs (https://doc.rust-lang.org/std/fmt/#named-parameters), this seems like a typo?

The docs here also seem to mix “named argument” and “named parameter”? Intentional? Mistake?

2 years agoRollup merge of #93753 - jeremyBanks:main-conflict, r=petrochenkov
Matthias Krüger [Wed, 9 Feb 2022 22:29:57 +0000 (23:29 +0100)]
Rollup merge of #93753 - jeremyBanks:main-conflict, r=petrochenkov

Complete removal of #[main] attribute from compiler

resolves #93786

---

The `#[main]` attribute was mostly removed from the language in #84217, but not completely. It is still recognized as a builtin attribute by the compiler, but it has no effect. However, this no-op attribute is no longer gated by `#[feature(main)]` (which no longer exists), so it's possible to include it in code *on stable* without any errors, which seems unintentional. For example, the following code is accepted ([playground link](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&code=%23%5Bmain%5D%0Afn%20main()%20%7B%0A%20%20%20%20println!(%22hello%20world%22)%3B%0A%7D%0A)).

```rust
#[main]
fn main() {
    println!("hello world");
}
```

Aside from that oddity, the existence of this attribute causes code like the following to fail ([playground link](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&code=use%20tokio%3A%3Amain%3B%0A%0A%23%5Bmain%5D%0Afn%20main()%20%7B%0A%20%20%20%20println!(%22hello%20world%22)%3B%0A%7D%0A)). According https://github.com/rust-lang/rust/pull/84062#issuecomment-825038275, the removal of `#[main]` was expected to eliminate this conflict (previously reported as #62127).

```rust
use tokio::main;

#[main]
fn main() {
    println!("hello world");
}
```

```
error[E0659]: `main` is ambiguous
 --> src/main.rs:3:3
  |
3 | #[main]
  |   ^^^^ ambiguous name
  |
  = note: ambiguous because of a name conflict with a builtin attribute
  = note: `main` could refer to a built-in attribute
```

[This error message can be confusing](https://stackoverflow.com/q/71024443/1114), as the mostly-removed `#[main]` attribute is not mentioned in any documentation.

Since the current availability of `#[main]` on stable seems unintentional, and to needlessly block use of the `main` identifier in the attribute namespace, this PR finishes removing the `#[main]` attribute as described in https://github.com/rust-lang/rust/issues/29634#issuecomment-274951753 by deleting it from `builtin_attrs.rs`, and adds two test cases to ensure that the attribute is no longer accepted and no longer conflicts with other attributes imported as `main`.

2 years agoRollup merge of #93503 - michaelwoerister:fix-vtable-holder-debuginfo-regression...
Matthias Krüger [Wed, 9 Feb 2022 22:29:56 +0000 (23:29 +0100)]
Rollup merge of #93503 - michaelwoerister:fix-vtable-holder-debuginfo-regression, r=wesleywiser

debuginfo: Fix DW_AT_containing_type vtable debuginfo regression

This PR brings back the `DW_AT_containing_type` attribute for vtables after it has accidentally been removed in #89597.

It also implements a more accurate description of vtables. Instead of describing them as an array of void pointers, the compiler will now emit a struct type description with a field for each entry of the vtable.

r? ``@wesleywiser``

This PR should fix issue https://github.com/rust-lang/rust/issues/93164.
~~The PR is blocked on https://github.com/rust-lang/rust/pull/93154 because both of them modify the `codegen/debug-vtable.rs` test case.~~

2 years agoRollup merge of #91504 - cynecx:used_retain, r=nikic
Matthias Krüger [Wed, 9 Feb 2022 22:29:56 +0000 (23:29 +0100)]
Rollup merge of #91504 - cynecx:used_retain, r=nikic

`#[used(linker)]` attribute

See https://github.com/dtolnay/linkme/issues/41#issuecomment-927255631.

2 years agoRollup merge of #91443 - compiler-errors:bad_collect_into_slice, r=wesleywiser
Matthias Krüger [Wed, 9 Feb 2022 22:29:55 +0000 (23:29 +0100)]
Rollup merge of #91443 - compiler-errors:bad_collect_into_slice, r=wesleywiser

Better suggestions when user tries to collect into an unsized `[_]`

1. Extend the predicate on `rustc_on_unimplemented` to support substitutions like note, label, etc (i.e. treat it as a `OnUnimplementedFormatString`) so we can have slightly more general `rustc_on_unimplemented` special-cases.
2. Add a `rustc_on_unimplemented` if we fail on `FromIterator<A> for [A]` which happens when we don't explicitly collect into a `vec<A>`, but then pass the return from a `.collect` call into something that takes a slice.

Fixes #91423

2 years agoAuto merge of #93741 - Mark-Simulacrum:global-job-id, r=cjgillot
bors [Wed, 9 Feb 2022 18:54:30 +0000 (18:54 +0000)]
Auto merge of #93741 - Mark-Simulacrum:global-job-id, r=cjgillot

Refactor query system to maintain a global job id counter

This replaces the per-shard counters with a single global counter, simplifying
the JobId struct down to just a u64 and removing the need to pipe a DepKind
generic through a bunch of code. The performance implications on non-parallel
compilers are likely minimal (this switches to `Cell<u64>` as the backing
storage over a `u64`, but the latter was already inside a `RefCell` so it's not
really a significance divergence). On parallel compilers, the cost of a single
global u64 counter may be more significant: it adds a serialization point in
theory. On the other hand, we can imagine changing the counter to have a
thread-local component if it becomes worrisome or some similar structure.

The new design is sufficiently simpler that it warrants the potential for slight
changes down the line if/when we get parallel compilation to be more of a
default.

A u64 counter, instead of u32 (the old per-shard width), is chosen to avoid
possibly overflowing it and causing problems; it is effectively impossible that
we would overflow a u64 counter in this context.

2 years agoSuggest collecting into `Vec<_>` when collecting into `[_]`
Michael Goulet [Thu, 2 Dec 2021 02:51:27 +0000 (18:51 -0800)]
Suggest collecting into `Vec<_>` when collecting into `[_]`

2 years agoAllow substitutions in `rustc_on_unimplemented` predicate
Michael Goulet [Thu, 2 Dec 2021 02:50:46 +0000 (18:50 -0800)]
Allow substitutions in `rustc_on_unimplemented` predicate

2 years agoMake a few cleanup MIR passes public
Xavier Denis [Wed, 9 Feb 2022 15:17:42 +0000 (16:17 +0100)]
Make a few cleanup MIR passes public

2 years agoAuto merge of #93724 - Mark-Simulacrum:drop-query-stats, r=michaelwoerister
bors [Wed, 9 Feb 2022 15:53:10 +0000 (15:53 +0000)]
Auto merge of #93724 - Mark-Simulacrum:drop-query-stats, r=michaelwoerister

Delete -Zquery-stats infrastructure

These statistics are computable from the self-profile data and/or ad-hoc collectable as needed, and in the meantime contribute to rustc bootstrap times -- locally, this PR shaves ~2.5% from rustc_query_impl builds in instruction counts.

If this does lose some functionality we want to keep, I think we should migrate it to self-profile (or a similar interface) rather than this ad-hoc reporting.

2 years agoAuto merge of #93681 - Mark-Simulacrum:rlink-binary, r=davidtwco,bjorn3
bors [Wed, 9 Feb 2022 12:51:53 +0000 (12:51 +0000)]
Auto merge of #93681 - Mark-Simulacrum:rlink-binary, r=davidtwco,bjorn3

Store rlink data in opaque binary format on disk

This removes one of the only uses of JSON decoding (to Rust structs) from the compiler, and fixes the FIXME comment. It's not clear to me what the reason for using JSON here originally was, and from what I can tell nothing outside of rustc expects to read the emitted information, so it seems like a reasonable step to move it to the metadata-encoding format (rustc_serialize::opaque).

Mostly intended as a FIXME fix, though potentially a stepping stone to dropping the support for Decodable to be used to decode JSON entirely (allowing for better/faster APIs on the Decoder trait).

cc #64191

2 years agoFix typo in `std::fmt` docs
Titus [Wed, 9 Feb 2022 10:26:10 +0000 (11:26 +0100)]
Fix typo in `std::fmt` docs

2 years agoMove tests into attributes directory to pacify tidy
Nikita Popov [Wed, 9 Feb 2022 10:00:39 +0000 (11:00 +0100)]
Move tests into attributes directory to pacify tidy

2 years agoAdd tracking issue
Nikita Popov [Wed, 9 Feb 2022 09:59:33 +0000 (10:59 +0100)]
Add tracking issue

2 years agoAuto merge of #92306 - Aaron1011:opaque-type-op, r=oli-obk
bors [Wed, 9 Feb 2022 09:41:48 +0000 (09:41 +0000)]
Auto merge of #92306 - Aaron1011:opaque-type-op, r=oli-obk

Improve opaque type higher-ranked region error message under NLL

Currently, any higher-ranked region errors involving opaque types
fall back to a generic "higher-ranked subtype error" message when
run under NLL. This PR adds better error message handling for this
case, giving us the same kinds of error messages that we currently
get without NLL:

```
error: implementation of `MyTrait` is not general enough
  --> $DIR/opaque-hrtb.rs:12:13
   |
LL | fn foo() -> impl for<'a> MyTrait<&'a str> {
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `MyTrait` is not general enough
   |
   = note: `impl MyTrait<&'2 str>` must implement `MyTrait<&'1 str>`, for any lifetime `'1`...
   = note: ...but it actually implements `MyTrait<&'2 str>`, for some specific lifetime `'2`

error: aborting due to previous error
```

To accomplish this, several different refactoring needed to be made:

* We now have a dedicated `InstantiateOpaqueType` struct which
implements `TypeOp`. This is used to invoke `instantiate_opaque_types`
during MIR type checking.
* `TypeOp` is refactored to pass around a `MirBorrowckCtxt`, which is
needed to report opaque type region errors.
* We no longer assume that all `TypeOp`s correspond to canonicalized
queries. This allows us to properly handle opaque type instantiation
(which does not occur in a query) as a `TypeOp`.
A new `ErrorInfo` associated type is used to determine what
additional information is used during higher-ranked region error
handling.
* The body of `try_extract_error_from_fulfill_cx`
has been moved out to a new function `try_extract_error_from_region_constraints`.
This allows us to re-use the same error reporting code between
canonicalized queries (which can extract region constraints directly
from a fresh `InferCtxt`) and opaque type handling (which needs to take
region constraints from the pre-existing `InferCtxt` that we use
throughout MIR borrow checking).

2 years agoAuto merge of #93795 - JohnTitor:rollup-n0dmsoo, r=JohnTitor
bors [Wed, 9 Feb 2022 06:54:16 +0000 (06:54 +0000)]
Auto merge of #93795 - JohnTitor:rollup-n0dmsoo, r=JohnTitor

Rollup of 7 pull requests

Successful merges:

 - #93445 (Add From<u8> for ExitCode)
 - #93694 (rustdoc: tweak line spacing and paragraph spacing for accessibility)
 - #93735 (Stabilize int_abs_diff in 1.60.0.)
 - #93746 (Remove defaultness from ImplItem.)
 - #93748 (rustc_query_impl: reduce visibility of some modules/fn's)
 - #93751 (Drop tracking: track borrows of projections)
 - #93781 (update `ty::TyKind` documentation)

Failed merges:

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

2 years agoRollup merge of #93781 - lcnr:ty-kind-docs, r=jackh726
Yuki Okushi [Wed, 9 Feb 2022 05:12:25 +0000 (14:12 +0900)]
Rollup merge of #93781 - lcnr:ty-kind-docs, r=jackh726

update `ty::TyKind` documentation

slightly unsure about `ty::Opaque` and `ty::Bound`/`ty::Placeholder`.

r? `@jackh726` `@nikomatsakis` `@oli-obk`

2 years agoRollup merge of #93751 - eholk:issue-93648-drop-tracking-projection, r=tmiasko
Yuki Okushi [Wed, 9 Feb 2022 05:12:24 +0000 (14:12 +0900)]
Rollup merge of #93751 - eholk:issue-93648-drop-tracking-projection, r=tmiasko

Drop tracking: track borrows of projections

Previous efforts to ignore partially consumed values meant we were also not considering borrows of a projection. This led to cases where we'd miss borrowed types which MIR expected to be there, leading to ICEs.

This PR also includes the `-Zdrop-tracking` flag from #93313. If that PR lands first, I'll rebase to drop the commit from this one.

Fixes #93648

2 years agoRollup merge of #93748 - klensy:vis-r, r=cjgillot
Yuki Okushi [Wed, 9 Feb 2022 05:12:23 +0000 (14:12 +0900)]
Rollup merge of #93748 - klensy:vis-r, r=cjgillot

rustc_query_impl: reduce visibility of some modules/fn's

Locally this reduces number of exported functions from 15221 -> 14952 and size a little.

Perf run please?

2 years agoRollup merge of #93746 - cjgillot:nodefii, r=nikomatsakis
Yuki Okushi [Wed, 9 Feb 2022 05:12:22 +0000 (14:12 +0900)]
Rollup merge of #93746 - cjgillot:nodefii, r=nikomatsakis

Remove defaultness from ImplItem.

This information is not really used anywhere, except HIR pretty-printing. This makes ImplItem and TraitItem more similar.

2 years agoRollup merge of #93735 - m-ou-se:stabilize-int-abs-diff, r=joshtriplett
Yuki Okushi [Wed, 9 Feb 2022 05:12:21 +0000 (14:12 +0900)]
Rollup merge of #93735 - m-ou-se:stabilize-int-abs-diff, r=joshtriplett

Stabilize int_abs_diff in 1.60.0.

FCP finished here: https://github.com/rust-lang/rust/issues/89492#issuecomment-1030694522

2 years agoRollup merge of #93694 - jsha:font-sizes-spacing, r=GuillaumeGomez
Yuki Okushi [Wed, 9 Feb 2022 05:12:18 +0000 (14:12 +0900)]
Rollup merge of #93694 - jsha:font-sizes-spacing, r=GuillaumeGomez

rustdoc: tweak line spacing and paragraph spacing for accessibility

The [W3C Web Content Accessibility Guidelines](https://www.w3.org/WAI/WCAG21/Understanding/visual-presentation.html) specify a minimum line spacing of 1.5 and a minimum paragraph spacing of 1.5 times the line spacing. Our current line spacing (implemented by line-height) is 1.4, so it's a small bump to go up to 1.5. Similarly, we have a paragraph spacing of 0.6em. Bump that to 0.75em (which is 1.5 times the 0.5em distance between lines).

Also, fix all the font sizes so instead of being round-ish numbers in rem (like 1.1rem, 1.2rem), they are round numbers in pixels: 16px, 18px, 20px, 22px, 24px. Ensure each font size is at least 2 pixels different than the nearest other font size, so distinctions can be clearly seen. Overall the font-sizes are mostly staying the same, being rounded up or down as appropriate. This will make reasoning about consistent layout sizes much easier.

Remove a few unused styles.

Simplify the display of the mobile-topbar location, by setting its margins to auto rather than trying to size it exactly to the topbar.

Part of #59845.

Demo: https://rustdoc.crud.net/jsha/font-sizes-spacing/std/string/struct.String.html

r? `@GuillaumeGomez`

2 years agoRollup merge of #93445 - yaahc:exitcode-constructor, r=dtolnay
Yuki Okushi [Wed, 9 Feb 2022 05:12:17 +0000 (14:12 +0900)]
Rollup merge of #93445 - yaahc:exitcode-constructor, r=dtolnay

Add From<u8> for ExitCode

This should cover a mostly cross-platform subset of supported exit codes.

We decided to stick with `u8` initially since its the common subset between all platforms that we support (excluding wasm which I think only works with `true` or `false`). Posix is supposed to take i32s, but in practice many unix platforms mask out all but the low 8 bits or in some cases the 8-15th bits. Windows takes a u32 instead of an i32. Bourne-compatible shells also report signals as exitcode 128 + `signal_no`, so there's some ambiguity there when returning exit codes > 127, but it is possible to disambiguate them on the other side so we decided against restricting the possible codes further than to `u8`.

## Related

- Detailed analysis of exit code support on various platforms: https://internals.rust-lang.org/t/mini-pre-rfc-redesigning-process-exitstatus/5426
- https://github.com/rust-lang/rust/issues/48711
- https://github.com/rust-lang/rust/issues/43301
- https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Termination.2FExit.20Status.20Stabilization

2 years agoAuto merge of #93793 - ehuss:update-cargo, r=ehuss
bors [Wed, 9 Feb 2022 04:05:55 +0000 (04:05 +0000)]
Auto merge of #93793 - ehuss:update-cargo, r=ehuss

Update cargo

5 commits in 25fcb135d02ea897ce894b67ae021f48107d522b..c082648646cbb2be266df9ecbcdc253058158d68
2022-02-01 01:32:48 +0000 to 2022-02-08 14:55:05 +0000
- Add rustup link (rust-lang/cargo#10371)
- Improve startup time of bash completion. (rust-lang/cargo#10365)
- Stabilize `-Ztimings` as `--timings` (rust-lang/cargo#10245)
- Remove needless borrow (rust-lang/cargo#10360)
- Compute non custom build and non transitive deps for doc (rust-lang/cargo#10341)

2 years agoUpdate cargo
Eric Huss [Wed, 9 Feb 2022 02:55:23 +0000 (18:55 -0800)]
Update cargo

2 years agoAuto merge of #93778 - matthiaskrgr:rollup-yfngdao, r=matthiaskrgr
bors [Wed, 9 Feb 2022 01:18:06 +0000 (01:18 +0000)]
Auto merge of #93778 - matthiaskrgr:rollup-yfngdao, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #91950 (Point at type when a `static` `#[global_allocator]` doesn't `impl` `GlobalAlloc`)
 - #92715 (Do not suggest char literal for zero-length strings)
 - #92917 (Don't constrain projection predicates with inference vars in GAT substs)
 - #93206 (Use `NtCreateFile` instead of `NtOpenFile` to open a file)
 - #93732 (add fut/back compat tests for implied trait bounds)
 - #93764 (:arrow_up: rust-analyzer)
 - #93767 (deduplicate `lcnr` in mailmap)

Failed merges:

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

2 years agoSwitch QueryJobId to a single global counter
Mark Rousskov [Mon, 7 Feb 2022 16:03:51 +0000 (11:03 -0500)]
Switch QueryJobId to a single global counter

This replaces the per-shard counters with a single global counter, simplifying
the JobId struct down to just a u64 and removing the need to pipe a DepKind
generic through a bunch of code. The performance implications on non-parallel
compilers are likely minimal (this switches to `Cell<u64>` as the backing
storage over a `u64`, but the latter was already inside a `RefCell` so it's not
really a significance divergence). On parallel compilers, the cost of a single
global u64 counter may be more significant: it adds a serialization point in
theory. On the other hand, we can imagine changing the counter to have a
thread-local component if it becomes worrisome or some similar structure.

The new design is sufficiently simpler that it warrants the potential for slight
changes down the line if/when we get parallel compilation to be more of a
default.

A u64 counter, instead of u32 (the old per-shard width), is chosen to avoid
possibly overflowing it and causing problems; it is effectively impossible that
we would overflow a u64 counter in this context.

2 years agoadd more tests and make used(linker/compiler) mutually exclusive
cynecx [Tue, 8 Feb 2022 22:51:17 +0000 (23:51 +0100)]
add more tests and make used(linker/compiler) mutually exclusive

2 years agoAuto merge of #93783 - oli-obk:lazy_tait_regression_fix, r=jackh726
bors [Tue, 8 Feb 2022 22:33:05 +0000 (22:33 +0000)]
Auto merge of #93783 - oli-obk:lazy_tait_regression_fix, r=jackh726

Fix regression from lazy opaque types

The breakage was found in https://github.com/rust-lang/rust/pull/92007#issuecomment-1032203011 and has not hit nightly yet.

2 years agoImprove opaque type higher-ranked region error message under NLL
Aaron Hill [Sun, 19 Dec 2021 00:06:53 +0000 (19:06 -0500)]
Improve opaque type higher-ranked region error message under NLL

Currently, any higher-ranked region errors involving opaque types
fall back to a generic "higher-ranked subtype error" message when
run under NLL. This PR adds better error message handling for this
case, giving us the same kinds of error messages that we currently
get without NLL:

```
error: implementation of `MyTrait` is not general enough
  --> $DIR/opaque-hrtb.rs:12:13
   |
LL | fn foo() -> impl for<'a> MyTrait<&'a str> {
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `MyTrait` is not general enough
   |
   = note: `impl MyTrait<&'2 str>` must implement `MyTrait<&'1 str>`, for any lifetime `'1`...
   = note: ...but it actually implements `MyTrait<&'2 str>`, for some specific lifetime `'2`

error: aborting due to previous error
```

To accomplish this, several different refactoring needed to be made:

* We now have a dedicated `InstantiateOpaqueType` struct which
implements `TypeOp`. This is used to invoke `instantiate_opaque_types`
during MIR type checking.
* `TypeOp` is refactored to pass around a `MirBorrowckCtxt`, which is
needed to report opaque type region errors.
* We no longer assume that all `TypeOp`s correspond to canonicalized
queries. This allows us to properly handle opaque type instantiation
(which does not occur in a query) as a `TypeOp`.
A new `ErrorInfo` associated type is used to determine what
additional information is used during higher-ranked region error
handling.
* The body of `try_extract_error_from_fulfill_cx`
has been moved out to a new function `try_extract_error_from_region_constraints`.
This allows us to re-use the same error reporting code between
canonicalized queries (which can extract region constraints directly
from a fresh `InferCtxt`) and opaque type handling (which needs to take
region constraints from the pre-existing `InferCtxt` that we use
throughout MIR borrow checking).

2 years agoUpdate compiler/rustc_middle/src/ty/sty.rs
lcnr [Tue, 8 Feb 2022 17:11:59 +0000 (18:11 +0100)]
Update compiler/rustc_middle/src/ty/sty.rs

2 years agoUpdate compiler/rustc_middle/src/ty/sty.rs
lcnr [Tue, 8 Feb 2022 17:10:28 +0000 (18:10 +0100)]
Update compiler/rustc_middle/src/ty/sty.rs

Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
2 years agoFix regression from lazy opaque types
Oli Scherer [Tue, 8 Feb 2022 16:47:24 +0000 (16:47 +0000)]
Fix regression from lazy opaque types

2 years agoupdate `ty::TyKind` documentation
lcnr [Tue, 8 Feb 2022 16:09:18 +0000 (17:09 +0100)]
update `ty::TyKind` documentation

2 years agoRollup merge of #93767 - lcnr:mailmap, r=Mark-Simulacrum
Matthias Krüger [Tue, 8 Feb 2022 15:40:51 +0000 (16:40 +0100)]
Rollup merge of #93767 - lcnr:mailmap, r=Mark-Simulacrum

deduplicate `lcnr` in mailmap

2 years agoRollup merge of #93764 - lnicola:rust-analyzer-2022-02-08, r=lnicola
Matthias Krüger [Tue, 8 Feb 2022 15:40:51 +0000 (16:40 +0100)]
Rollup merge of #93764 - lnicola:rust-analyzer-2022-02-08, r=lnicola

:arrow_up: rust-analyzer

r? ``@ghost``

2 years agoRollup merge of #93732 - lcnr:hrlt-backcompa, r=Mark-Simulacrum
Matthias Krüger [Tue, 8 Feb 2022 15:40:50 +0000 (16:40 +0100)]
Rollup merge of #93732 - lcnr:hrlt-backcompa, r=Mark-Simulacrum

add fut/back compat tests for implied trait bounds

the `guard` test was tested to cause a segfault with `-Zchalk`, very nice

cc ``@nikomatsakis`` #44491 #25860

2 years agoRollup merge of #93206 - ChrisDenton:ntopenfile, r=nagisa
Matthias Krüger [Tue, 8 Feb 2022 15:40:49 +0000 (16:40 +0100)]
Rollup merge of #93206 - ChrisDenton:ntopenfile, r=nagisa

Use `NtCreateFile` instead of `NtOpenFile` to open a file

Generally the internal `Nt*` functions should be avoided but when we do need to use one we should stick to the most commonly used for the job. To that end, this PR replaces `NtOpenFile` with `NtCreateFile`.

NOTE: The initial version of this comment hypothesised that this may help with some recent false positives from malware scanners. This hypothesis proved wrong. Sorry for the distraction.

2 years agoRollup merge of #92917 - jackh726:issue-91762-2, r=nikomatsakis
Matthias Krüger [Tue, 8 Feb 2022 15:40:48 +0000 (16:40 +0100)]
Rollup merge of #92917 - jackh726:issue-91762-2, r=nikomatsakis

Don't constrain projection predicates with inference vars in GAT substs

cc #91762

Not a fix, but a mitigation to prevent a backwards-compatible hazard where we normalize using a predicate only because it's the only one available, but shouldn't. This would constrain an inference variable which didn't really want. We already do this when selecting a projection candidate, which isn't always correct. But changing that is a problem for a different day.

Also found out that a suggestion for `await`ing a future was using the wrong substs.

r? ``@nikomatsakis``

2 years agoRollup merge of #92715 - chordtoll:empty-string, r=davidtwco
Matthias Krüger [Tue, 8 Feb 2022 15:40:47 +0000 (16:40 +0100)]
Rollup merge of #92715 - chordtoll:empty-string, r=davidtwco

Do not suggest char literal for zero-length strings

PR #92507 adds a hint to switch to single quotes when a char is expected and a single-character string literal is provided.

The check to ensure the string literal is one character long missed the 0-char case, and would incorrectly offer the hint.

This PR adds the missing check, and a test case to confirm the new behavior.

2 years agoRollup merge of #91950 - estebank:point-at-type-of-non-allocator, r=matthewjasper
Matthias Krüger [Tue, 8 Feb 2022 15:40:45 +0000 (16:40 +0100)]
Rollup merge of #91950 - estebank:point-at-type-of-non-allocator, r=matthewjasper

Point at type when a `static` `#[global_allocator]` doesn't `impl` `GlobalAlloc`

2 years agodebuginfo: Bring back DW_AT_containing_type for vtables -- address review comments
Michael Woerister [Tue, 8 Feb 2022 14:31:09 +0000 (15:31 +0100)]
debuginfo: Bring back DW_AT_containing_type for vtables -- address review comments

2 years agoAuto merge of #93572 - scottmcm:generic-iter-process, r=yaahc
bors [Tue, 8 Feb 2022 13:41:40 +0000 (13:41 +0000)]
Auto merge of #93572 - scottmcm:generic-iter-process, r=yaahc

Change `ResultShunt` to be generic over `Try`

Just a refactor (and rename) for now, so it's not `Result`-specific.

This could be used for a future `Iterator::try_collect`, or similar, but anything like that is left for a future PR.

2 years agorustdoc: tweak line and ¶ spacing for a11y
Jacob Hoffman-Andrews [Sat, 5 Feb 2022 13:05:05 +0000 (05:05 -0800)]
rustdoc: tweak line and ¶ spacing for a11y

The W3C Web Content Accessibility Guidelines specify a minimum line
spacing of 1.5 and a minimum paragraph spacing of 1.5 times the line
spacing. Our current line spacing (implemented by line-height) is 1.4,
so it's a small bump to go up to 1.5. Similarly, we have a paragraph
spacing of 0.6em. Bump that to 0.75em (which is 1.5 times the 0.5em
distance between lines).

Also, fix all the font sizes so instead of being round-ish numbers in
rem (like 1.1rem, 1.2rem), they are round numbers in pixels. Ensure each
font size is at least 2 pixels different than the nearest other font
size, so distinctions can be clearly seen. Overall the font-sizes are
mostly staying the same, being rounded up or down as appropriate.

Remove a few unused styles.

Simplify the display of the mobile-topbar location, by setting its
margins to auto rather than trying to size it exactly to the topbar.

2 years agodeduplicate `lcnr` in mailmap
lcnr [Tue, 8 Feb 2022 10:30:59 +0000 (11:30 +0100)]
deduplicate `lcnr` in mailmap

2 years agoAuto merge of #93626 - wesleywiser:fix_hashmap_natvis, r=michaelwoerister
bors [Tue, 8 Feb 2022 10:05:05 +0000 (10:05 +0000)]
Auto merge of #93626 - wesleywiser:fix_hashmap_natvis, r=michaelwoerister

Fix HashMap not displaying correctly in VS debugger

The natvis to render HashMaps was not working correctly in Visual Studio
because the type names for tuples changed from `tuple$<A, B>` to
`tuple$<A,B>` (notice the missing space). WinDbg and cdb continued to
parse this type name which is why no tests in CI broke. VS however is
slightly more strict and this caused the visualizer to break.

Since we cannot test the VS debugger in CI, I'm not checking in any
test changes.

Fixes #92286

r? `@michaelwoerister`

2 years ago:arrow_up: rust-analyzer
Laurențiu Nicola [Tue, 8 Feb 2022 09:10:44 +0000 (11:10 +0200)]
:arrow_up: rust-analyzer

2 years agoAuto merge of #93762 - matthiaskrgr:rollup-vdjpfmz, r=matthiaskrgr
bors [Tue, 8 Feb 2022 06:34:18 +0000 (06:34 +0000)]
Auto merge of #93762 - matthiaskrgr:rollup-vdjpfmz, r=matthiaskrgr

Rollup of 9 pull requests

Successful merges:

 - #86497 (Add {floor,ceil}_char_boundary methods to str)
 - #92695 (Add `#[no_coverage]` tests for nested functions)
 - #93521 (Fix hover effects in sidebar)
 - #93568 (Include all contents of first line of scraped item in Rustdoc)
 - #93569 (rustdoc: correct unclosed HTML tags as generics)
 - #93672 (update comment wrt const param defaults)
 - #93715 (Fix horizontal trim for block doc comments)
 - #93721 (rustdoc: Special-case macro lookups less)
 - #93728 (Add in ValuePair::Term)

Failed merges:

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

2 years agonit
lcnr [Mon, 7 Feb 2022 15:35:28 +0000 (16:35 +0100)]
nit

2 years agoRollup merge of #93728 - JulianKnodt:toterm, r=oli-obk
Matthias Krüger [Tue, 8 Feb 2022 05:47:38 +0000 (06:47 +0100)]
Rollup merge of #93728 - JulianKnodt:toterm, r=oli-obk

Add in ValuePair::Term

This adds in an enum when matching on positions which can either be types or consts.
It will default to emitting old special cased error messages for types.

r? `@oli-obk`
cc `@matthiaskrgr`
Fixes #93578

2 years agoRollup merge of #93721 - jyn514:less-macro-special-casing, r=petrochenkov
Matthias Krüger [Tue, 8 Feb 2022 05:47:37 +0000 (06:47 +0100)]
Rollup merge of #93721 - jyn514:less-macro-special-casing, r=petrochenkov

rustdoc: Special-case macro lookups less

Previously, rustdoc had 3 fallbacks it used:
1. `resolve_macro_path`
2. `all_macros`
3. `resolve_str_path_error`

Ideally, it would only use `resolve_str_path_error`, to be consistent with other namespaces.
Unfortunately, that doesn't consider macros that aren't defined at module scope;
consider for instance
```rust
{
    struct S;

    macro_rules! mac { () => {} }
    // `mac`'s scope starts here

    /// `mac` <- `resolve_str_path_error` won't see this
   struct Z;

    //`mac`'s scope ends here
}
```

This changes it to only use `all_macros` and `resolve_str_path_error`, and gives
`resolve_str_path_error` precedence over `all_macros` in case there are two macros with the same
name in the same module.

This is a smaller version of https://github.com/rust-lang/rust/pull/91427.

r? `@petrochenkov`

2 years agoRollup merge of #93715 - GuillaumeGomez:horizontal-trim, r=notriddle
Matthias Krüger [Tue, 8 Feb 2022 05:47:36 +0000 (06:47 +0100)]
Rollup merge of #93715 - GuillaumeGomez:horizontal-trim, r=notriddle

Fix horizontal trim for block doc comments

Fixes #93662.

r? `@notriddle`

2 years agoRollup merge of #93672 - lcnr:const-param-defaults-xx, r=matthewjasper
Matthias Krüger [Tue, 8 Feb 2022 05:47:35 +0000 (06:47 +0100)]
Rollup merge of #93672 - lcnr:const-param-defaults-xx, r=matthewjasper

update comment wrt const param defaults

after #93669 i looked through all other uses of `GenericParamKind::Const` again to detect if we missed the `default` there as well, but afaict we really only missed lifetime resolution '^^ at least i found an outdated comment :3

2 years agoRollup merge of #93569 - notriddle:notriddle/rustdoc-html-tags-generics, r=CraftSpider
Matthias Krüger [Tue, 8 Feb 2022 05:47:34 +0000 (06:47 +0100)]
Rollup merge of #93569 - notriddle:notriddle/rustdoc-html-tags-generics, r=CraftSpider

rustdoc: correct unclosed HTML tags as generics

CC https://github.com/rust-lang/rust/issues/67799

2 years agoRollup merge of #93568 - willcrichton:scrape-examples-leading-whitespace, r=CraftSpider
Matthias Krüger [Tue, 8 Feb 2022 05:47:33 +0000 (06:47 +0100)]
Rollup merge of #93568 - willcrichton:scrape-examples-leading-whitespace, r=CraftSpider

Include all contents of first line of scraped item in Rustdoc

This fixes #93528. When scraping examples, it extends the span of the enclosing item to include all characters up to the start of the first line of the span.

r? `@camelid`

2 years agoRollup merge of #93521 - jsha:sidebar-hover, r=GuillaumeGomez
Matthias Krüger [Tue, 8 Feb 2022 05:47:32 +0000 (06:47 +0100)]
Rollup merge of #93521 - jsha:sidebar-hover, r=GuillaumeGomez

Fix hover effects in sidebar

The dark and ayu themes have a menu-like highlight on sidebar items. The light theme used to, but it was accidentally lost in the sidebar unification. The change brings back the hover effect in the light theme.

It also makes the hover effect apply consistently to all links in the sidebar, including headings.

It also simplifies the "In _path_" heading so it's one big link. The breadcrumbs are still readily available at the top of the page.

Note that a small number of headings are not linkified and so don't get the hover effect. That will be fixed with #92957.

Demo: https://rustdoc.crud.net/jsha/sidebar-hover/std/string/trait.ToString.html

r? `@GuillaumeGomez`

Fixes #93115

2 years agoRollup merge of #92695 - Swatinem:cover-nested, r=wesleywiser
Matthias Krüger [Tue, 8 Feb 2022 05:47:32 +0000 (06:47 +0100)]
Rollup merge of #92695 - Swatinem:cover-nested, r=wesleywiser

Add `#[no_coverage]` tests for nested functions

I was playing around a bit trying to figure out how `#[no_coverage]` behaves for nested functions and thought I might as well add this as a testcase.

The "nesting covered fn inside not covered fn" case looks pretty much as expected.

The "nesting not covered fn inside a covered fn" case however seems a bit counterintuitive.
Essentially the region of the outer function "covers" its whole lexical range. And the inner function does not generate any region at all. 🤷🏻‍♂️

r? `@richkadel`

2 years agoRollup merge of #86497 - clarfonthey:nearest_char_boundary, r=scottmcm
Matthias Krüger [Tue, 8 Feb 2022 05:47:31 +0000 (06:47 +0100)]
Rollup merge of #86497 - clarfonthey:nearest_char_boundary, r=scottmcm

Add {floor,ceil}_char_boundary methods to str

This is technically already used internally by the standard library in the form of `truncate_to_char_boundary`.

Essentially these are two building blocks to allow for approximate string truncation, where you want to cut off the string at "approximately" a given length in bytes but don't know exactly where the character boundaries lie. It's also a good candidate for the standard library as it can easily be done naively, but would be difficult to properly optimise. Although the existing code that's done in error messages is done naively, this code will explicitly only check a window of 4 bytes since we know that a boundary must lie in that range, and because it will make it possible to vectorise.

Although this method doesn't take into account graphemes or other properties, this would still be a required building block for splitting that takes those into account. For example, if you wanted to split at a grapheme boundary, you could take your approximate splitting point and then determine the graphemes immediately following and preceeding the split. If you then notice that these two graphemes could be merged, you can decide to either include the whole grapheme or exclude it depending on whether you decide splitting should shrink or expand the string.

This takes the most conservative approach and just offers the raw indices to the user, and they can decide how to use them. That way, the methods are as useful as possible despite having as few methods as possible.

(Note: I'll add some tests and a tracking issue if it's decided that this is worth including.)

2 years agoAuto merge of #93561 - Amanieu:more-unwind-abi, r=nagisa
bors [Tue, 8 Feb 2022 03:20:05 +0000 (03:20 +0000)]
Auto merge of #93561 - Amanieu:more-unwind-abi, r=nagisa

Add more *-unwind ABI variants

The following *-unwind ABIs are now supported:
- "C-unwind"
- "cdecl-unwind"
- "stdcall-unwind"
- "fastcall-unwind"
- "vectorcall-unwind"
- "thiscall-unwind"
- "aapcs-unwind"
- "win64-unwind"
- "sysv64-unwind"
- "system-unwind"

cc `@rust-lang/wg-ffi-unwind`

2 years agoRemove obsolete no-op #[main] attribute from compiler.
Jeremy Banks [Mon, 7 Feb 2022 23:40:17 +0000 (23:40 +0000)]
Remove obsolete no-op #[main] attribute from compiler.

2 years agoDrop tracking: track borrows of projections
Eric Holk [Tue, 8 Feb 2022 00:01:27 +0000 (16:01 -0800)]
Drop tracking: track borrows of projections

Previous efforts to ignore partially consumed values meant we were also
not considering borrows of a projection. This led to cases where we'd
miss borrowed types which MIR expected to be there, leading to ICEs.

2 years agoAuto merge of #92007 - oli-obk:lazy_tait2, r=nikomatsakis
bors [Mon, 7 Feb 2022 23:40:26 +0000 (23:40 +0000)]
Auto merge of #92007 - oli-obk:lazy_tait2, r=nikomatsakis

Lazy type-alias-impl-trait

Previously opaque types were processed by

1. replacing all mentions of them with inference variables
2. memorizing these inference variables in a side-table
3. at the end of typeck, resolve the inference variables in the side table and use the resolved type as the hidden type of the opaque type

This worked okayish for `impl Trait` in return position, but required lots of roundabout type inference hacks and processing.

This PR instead stops this process of replacing opaque types with inference variables, and just keeps the opaque types around.
Whenever an opaque type `O` is compared with another type `T`, we make the comparison succeed and record `T` as the hidden type. If `O` is compared to `U` while there is a recorded hidden type for it, we grab the recorded type (`T`) and compare that against `U`. This makes implementing

* https://github.com/rust-lang/rfcs/pull/2515

much simpler (previous attempts on the inference based scheme were very prone to ICEs and general misbehaviour that was not explainable except by random implementation defined oddities).

r? `@nikomatsakis`

fixes #93411
fixes #88236

2 years ago14956 -> 14952 exports
klensy [Mon, 7 Feb 2022 21:13:31 +0000 (00:13 +0300)]
14956 -> 14952 exports

2 years agoChange `ResultShunt` to be generic over `Try`
Scott McMurray [Wed, 2 Feb 2022 05:53:30 +0000 (21:53 -0800)]
Change `ResultShunt` to be generic over `Try`

Just a refactor (and rename) for now, so it's not `Result`-specific.

This could be used for a future `Iterator::try_collect`, or similar, but anything like that is left for a future PR.

2 years agofix exclusive range error
Jane Lusby [Mon, 7 Feb 2022 20:45:36 +0000 (12:45 -0800)]
fix exclusive range error

2 years agoAuto merge of #87869 - thomcc:skinny-io-error, r=yaahc
bors [Mon, 7 Feb 2022 20:32:56 +0000 (20:32 +0000)]
Auto merge of #87869 - thomcc:skinny-io-error, r=yaahc

Make io::Error use 64 bits on targets with 64 bit pointers.

I've wanted this for a long time, but didn't see a good way to do it without having extra allocation. When looking at it yesterday, it was more clear what to do for some reason.

This approach avoids any additional allocations, and reduces the size by half (8 bytes, down from 16). AFAICT it doesn't come additional runtime cost, and the compiler seems to do a better job with code using it.

Additionally, this `io::Error` has a niche (still), so `io::Result<()>` is *also* 64 bits (8 bytes, down from 16), and `io::Result<usize>` (used for lots of io trait functions) is 2x64 bits (16 bytes, down from 24 — this means on x86_64 it can use the nice rax/rdx 2-reg struct return). More generally, it shaves a whole 64 bit integer register off of the size of basically any `io::Result<()>`.

(For clarity: Improving `io::Result` (rather than io::Error) was most of the motivation for this)

On 32 bit (or other non-64bit) targets we still use something equivalent the old repr — I don't think think there's improving it, since one of the fields it stores is a `i32`, so we can't get below that, and it's already about as close as we can get to it.

---

### Isn't Pointer Tagging Dodgy?

The details of the layout, and why its implemented the way it is, are explained in the header comment of library/std/src/io/error/repr_bitpacked.rs. There's probably more details than there need to be, but I didn't trim it down that much, since there's a lot of stuff I did deliberately, that might have not seemed that way.

There's actually only one variant holding a pointer which gets tagged. This one is the (holder for the) user-provided error.

I believe the scheme used to tag it is not UB, and that it preserves pointer provenance (even though often pointer tagging does not) because the tagging operation is just `core::ptr::add`, and untagging is `core::ptr::sub`. The result of both operations lands inside the original allocation, so it would follow the safety contract of `core::ptr::{add,sub}`.

The other pointer this had to encode is not tagged — or rather, the tagged repr is equivalent to untagged (it's tagged with 0b00, and has >=4b alignment, so we can reuse the bottom bits). And the other variants we encode are just integers, which (which can be untagged using bitwise operations without worry — they're integers).

CC `@RalfJung` for the stuff in repr_bitpacked.rs, as my comments are informed by a lot of the UCG work, but it's possible I missed something or got it wrong (even if the implementation is okay, there are parts of the header comment that says things like "We can't do $x" which could be false).

---

### Why So Many Changes?

The repr change was mostly internal, but changed one widely used API: I had to switch how `io::Error::new_const` works.

This required switching `io::Error::new_const` to take the full message data (including the kind) as a `&'static`, rather than just the string. This would have been really tedious, but I made a macro that made it much simpler, but it was a wide change since `io::Error::new_const` is used everywhere.

This included changing files for a lot of targets I don't have easy access to (SGX? Haiku? Windows? Who has heard of these things), so I expect there to be spottiness in CI initially, unless luck is on my side.

Anyway this large only tangentially-related change is all in the first commit (although that commit also pulls the previous repr out into its own file), whereas the packing stuff is all in commit 2.

---

P.S. I haven't looked at all of this since writing it, and will do a pass over it again later, sorry for any obvious typos or w/e. I also definitely repeat myself in comments and such.

(It probably could use more tests too. I did some basic testing, and made it so we `debug_assert!` in cases the decode isn't what we encoded, but I don't know the degree which I can assume libstd's testing of IO would exercise this. That is: it wouldn't be surprising to me if libstds IO testing were minimal, especially around error cases, although I have no idea).

2 years agoAdd a flag enabling drop range tracking in generators
Tomasz Miąsko [Wed, 2 Feb 2022 09:40:39 +0000 (10:40 +0100)]
Add a flag enabling drop range tracking in generators

2 years agoFix hover effects in sidebar
Jacob Hoffman-Andrews [Mon, 31 Jan 2022 13:53:43 +0000 (05:53 -0800)]
Fix hover effects in sidebar

The dark and ayu themes have a menu-like highlight on sidebar items. The
light theme used to, but it was accidentally lost in the sidebar
unification. The change brings back the hover effect in the light theme.

It also makes the hover effect apply consistently to all links in the
sidebar, including headings.

It also simplifies the "In _path_" heading so it's one big link. The
breadcrumbs are still readily available at the top of the page.

2 years agoChange inference var check to be in project_type
Jack Huey [Sat, 15 Jan 2022 02:21:40 +0000 (21:21 -0500)]
Change inference var check to be in project_type

2 years agoDon't match any projection predicates when the obligation has inference types or...
Jack Huey [Sat, 15 Jan 2022 01:51:30 +0000 (20:51 -0500)]
Don't match any projection predicates when the obligation has inference types or consts in GAT substs

2 years ago15221 -> 14956 exports
klensy [Mon, 7 Feb 2022 19:45:29 +0000 (22:45 +0300)]
15221 -> 14956 exports

2 years agoAdd {floor,ceil}_char_boundary methods to str
ltdk [Sun, 20 Jun 2021 20:24:10 +0000 (16:24 -0400)]
Add {floor,ceil}_char_boundary methods to str

2 years agoRm ValuePairs::Ty/Const
kadmin [Mon, 7 Feb 2022 16:40:16 +0000 (16:40 +0000)]
Rm ValuePairs::Ty/Const

Remove old value pairs which is a strict subset of Terms.

2 years agoUpdate rustdoc test
Guillaume Gomez [Sun, 6 Feb 2022 21:51:47 +0000 (22:51 +0100)]
Update rustdoc test

2 years agoAdd test for block doc comments horizontal trim
Guillaume Gomez [Sun, 6 Feb 2022 21:21:09 +0000 (22:21 +0100)]
Add test for block doc comments horizontal trim

2 years agoAdd a test showing that we don't infer across multiple uses of the same opaque type...
Oli Scherer [Mon, 7 Feb 2022 16:04:23 +0000 (16:04 +0000)]
Add a test showing that we don't infer across multiple uses of the same opaque type but with a different order of generic arguments

2 years agoFix horizontal trim for block doc comments
Guillaume Gomez [Sat, 5 Feb 2022 13:45:29 +0000 (14:45 +0100)]
Fix horizontal trim for block doc comments

2 years agoPrint opaque types from type aliases via their path
Oli Scherer [Mon, 7 Feb 2022 15:50:42 +0000 (15:50 +0000)]
Print opaque types from type aliases via their path

2 years agoAuto merge of #93738 - m-ou-se:rollup-zjyd2et, r=m-ou-se
bors [Mon, 7 Feb 2022 15:32:19 +0000 (15:32 +0000)]
Auto merge of #93738 - m-ou-se:rollup-zjyd2et, r=m-ou-se

Rollup of 13 pull requests

Successful merges:

 - #88313 (Make the pre-commit script pre-push instead)
 - #91530 (Suggest 1-tuple parentheses on exprs without existing parens)
 - #92724 (Cleanup c_str.rs)
 - #93208 (Impl {Add,Sub,Mul,Div,Rem,BitXor,BitOr,BitAnd}Assign<$t> for Wrapping<$t> for rust 1.60.0)
 - #93394 (Don't allow {} to refer to implicit captures in format_args.)
 - #93416 (remove `allow_fail` test flag)
 - #93487 (Fix linking stage1 toolchain in `./x.py setup`)
 - #93673 (Linkify sidebar headings for sibling items)
 - #93680 (Drop json::from_reader)
 - #93682 (Update tracking issue for `const_fn_trait_bound`)
 - #93722 (Use shallow clones for submodules managed by rustbuild, not just bootstrap.py)
 - #93723 (Rerun bootstrap's build script when RUSTC changes)
 - #93737 (bootstrap: prefer using '--config' over 'RUST_BOOTSTRAP_CONFIG')

Failed merges:

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

2 years agoRollup merge of #93737 - mfrw:mfrw/bootstrap-config, r=Mark-Simulacrum
Mara Bos [Mon, 7 Feb 2022 14:08:40 +0000 (14:08 +0000)]
Rollup merge of #93737 - mfrw:mfrw/bootstrap-config, r=Mark-Simulacrum

bootstrap: prefer using '--config' over 'RUST_BOOTSTRAP_CONFIG'

Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
Closes: #93725
Rleated: #92260

2 years agoRollup merge of #93723 - jyn514:rerun-if-changed, r=Mark-Simulacrum
Mara Bos [Mon, 7 Feb 2022 14:08:39 +0000 (14:08 +0000)]
Rollup merge of #93723 - jyn514:rerun-if-changed, r=Mark-Simulacrum

Rerun bootstrap's build script when RUSTC changes

Previously, rustbuild would give strange errors if you tried to reuse the same build directory under two names:

```
$ mkdir tmp && cd tmp
$ ../x.py check
Building rustbuild
    Finished dev [unoptimized] target(s) in 35.27s
Checking stage0 std artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
^C
$ cd ..
$ mv tmp/build build
$ ./x.py check
Building rustbuild
   Compiling bootstrap v0.0.0 (/home/jnelson/rust-lang/rust/src/bootstrap)
    Finished dev [unoptimized] target(s) in 11.18s

failed to execute command: "/home/jnelson/rust-lang/rust/tmp/build/x86_64-unknown-linux-gnu/stage0/bin/rustc" "--target" "x86_64-unknown-linux-gnu" "--print" "target-libdir"
error: No such file or directory (os error 2)
```

This fixes the error. Reusing the same build directory is useful if you want to test path-related things in
bootstrap itself, without having to recompile it each time.

For good measure, this also reruns the build script when PATH changes.

2 years agoRollup merge of #93722 - jyn514:less-submodule-cloning, r=Mark-Simulacrum
Mara Bos [Mon, 7 Feb 2022 14:08:37 +0000 (14:08 +0000)]
Rollup merge of #93722 - jyn514:less-submodule-cloning, r=Mark-Simulacrum

Use shallow clones for submodules managed by rustbuild, not just bootstrap.py

I missed this in https://github.com/rust-lang/rust/pull/89757; it made
`x.py test src/bootstrap` very slow.

2 years agoRollup merge of #93682 - PatchMixolydic:where-in-the-world-is-const_fn_trait_bound...
Mara Bos [Mon, 7 Feb 2022 14:08:37 +0000 (14:08 +0000)]
Rollup merge of #93682 - PatchMixolydic:where-in-the-world-is-const_fn_trait_bound, r=oli-obk

Update tracking issue for `const_fn_trait_bound`

It previously pointed to #57563, the conglomerate issue for `const fn` (presumably under the feature gate `const_fn`). This tracking issue doesn't mention anything about `const_fn_trait_bound`(the only occurrence of "trait bound" is for the now-removed `?const Trait` syntax), which can be confusing to people who want to find out more about trait bounds on `const fn`s. This pull request changes the tracking issue to one meant specifically for `const_fn_trait_bound`, #93706, which can help collect information on this feature's stabilization and point users towards `const_trait_impl` if they're looking for const-in-const-contexts trait bounds.

Fixes #93679.

`````@rustbot````` modify labels +A-const-fn +F-const_trait_impl

2 years agoRollup merge of #93680 - Mark-Simulacrum:drop-json-reader, r=bjorn3
Mara Bos [Mon, 7 Feb 2022 14:08:36 +0000 (14:08 +0000)]
Rollup merge of #93680 - Mark-Simulacrum:drop-json-reader, r=bjorn3

Drop json::from_reader

Just a small cleanup -- this was essentially unused; the one use site is better suited to reading from &str regardless.

2 years agoRollup merge of #93673 - jsha:linkify-sidebar-headings, r=GuillaumeGomez
Mara Bos [Mon, 7 Feb 2022 14:08:35 +0000 (14:08 +0000)]
Rollup merge of #93673 - jsha:linkify-sidebar-headings, r=GuillaumeGomez

Linkify sidebar headings for sibling items

Also adjust CSS so this doesn't produce excess padding/margin.

Note: I tried and failed to write a test with browser-UI-test. First I tried to `assert-property: (".block.mod h3 a", {"href": "index.html#macros"})`. But the `href` that gets read out is the fully-quallified URL, starting with `file:///`. That URL will differ depending on what path the test is run from, so that doesn't work.

Next I tried clicking on the appropriate sidebar link, and verifying that the appropriate heading on the next page is highlighted with the right background color. However, that also didn't work: according to browser-UI-test, the targeted heading was plain white. However, running with no-headless, I could see that it actually was yellow. I suspect this is a bug in the older version of Chromium used with browser-UI-test's bundled puppeteer, since it doesn't reproduce on latest Chrome.

Fixes #92957

Demo: https://rustdoc.crud.net/jsha/linkify-sidebar-headings/std/string/trait.ToString.html

r? ``@GuillaumeGomez``

2 years agoRollup merge of #93487 - yerke:yerke/fix-link-toolchain-in-setup, r=Mark-Simulacrum
Mara Bos [Mon, 7 Feb 2022 14:08:34 +0000 (14:08 +0000)]
Rollup merge of #93487 - yerke:yerke/fix-link-toolchain-in-setup, r=Mark-Simulacrum

Fix linking stage1 toolchain in `./x.py setup`

Closes [92319](https://github.com/rust-lang/rust/issues/92319)

Fix linking stage1 toolchain in `./x.py setup`. I guess this can be considered a follow up to https://github.com/rust-lang/rust/pull/89212 by `````@Sl1mb0.`````

We create 2 directories and 1 file that are required by rustup to [link a custom toolchain from path](https://github.com/rust-lang/rustup/blob/5225e87a5d974ab5f1626bcb2a7b43f76ab883f0/src/toolchain.rs#L479-L497).

cc `````@jyn514````` and `````@Mark-Simulacrum````` as they were active in https://github.com/rust-lang/rust/issues/89206

2 years agoRollup merge of #93416 - name1e5s:chore/remove_allow_fail, r=m-ou-se
Mara Bos [Mon, 7 Feb 2022 14:08:34 +0000 (14:08 +0000)]
Rollup merge of #93416 - name1e5s:chore/remove_allow_fail, r=m-ou-se

remove `allow_fail` test flag

close #93345

2 years agoRollup merge of #93394 - m-ou-se:fix-93378, r=estebank
Mara Bos [Mon, 7 Feb 2022 14:08:33 +0000 (14:08 +0000)]
Rollup merge of #93394 - m-ou-se:fix-93378, r=estebank

Don't allow {} to refer to implicit captures in format_args.

Fixes #93378

2 years agoRollup merge of #93208 - kellerkindt:wrapping_int_assign_impl, r=m-ou-se
Mara Bos [Mon, 7 Feb 2022 14:08:32 +0000 (14:08 +0000)]
Rollup merge of #93208 - kellerkindt:wrapping_int_assign_impl, r=m-ou-se

Impl {Add,Sub,Mul,Div,Rem,BitXor,BitOr,BitAnd}Assign<$t> for Wrapping<$t> for rust 1.60.0

Tracking issue #93204

This is about adding basic integer operations to the `Wrapping` type:

```rust
let mut value = Wrapping(2u8);
value += 3u8;
value -= 1u8;
value *= 2u8;
value /= 2u8;
value %= 2u8;
value ^= 255u8;
value |= 123u8;
value &= 2u8;
```

Because this adds stable impls on a stable type, it runs into the following issue if an `#[unstable(...)]` attribute is used:

```
an `#[unstable]` annotation here has no effect
note: see issue #55436 <https://github.com/rust-lang/rust/issues/55436> for more information
```

This means - if I understood this correctly - the new impls have to be stabilized instantly.
Which in turn means, this PR has to kick of an FCP on the tracking issue as well?

This impl is analog to 1c0dc1810d778bb6fea16aac02cafc5aa2e84b11 #92356 for the `Saturating` type ``@dtolnay``  ``@Mark-Simulacrum``

2 years agoRollup merge of #92724 - inteon:cleanup, r=Mark-Simulacrum
Mara Bos [Mon, 7 Feb 2022 14:08:32 +0000 (14:08 +0000)]
Rollup merge of #92724 - inteon:cleanup, r=Mark-Simulacrum

Cleanup c_str.rs

Some code cleanups in `c_str.rs`.
No functional changes.

ref: https://github.com/bytecodealliance/rustix/pull/163

2 years agoRollup merge of #91530 - bobrippling:suggest-1-tuple-parens, r=camelid
Mara Bos [Mon, 7 Feb 2022 14:08:31 +0000 (14:08 +0000)]
Rollup merge of #91530 - bobrippling:suggest-1-tuple-parens, r=camelid

Suggest 1-tuple parentheses on exprs without existing parens

A follow-on from #86116, split out from #90677.

This alters the suggestion to add a trailing comma to create a 1-tuple - previously we would only apply this if the relevant expression was parenthesised. We now make the suggestion regardless of parentheses, which reduces the fragility of the check (w.r.t formatting).

e.g.
```rust
let a: Option<(i32,)> = Some(3);
```

gets the below suggestion:

```rust
let a: Option<(i32,)> = Some((3,));
//                           ^ ^^
```

This change also improves the suggestion in other ways, such as by only making the suggestion if the types would match after the suggestion is applied and making the suggestion a multipart suggestion.

2 years agoRollup merge of #88313 - jyn514:pre-push, r=Mark-Simulacrum
Mara Bos [Mon, 7 Feb 2022 14:08:29 +0000 (14:08 +0000)]
Rollup merge of #88313 - jyn514:pre-push, r=Mark-Simulacrum

Make the pre-commit script pre-push instead

This should make it substantially less annoying, and hopefully more
people will find it useful. In particular, it will no longer run tidy
each time you run `git commit --amend` or rebase a branch.

This also warns if you have the old script in pre-commit; see the HACK
comment for details.

r? ````@Mark-Simulacrum```` cc ````@caass````

2 years agobootstrap: prefer using '--config' over 'RUST_BOOTSTRAP_CONFIG'
Muhammad Falak R Wani [Mon, 7 Feb 2022 12:52:08 +0000 (18:22 +0530)]
bootstrap: prefer using '--config' over 'RUST_BOOTSTRAP_CONFIG'

Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
2 years agoAuto merge of #93719 - scottmcm:core-as-2021-everywhere, r=Mark-Simulacrum
bors [Mon, 7 Feb 2022 12:38:21 +0000 (12:38 +0000)]
Auto merge of #93719 - scottmcm:core-as-2021-everywhere, r=Mark-Simulacrum

Build libcore as 2021 in a few more places

The `Cargo.toml` has `edition = "2021"` (as of #92068), so that's what these command lines should use too.