]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoFix pretty printing named bound regions under -Zverbose
Jack Huey [Sat, 4 Jun 2022 18:31:17 +0000 (14:31 -0400)]
Fix pretty printing named bound regions under -Zverbose

2 years agoAuto merge of #97729 - Dylan-DPC:rollup-dv43xo9, r=Dylan-DPC
bors [Sat, 4 Jun 2022 11:29:29 +0000 (11:29 +0000)]
Auto merge of #97729 - Dylan-DPC:rollup-dv43xo9, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #96642 (Avoid zero-sized allocs in ThinBox if T and H are both ZSTs.)
 - #97647 (Lazily allocate and initialize pthread locks.)
 - #97715 (Support the `#[expect]` attribute on fn parameters (RFC-2383))
 - #97716 (Fix reachability analysis for const methods)
 - #97722 (Tighten spans for bad fields in struct deriving `Copy`)

Failed merges:

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

2 years agoRollup merge of #97722 - compiler-errors:tighten-copy-type-error-spans, r=Dylan-DPC
Dylan DPC [Sat, 4 Jun 2022 09:06:42 +0000 (11:06 +0200)]
Rollup merge of #97722 - compiler-errors:tighten-copy-type-error-spans, r=Dylan-DPC

Tighten spans for bad fields in struct deriving `Copy`

r? `@estebank`

Closes #89137 for good, I think

Not sure if this is what you were looking for in https://github.com/rust-lang/rust/issues/89137#issuecomment-1146201791

2 years agoRollup merge of #97716 - compiler-errors:issue-97708, r=wesleywiser
Dylan DPC [Sat, 4 Jun 2022 09:06:42 +0000 (11:06 +0200)]
Rollup merge of #97716 - compiler-errors:issue-97708, r=wesleywiser

Fix reachability analysis for const methods

Use `method_might_be_inlined` directly for `ImplItemKind::Fn` instead of duplicating the logic in `def_id_represents_local_inlined_item`.

This is parallel to how we use `item_might_be_inlined` for `ItemKind::Fn` in that same body.

Fixes #97708

2 years agoRollup merge of #97715 - xFrednet:97650-expect-in-fuction-arg, r=wesleywiser
Dylan DPC [Sat, 4 Jun 2022 09:06:41 +0000 (11:06 +0200)]
Rollup merge of #97715 - xFrednet:97650-expect-in-fuction-arg, r=wesleywiser

Support the `#[expect]` attribute on fn parameters (RFC-2383)

A small PR to allow the `#[expect]` attribute on function parameters.

Nothing more to say, I hope everyone reading this has a lovely day.

---

r? ``@wesleywiser``

closes: https://github.com/rust-lang/rust/issues/97650

cc: https://github.com/rust-lang/rust/issues/85549

2 years agoRollup merge of #97647 - m-ou-se:lazy-box-locks, r=Amanieu
Dylan DPC [Sat, 4 Jun 2022 09:06:40 +0000 (11:06 +0200)]
Rollup merge of #97647 - m-ou-se:lazy-box-locks, r=Amanieu

Lazily allocate and initialize pthread locks.

Lazily allocate and initialize pthread locks.

This allows {Mutex, Condvar, RwLock}::new() to be const, while still using the platform's native locks for features like priority inheritance and debug tooling. E.g. on macOS, we cannot directly use the (private) APIs that pthread's locks are implemented with, making it impossible for us to use anything other than pthread while still preserving priority inheritance, etc.

This PR doesn't yet make the public APIs const. That's for a separate PR with an FCP.

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

2 years agoRollup merge of #96642 - thomcc:thinbox-zst-ugh, r=yaahc
Dylan DPC [Sat, 4 Jun 2022 09:06:39 +0000 (11:06 +0200)]
Rollup merge of #96642 - thomcc:thinbox-zst-ugh, r=yaahc

Avoid zero-sized allocs in ThinBox if T and H are both ZSTs.

This was surprisingly tricky, and took longer to get right than expected. `ThinBox` is a surprisingly subtle piece of code. That said, in the end, a lot of this was due to overthinking[^overthink] -- ultimately the fix ended up fairly clean and simple.

[^overthink]: Honestly, for a while I was convinced this couldn't be done without allocations or runtime branches in these cases, but that's obviously untrue.

Anyway, as a result of spending all that time debugging, I've extended the tests quite a bit, and also added more debug assertions. Many of these helped for subtle bugs I made in the middle (for example, the alloc/drop tracking is because I ended up double-dropping the value in the case where both were ZSTs), they're arguably a bit of overkill at this point, although I imagine they could help in the future too.

Anyway, these tests cover a wide range of size/align cases, nd fully pass under miri[^1]. They also do some smoke-check asserting that the value has the correct alignment, although in practice it's totally within the compiler's rights to delete these assertions since we'd have already done UB if they get hit. They have more boilerplate than they really need, but it's not *too* bad on a per-test basis.

A notable absence from testing is atypical header types, but at the moment it's impossible to manually implement `Pointee`. It would be really nice to have testing here, since it's not 100% obvious to me that the aligned read/write we use for `H` are correct in the face of arbitrary combinations of `size_of::<H>()`, `align_of::<H>()`, and `align_of::<T>()`. (That said, I spent a while thinking through it and am *pretty* sure it's fine -- I'd just feel... better if we could test some cases for non-ZST headers which have unequal and align).

[^1]: Or at least, they pass under miri if I copy the code and tests into a new crate and run miri on it (after making it less stdlibified).

Fixes #96485.

I'd request review ``@yaahc,`` but I believe you're taking some time away from reviews, so I'll request from the previous PR's reviewer (I think that the context helps, even if the actual change didn't end up being bad here).

r? ``@joshtriplett``

2 years agoAuto merge of #97690 - nikic:update-llvm-4, r=cuviper
bors [Sat, 4 Jun 2022 08:48:32 +0000 (08:48 +0000)]
Auto merge of #97690 - nikic:update-llvm-4, r=cuviper

Update LLVM submodule

Merge upstream release/14.x branch.

Fixes #97428.

2 years agoAuto merge of #97604 - nnethercote:inline-bridge-Buffer-methods, r=eddyb
bors [Sat, 4 Jun 2022 04:51:26 +0000 (04:51 +0000)]
Auto merge of #97604 - nnethercote:inline-bridge-Buffer-methods, r=eddyb

Inline `bridge::Buffer` methods.

This fixes a performance regression caused by making `Buffer`
non-generic in #97004.

r? `@eddyb`

2 years agoTighten spans for bad fields in Copy struct
Michael Goulet [Sat, 4 Jun 2022 02:17:12 +0000 (19:17 -0700)]
Tighten spans for bad fields in Copy struct

2 years agoAuto merge of #97717 - matthiaskrgr:rollup-lalaii2, r=matthiaskrgr
bors [Sat, 4 Jun 2022 02:10:35 +0000 (02:10 +0000)]
Auto merge of #97717 - matthiaskrgr:rollup-lalaii2, r=matthiaskrgr

Rollup of 5 pull requests

Successful merges:

 - #97446 (Make hir().get_generics and generics_of consistent.)
 - #97656 (Add a suggestion to replace parentheses with angle brackets on associated trait constraint)
 - #97692 (Add `#T-types/nominated` zulip notification)
 - #97696 (Do not ICE when failing to normalize during inlining.)
 - #97702 (Remove useless LocalDefId in ImplTraitContext::Universal.)

Failed merges:

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

2 years agoEncode MIR for 'unreachable' non-generic fns
Michael Goulet [Fri, 3 Jun 2022 22:21:57 +0000 (15:21 -0700)]
Encode MIR for 'unreachable' non-generic fns

2 years agoAuto merge of #97670 - spastorino:simplify-universal-impl-trait-lowering2, r=Dylan-DPC
bors [Fri, 3 Jun 2022 23:29:30 +0000 (23:29 +0000)]
Auto merge of #97670 - spastorino:simplify-universal-impl-trait-lowering2, r=Dylan-DPC

Make params be SmallVec as originally was

r? `@cjgillot`
It was originally a [`SmallVec`](https://github.com/rust-lang/rust/pull/97598/files#diff-0a61b538a3cec072c76fecae4635af6a12ec3256860029ac70549c2aa53ab394L1497), I've mistakenly changed it [here](https://github.com/rust-lang/rust/pull/97598/files#diff-0a61b538a3cec072c76fecae4635af6a12ec3256860029ac70549c2aa53ab394R1377) to a `Vec`

2 years agoSupport the `#[expect]` attribute on fn parameters (RFC-2383)
xFrednet [Fri, 3 Jun 2022 22:04:19 +0000 (00:04 +0200)]
Support the `#[expect]` attribute on fn parameters (RFC-2383)

2 years agoRollup merge of #97702 - cjgillot:no-universal-did, r=spastorino
Matthias Krüger [Fri, 3 Jun 2022 22:42:52 +0000 (00:42 +0200)]
Rollup merge of #97702 - cjgillot:no-universal-did, r=spastorino

Remove useless LocalDefId in ImplTraitContext::Universal.

2 years agoRollup merge of #97696 - cjgillot:normalize-inline, r=compiler-errors
Matthias Krüger [Fri, 3 Jun 2022 22:42:51 +0000 (00:42 +0200)]
Rollup merge of #97696 - cjgillot:normalize-inline, r=compiler-errors

Do not ICE when failing to normalize during inlining.

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

2 years agoRollup merge of #97692 - compiler-errors:types-nominated, r=Mark-Simulacrum
Matthias Krüger [Fri, 3 Jun 2022 22:42:50 +0000 (00:42 +0200)]
Rollup merge of #97692 - compiler-errors:types-nominated, r=Mark-Simulacrum

Add `#T-types/nominated` zulip notification

Add rule to create topic in aforementioned stream when `I-types-nominated` tag is added

2 years agoRollup merge of #97656 - EdwinRy:error_ast_low_type_contraint_parentheses, r=cjgillot
Matthias Krüger [Fri, 3 Jun 2022 22:42:50 +0000 (00:42 +0200)]
Rollup merge of #97656 - EdwinRy:error_ast_low_type_contraint_parentheses, r=cjgillot

Add a suggestion to replace parentheses with angle brackets on associated trait constraint

This implements a requested suggestion FIXME in [`compiler/rustc_ast_lowering/src/lib.rs` ](https://github.com/rust-lang/rust/blob/9598b4b594c97dff66feb93522e22db500deea07/compiler/rustc_ast_lowering/src/lib.rs#L921)

The suggestion asks for the parentheses to either be replaced with angle brackets or removed completely depending on whether there are arguments provided within.

![image](https://user-images.githubusercontent.com/20026256/171770414-ab60bfe2-ae27-44b0-964d-9ffcc32a7475.png)

![image](https://user-images.githubusercontent.com/20026256/171770383-ca8a2766-b3aa-43e3-8ba4-ae18874886ce.png)

r? `@oli-obk`

2 years agoRollup merge of #97446 - cjgillot:get-generics, r=michaelwoerister
Matthias Krüger [Fri, 3 Jun 2022 22:42:49 +0000 (00:42 +0200)]
Rollup merge of #97446 - cjgillot:get-generics, r=michaelwoerister

Make hir().get_generics and generics_of consistent.

Fetching generics from a HIR node is currently implemented differently in 4 different places.
This PR makes the 4 implementations call the single `hir::Node::generics`, which implements the more general version from `generics_of` query.

2 years agoMake hir().get_generics and generics_of consistent.
Camille GILLOT [Fri, 27 May 2022 07:35:28 +0000 (09:35 +0200)]
Make hir().get_generics and generics_of consistent.

2 years agoAuto merge of #95833 - notriddle:notriddle/human-readable-signals, r=yaahc
bors [Fri, 3 Jun 2022 20:18:14 +0000 (20:18 +0000)]
Auto merge of #95833 - notriddle:notriddle/human-readable-signals, r=yaahc

std: `<ExitStatus as Display>::fmt` name the signal it died from

Related to #95601

2 years agoRemove useless LocalDefId in ImplTraitContext::Universal.
Camille GILLOT [Fri, 3 Jun 2022 18:17:12 +0000 (20:17 +0200)]
Remove useless LocalDefId in ImplTraitContext::Universal.

2 years agoAuto merge of #85993 - bjorn3:serde_json, r=wesleywiser
bors [Fri, 3 Jun 2022 17:55:02 +0000 (17:55 +0000)]
Auto merge of #85993 - bjorn3:serde_json, r=wesleywiser

Remove all json handling from rustc_serialize

Json is now handled using serde_json. Where appropriate I have replaced json usage with binary serialization (rmeta files) or manual string formatting (emcc linker arg generation).

This allowed for removing and simplifying a lot of code, which hopefully results in faster serialization/deserialization and faster compiles of rustc itself.

Where sensible we now use serde. Metadata and incr cache serialization keeps using a heavily modified (compared to crates.io) rustc-serialize version that in the future could probably be extended with zero-copy deserialization or other perf tricks that serde can't support due to supporting more than one serialization format.

Note that I had to remove `-Zast-json` and `-Zast-json-noexpand` as the relevant AST types don't implement `serde::Serialize`.

Fixes #40177

See also https://github.com/rust-lang/compiler-team/issues/418

2 years agoDo not ICE when failing to normalize during inlining.
Camille GILLOT [Fri, 3 Jun 2022 16:44:46 +0000 (18:44 +0200)]
Do not ICE when failing to normalize during inlining.

2 years agoFix emscripten linker invocation
bjorn3 [Fri, 6 May 2022 15:20:42 +0000 (17:20 +0200)]
Fix emscripten linker invocation

2 years agoFix all tests
bjorn3 [Thu, 5 May 2022 16:34:13 +0000 (18:34 +0200)]
Fix all tests

2 years agoRemove emit_unit
bjorn3 [Fri, 4 Jun 2021 16:32:00 +0000 (18:32 +0200)]
Remove emit_unit

It doesn't do anything for all encoders

2 years agoInline many methods of Encoder
bjorn3 [Fri, 4 Jun 2021 16:23:50 +0000 (18:23 +0200)]
Inline many methods of Encoder

They aren't overridden anyway

2 years agoRemove all names from Encoder
bjorn3 [Fri, 4 Jun 2021 15:33:26 +0000 (17:33 +0200)]
Remove all names from Encoder

They aren't used anymore now that the json format has been removed

2 years agoRemove json support from rustc_serialize
bjorn3 [Fri, 4 Jun 2021 14:37:15 +0000 (16:37 +0200)]
Remove json support from rustc_serialize

2 years agoRemove support for -Zast-json and -Zast-json-noexpand
bjorn3 [Fri, 4 Jun 2021 14:36:40 +0000 (16:36 +0200)]
Remove support for -Zast-json and -Zast-json-noexpand

2 years agoAvoid rustc_serialize in linker.rs
bjorn3 [Fri, 4 Jun 2021 14:35:19 +0000 (16:35 +0200)]
Avoid rustc_serialize in linker.rs

2 years agoUse serde_json for json error messages
bjorn3 [Thu, 3 Jun 2021 19:14:15 +0000 (21:14 +0200)]
Use serde_json for json error messages

2 years agoUse serde_json for target spec json
bjorn3 [Thu, 3 Jun 2021 15:45:09 +0000 (17:45 +0200)]
Use serde_json for target spec json

2 years agoRemove a couple of unused Encodable and Decodable derives
bjorn3 [Thu, 3 Jun 2021 09:16:05 +0000 (11:16 +0200)]
Remove a couple of unused Encodable and Decodable derives

2 years agoSuggest replace parentheses with angle brackets
EdwinRy [Thu, 2 Jun 2022 17:22:25 +0000 (18:22 +0100)]
Suggest replace parentheses with angle brackets

2 years agoAuto merge of #97694 - Dylan-DPC:rollup-2yxo7ce, r=Dylan-DPC
bors [Fri, 3 Jun 2022 15:26:06 +0000 (15:26 +0000)]
Auto merge of #97694 - Dylan-DPC:rollup-2yxo7ce, r=Dylan-DPC

Rollup of 3 pull requests

Successful merges:

 - #97415 (Compute `is_late_bound_map` query separately from lifetime resolution)
 - #97471 (Provide more context when denying invalid type params )
 - #97681 (Add more eslint checks)

Failed merges:

 - #97446 (Make hir().get_generics and generics_of consistent.)

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

2 years agoRollup merge of #97681 - GuillaumeGomez:more-eslint, r=Dylan-DPC
Dylan DPC [Fri, 3 Jun 2022 15:10:53 +0000 (17:10 +0200)]
Rollup merge of #97681 - GuillaumeGomez:more-eslint, r=Dylan-DPC

Add more eslint checks

A new batch of eslint rules:

 * [no-fallthrough](https://eslint.org/docs/rules/no-fallthrough)
 * [no-invalid-regexp](https://eslint.org/docs/rules/no-invalid-regexp)
 * [no-import-assign](https://eslint.org/docs/rules/no-import-assign)
 * [no-self-compare](https://eslint.org/docs/rules/no-self-compare)
 * [no-template-curly-in-string](https://eslint.org/docs/rules/no-template-curly-in-string)
 * [block-scoped-var](https://eslint.org/docs/rules/block-scoped-var)
 * [guard-for-in](https://eslint.org/docs/rules/guard-for-in)
 * [no-alert](https://eslint.org/docs/rules/no-alert)

r? ``@notriddle``

2 years agoRollup merge of #97471 - estebank:prohibit-generics, r=cjgillot
Dylan DPC [Fri, 3 Jun 2022 15:10:52 +0000 (17:10 +0200)]
Rollup merge of #97471 - estebank:prohibit-generics, r=cjgillot

Provide more context when denying invalid type params

2 years agoRollup merge of #97415 - cjgillot:is-late-bound-solo, r=estebank
Dylan DPC [Fri, 3 Jun 2022 15:10:51 +0000 (17:10 +0200)]
Rollup merge of #97415 - cjgillot:is-late-bound-solo, r=estebank

Compute `is_late_bound_map` query separately from lifetime resolution

This query is actually very simple, and is only useful for functions and method.  It can be computed directly by fetching the HIR, with no need to embed it within the lifetime resolution visitor.

Based on https://github.com/rust-lang/rust/pull/96296

2 years agoLazily allocate+initialize locks.
Mara Bos [Fri, 3 Jun 2022 15:04:14 +0000 (17:04 +0200)]
Lazily allocate+initialize locks.

2 years agoUse Drop instead of destroy() for locks.
Mara Bos [Fri, 3 Jun 2022 14:45:47 +0000 (16:45 +0200)]
Use Drop instead of destroy() for locks.

2 years agoAdd `#T-types/nominated` zulip notification
Michael Goulet [Fri, 3 Jun 2022 14:08:17 +0000 (07:08 -0700)]
Add `#T-types/nominated` zulip notification

2 years agoUpdate LLVM submodule
Nikita Popov [Fri, 3 Jun 2022 13:57:32 +0000 (15:57 +0200)]
Update LLVM submodule

2 years agoAuto merge of #89862 - lcnr:path-generics-diagnostics, r=estebank
bors [Fri, 3 Jun 2022 12:37:16 +0000 (12:37 +0000)]
Auto merge of #89862 - lcnr:path-generics-diagnostics, r=estebank

rewrite error handling for unresolved inference vars

Pretty much completely rewrites `fn emit_inference_failure_err`.

This new setup should hopefully be easier to extend and is already a lot better when looking for generic arguments.
Because this is a rewrite there are still some parts which are lacking, these are tracked in #94483 and will be fixed in later PRs.

r? `@estebank` `@petrochenkov`

2 years agoCompute `is_late_bound` in a separate query.
Camille GILLOT [Thu, 26 May 2022 06:59:15 +0000 (08:59 +0200)]
Compute `is_late_bound` in a separate query.

The computation is actually much simpler, and can be done by directly
fetching the HIR for the `FnDecl` and its generics.

2 years agoManipulate lifetimes by LocalDefId for region resolution.
Camille GILLOT [Wed, 27 Apr 2022 20:15:58 +0000 (22:15 +0200)]
Manipulate lifetimes by LocalDefId for region resolution.

2 years agoAuto merge of #97679 - Dylan-DPC:rollup-nswmgmx, r=Dylan-DPC
bors [Fri, 3 Jun 2022 09:56:21 +0000 (09:56 +0000)]
Auto merge of #97679 - Dylan-DPC:rollup-nswmgmx, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #97366 (Stabilize `{slice,array}::from_ref`)
 - #97653 (add cast kind of from_exposed_addr (int-to-ptr casts))
 - #97663 (take back half-baked noaliasing check in Assignment)
 - #97664 (On E0204 suggest missing type param bounds)
 - #97668 (rustdoc: clean up primitive.slice.html links)

Failed merges:

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

2 years agoAdd "no-alert" eslint rule
Guillaume Gomez [Fri, 3 Jun 2022 09:29:49 +0000 (11:29 +0200)]
Add "no-alert" eslint rule

2 years agoAdd "guard-for-in" eslint rule
Guillaume Gomez [Fri, 3 Jun 2022 09:28:34 +0000 (11:28 +0200)]
Add "guard-for-in" eslint rule

2 years agoAdd "block-scoped-var" eslint rule
Guillaume Gomez [Fri, 3 Jun 2022 09:20:46 +0000 (11:20 +0200)]
Add "block-scoped-var" eslint rule

2 years agoRollup merge of #97668 - notriddle:notriddle/slice-link, r=jsha
Dylan DPC [Fri, 3 Jun 2022 09:18:27 +0000 (11:18 +0200)]
Rollup merge of #97668 - notriddle:notriddle/slice-link, r=jsha

rustdoc: clean up primitive.slice.html links

Before: <a href="https://doc.rust-lang.org/stable/std/boxed/struct.Box.html">Box</a>&lt;<a href="https://doc.rust-lang.org/stable/std/primitive.slice.html">[</a>T<a href="https://doc.rust-lang.org/stable/std/primitive.slice.html">]</a>&gt;

After: <a href="https://doc.rust-lang.org/stable/std/boxed/struct.Box.html">Box</a>&lt;<a href="https://doc.rust-lang.org/stable/std/primitive.slice.html">[T]</a>&gt;

2 years agoRollup merge of #97664 - estebank:suggest-bound-derive-copy, r=compiler-errors
Dylan DPC [Fri, 3 Jun 2022 09:18:26 +0000 (11:18 +0200)]
Rollup merge of #97664 - estebank:suggest-bound-derive-copy, r=compiler-errors

On E0204 suggest missing type param bounds

```
error[E0204]: the trait `Copy` may not be implemented for this type
  --> f42.rs:9:17
   |
9  | #[derive(Debug, Copy, Clone)]
   |                 ^^^^
10 | pub struct AABB<K>{
11 |     pub loc: Vector2<K>,
   |     ------------------- this field does not implement `Copy`
12 |     pub size: Vector2<K>
   |     -------------------- this field does not implement `Copy`
   |
note: the `Copy` impl for `Vector2<K>` requires that `K: Debug`
  --> f42.rs:11:5
   |
11 |     pub loc: Vector2<K>,
   |     ^^^^^^^^^^^^^^^^^^^
note: the `Copy` impl for `Vector2<K>` requires that `K: Debug`
  --> f42.rs:12:5
   |
12 |     pub size: Vector2<K>
   |     ^^^^^^^^^^^^^^^^^^^^
   = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider restricting type parameter `K`
   |
10 | pub struct AABB<K: Debug>{
   |                  +++++++
```

Fix #89137.

2 years agoRollup merge of #97663 - RalfJung:keine-halben-sachen, r=oli-obk
Dylan DPC [Fri, 3 Jun 2022 09:18:25 +0000 (11:18 +0200)]
Rollup merge of #97663 - RalfJung:keine-halben-sachen, r=oli-obk

take back half-baked noaliasing check in Assignment

Doing an aliasing check in `copy_op` does not make a ton of sense. We have to eventually do something in the `Assignment` statement handling instead.

2 years agoRollup merge of #97653 - RalfJung:int-to-ptr, r=oli-obk
Dylan DPC [Fri, 3 Jun 2022 09:18:24 +0000 (11:18 +0200)]
Rollup merge of #97653 - RalfJung:int-to-ptr, r=oli-obk

add cast kind of from_exposed_addr (int-to-ptr casts)

This is basically the dual to https://github.com/rust-lang/rust/pull/97582, for int2ptr casts.

Cc `@tmiasko` https://github.com/rust-lang/rust/issues/97649

2 years agoRollup merge of #97366 - WaffleLapkin:stabilize_array_slice_from_ref, r=dtolnay
Dylan DPC [Fri, 3 Jun 2022 09:18:23 +0000 (11:18 +0200)]
Rollup merge of #97366 - WaffleLapkin:stabilize_array_slice_from_ref, r=dtolnay

Stabilize `{slice,array}::from_ref`

This PR stabilizes the following APIs as `const` functions in Rust `1.63`:
```rust
// core::array
pub const fn from_ref<T>(s: &T) -> &[T; 1];

// core::slice
pub const fn from_ref<T>(s: &T) -> &[T];
```

Note that the `mut` versions are not stabilized as unique references (`&mut _`) are [unstable in const context].

FCP: https://github.com/rust-lang/rust/issues/90206#issuecomment-1134586665

r? rust-lang/libs-api `@rustbot` label +T-libs-api -T-libs

[unstable in const context]: https://github.com/rust-lang/rust/issues/57349

2 years agoAdd "no-template-curly-in-string" eslint rule
Guillaume Gomez [Fri, 3 Jun 2022 09:16:23 +0000 (11:16 +0200)]
Add "no-template-curly-in-string" eslint rule

2 years agoAdd "no-self-compare" eslint rule
Guillaume Gomez [Fri, 3 Jun 2022 09:14:07 +0000 (11:14 +0200)]
Add "no-self-compare" eslint rule

2 years agoAdd "no-import-assign" eslint rule
Guillaume Gomez [Fri, 3 Jun 2022 09:13:42 +0000 (11:13 +0200)]
Add "no-import-assign" eslint rule

2 years agoAdd "no-invalid-regexp" eslint rule
Guillaume Gomez [Fri, 3 Jun 2022 09:11:33 +0000 (11:11 +0200)]
Add "no-invalid-regexp" eslint rule

2 years agoAdd "no-fallthrough" eslint rule
Guillaume Gomez [Fri, 3 Jun 2022 09:09:23 +0000 (11:09 +0200)]
Add "no-fallthrough" eslint rule

2 years agoAuto merge of #96296 - cjgillot:remove-label-lt-shadow, r=petrochenkov
bors [Fri, 3 Jun 2022 07:27:09 +0000 (07:27 +0000)]
Auto merge of #96296 - cjgillot:remove-label-lt-shadow, r=petrochenkov

Remove label/lifetime shadowing warnings

This PR removes some pre-1.0 shadowing warnings for labels and lifetimes.

The current behaviour of the compiler is to warn
* labels that shadow unrelated labels in the same function --> removed
```rust
'a: loop {}
'a: loop {} // STOP WARNING
```

* labels that shadow enclosing labels --> kept, but only if shadowing is hygienic
```rust
'a: loop {
  'a: loop {} // KEEP WARNING
}
```

* labels that shadow lifetime --> removed
```rust
fn foo<'a>() {
  'a: loop {} // STOP WARNING
}
```

* lifetimes that shadow labels --> removed
```rust
'a: loop {
  let b = Box::new(|x: &i8| *x) as Box<dyn for <'a> Fn(&'a i8) -> i8>; // STOP WARNING
}
```

* lifetimes that shadow lifetimes --> kept
```rust
fn foo<'a>() {
  let b = Box::new(|x: &i8| *x) as Box<dyn for <'a> Fn(&'a i8) -> i8>; // KEEP WARNING
}
```

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

-----

From `@petrochenkov` in https://github.com/rust-lang/rust/pull/95781#issuecomment-1105199014
> I think we should remove these silly checks entirely.
> They were introduced long time ago in case some new language features appear and require this space.
> Now we have another mechanism for such language changes - editions, and if "lifetimes in expressions" or something like that needs to be introduced it could be introduced as an edition change.
> However, there was no plans to introduce anything like for years, so it's unlikely that even the edition mechanism will be necessary.

r? rust-lang/lang

2 years agoUse the same message as type & const generics.
Camille GILLOT [Thu, 2 Jun 2022 18:46:40 +0000 (20:46 +0200)]
Use the same message as type & const generics.

2 years agoReuse resolve_label to check lifetime shadowing.
Camille GILLOT [Thu, 2 Jun 2022 18:35:14 +0000 (20:35 +0200)]
Reuse resolve_label to check lifetime shadowing.

2 years agoDo not lower generic lifetime params when AST resolution emitted an error.
Camille GILLOT [Fri, 27 May 2022 09:29:18 +0000 (11:29 +0200)]
Do not lower generic lifetime params when AST resolution emitted an error.

2 years agoAuto merge of #97497 - c410-f3r:z-errors, r=petrochenkov
bors [Fri, 3 Jun 2022 04:46:10 +0000 (04:46 +0000)]
Auto merge of #97497 - c410-f3r:z-errors, r=petrochenkov

Move some tests to more reasonable places

r? `@petrochenkov`

2 years agoMake params be SmallVec as originally was
Santiago Pastorino [Fri, 3 Jun 2022 02:42:49 +0000 (23:42 -0300)]
Make params be SmallVec as originally was

2 years agoAuto merge of #97667 - matthiaskrgr:rollup-5cfxc85, r=matthiaskrgr
bors [Fri, 3 Jun 2022 00:21:29 +0000 (00:21 +0000)]
Auto merge of #97667 - matthiaskrgr:rollup-5cfxc85, r=matthiaskrgr

Rollup of 5 pull requests

Successful merges:

 - #97502 (rustdoc: Add more test coverage)
 - #97627 (update explicit impls error msg)
 - #97640 (Fix wrong suggestion for adding where clauses)
 - #97645 (don't use a `span_note` for ignored impls)
 - #97655 (Improve documentation for constructors of pinned `Box`es)

Failed merges:

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

2 years agoreview comments
Esteban Küber [Thu, 2 Jun 2022 21:06:54 +0000 (14:06 -0700)]
review comments

2 years agoFix MIPS-specific signal bug
Michael Howell [Thu, 2 Jun 2022 22:18:16 +0000 (15:18 -0700)]
Fix MIPS-specific signal bug

2 years agoTweak output
Esteban Küber [Thu, 2 Jun 2022 20:15:56 +0000 (13:15 -0700)]
Tweak output

2 years agorustdoc: add channel normalization to htmldocck.py
Michael Howell [Thu, 2 Jun 2022 22:02:26 +0000 (15:02 -0700)]
rustdoc: add channel normalization to htmldocck.py

2 years agorustdoc: clean up primitive.slice.html links
Michael Howell [Thu, 2 Jun 2022 21:28:18 +0000 (14:28 -0700)]
rustdoc: clean up primitive.slice.html links

2 years agoRollup merge of #97655 - steffahn:better-pin-box-construction-docs, r=thomcc
Matthias Krüger [Thu, 2 Jun 2022 21:39:07 +0000 (23:39 +0200)]
Rollup merge of #97655 - steffahn:better-pin-box-construction-docs, r=thomcc

Improve documentation for constructors of pinned `Box`es

Adds a cross-references between `Box::pin` and `Box::into_pin` (and other related methods, i.e. the equivalent `From` implementation, and the unstable `pin_in` method), in particular now that `into_pin` [was stabilized](https://github.com/rust-lang/rust/pull/97397). The main goal is to further improve visibility of the fact that `Box<T> -> Pin<Box<T>>` conversion exits in the first place, and that `Box::pin(x)` is – essentially – just a convenience function for `Box::into_pin(Box::new(x))`

The motivating context why I think this is important is even experienced Rust users overlooking the existence this kind of conversion, [e.g. in this thread on IRLO](https://internals.rust-lang.org/t/pre-rfc-function-variants/16732/7?u=steffahn); and also the fact that that discussion brought up that there would be a bunch of Box-construction methods "missing" such as e.g. methods with fallible allocation a la "`Box::try_pin`", and similar; while those are in fact *not* necessary, because you can use `Box::into_pin(Box::try_new(x)?)` instead.

I have *not* included explicit mention of methods (e.g. `try_new`) in the docs of stable methods (e.g. `into_pin`). (Referring to unstable API in stable API docs would be bad style IMO.) Stable examples I have in mind with the statement "constructing a (pinned) Box in a different way than with `Box::new`" are things like cloning a `Box`, or `Box::from_raw`. If/when `try_new` would get stabilized, it would become a very good concrete example use-case of `Box::into_pin` IMO.

2 years agoRollup merge of #97645 - lcnr:derived-impl-debug, r=cjgillot
Matthias Krüger [Thu, 2 Jun 2022 21:39:06 +0000 (23:39 +0200)]
Rollup merge of #97645 - lcnr:derived-impl-debug, r=cjgillot

don't use a `span_note` for ignored impls

Searching for the `derive` isn't too difficult as it's right above the field definition.

By using a span these errors are a lot more verbose than they should be, which is especially annoying as one can end up with a lot of `dead_code` warnings.

2 years agoRollup merge of #97640 - TaKO8Ki:fix-wrong-suggestion-for-adding-where-clauses, r...
Matthias Krüger [Thu, 2 Jun 2022 21:39:05 +0000 (23:39 +0200)]
Rollup merge of #97640 - TaKO8Ki:fix-wrong-suggestion-for-adding-where-clauses, r=lcnr

Fix wrong suggestion for adding where clauses

closes #97576

2 years agoRollup merge of #97627 - lcnr:comment-tick, r=Dylan-DPC
Matthias Krüger [Thu, 2 Jun 2022 21:39:04 +0000 (23:39 +0200)]
Rollup merge of #97627 - lcnr:comment-tick, r=Dylan-DPC

update explicit impls error msg

2 years agoRollup merge of #97502 - onlineSoftwareDevOK:rustdocTests, r=GuillaumeGomez
Matthias Krüger [Thu, 2 Jun 2022 21:39:03 +0000 (23:39 +0200)]
Rollup merge of #97502 - onlineSoftwareDevOK:rustdocTests, r=GuillaumeGomez

rustdoc: Add more test coverage

Related issue https://github.com/rust-lang/rust/issues/91113

2 years agoAuto merge of #97598 - spastorino:simplify-universal-impl-trait-lowering, r=cjgillot
bors [Thu, 2 Jun 2022 21:37:38 +0000 (21:37 +0000)]
Auto merge of #97598 - spastorino:simplify-universal-impl-trait-lowering, r=cjgillot

Simplify universal impl trait lowering

Closes #96644

r? `@cjgillot`

2 years agoOn E0204 suggest missing type param bounds
Esteban Küber [Thu, 2 Jun 2022 19:34:55 +0000 (12:34 -0700)]
On E0204 suggest missing type param bounds

```
error[E0204]: the trait `Copy` may not be implemented for this type
  --> f42.rs:9:17
   |
9  | #[derive(Debug, Copy, Clone)]
   |                 ^^^^
10 | pub struct AABB<K>{
11 |     pub loc: Vector2<K>,
   |     ------------------- this field does not implement `Copy`
12 |     pub size: Vector2<K>
   |     -------------------- this field does not implement `Copy`
   |
note: the `Copy` impl for `Vector2<K>` requires that `K: Debug`
  --> f42.rs:11:5
   |
11 |     pub loc: Vector2<K>,
   |     ^^^^^^^^^^^^^^^^^^^
note: the `Copy` impl for `Vector2<K>` requires that `K: Debug`
  --> f42.rs:12:5
   |
12 |     pub size: Vector2<K>
   |     ^^^^^^^^^^^^^^^^^^^^
   = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider restricting type parameter `K`
   |
10 | pub struct AABB<K: Debug>{
   |                  +++++++
```

Fix #89137.

2 years agotake back half-baked noaliasing check in Assignment
Ralf Jung [Thu, 2 Jun 2022 19:12:08 +0000 (15:12 -0400)]
take back half-baked noaliasing check in Assignment

2 years agoAuto merge of #97575 - nnethercote:lazify-SourceFile-lines, r=Mark-Simulacrum
bors [Thu, 2 Jun 2022 18:45:29 +0000 (18:45 +0000)]
Auto merge of #97575 - nnethercote:lazify-SourceFile-lines, r=Mark-Simulacrum

Lazify `SourceFile::lines`.

`SourceFile::lines` is a big part of metadata. It's stored in a compressed form
(a difference list) to save disk space. Decoding it is a big fraction of
compile time for very small crates/programs.

This commit introduces a new type `SourceFileLines` which has a `Lines`
form and a `Diffs` form. The latter is used when the metadata is first
read, and it is only decoded into the `Lines` form when line data is
actually needed. This avoids the decoding cost for many files,
especially in `std`. It's a performance win of up to 15% for tiny
crates/programs where metadata decoding is a high part of compilation
costs.

A `RefCell` is needed because the methods that access lines data (which can
trigger decoding) take `&self` rather than `&mut self`. To allow for this,
`SourceFile::lines` now takes a `FnMut` that operates on the lines slice rather
than returning the lines slice.

r? `@Mark-Simulacrum`

2 years agoRebase fallout.
Camille GILLOT [Thu, 5 May 2022 18:49:48 +0000 (20:49 +0200)]
Rebase fallout.

2 years agoStop warning against unrelated labels.
Camille GILLOT [Sun, 1 May 2022 11:07:57 +0000 (13:07 +0200)]
Stop warning against unrelated labels.

2 years agoBless tests.
Camille GILLOT [Thu, 21 Apr 2022 20:44:48 +0000 (22:44 +0200)]
Bless tests.

2 years agoDo not report mixed label/lifetime shadowing.
Camille GILLOT [Thu, 21 Apr 2022 17:48:40 +0000 (19:48 +0200)]
Do not report mixed label/lifetime shadowing.

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

2 years agoDiagnose shadowing on AST.
Camille GILLOT [Sat, 4 Dec 2021 20:20:58 +0000 (21:20 +0100)]
Diagnose shadowing on AST.

2 years agoAuto merge of #97654 - Dylan-DPC:rollup-w6zrzxf, r=Dylan-DPC
bors [Thu, 2 Jun 2022 16:04:42 +0000 (16:04 +0000)]
Auto merge of #97654 - Dylan-DPC:rollup-w6zrzxf, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #97420 (Be a little nicer with casts when formatting `fn` pointers)
 - #97450 ([RFC 2011] Basic compiler infrastructure)
 - #97599 (Fix JSON reexport ICE)
 - #97617 (Rustdoc anonymous reexports)
 - #97636 (Revert #96682.)

Failed merges:

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

2 years agocomment
Ralf Jung [Thu, 2 Jun 2022 15:10:34 +0000 (11:10 -0400)]
comment

Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
2 years agorustdoc: Add more test coverage
onlinesoftwaredevok@protonmail.com [Thu, 2 Jun 2022 14:50:36 +0000 (11:50 -0300)]
rustdoc: Add more test coverage

2 years agoadd cast kind of from_exposed_addr (int-to-ptr casts)
Ralf Jung [Thu, 2 Jun 2022 13:05:37 +0000 (09:05 -0400)]
add cast kind of from_exposed_addr (int-to-ptr casts)

2 years agoImprove documentation for constructors of pinned `Box`es
Frank Steffahn [Thu, 2 Jun 2022 10:36:11 +0000 (12:36 +0200)]
Improve documentation for constructors of pinned `Box`es

2 years agoRollup merge of #97636 - nnethercote:revert-96682, r=dtolnay
Dylan DPC [Thu, 2 Jun 2022 13:27:01 +0000 (15:27 +0200)]
Rollup merge of #97636 - nnethercote:revert-96682, r=dtolnay

Revert #96682.

The change was "Show invisible delimiters (within comments) when pretty
printing". It's useful to show these delimiters, but is a breaking
change for some proc macros.

Fixes #97608.

r? ``@petrochenkov``

2 years agoRollup merge of #97617 - GuillaumeGomez:rustdoc-anonymous-reexports, r=Nemo157
Dylan DPC [Thu, 2 Jun 2022 13:27:00 +0000 (15:27 +0200)]
Rollup merge of #97617 - GuillaumeGomez:rustdoc-anonymous-reexports, r=Nemo157

Rustdoc anonymous reexports

Fixes #97615.

r? `@Nemo157`

2 years agoRollup merge of #97599 - GuillaumeGomez:reexport-json, r=CraftSpider
Dylan DPC [Thu, 2 Jun 2022 13:26:59 +0000 (15:26 +0200)]
Rollup merge of #97599 - GuillaumeGomez:reexport-json, r=CraftSpider

Fix JSON reexport ICE

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

The problem was that the ID was conflicting because the reexports have the same one. To fix it, I "extended" it by adding the `Symbol` into it as well.

r? `@notriddle`

2 years agoRollup merge of #97450 - c410-f3r:assert-compiler, r=oli-obk
Dylan DPC [Thu, 2 Jun 2022 13:26:58 +0000 (15:26 +0200)]
Rollup merge of #97450 - c410-f3r:assert-compiler, r=oli-obk

[RFC 2011] Basic compiler infrastructure

Splitting https://github.com/rust-lang/rust/pull/96496 into smaller pieces as was done in https://github.com/rust-lang/rust/pull/97233. Hope review will be easier.

This PR practically contains no logic and only serves as a building ground for the actual code that will be placed in a posterior step.

* Adds `context.rs` to place the new `assert!` logic. Has a lot of unused elements but all of them are used by the implementation.
* Creates an unstable flag because the feature is not yet complete and also to allow external feedback.
* Creates the necessary `sym` identifiers that are mostly based on the library elements -> https://github.com/rust-lang/rust/blob/master/library/core/src/asserting.rs
* Modifies `assert.rs` to branch to `context.rs` if the unstable flag is enabled.
* Adds a test to satisfy tidy but the test does nothing in reality.

2 years agoRollup merge of #97420 - WaffleLapkin:no_oxford_casts_qqq, r=Mark-Simulacrum
Dylan DPC [Thu, 2 Jun 2022 13:26:57 +0000 (15:26 +0200)]
Rollup merge of #97420 - WaffleLapkin:no_oxford_casts_qqq, r=Mark-Simulacrum

Be a little nicer with casts when formatting `fn` pointers

This removes a `fn(...) -> ...` -> `usize` -> `*const ()` -> `usize` cast. cc #95489.

2 years agoAuto merge of #97293 - est31:remove_box, r=oli-obk
bors [Thu, 2 Jun 2022 13:20:19 +0000 (13:20 +0000)]
Auto merge of #97293 - est31:remove_box, r=oli-obk

Add #[rustc_box] and use it inside alloc

This commit adds an alternative content boxing syntax, and uses it inside alloc.

```Rust
#![feature(box_syntax)]

fn foo() {
    let foo = box bar;
}
```

is equivalent to

```Rust
#![feature(rustc_attrs)]

fn foo() {
    let foo = #[rustc_box] Box::new(bar);
}
```

The usage inside the very performance relevant code in
liballoc is the only remaining relevant usage of box syntax
in the compiler (outside of tests, which are comparatively easy to port).

box syntax was originally designed to be used by all Rust
developers. This introduces a replacement syntax more tailored
to only being used inside the Rust compiler, and with it,
lays the groundwork for eventually removing box syntax.

[Earlier work](https://github.com/rust-lang/rust/pull/87781#issuecomment-894714878) by `@nbdd0121` to lower `Box::new` to `box` during THIR -> MIR building ran into borrow checker problems, requiring the lowering to be adjusted in a way that led to [performance regressions](https://github.com/rust-lang/rust/pull/87781#issuecomment-894872367). The proposed change in this PR lowers `#[rustc_box] Box::new` -> `box` in the AST -> HIR lowering step, which is way earlier in the compiler, and thus should cause less issues both performance wise as well as regarding type inference/borrow checking/etc. Hopefully, future work can move the lowering further back in the compiler, as long as there are no performance regressions.

2 years agoBasic compiler infra
Caio [Thu, 2 Jun 2022 12:00:04 +0000 (09:00 -0300)]
Basic compiler infra