]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoAuto merge of #90986 - camsteffen:nested-filter, r=cjgillot
bors [Mon, 17 Jan 2022 14:50:50 +0000 (14:50 +0000)]
Auto merge of #90986 - camsteffen:nested-filter, r=cjgillot

Replace `NestedVisitorMap` with generic `NestedFilter`

This is an attempt to make the `intravisit::Visitor` API simpler and "more const" with regard to nested visiting.

With this change, `intravisit::Visitor` does not visit nested things by default, unless you specify `type NestedFilter = nested_filter::OnlyBodies` (or `All`). `nested_visit_map` returns `Self::Map` instead of `NestedVisitorMap<Self::Map>`. It panics by default (unreachable if `type NestedFilter` is omitted).

One somewhat trixty thing here is that `nested_filter::{OnlyBodies, All}` live in `rustc_middle` so that they may have `type Map = map::Map` and so that `impl Visitor`s never need to specify `type Map` - it has a default of `Self::NestedFilter::Map`.

2 years agoAuto merge of #92816 - tmiasko:rm-llvm-asm, r=Amanieu
bors [Mon, 17 Jan 2022 09:40:29 +0000 (09:40 +0000)]
Auto merge of #92816 - tmiasko:rm-llvm-asm, r=Amanieu

Remove deprecated LLVM-style inline assembly

The `llvm_asm!` was deprecated back in #87590 1.56.0, with intention to remove
it once `asm!` was stabilized, which already happened in #91728 1.59.0. Now it
is time to remove `llvm_asm!` to avoid continued maintenance cost.

Closes #70173.
Closes #92794.
Closes #87612.
Closes #82065.

cc `@rust-lang/wg-inline-asm`

r? `@Amanieu`

2 years agoAuto merge of #92996 - matthiaskrgr:rollup-50wpzva, r=matthiaskrgr
bors [Mon, 17 Jan 2022 05:46:53 +0000 (05:46 +0000)]
Auto merge of #92996 - matthiaskrgr:rollup-50wpzva, r=matthiaskrgr

Rollup of 10 pull requests

Successful merges:

 - #92795 (Link sidebar "location" heading to top of page)
 - #92799 (Remove some unnecessary uses of `FieldDef::ident`)
 - #92808 (Fix `try wrapping expression in variant` suggestion with struct field shorthand)
 - #92819 (rustdoc: remove hand-rolled isatty)
 - #92876 (Fix suggesting turbofish with lifetime arguments)
 - #92921 (Rename Printer constructor from mk_printer() to Printer::new())
 - #92937 (rustdoc: Add missing dot separator)
 - #92953 (Copy an example to PartialOrd as well)
 - #92977 (Docs: recommend VecDeque instead of Vec::remove(0))
 - #92981 (fix const_ptr_offset_from tracking issue)

Failed merges:

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

2 years agoRollup merge of #92981 - RalfJung:const_ptr_offset_from, r=dtolnay
Matthias Krüger [Mon, 17 Jan 2022 05:08:19 +0000 (06:08 +0100)]
Rollup merge of #92981 - RalfJung:const_ptr_offset_from, r=dtolnay

fix const_ptr_offset_from tracking issue

The old tracking issue #41079 was for exposing those functions at all, and got closed when they were stabilized. We had nothing tracking their `const`ness so I opened a new tracking issue: https://github.com/rust-lang/rust/issues/92980.

2 years agoRollup merge of #92977 - kornelski:popdoc, r=dtolnay
Matthias Krüger [Mon, 17 Jan 2022 05:08:18 +0000 (06:08 +0100)]
Rollup merge of #92977 - kornelski:popdoc, r=dtolnay

Docs: recommend VecDeque instead of Vec::remove(0)

Suggestion based on a [discussion](https://internals.rust-lang.org/t/should-vec-have-a-try-remove-mut-self-usize-option-t-function/15964/9?u=kornel) where user needlessly struggled with `remove(0)` and accidentally created a quadratic cost.

2 years agoRollup merge of #92953 - azdavis:azdavis-copy-example, r=dtolnay
Matthias Krüger [Mon, 17 Jan 2022 05:08:17 +0000 (06:08 +0100)]
Rollup merge of #92953 - azdavis:azdavis-copy-example, r=dtolnay

Copy an example to PartialOrd as well

In https://github.com/rust-lang/rust/pull/88202 I added an example for deriving PartialOrd on enums, but only later did I realize that I actually put the example on Ord.

This copies the example to PartialOrd as well, which is where I intended for it to be.

We could also delete the example on Ord, but I see there's already some highly similar examples shared between Ord and PartialOrd, so I figured we could leave it.

I also changed some type annotations in an example from `x : T` to the more common style (in Rust) of `x: T`.

2 years agoRollup merge of #92937 - GuillaumeGomez:dot-separator, r=jsha
Matthias Krüger [Mon, 17 Jan 2022 05:08:17 +0000 (06:08 +0100)]
Rollup merge of #92937 - GuillaumeGomez:dot-separator, r=jsha

rustdoc: Add missing dot separator

Fixes #92901.

![Screenshot from 2022-01-15 17-47-18](https://user-images.githubusercontent.com/3050060/149631249-e2c0c3a4-9ed8-48e2-92cc-79a5bb347b35.png)

r? ``@jsha``

2 years agoRollup merge of #92921 - dtolnay:printernew, r=wesleywiser
Matthias Krüger [Mon, 17 Jan 2022 05:08:16 +0000 (06:08 +0100)]
Rollup merge of #92921 - dtolnay:printernew, r=wesleywiser

Rename Printer constructor from mk_printer() to Printer::new()

The original naming is left over from 2011 which was before impl blocks and associated functions existed.

https://github.com/rust-lang/rust/blob/21313d623a505086b2973f30c19db4f1d6ec8f61/src/comp/pretty/pp.rs

2 years agoRollup merge of #92876 - compiler-errors:fix-turbofish-lifetime-suggestion, r=nagisa
Matthias Krüger [Mon, 17 Jan 2022 05:08:15 +0000 (06:08 +0100)]
Rollup merge of #92876 - compiler-errors:fix-turbofish-lifetime-suggestion, r=nagisa

Fix suggesting turbofish with lifetime arguments

Now we suggest turbofish correctly given exprs like `foo<'_>`.

Also fix suggestion when we have `let x = foo<bar, baz>;` which was broken.

2 years agoRollup merge of #92819 - euclio:atty, r=CraftSpider
Matthias Krüger [Mon, 17 Jan 2022 05:08:14 +0000 (06:08 +0100)]
Rollup merge of #92819 - euclio:atty, r=CraftSpider

rustdoc: remove hand-rolled isatty

This PR replaces bindings to the platform-specific isatty APIs with the `isatty` crate, as done elsewhere in the repository.

2 years agoRollup merge of #92808 - compiler-errors:wrap-struct-shorthand-field-in-variant,...
Matthias Krüger [Mon, 17 Jan 2022 05:08:13 +0000 (06:08 +0100)]
Rollup merge of #92808 - compiler-errors:wrap-struct-shorthand-field-in-variant, r=davidtwco

Fix `try wrapping expression in variant` suggestion with struct field shorthand

Fixes a broken suggestion: [playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=83fe2dbfe1485f8cfca1aef2a6582e77)

before:
```
error[E0308]: mismatched types
 --> src/main.rs:7:19
  |
7 |     let x = Foo { bar };
  |                   ^^^ expected enum `Option`, found integer
  |
  = note: expected enum `Option<i32>`
             found type `{integer}`
help: try wrapping the expression in `Some`
  |
7 |     let x = Foo { Some(bar) };
  |                   +++++   +
```

after:
```
error[E0308]: mismatched types
 --> src/main.rs:7:19
  |
7 |     let x = Foo { bar };
  |                   ^^^ expected enum `Option`, found integer
  |
  = note: expected enum `Option<i32>`
             found type `{integer}`
help: try wrapping the expression in `Some`
  |
7 |     let x = Foo { bar: Some(bar) };
  |                   ~~~~~~~~~~~~~~
```

r? ``@m-ou-se``
since you touched the code last in #91080

2 years agoRollup merge of #92799 - rust-lang:followup-from-92533, r=Aaron1011
Matthias Krüger [Mon, 17 Jan 2022 05:08:11 +0000 (06:08 +0100)]
Rollup merge of #92799 - rust-lang:followup-from-92533, r=Aaron1011

Remove some unnecessary uses of `FieldDef::ident`

Followup from #92533.

cc ``@Aaron1011`` ``@petrochenkov``

2 years agoRollup merge of #92795 - jsha:link-to-top, r=GuillaumeGomez
Matthias Krüger [Mon, 17 Jan 2022 05:08:10 +0000 (06:08 +0100)]
Rollup merge of #92795 - jsha:link-to-top, r=GuillaumeGomez

Link sidebar "location" heading to top of page

This makes it easy, when you are scrolled far down in a page, to jump back to the top.

Demo: https://rustdoc.crud.net/jsha/link-to-top/std/string/struct.String.html

r? ``@GuillaumeGomez``

2 years agoAuto merge of #92473 - petrochenkov:ltrattr2, r=Aaron1011
bors [Mon, 17 Jan 2022 02:06:54 +0000 (02:06 +0000)]
Auto merge of #92473 - petrochenkov:ltrattr2, r=Aaron1011

expand: Pick `cfg`s and `cfg_attrs` one by one, like other attributes

This is a rebase of https://github.com/rust-lang/rust/pull/83354, but without any language-changing parts ~(except for https://github.com/rust-lang/rust/pull/84110)~, i.e. the attribute expansion order is the same.

This is a pre-requisite for any other changes making cfg attributes closer to regular macro attributes
- Possibly changing their expansion order (https://github.com/rust-lang/rust/issues/83331)
- Keeping macro backtraces for cfg attributes, or otherwise making them visible after expansion without keeping them in place literally (https://github.com/rust-lang/rust/pull/84110).

Two exceptions to the "one by one" behavior are:
- cfgs eagerly expanded by `derive` and `cfg_eval`, they are still expanded in a batch, that's by design.
- cfgs at the crate root, they are currently expanded not during the main expansion pass, but before that, during `#![feature]` collection. I'll try to disentangle that logic later in a separate PR.

r? `@Aaron1011`

2 years agoAuto merge of #92935 - Xanewok:update-rls, r=pietroalbini
bors [Sun, 16 Jan 2022 23:03:33 +0000 (23:03 +0000)]
Auto merge of #92935 - Xanewok:update-rls, r=pietroalbini

Update RLS and drop rustc-ap-packages

Closes #91543

r? `@pietroalbini`

cc `@calebcartwright` `@flip1995`

2 years agoFix Visitor::NestedFilter in Clippy
Cameron Steffen [Sat, 15 Jan 2022 22:07:52 +0000 (16:07 -0600)]
Fix Visitor::NestedFilter in Clippy

2 years agoFormat clippy
Cameron Steffen [Sun, 16 Jan 2022 21:58:54 +0000 (15:58 -0600)]
Format clippy

2 years agoReplace NestedVisitorMap with NestedFilter
Cameron Steffen [Wed, 3 Nov 2021 23:03:12 +0000 (18:03 -0500)]
Replace NestedVisitorMap with NestedFilter

2 years agofix const_ptr_offset_from tracking issue
Ralf Jung [Sun, 16 Jan 2022 19:24:46 +0000 (14:24 -0500)]
fix const_ptr_offset_from tracking issue

2 years agoDocs: recommend VecDeque instead of Vec::remove(0)
Kornel [Sun, 16 Jan 2022 16:51:55 +0000 (16:51 +0000)]
Docs: recommend VecDeque instead of Vec::remove(0)

2 years agoAuto merge of #92970 - matthiaskrgr:rollup-tcx7cfb, r=matthiaskrgr
bors [Sun, 16 Jan 2022 17:22:57 +0000 (17:22 +0000)]
Auto merge of #92970 - matthiaskrgr:rollup-tcx7cfb, r=matthiaskrgr

Rollup of 10 pull requests

Successful merges:

 - #92487 (Fix unclosed boxes in pretty printing of TraitAlias)
 - #92581 (ARMv6K Horizon - Enable default libraries)
 - #92619 (Add diagnostic items for macros)
 - #92635 (rustdoc: Yet more intra-doc links cleanup)
 - #92646 (feat: rustc_pass_by_value lint attribute)
 - #92706 (Clarify explicitly that BTree{Map,Set} are ordered.)
 - #92710 (Include Projections when elaborating TypeOutlives)
 - #92746 (Parse `Ty?` as `Option<Ty>` and provide structured suggestion)
 - #92792 (rustdoc: fix intra-link for generic trait impls)
 - #92814 (remove unused FIXME)

Failed merges:

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

2 years agoRollup merge of #92814 - lcnr:unused-fixme, r=Mark-Simulacrum
Matthias Krüger [Sun, 16 Jan 2022 15:58:20 +0000 (16:58 +0100)]
Rollup merge of #92814 - lcnr:unused-fixme, r=Mark-Simulacrum

remove unused FIXME

#56935 seems to be fixed.

2 years agoRollup merge of #92792 - mdibaiee:92662/fix-intra-doc-generics, r=camelid
Matthias Krüger [Sun, 16 Jan 2022 15:58:19 +0000 (16:58 +0100)]
Rollup merge of #92792 - mdibaiee:92662/fix-intra-doc-generics, r=camelid

rustdoc: fix intra-link for generic trait impls

fixes #92662

r? `````@camelid`````

2 years agoRollup merge of #92746 - estebank:question-mark-in-type, r=davidtwco
Matthias Krüger [Sun, 16 Jan 2022 15:58:18 +0000 (16:58 +0100)]
Rollup merge of #92746 - estebank:question-mark-in-type, r=davidtwco

Parse `Ty?` as `Option<Ty>` and provide structured suggestion

Swift has specific syntax that desugars to `Option<T>` similar to our
`?` operator, which means that people might try to use it in Rust. Parse
it and gracefully recover.

2 years agoRollup merge of #92710 - jackh726:issue-92280, r=nikomatsakis
Matthias Krüger [Sun, 16 Jan 2022 15:58:17 +0000 (16:58 +0100)]
Rollup merge of #92710 - jackh726:issue-92280, r=nikomatsakis

Include Projections when elaborating TypeOutlives

Fixes #92280

In `Elaborator`, we elaborate that `Foo<<Bar as Baz>::Assoc>: 'a` -> `<Bar as Baz>::Assoc: 'a`. This is the same rule that would be applied to any other `Param`. If there are escaping vars, we continue to do nothing.

r? `@nikomatsakis`

2 years agoRollup merge of #92706 - umanwizard:btree, r=dtolnay
Matthias Krüger [Sun, 16 Jan 2022 15:58:16 +0000 (16:58 +0100)]
Rollup merge of #92706 - umanwizard:btree, r=dtolnay

Clarify explicitly that BTree{Map,Set} are ordered.

One of the main reasons one would want to use a BTree{Map,Set} rather than a Hash{Map,Set} is because they maintain their keys in sorted order; but this was never explicitly stated in the top-level docs (it was only indirectly alluded to there, and stated explicitly in the docs for `iter`, `values`, etc.)

This PR states the ordering guarantee more prominently.

2 years agoRollup merge of #92646 - mdibaiee:76935/pass-by-value, r=lcnr
Matthias Krüger [Sun, 16 Jan 2022 15:58:15 +0000 (16:58 +0100)]
Rollup merge of #92646 - mdibaiee:76935/pass-by-value, r=lcnr

feat: rustc_pass_by_value lint attribute

Useful for thin wrapper attributes that are best passed as value instead
of reference.

Fixes #76935

2 years agoRollup merge of #92635 - camelid:yet-more-cleanup, r=Manishearth
Matthias Krüger [Sun, 16 Jan 2022 15:58:14 +0000 (16:58 +0100)]
Rollup merge of #92635 - camelid:yet-more-cleanup, r=Manishearth

rustdoc: Yet more intra-doc links cleanup

r? `@Manishearth`

2 years agoRollup merge of #92619 - Alexendoo:macro-diagnostic-items, r=matthewjasper
Matthias Krüger [Sun, 16 Jan 2022 15:58:14 +0000 (16:58 +0100)]
Rollup merge of #92619 - Alexendoo:macro-diagnostic-items, r=matthewjasper

Add diagnostic items for macros

For use in Clippy, it adds diagnostic items to all the stable public macros

Clippy has lints that look for almost all of these (currently by name or path), but there are a few that aren't currently part of any lint, I could remove those if it's preferred to add them as needed rather than ahead of time

2 years agoRollup merge of #92581 - Meziu:armv6k-3ds-target, r=nagisa
Matthias Krüger [Sun, 16 Jan 2022 15:58:12 +0000 (16:58 +0100)]
Rollup merge of #92581 - Meziu:armv6k-3ds-target, r=nagisa

ARMv6K Horizon - Enable default libraries

Due to the nature of the external gcc linker, default libraries are required, even for `no_std` programs.

2 years agoRollup merge of #92487 - dtolnay:traitalias, r=matthewjasper
Matthias Krüger [Sun, 16 Jan 2022 15:58:10 +0000 (16:58 +0100)]
Rollup merge of #92487 - dtolnay:traitalias, r=matthewjasper

Fix unclosed boxes in pretty printing of TraitAlias

This was causing trait aliases to not even render at all in stringified / pretty printed output.

```rust
macro_rules! repro {
    ($item:item) => {
        stringify!($item)
    };
}

fn main() {
    println!("{:?}", repro!(pub trait Trait<T> = Sized where T: 'a;));
}
```

Before:&ensp;`""`
After:&ensp;`"pub trait Trait<T> = Sized where T: 'a;"`

The fix is copied from how `head`/`end` for `ItemKind::Use`, `ItemKind::ExternCrate`, and `ItemKind::Mod` are all done in the pretty printer:

https://github.com/rust-lang/rust/blob/dd3ac41495e85a9b7b5cb3186379d02ce17e51fe/compiler/rustc_ast_pretty/src/pprust/state.rs#L1178-L1184

2 years agoUse new Racer from crates.io
Igor Matuszewski [Sat, 15 Jan 2022 17:09:29 +0000 (18:09 +0100)]
Use new Racer from crates.io

2 years agoDrop duplicate checks for now missing rustc_ast dep in tidy
Igor Matuszewski [Sat, 15 Jan 2022 16:47:09 +0000 (17:47 +0100)]
Drop duplicate checks for now missing rustc_ast dep in tidy

2 years agoUpdate RLS and drop rustc-ap-packages
Igor Matuszewski [Sat, 15 Jan 2022 16:31:37 +0000 (17:31 +0100)]
Update RLS and drop rustc-ap-packages

2 years agoAuto merge of #92245 - petrochenkov:cmrval, r=nagisa
bors [Sun, 16 Jan 2022 14:25:25 +0000 (14:25 +0000)]
Auto merge of #92245 - petrochenkov:cmrval, r=nagisa

rustc_metadata: Switch all decoder methods from vectors to iterators

To avoid allocations in some cases.

Also remove unnecessary `is_proc_macro_crate` checks from decoder, currently the general strategy is to shift all the work to the encoder and assume that all the encoded data is correct and can be decoded unconditionally in the decoder.

2 years agoAuto merge of #92805 - BoxyUwU:revert-lazy-anon-const-substs, r=lcnr
bors [Sun, 16 Jan 2022 11:19:21 +0000 (11:19 +0000)]
Auto merge of #92805 - BoxyUwU:revert-lazy-anon-const-substs, r=lcnr

partially revertish `lazily "compute" anon const default substs`

reverts #87280 except for some of the changes around `ty::Unevaluated` having a visitor and a generic for promoted
why revert: <https://github.com/rust-lang/rust/pull/92805#issuecomment-1010736049>

r? `@lcnr`

2 years agoAuto merge of #92740 - cuviper:update-rayons, r=Mark-Simulacrum
bors [Sun, 16 Jan 2022 08:12:23 +0000 (08:12 +0000)]
Auto merge of #92740 - cuviper:update-rayons, r=Mark-Simulacrum

Update rayon and rustc-rayon

This updates rayon for various tools and rustc-rayon for the compiler's parallel mode.

- rayon v1.3.1 -> v1.5.1
- rayon-core v1.7.1 -> v1.9.1
- rustc-rayon v0.3.1 -> v0.3.2
- rustc-rayon-core v0.3.1 -> v0.3.2

... and indirectly, this updates all of crossbeam-* to their latest versions.

Fixes #92677 by removing crossbeam-queue, but there's still a lingering question about how tidy discovers "runtime" dependencies. None of this is truly in the standard library's dependency tree at all.

2 years agorustc_metadata: Switch all decoder methods from vectors to iterators
Vadim Petrochenkov [Fri, 24 Dec 2021 06:57:21 +0000 (14:57 +0800)]
rustc_metadata: Switch all decoder methods from vectors to iterators

Also remove unnecessary `is_proc_macro_crate` checks from decoder

2 years agoAuto merge of #92356 - kellerkindt:saturating_int_assign_impl, r=dtolnay
bors [Sun, 16 Jan 2022 05:23:44 +0000 (05:23 +0000)]
Auto merge of #92356 - kellerkindt:saturating_int_assign_impl, r=dtolnay

Add {Add,Sub,Mul,Div,Rem,BitXor,BitOr,BitAnd}{,Assign}<$t> to Saturat…

Tracking issue #92354

2 years agoTouch up stray comment in PR 92953
David Tolnay [Sun, 16 Jan 2022 04:44:47 +0000 (20:44 -0800)]
Touch up stray comment in PR 92953

2 years agoClear up discriminants with more examples
Ariel Davis [Sun, 16 Jan 2022 04:24:38 +0000 (20:24 -0800)]
Clear up discriminants with more examples

2 years agoAdd nll revision for issue-92096 test that passes
Jack Huey [Sun, 16 Jan 2022 04:17:32 +0000 (23:17 -0500)]
Add nll revision for issue-92096 test that passes

2 years agoTweak btree iterator wording to not use 'yield'
David Tolnay [Sun, 16 Jan 2022 03:28:19 +0000 (19:28 -0800)]
Tweak btree iterator wording to not use 'yield'

Yield means something else in the context of generators, which are
sufficiently close to iterators that it's better to avoid the
terminology collision here.

2 years agoAuto merge of #92598 - Badel2:panic-update-hook, r=yaahc
bors [Sun, 16 Jan 2022 02:18:42 +0000 (02:18 +0000)]
Auto merge of #92598 - Badel2:panic-update-hook, r=yaahc

Implement `panic::update_hook`

Add a new function `panic::update_hook` to allow creating panic hooks that forward the call to the previously set panic hook, without race conditions. It works by taking a closure that transforms the old panic hook into a new one, while ensuring that during the execution of the closure no other thread can modify the panic hook. This is a small function so I hope it can be discussed here without a formal RFC, however if you prefer I can write one.

Consider the following example:

```rust
let prev = panic::take_hook();
panic::set_hook(Box::new(move |info| {
    println!("panic handler A");
    prev(info);
}));
```

This is a common pattern in libraries that need to do something in case of panic: log panic to a file, record code coverage, send panic message to a monitoring service, print custom message with link to github to open a new issue, etc. However it is impossible to avoid race conditions with the current API, because two threads can execute in this order:

* Thread A calls `panic::take_hook()`
* Thread B calls `panic::take_hook()`
* Thread A calls `panic::set_hook()`
* Thread B calls `panic::set_hook()`

And the result is that the original panic hook has been lost, as well as the panic hook set by thread A. The resulting panic hook will be the one set by thread B, which forwards to the default panic hook. This is not considered a big issue because the panic handler setup is usually run during initialization code, probably before spawning any other threads.

Using the new `panic::update_hook` function, this race condition is impossible, and the result will be either `A, B, original` or `B, A, original`.

```rust
panic::update_hook(|prev| {
    Box::new(move |info| {
        println!("panic handler A");
        prev(info);
    })
});
```

I found one real world use case here: https://github.com/dtolnay/proc-macro2/blob/988cf403e741aadfd5340bbf67e35e1062a526aa/src/detection.rs#L32 the workaround is to detect the race condition and panic in that case.

The pattern of `take_hook` + `set_hook` is very common, you can see some examples in this pull request, so I think it's natural to have a function that combines them both. Also using `update_hook` instead of `take_hook` + `set_hook` reduces the number of calls to `HOOK_LOCK.write()` from 2 to 1, but I don't expect this to make any difference in performance.

### Unresolved questions:

* `panic::update_hook` takes a closure, if that closure panics the error message is "panicked while processing panic" which is not nice. This is a consequence of holding the `HOOK_LOCK` while executing the closure. Could be avoided using `catch_unwind`?

* Reimplement `panic::set_hook` as `panic::update_hook(|_prev| hook)`?

2 years agoCopy an example to PartialOrd as well
Ariel Davis [Sun, 16 Jan 2022 00:25:09 +0000 (16:25 -0800)]
Copy an example to PartialOrd as well

2 years agoAuto merge of #90146 - cjgillot:no-id-map, r=nagisa
bors [Sat, 15 Jan 2022 23:10:14 +0000 (23:10 +0000)]
Auto merge of #90146 - cjgillot:no-id-map, r=nagisa

Reduce use of LocalDefId <-> HirId maps

This is an attempt to reduce the perf effect of https://github.com/rust-lang/rust/pull/89278.
r? `@ghost`

2 years agoAdd inline.
Camille GILLOT [Fri, 10 Dec 2021 12:23:48 +0000 (13:23 +0100)]
Add inline.

2 years agoDo not ICE when accesing large LocalDefId.
Camille GILLOT [Fri, 22 Oct 2021 14:43:43 +0000 (16:43 +0200)]
Do not ICE when accesing large LocalDefId.

2 years agoReduce use of local_def_id_to_hir_id.
Camille GILLOT [Wed, 20 Oct 2021 18:59:15 +0000 (20:59 +0200)]
Reduce use of local_def_id_to_hir_id.

2 years agoMake ty_param_owner return a LocalDefId.
Camille GILLOT [Sun, 5 Dec 2021 12:09:56 +0000 (13:09 +0100)]
Make ty_param_owner return a LocalDefId.

2 years agoUse LocalDefId in rustc_passes::hir_id_validator.
Camille GILLOT [Sun, 5 Dec 2021 12:08:52 +0000 (13:08 +0100)]
Use LocalDefId in rustc_passes::hir_id_validator.

2 years agoSimplify DefIdForest.
Camille GILLOT [Sun, 5 Dec 2021 12:08:24 +0000 (13:08 +0100)]
Simplify DefIdForest.

2 years agoUse LocalDefId in rustc_passes::entry.
Camille GILLOT [Sun, 5 Dec 2021 12:07:51 +0000 (13:07 +0100)]
Use LocalDefId in rustc_passes::entry.

2 years agoReturn a LocalDefId in get_parent_item.
Camille GILLOT [Thu, 21 Oct 2021 17:41:47 +0000 (19:41 +0200)]
Return a LocalDefId in get_parent_item.

2 years agoAdd fast path to `opt_local_def_id`.
Camille GILLOT [Sun, 5 Dec 2021 10:18:16 +0000 (11:18 +0100)]
Add fast path to `opt_local_def_id`.

2 years agoFix broken link
Noah Lev [Sat, 15 Jan 2022 18:18:24 +0000 (10:18 -0800)]
Fix broken link

2 years agoAdd test for dot separator
Guillaume Gomez [Sat, 15 Jan 2022 17:19:54 +0000 (18:19 +0100)]
Add test for dot separator

2 years agoFix missing dot separator
Guillaume Gomez [Sat, 15 Jan 2022 17:19:44 +0000 (18:19 +0100)]
Fix missing dot separator

2 years agoAuto merge of #92441 - cjgillot:resolve-trait-impl-item, r=matthewjasper
bors [Sat, 15 Jan 2022 14:43:45 +0000 (14:43 +0000)]
Auto merge of #92441 - cjgillot:resolve-trait-impl-item, r=matthewjasper

Link impl items to corresponding trait items in late resolver.

Hygienically linking trait impl items to declarations in the trait can be done directly by the late resolver. In fact, it is already done to diagnose unknown items.

This PR uses this resolution work and stores the `DefId` of the trait item in the HIR. This avoids having to do this resolution manually later.

r? `@matthewjasper`
Related to #90639. The added `trait_item_id` field can be moved to `ImplItemRef` to be used directly by your PR.

2 years agoAuto merge of #92927 - matthiaskrgr:rollup-pgzwfcm, r=matthiaskrgr
bors [Sat, 15 Jan 2022 10:57:03 +0000 (10:57 +0000)]
Auto merge of #92927 - matthiaskrgr:rollup-pgzwfcm, r=matthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - #92747 (Simplification of BigNum::bit_length)
 - #92767 (Use the new language identifier for Rust in the PDB debug format)
 - #92775 (Inline std::os::unix::ffi::OsStringExt methods)
 - #92863 (Remove `&mut` from `io::read_to_string` signature)
 - #92865 (Ignore static lifetimes for GATs outlives lint)
 - #92873 (Generate more precise generator names)
 - #92879 (Add Sync bound to allocator parameter in vec::IntoIter)
 - #92892 (Do not fail evaluation in const blocks)

Failed merges:

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

2 years agoRollup merge of #92892 - compiler-errors:const-param-env-for-const-block, r=fee1...
Matthias Krüger [Sat, 15 Jan 2022 10:28:28 +0000 (11:28 +0100)]
Rollup merge of #92892 - compiler-errors:const-param-env-for-const-block, r=fee1-dead

Do not fail evaluation in const blocks

Evaluate const blocks with a const param-env, so we properly check `~const` trait bounds.

Fixes #92713
(I will fix the poor diagnostics in #92713 and #92712 in a separate PR)

cc `@nbdd0121` who wrote the code this PR touches in #89561

2 years agoRollup merge of #92879 - compiler-errors:into_iter_unsound, r=dtolnay
Matthias Krüger [Sat, 15 Jan 2022 10:28:27 +0000 (11:28 +0100)]
Rollup merge of #92879 - compiler-errors:into_iter_unsound, r=dtolnay

Add Sync bound to allocator parameter in vec::IntoIter

The `A: Sync` bound was forgotten in https://github.com/rust-lang/rust/commit/8725e4c33749b23f260b2fc46e090c3792b6f97e#diff-b78c3ab6d37f4ede32195707528f8a76c49d4557cc9d3a7a09417b5157729b9fR3132

Similar `unsafe impl Sync` in that commit _do_ include the `A: Sync` bound (and around the alloc lib), so I think this was just an honest mistake.

Here's an example of the unsoundness:  https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=16cbfeff7c934ae72ab632c1476fdd8b

`@steffahn` found this, I'm just putting up the fix cause nobody else did :^)

Fixes #92633

2 years agoRollup merge of #92873 - eholk:async-symbol-names, r=tmandry
Matthias Krüger [Sat, 15 Jan 2022 10:28:26 +0000 (11:28 +0100)]
Rollup merge of #92873 - eholk:async-symbol-names, r=tmandry

Generate more precise generator names

Currently all generators are named with a `generator$N` suffix, regardless of where they come from. This means an `async fn` shows up as a generator in stack traces, which can be surprising to async programmers since they should not need to know that async functions are implementated using generators.

This change generators a different name depending on the generator kind, allowing us to tell whether the generator is the result of an async block, an async closure, an async fn, or a plain generator.

r? `@tmandry`
cc `@michaelwoerister` `@wesleywiser` `@dpaoliello`

2 years agoRollup merge of #92865 - jackh726:gats-outlives-no-static, r=nikomatsakis
Matthias Krüger [Sat, 15 Jan 2022 10:28:25 +0000 (11:28 +0100)]
Rollup merge of #92865 - jackh726:gats-outlives-no-static, r=nikomatsakis

Ignore static lifetimes for GATs outlives lint

cc https://github.com/rust-lang/rust/issues/87479#issuecomment-1010484170

Also included a bit of cleanup of `ty_known_to_outlive` and `region_known_to_outlive`

r? `@nikomatsakis`

2 years agoRollup merge of #92863 - camelid:read_to_string-rm-mut, r=m-ou-se
Matthias Krüger [Sat, 15 Jan 2022 10:28:24 +0000 (11:28 +0100)]
Rollup merge of #92863 - camelid:read_to_string-rm-mut, r=m-ou-se

Remove `&mut` from `io::read_to_string` signature

``@m-ou-se`` [realized][1] that because `Read` is implemented for `&mut impl
Read`, there's no need to take `&mut` in `io::read_to_string`.

Removing the `&mut` from the signature allows users to remove the `&mut`
from their calls (and thus pass an owned reader) if they don't use the
reader later.

r? `@m-ou-se`

[1]: https://github.com/rust-lang/rust/issues/80218#issuecomment-874322129

2 years agoRollup merge of #92775 - xfix:osstringext-inline, r=m-ou-se
Matthias Krüger [Sat, 15 Jan 2022 10:28:23 +0000 (11:28 +0100)]
Rollup merge of #92775 - xfix:osstringext-inline, r=m-ou-se

Inline std::os::unix::ffi::OsStringExt methods

Those methods essentially do nothing at assembly level. On Unix systems, `OsString` is represented as a `Vec` without performing any transformations.

2 years agoRollup merge of #92767 - arlosi:pdbenum, r=cuviper
Matthias Krüger [Sat, 15 Jan 2022 10:28:22 +0000 (11:28 +0100)]
Rollup merge of #92767 - arlosi:pdbenum, r=cuviper

Use the new language identifier for Rust in the PDB debug format

Rust currently identifies as MASM (Microsoft Assembler) in the PDB
debug info format on Windows because no identifier was available.

This change pulls in a cherry-pick to Rust's LLVM that includes the
change to use the new identifier for Rust.

https://docs.microsoft.com/en-us/visualstudio/debugger/debug-interface-access/cv-cfl-lang

2 years agoRollup merge of #92747 - swenson:bignum-bit-length-optimization, r=scottmcm
Matthias Krüger [Sat, 15 Jan 2022 10:28:22 +0000 (11:28 +0100)]
Rollup merge of #92747 - swenson:bignum-bit-length-optimization, r=scottmcm

Simplification of BigNum::bit_length

As indicated in the comment, the BigNum::bit_length function could be
optimized by using CLZ, which is often a single instruction instead a
loop.

I think the code is also simpler now without the loop.

I added some additional tests for Big8x3 and Big32x40 to ensure that
there were no regressions.

2 years agoAuto merge of #92604 - nnethercote:optimize-impl_read_unsigned_leb128, r=michaelwoerister
bors [Sat, 15 Jan 2022 07:27:30 +0000 (07:27 +0000)]
Auto merge of #92604 - nnethercote:optimize-impl_read_unsigned_leb128, r=michaelwoerister

Optimize `impl_read_unsigned_leb128`

I see instruction count improvements of up to 3.5% locally with these changes, mostly on the smaller benchmarks.

r? `@michaelwoerister`

2 years agoRename Printer constructor from mk_printer() to Printer::new()
David Tolnay [Sat, 15 Jan 2022 05:12:39 +0000 (21:12 -0800)]
Rename Printer constructor from mk_printer() to Printer::new()

2 years agoDon't use source-map when detecting struct field shorthand
Michael Goulet [Thu, 13 Jan 2022 22:03:56 +0000 (14:03 -0800)]
Don't use source-map when detecting struct field shorthand

2 years agoFix `try wrapping expression in variant` suggestion with struct field shorthand
Michael Goulet [Wed, 12 Jan 2022 04:22:00 +0000 (20:22 -0800)]
Fix `try wrapping expression in variant` suggestion with struct field shorthand

2 years agoAuto merge of #92915 - matthiaskrgr:rollup-pxxk8jp, r=matthiaskrgr
bors [Sat, 15 Jan 2022 04:24:13 +0000 (04:24 +0000)]
Auto merge of #92915 - matthiaskrgr:rollup-pxxk8jp, r=matthiaskrgr

Rollup of 9 pull requests

Successful merges:

 - #92191 (Prefer projection candidates instead of param_env candidates for Sized predicates)
 - #92382 (Extend const_convert to rest of blanket core::convert impls)
 - #92625 (Add `#[track_caller]` to `mirbug`)
 - #92684 (Export `tcp::IntoIncoming`)
 - #92743 (Use pre-interned symbols in a couple of places)
 - #92838 (Clean up some links in RELEASES)
 - #92868 (librustdoc: Address some clippy lints)
 - #92875 (Make `opt_const_param_of` work in the presence of `GenericArg::Infer`)
 - #92891 (Add myself to .mailmap)

Failed merges:

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

2 years agoRollup merge of #92891 - JamesHinshelwood:patch-1, r=Mark-Simulacrum
Matthias Krüger [Sat, 15 Jan 2022 01:25:21 +0000 (02:25 +0100)]
Rollup merge of #92891 - JamesHinshelwood:patch-1, r=Mark-Simulacrum

Add myself to .mailmap

(to de-duplicate my identities in the contributors list)

2 years agoRollup merge of #92875 - BoxyUwU:infer_arg_opt_const_param_of, r=lcnr
Matthias Krüger [Sat, 15 Jan 2022 01:25:20 +0000 (02:25 +0100)]
Rollup merge of #92875 - BoxyUwU:infer_arg_opt_const_param_of, r=lcnr

Make `opt_const_param_of` work in the presence of `GenericArg::Infer`

highly recommend viewing the first and second commits on their own rather than looking at file changes :rofl:

Because we filtered args down to just const args we would ignore `GenericArg::Infer` which made us get a `arg_index` which was wrong by however many const `GenericArg::Infer` came previously

[example](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=46dba6a53aca6333028a10908ef16e0b) of the [bugs](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=a8eebced26eefa4119fc2e7ae0c76de6) fixed.

r? ```@lcnr```

2 years agoRollup merge of #92868 - pierwill:librustdoc-clippy, r=camelid
Matthias Krüger [Sat, 15 Jan 2022 01:25:19 +0000 (02:25 +0100)]
Rollup merge of #92868 - pierwill:librustdoc-clippy, r=camelid

librustdoc: Address some clippy lints

2 years agoRollup merge of #92838 - ehuss:cleanup-release-links, r=Mark-Simulacrum
Matthias Krüger [Sat, 15 Jan 2022 01:25:18 +0000 (02:25 +0100)]
Rollup merge of #92838 - ehuss:cleanup-release-links, r=Mark-Simulacrum

Clean up some links in RELEASES

This fixes some issues with markdown links in the RELEASES file.

2 years agoRollup merge of #92743 - bjorn3:less_symbol_intern, r=camelid
Matthias Krüger [Sat, 15 Jan 2022 01:25:17 +0000 (02:25 +0100)]
Rollup merge of #92743 - bjorn3:less_symbol_intern, r=camelid

Use pre-interned symbols in a couple of places

Re-open of https://github.com/rust-lang/rust/pull/92733 as bors glitched.

2 years agoRollup merge of #92684 - ibraheemdev:patch-10, r=m-ou-se
Matthias Krüger [Sat, 15 Jan 2022 01:25:16 +0000 (02:25 +0100)]
Rollup merge of #92684 - ibraheemdev:patch-10, r=m-ou-se

Export `tcp::IntoIncoming`

Added in #88339 but not publicly exported.

2 years agoRollup merge of #92625 - inquisitivecrystal:mirbug-caller, r=michaelwoerister
Matthias Krüger [Sat, 15 Jan 2022 01:25:15 +0000 (02:25 +0100)]
Rollup merge of #92625 - inquisitivecrystal:mirbug-caller, r=michaelwoerister

Add `#[track_caller]` to `mirbug`

When a "'no errors encountered even though `delay_span_bug` issued" error results from the `mirbug` function, the file location information points to the `mirbug` function itself, rather than its caller. This doesn't make sense, since the caller is the real source of the bug. Adding `#[track_caller]` will produce diagnostics that are more useful to anyone fixing the ICE.

2 years agoRollup merge of #92382 - clarfonthey:const_convert, r=scottmcm
Matthias Krüger [Sat, 15 Jan 2022 01:25:14 +0000 (02:25 +0100)]
Rollup merge of #92382 - clarfonthey:const_convert, r=scottmcm

Extend const_convert to rest of blanket core::convert impls

This adds constness to all the blanket impls in `core::convert` under the existing `const_convert` feature, tracked by #88674.

Existing impls under that feature:

```rust
impl<T> const From<T> for T;
impl<T, U> const Into<U> for T where U: ~const From<T>;

impl<T> const ops::Try for Option<T>;
impl<T> const ops::FromResidual for Option<T>;

impl<T, E> const ops::Try for Result<T, E>;
impl<T, E, F> const ops::FromResidual<Result<convert::Infallible, E>> for Result<T, F> where F: ~const From<E>;
```

Additional impls:

```rust
impl<T: ?Sized, U: ?Sized> const AsRef<U> for &T where T: ~const AsRef<U>;
impl<T: ?Sized, U: ?Sized> const AsRef<U> for &mut T where T: ~const AsRef<U>;
impl<T: ?Sized, U: ?Sized> const AsMut<U> for &mut T where T: ~const AsMut<U>;

impl<T, U> const TryInto<U> for T where U: ~const TryFrom<T>;
impl<T, U> const TryFrom<U> for T where U: ~const Into<T>;
```

2 years agoRollup merge of #92191 - jackh726:issue-89352, r=nikomatsakis
Matthias Krüger [Sat, 15 Jan 2022 01:25:14 +0000 (02:25 +0100)]
Rollup merge of #92191 - jackh726:issue-89352, r=nikomatsakis

Prefer projection candidates instead of param_env candidates for Sized predicates

Fixes #89352

Also includes some drive by logging and verbose printing changes that I found useful when debugging this, but I can remove this if needed.

This is a little hacky - but imo no more than the rest of `candidate_should_be_dropped_in_favor_of`. Importantly, in a Chalk-like world, both candidates should be completely compatible.

r? ```@nikomatsakis```

2 years agoAuto merge of #92912 - calebcartwright:rustfmt-generated-files, r=Mark-Simulacrum
bors [Sat, 15 Jan 2022 01:18:10 +0000 (01:18 +0000)]
Auto merge of #92912 - calebcartwright:rustfmt-generated-files, r=Mark-Simulacrum

resolve rustfmt issue with generated files

Discussed in https://rust-lang.zulipchat.com/#narrow/stream/241545-t-release/topic/1.2E58.20patch.20release

refs https://github.com/rust-lang/rustfmt/issues/5080#issuecomment-1013303455 and https://github.com/rust-lang/rustfmt/issues/5172

updating in-tree vs. subtree sync to make backporting easier, would like to nominate backporting to both beta/1.59 as well as the 1.58.1 patch release

2 years agonyahggdshjjghsdfhgsf
Ellen [Thu, 13 Jan 2022 09:26:27 +0000 (09:26 +0000)]
nyahggdshjjghsdfhgsf

2 years agounrevert # 88557
Ellen [Wed, 12 Jan 2022 23:38:32 +0000 (23:38 +0000)]
unrevert # 88557

2 years agoattempt to re-add `ty::Unevaluated` visitor and friends
Ellen [Wed, 12 Jan 2022 23:29:10 +0000 (23:29 +0000)]
attempt to re-add `ty::Unevaluated` visitor and friends

2 years agoinitial revert
Ellen [Wed, 12 Jan 2022 03:19:52 +0000 (03:19 +0000)]
initial revert

2 years agofix(rustfmt): resolve generated file formatting issue
Caleb Cartwright [Sat, 15 Jan 2022 00:18:37 +0000 (18:18 -0600)]
fix(rustfmt): resolve generated file formatting issue

2 years agoDo not fail evaluation in const blocks
Michael Goulet [Fri, 14 Jan 2022 11:39:29 +0000 (03:39 -0800)]
Do not fail evaluation in const blocks

2 years agoAuto merge of #91948 - nnethercote:rustdoc-more-Symbols, r=GuillaumeGomez
bors [Fri, 14 Jan 2022 20:34:18 +0000 (20:34 +0000)]
Auto merge of #91948 - nnethercote:rustdoc-more-Symbols, r=GuillaumeGomez

rustdoc: avoid many `Symbol` to `String` conversions.

Particularly when constructing file paths and fully qualified paths.
This avoids a lot of allocations, speeding things up on almost all
examples.

r? `@GuillaumeGomez`

2 years agoDocument and test `UrlPartsBuilder::push_fmt`
Noah Lev [Mon, 10 Jan 2022 23:33:20 +0000 (15:33 -0800)]
Document and test `UrlPartsBuilder::push_fmt`

2 years agoMake `AVG_PART_LENGTH` a power of 2
Noah Lev [Mon, 10 Jan 2022 20:24:20 +0000 (12:24 -0800)]
Make `AVG_PART_LENGTH` a power of 2

I seem to recall that in general, it's best to request an allocation
with a size that's a power of 2. The low estimate of 5 was probably a
little too low as well.

2 years agoEstimate path length instead of hardcoding 64 bytes
Noah Lev [Mon, 10 Jan 2022 20:23:58 +0000 (12:23 -0800)]
Estimate path length instead of hardcoding 64 bytes

2 years agoUse UrlPartsBuilder and remove `join_with_slash`
Noah Lev [Mon, 10 Jan 2022 20:18:26 +0000 (12:18 -0800)]
Use UrlPartsBuilder and remove `join_with_slash`

2 years agorustdoc: remove some unnecessary sigils.
Nicholas Nethercote [Wed, 15 Dec 2021 00:14:21 +0000 (11:14 +1100)]
rustdoc: remove some unnecessary sigils.

2 years agorustdoc: remove many unnecessary `.as_ref()` calls.
Nicholas Nethercote [Tue, 14 Dec 2021 23:01:08 +0000 (10:01 +1100)]
rustdoc: remove many unnecessary `.as_ref()` calls.

2 years agorustdoc: avoid many `Symbol` to `String` conversions.
Nicholas Nethercote [Tue, 14 Dec 2021 19:18:18 +0000 (06:18 +1100)]
rustdoc: avoid many `Symbol` to `String` conversions.

Particularly when constructing file paths and fully qualified paths.
This avoids a lot of allocations, speeding things up on almost all
examples.

2 years agoLink sidebar "location" heading to top of page
Jacob Hoffman-Andrews [Tue, 11 Jan 2022 22:39:51 +0000 (14:39 -0800)]
Link sidebar "location" heading to top of page

This makes it easy, when you are scrolled far down in a page, to jump
back to the top.

2 years agoAuto merge of #92883 - matthiaskrgr:rollup-uoudywx, r=matthiaskrgr
bors [Fri, 14 Jan 2022 17:31:28 +0000 (17:31 +0000)]
Auto merge of #92883 - matthiaskrgr:rollup-uoudywx, r=matthiaskrgr

Rollup of 9 pull requests

Successful merges:

 - #92045 (Don't fall back to crate-level opaque type definitions.)
 - #92381 (Suggest `return`ing tail expressions in async functions)
 - #92768 (Partially stabilize `maybe_uninit_extra`)
 - #92810 (Deduplicate box deref and regular deref suggestions)
 - #92818 (Update documentation for doc_cfg feature)
 - #92840 (Fix some lints documentation)
 - #92849 (Clippyup)
 - #92854 (Use the updated Rust logo in rustdoc)
 - #92864 (Fix a missing dot in the main item heading)

Failed merges:

 - #92838 (Clean up some links in RELEASES)

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

2 years agoFix some links that had colliding reference names.
Eric Huss [Thu, 13 Jan 2022 02:07:53 +0000 (18:07 -0800)]
Fix some links that had colliding reference names.

These reference names were very general, and used in other places.