Commit Graph

3577 Commits

Author SHA1 Message Date
Matthias Krüger
3238a97d39
Rollup merge of #113058 - GuillaumeGomez:improve-code-comments, r=notriddle
Add/improve code comments

Working on something else and did some small comments updates/adds.

r? `@notriddle`
2023-06-27 07:01:32 +02:00
Michael Goulet
724f3ff50d migrate lifetime too 2023-06-26 19:14:49 +00:00
Michael Goulet
26cd5486f8 Account for late-bound vars from parent arg-position impl trait 2023-06-26 19:14:27 +00:00
bors
36fb58e433 Auto merge of #113057 - TaKO8Ki:rollup-071lc9g, r=TaKO8Ki
Rollup of 2 pull requests

Successful merges:

 - #112677 (remove unused field)
 - #112920 (rustdoc: render generic params & where-clauses of cross-crate assoc tys in impls)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-26 18:42:01 +00:00
Guillaume Gomez
32f056ce6b Add/improve code comments 2023-06-26 16:38:14 +02:00
Takayuki Maeda
40e3fcfd59
Rollup merge of #112920 - fmease:rustdoc-fix-112904, r=GuillaumeGomez
rustdoc: render generic params & where-clauses of cross-crate assoc tys in impls

We used to only ever render generic parameters & where-clauses of cross-crate associated types when the item was located inside of a trait and we used to just drop them when it was inside of an impl block (trait or inherent).

Fixes #112904.

`@rustbot` label A-cross-crate-reexports
2023-06-26 23:16:16 +09:00
bors
6f8c27ae89 Auto merge of #112887 - WaffleLapkin:become_unuwuable_in_hir, r=compiler-errors,Nilstrieb
`hir`: Add `Become` expression kind (explicit tail calls experiment)

This adds `hir::ExprKind::Become` alongside ast lowering. During hir-thir lowering we currently lower `become` as `return`, so that we can partially test `become` without ICEing.

cc `@scottmcm`
r? `@Nilstrieb`
2023-06-26 13:51:04 +00:00
Oli Scherer
042f6052ab Add some tests around where bounds on associated items and their lack of effect on impls 2023-06-26 09:56:28 +00:00
Maybe Waffle
ccb71ff424 hir: Add Become expression kind 2023-06-26 08:56:32 +00:00
bors
7f01f03061 Auto merge of #113038 - matthiaskrgr:rollup-sdcfkxa, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #112976 (Add test for futures with HRTB)
 - #113013 (rustdoc: get rid of extra line when line-wrapping fn decls with empty arg list)
 - #113030 (Add a regression test for #109071)
 - #113031 (Add a regression test for #110933)
 - #113036 (Accept `ReStatic` for RPITIT)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-25 22:01:21 +00:00
Matthias Krüger
6c7575721f
Rollup merge of #113036 - TaKO8Ki:fix-112094, r=compiler-errors
Accept `ReStatic` for RPITIT

Fixes #112094

Regression in 8216b7f229

If there is a better suggestion, I will go with that.
2023-06-25 22:34:32 +02:00
Matthias Krüger
d7723f4180
Rollup merge of #113031 - JohnTitor:issue-110933, r=compiler-errors
Add a regression test for #110933

Closes #110933
r? `@compiler-errors`
2023-06-25 22:34:31 +02:00
Matthias Krüger
dfd6d708db
Rollup merge of #113030 - JohnTitor:issue-109071, r=TaKO8Ki
Add a regression test for #109071

Closes #109071
r? `@compiler-errors`
2023-06-25 22:34:31 +02:00
Matthias Krüger
32995d87e6
Rollup merge of #113013 - fmease:rustdoc-decl-line-wrapping-slim-arg-list, r=camelid
rustdoc: get rid of extra line when line-wrapping fn decls with empty arg list

Fixes https://github.com/bevyengine/bevy/issues/8898#issuecomment-1605683417:

![Screenshot 2023-06-24 at 23-42-53 any_with_component in bevy_ecs schedule common_conditions - Rust](https://github.com/rust-lang/rust/assets/14913065/4646eba6-b186-4d78-96d9-aad716a4ef5d)

It now prints as shown below (which conforms to the style guide):

```rs
pub fn any_with_component<T: Component>(
) -> impl FnMut(Query<'_, '_, (), With<T>>) -> bool + Clone
```

The bug was introduced in #109011.
2023-06-25 22:34:30 +02:00
Matthias Krüger
aa8a885cc1
Rollup merge of #112976 - dswij:issue-112347, r=compiler-errors
Add test for futures with HRTB

Part of #112347

This PR adds test for ice when resolving for `Futures` with HRTB.
2023-06-25 22:34:30 +02:00
Takayuki Maeda
019f43e6c2
Rollup merge of #113028 - fmease:rustdoc-x-crate-itiap-clean-term, r=notriddle
rustdoc: handle assoc const equalities in cross-crate impl-Trait-in-arg-pos

Fixes FIXME (the added test previously lead to an ICE).

`@rustbot` label A-cross-crate-reexports
2023-06-26 01:50:28 +09:00
Takayuki Maeda
83722c62b0 accept ReStatic for RPITIT
add an ui test for #112094
2023-06-26 01:11:44 +09:00
Yuki Okushi
421105b453
Add a regression test for #110933
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2023-06-25 23:03:22 +09:00
Yuki Okushi
abe52cdcc7
Add a regression test for #109071
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2023-06-25 23:01:06 +09:00
León Orell Valerian Liehr
247aa06f10
rustdoc: handle assoc const equalities in cross-crate impl-Trait-in-arg-pos 2023-06-25 15:42:32 +02:00
dswij
91351ef486 Add test for futures with HRTB 2023-06-25 21:32:02 +08:00
Matthias Krüger
d2f82a00d0
Rollup merge of #113023 - GuillaumeGomez:migrate-gui-test-color-17, r=notriddle
Migrate GUI colors test to original CSS color format

Follow-up of https://github.com/rust-lang/rust/pull/111459.

r? `@notriddle`
2023-06-25 13:48:37 +02:00
Matthias Krüger
75f6a7aa00
Rollup merge of #113007 - compiler-errors:dont-structural-resolve-byte-str-pat, r=oli-obk
Revert "Structurally resolve correctly in check_pat_lit"

This reverts commit 54fb5a48b9. Also adds a couple of tests, and downgrades the existing `-Ztrait-solver=next` test to a known-bug.

Fixes #112993
2023-06-25 13:48:36 +02:00
Guillaume Gomez
0979bf7413 Migrate GUI colors test to original CSS color format 2023-06-25 10:49:28 +02:00
Guillaume Gomez
a3c147b90b
Rollup merge of #113018 - asquared31415:test_fix, r=TaKO8Ki
Fix test for #96258

#98644 did not properly test enabling the problematic lint as a warning due to improper use of `compile-flags:` (missing `:`). This makes it use `#![warn]` instead, like in the reproducer.

cc #96258
2023-06-25 10:46:16 +02:00
Guillaume Gomez
691580f566
Rollup merge of #112990 - JohnTitor:issue-96699, r=TaKO8Ki
Add a regression test for #96699

Closes #96699
r? `@BoxyUwU`
2023-06-25 10:46:15 +02:00
bors
3c5d71a99d Auto merge of #112476 - chenyukang:yukang-fix-109991, r=compiler-errors
Do not emit coerce_suggestions for expr from destructuring assignment desugaring

Fixes #109991
2023-06-25 04:45:52 +00:00
asquared31415
9dd655ff91 fix test 2023-06-24 21:49:38 -04:00
yukang
33f73c2e93 Do not offer any of the suggestions in emit_coerce_suggestions for expr from destructuring assignment desugaring 2023-06-25 09:26:17 +08:00
Matthias Krüger
8816f9ee1e
Rollup merge of #112937 - camelid:align-typenames, r=notriddle,GuillaumeGomez
rustdoc: Align search results horizontally for easy scanning

The recent PR #110688 added info about an item's kind before its name in
search results. However, because the kind and name are inline with no
alignment, it's now hard to visually scan downward through the search
results, looking at item names. This PR fixes that by horizontally
aligning search results such that there are now two columns of
information.

r? `@GuillaumeGomez`
2023-06-25 02:04:20 +02:00
León Orell Valerian Liehr
d23c334707
rustdoc: get rid of extra line when line-wrapping fn decls with empty arg list 2023-06-24 23:39:35 +02:00
Noah Lev
9b97ae1d8c rustdoc: Update GUI test 2023-06-24 14:30:35 -07:00
Michael Goulet
e304a1f13b Revert "Structurally resolve correctly in check_pat_lit"
This reverts commit 54fb5a48b9.
2023-06-24 18:41:27 +00:00
Guillaume Gomez
9e0f427e5c
Rollup merge of #112989 - JohnTitor:issue-109141, r=compiler-errors
Add a regression test for #109141

Closes #109141
r? ``@compiler-errors``
2023-06-24 20:26:46 +02:00
Guillaume Gomez
a1f2f23f0f
Rollup merge of #112854 - bvanjoi:fix-112674, r=Nilstrieb
fix: add cfg diagnostic for unresolved import error

Fixes #112674

An easy fix, r? `@Nilstrieb`
2023-06-24 20:26:44 +02:00
Guillaume Gomez
696d722169
Rollup merge of #112703 - aliemjay:next-solver-root-var, r=compiler-errors
[-Ztrait-solver=next, mir-typeck] instantiate hidden types in the root universe

Fixes an ICE in the test `member-constraints-in-root-universe`.

Main motivation is to make #112691 pass under the new solver.

r? ``@compiler-errors``
2023-06-24 20:26:43 +02:00
Michael Goulet
28f39862a8 use Const::eval instead of QueryNormalize in error reporting 2023-06-24 18:04:14 +00:00
bohan
8c8c7ef78a fix: add cfg diagnostic for unresolved import error 2023-06-24 21:45:17 +08:00
Ali MJ Al-Nasrawy
a72013f7f0 instantiate hidden types in root universe 2023-06-24 13:00:15 +00:00
Guillaume Gomez
fa1f16116e Migrate GUI colors test to original CSS color format 2023-06-24 14:47:16 +02:00
León Orell Valerian Liehr
c643bedf7c
rustdoc: render gen params & where-clauses of cross-crate assoc tys in impl blocks 2023-06-24 12:20:26 +02:00
Yuki Okushi
ab87f72a22
Add a regression test for #96699
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2023-06-24 14:46:02 +09:00
Yuki Okushi
13cc8dd580
Add a regression test for #109141
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2023-06-24 14:27:58 +09:00
Michael Goulet
bfe6e5c418
Rollup merge of #112983 - spastorino:new-rpitit-23, r=compiler-errors
Fix return type notation associated type suggestion when -Zlower-impl-trait-in-trait-to-assoc-ty

This avoid suggesting the associated types generated for RPITITs when the one the code refers to doesn't exist and rustc looks for a suggestion.

r? `@compiler-errors`
2023-06-23 19:47:22 -07:00
Michael Goulet
4a175523b1
Rollup merge of #112981 - spastorino:new-rpitit-22, r=compiler-errors
Fix return type notation errors with -Zlower-impl-trait-in-trait-to-assoc-ty

This just adjust the way we check for RPITITs and uses the new helper method to do the "old" and "new" check at once.

r? `@compiler-errors`
2023-06-23 19:47:21 -07:00
Michael Goulet
3148bcf0a9
Rollup merge of #112973 - compiler-errors:oops-forgot-ftl, r=jyn514
Make sure to include default en-US ftl resources for `rustc_error` crate

Fixes #112928
2023-06-23 19:47:21 -07:00
Michael Goulet
766db8161b
Rollup merge of #112965 - compiler-errors:circular-wf, r=aliemjay
Don't emit same goal as input during `wf::unnormalized_obligations`

r? `@aliemjay` cc `@lcnr`

I accidentally pruned the logic to handle `WF(?0)` when writing `wf::unnormalized_obligations`.

idk if you wanted to construct a test first, but this is an obvious fix. Copied the comment from above.

Fixes rust-lang/trait-system-refactor-initiative#36
2023-06-23 19:47:21 -07:00
Michael Goulet
4a01a38466
Rollup merge of #111087 - ibraheemdev:patch-15, r=dtolnay
Implement `Sync` for `mpsc::Sender`

`mpsc::Sender` is currently `!Sync` because the previous implementation contained an optimization where the channel started out as single-producer and was dynamically upgraded on the first clone, which relied on a unique reference to the sender. This optimization is one of the main reasons the old implementation was so complex and was removed in #93563. `mpsc::Sender` can now soundly implement `Sync`.

Note for any potential confusion, this chance does *not* add MPMC behavior. This only affects the already `Send + Clone` *sender*, not *receiver*.

It's technically possible to rely on the `!Sync` behavior in the same way as a `PhantomData<*mut T>`, but that seems very unlikely in practice. Either way, this change is insta-stable and needs an FCP.

`@rustbot` label +T-libs-api -T-libs
2023-06-23 19:47:19 -07:00
bors
1d67eba687 Auto merge of #112891 - oli-obk:impl_trait_in_assoc_tys_cleanup, r=compiler-errors
Various impl trait in assoc tys cleanups

r? `@compiler-errors`

All commits except for the last are pure refactorings. 274dab5bd658c97886a8987340bf50ae57900c39 allows struct fields to participate in deciding whether a function has an opaque in its signature.

best reviewed commit by commit
2023-06-23 23:26:38 +00:00
Santiago Pastorino
6d997876c1
Fix associated type suggestion when -Zlower-impl-trait-in-trait-to-assoc-ty 2023-06-23 18:23:52 -03:00
bors
22e9fe644e Auto merge of #112974 - matthiaskrgr:rollup-hnk7ans, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #112616 (Improve tests on targets without unwinding)
 - #112643 (Always register sized obligation for argument)
 - #112740 (Add link to rustdoc book search chapter in help popover)
 - #112810 (Don't ICE on unnormalized struct tail in layout computation)
 - #112870 (Migrate `item_bounds` to `ty::Clause`)
 - #112925 (Stop hiding const eval limit in external macros)
 - #112960 ([tests/rustdoc] Add `@files` command)
 - #112962 (Fix rustdoc gui tester)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-23 20:45:23 +00:00
Santiago Pastorino
d77e55bbb9
Fix return type notation errors with -Zlower-impl-trait-in-trait-to-assoc-ty 2023-06-23 17:34:33 -03:00
Michael Goulet
2cc7782cfd Add suggestion for bad block fragment error 2023-06-23 19:18:20 +00:00
Matthias Krüger
9d7f297f3c
Rollup merge of #112962 - GuillaumeGomez:fix-rustdoc-gui-tester, r=ozkanonur
Fix rustdoc gui tester

Problem was that the `main` was always exiting with `0`, whether or not there was an error. It led to failing GUI tests being ignored in the CI since no one saw them.

r? ````@klensy````
2023-06-23 19:40:01 +02:00
Matthias Krüger
4821f80716
Rollup merge of #112960 - GuillaumeGomez:rustdoc-files-check, r=notriddle
[tests/rustdoc] Add @files command

The ``````@!has`````` checks is very problematic as it wouldn't catch if the file scheme is updated and the file is generated again. ``````@files`````` allows to ensure that the given folder contains exactly the provided entries (files and folders).

I'm wondering if we should forbid the ``````@!has`````` for files. To be discussed after this PR I suppose.

r? `````@notriddle`````
2023-06-23 19:40:00 +02:00
Matthias Krüger
c9139521e7
Rollup merge of #112925 - oli-obk:timeout_lint, r=cjgillot
Stop hiding const eval limit in external macros

fixes #112748

We don't emit a hard error if there was a previous deny lint triggering with the same message. If that lint ends up not being emitted, we ICE and don't emit an error either.
2023-06-23 19:39:59 +02:00
Matthias Krüger
cea5ae00d2
Rollup merge of #112810 - compiler-errors:dont-ice-on-bad-layout, r=wesleywiser
Don't ICE on unnormalized struct tail in layout computation

1. We try to compute a `SizeSkeleton` even if a layout error occurs, but we really only need to do this if we get `LayoutError::Unknown`, since that means our type is too polymorphic to actually compute the full layout. If we have other errors, like `LayoutError::NormalizationError` or `LayoutError::Cycle`, then we can't really make any progress, since this represents an actual error.
2. Avoid using `normalize_erasing_regions` and `struct_tail_erasing_lifetimes` since those ICE on normalization errors, and since we may call `layout_of` in HIR typeck, we don't know for certain that we're on the happy path.

Fixes #112736
2023-06-23 19:39:58 +02:00
Matthias Krüger
afe337d2f1
Rollup merge of #112740 - GuillaumeGomez:link-to-search-chapter, r=notriddle
Add link to rustdoc book search chapter in help popover

One thing that was missing in the rustdoc output and its help popover was a link back to the search feature chapter in the rustdoc book.

It looks like this:

![image](https://github.com/rust-lang/rust/assets/3050060/425413e5-e734-4d40-b675-8b2dcef874a2)

r? `@notriddle`
2023-06-23 19:39:58 +02:00
Matthias Krüger
27ae068de3
Rollup merge of #112643 - compiler-errors:sized-obl-for-arg, r=wesleywiser
Always register sized obligation for argument

Removes a "hack" that skips registering sized obligations for parameters that are simple identifiers. This doesn't seem to affect diagnostics because we're probably already being smart enough about deduplicating identical error messages anyways.

Fixes #112608
2023-06-23 19:39:57 +02:00
Matthias Krüger
ff596144be
Rollup merge of #112616 - ferrocene:pa-more-test-suite-fixes, r=Nilstrieb
Improve tests on targets without unwinding

This PR makes more miscellaneous changes to tests, to make it work on targets without unwinding support.
2023-06-23 19:39:57 +02:00
Gary Guo
19ce326a08 Bless tests 2023-06-23 18:36:25 +01:00
Guillaume Gomez
3b17012ac9 Fix GUI test for popover 2023-06-23 19:34:37 +02:00
Michael Goulet
0710040648 Make sure to include default en-US ftl resources for rustc_error crate 2023-06-23 17:22:07 +00:00
bors
c79d6be6a2 Auto merge of #109982 - durin42:plt-no-x86_64-only, r=nikic
rustc_session: default to -Z plt=yes on non-x86_64

Per the discussion in #106380 plt=no isn't a great default, and rust-lang/compiler-team#581 decided that the default should be PLT=yes for everything except x86_64. Not everyone agrees about the x86_64 part of this change, but this at least is an improvement in the state of things without changing the x86_64 situation, so I've attempted making this change in the name of not letting the perfect be the enemy of the good.

Please let me know if I've messed this up somehow - I'm not wholly confident I got this right.

r? `@nikic`
2023-06-23 16:50:37 +00:00
Michael Goulet
2eb7d69309 Resolve vars when reporting WF error 2023-06-23 16:26:22 +00:00
Michael Goulet
f12695b53b Don't emit same goal as input during wf obligations 2023-06-23 16:23:27 +00:00
clubby789
8969d97437 Add test for invalid variables 2023-06-23 14:20:45 +00:00
Guillaume Gomez
d70faf3645 Fix failing rustdoc GUI test 2023-06-23 15:50:30 +02:00
Augie Fackler
52d50fba2a tests: be even more permissive on attributes in one test 2023-06-23 09:48:00 -04:00
Guillaume Gomez
752fb52ae9 Add @files checks in rustdoc tests 2023-06-23 15:12:48 +02:00
Matthias Krüger
c5fd53774f
Rollup merge of #112948 - bkrl:trait-impl-suggestion, r=compiler-errors
Avoid guessing unknown trait implementation in suggestions

When a trait is used without specifying the implementation (e.g. calling a non-member associated function without fully-qualified syntax) and there are multiple implementations available, use a placeholder comment for the implementation type in the suggestion instead of picking a random implementation.

Example:

```
fn main() {
    let _ = Default::default();
}
```

Previous output:

```
error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
 --> test.rs:2:13
  |
2 |     let _ = Default::default();
  |             ^^^^^^^^^^^^^^^^ cannot call associated function of trait
  |
help: use a fully-qualified path to a specific available implementation (273 found)
  |
2 |     let _ = <FileTimes as Default>::default();
  |             +++++++++++++        +
```

New output:

```
error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
 --> test.rs:2:13
  |
2 |     let _ = Default::default();
  |             ^^^^^^^^^^^^^^^^ cannot call associated function of trait
  |
help: use a fully-qualified path to a specific available implementation (273 found)
  |
2 |     let _ = </* self type */ as Default>::default();
  |             +++++++++++++++++++        +
```

Fixes #112897
2023-06-23 13:18:16 +02:00
Matthias Krüger
46aacf5ca7
Rollup merge of #112941 - tshepang:patch-1, r=lqd
typo
2023-06-23 13:18:15 +02:00
Matthias Krüger
3feee9f1f2
Rollup merge of #112927 - GuillaumeGomez:where-clause-indent, r=notriddle
Fix indentation for where clause in rustdoc pages

Screenshot of the bug:

![image](https://github.com/rust-lang/rust/assets/3050060/090cfeaa-0edc-46c7-9ea0-e26ac865b2c2)

I used this opportunity to clarify the code a bit because some weird things were going on.

r? ````@notriddle````
2023-06-23 13:18:13 +02:00
Alexander Zhang
48167bd4bd Avoid guessing unknown trait impl in suggestions
When a trait is used without specifying the implementation (e.g. calling
a non-member associated function without fully-qualified syntax) and
there are multiple implementations available, use a placeholder comment
for the implementation type in the suggestion instead of picking a
random implementation.

Example:

```
fn main() {
    let _ = Default::default();
}
```

Previous output:

```
error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
 --> test.rs:2:13
  |
2 |     let _ = Default::default();
  |             ^^^^^^^^^^^^^^^^ cannot call associated function of trait
  |
help: use a fully-qualified path to a specific available implementation (273 found)
  |
2 |     let _ = <FileTimes as Default>::default();
  |             +++++++++++++        +
```

New output:

```
error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
 --> test.rs:2:13
  |
2 |     let _ = Default::default();
  |             ^^^^^^^^^^^^^^^^ cannot call associated function of trait
  |
help: use a fully-qualified path to a specific available implementation (273 found)
  |
2 |     let _ = </* self type */ as Default>::default();
  |             +++++++++++++++++++        +
```
2023-06-22 16:37:52 -07:00
Michael Goulet
afe36507e8 Don't structurally resolve during method ambiguity in probe 2023-06-22 23:31:06 +00:00
Augie Fackler
d94d17c0bb tests: be more permissive on attributes in one test 2023-06-22 18:03:23 -04:00
Tshepang Mbambo
2828c5605e
typo 2023-06-22 23:01:48 +02:00
bors
04075b3202 Auto merge of #112686 - estebank:sealed-traits, r=petrochenkov
Account for sealed traits in privacy and trait bound errors

On trait bound errors caused by super-traits, identify if the super-trait is publicly accessibly and if not, explain "sealed traits".

```
error[E0277]: the trait bound `S: Hidden` is not satisfied
  --> $DIR/sealed-trait-local.rs:17:20
   |
LL | impl a::Sealed for S {}
   |                    ^ the trait `Hidden` is not implemented for `S`
   |
note: required by a bound in `Sealed`
  --> $DIR/sealed-trait-local.rs:3:23
   |
LL |     pub trait Sealed: self:🅱️:Hidden {
   |                       ^^^^^^^^^^^^^^^ required by this bound in `Sealed`
   = note: `Sealed` is a "sealed trait", because to implement it you also need to implelement `a:🅱️:Hidden`, which is not accessible; this is usually done to force you to use one of the provided types that already implement it
```

Deduplicate privacy errors that point to the same path segment even if their deduplication span are different.

When encountering a path that is not reachable due to privacy constraints path segments other than the last, keep metadata for the last path segment's `Res` in order to look for alternative import paths for that item to suggest. If there are none, be explicit that the item is not accessible.

```
error[E0603]: module `b` is private
  --> $DIR/re-exported-trait.rs:11:9
   |
LL | impl a:🅱️:Trait for S {}
   |         ^ private module
   |
note: the module `b` is defined here
  --> $DIR/re-exported-trait.rs:5:5
   |
LL |     mod b {
   |     ^^^^^
help: consider importing this trait through its public re-export instead
   |
LL | impl a::Trait for S {}
   |      ~~~~~~~~
```

```
error[E0603]: module `b` is private
  --> $DIR/private-trait.rs:8:9
   |
LL | impl a:🅱️:Hidden for S {}
   |         ^  ------ trait `b` is not publicly reachable
   |         |
   |         private module
   |
note: the module `b` is defined here
  --> $DIR/private-trait.rs:2:5
   |
LL |     mod b {
   |     ^^^^^
```
2023-06-22 18:23:19 +00:00
Esteban Küber
7dffd24da5 Tweak privacy errors to account for reachable items
Suggest publicly accessible paths for items in private mod:

  When encountering a path in non-import situations that are not reachable
  due to privacy constraints, search for any public re-exports that the
  user could use instead.

Track whether an import suggestion is offering a re-export.

When encountering a path with private segments, mention if the item at
the final path segment is not publicly accessible at all.

Add item visibility metadata to privacy errors from imports:

  On unreachable imports, record the item that was being imported in order
  to suggest publicly available re-exports or to be explicit that the item
  is not available publicly from any path.

  In order to allow this, we add a mode to `resolve_path` that will not
  add new privacy errors, nor return early if it encounters one. This way
  we can get the `Res` corresponding to the final item in the import,
  which is used in the privacy error machinery.
2023-06-22 16:50:31 +00:00
Esteban Küber
717c481739 Account for sealed traits in trait bound errors
When implementing a public trait with a private super-trait, we now emit
a note that the missing bound is not going to be able to be satisfied,
and we explain the concept of a sealed trait.
2023-06-22 16:50:21 +00:00
Oli Scherer
27b386ad17 Only walk the identity substituted version of struct fields 2023-06-22 15:51:20 +00:00
Oli Scherer
b323f587fc Handle weak type aliases by immediately resolving them to their aliased type 2023-06-22 15:51:19 +00:00
Oli Scherer
30ff127036 Re-use error code for duplicate error 2023-06-22 15:51:14 +00:00
Guillaume Gomez
b858a4745c Update existing snapshot and add more snapshots of where clause indentation 2023-06-22 17:39:23 +02:00
Oli Scherer
d6e1b20623 Fix a codegen test 2023-06-22 15:36:46 +00:00
Oli Scherer
a71628c114 Treat opaque types failing the signature defining scope check as defining, as we already errored and can hide subsequent errors this way. 2023-06-22 15:36:42 +00:00
Oli Scherer
41881aece2 Stop failing eagerly, and collect all opaque types even if some are erroneous. 2023-06-22 15:08:18 +00:00
Oli Scherer
326a9fa8e8 Add tests showcasing our short circuiting behaviour in the signature checks for defining scopes 2023-06-22 15:02:44 +00:00
Oli Scherer
12243ec415 Point to argument/return type instead of the whole function header 2023-06-22 15:00:12 +00:00
Oli Scherer
aacd702895 Stop hiding const eval limit in external macros 2023-06-22 14:11:10 +00:00
Matthias Krüger
b13c9417cf
Rollup merge of #112908 - spastorino:add-def-id-to-early-bound-region-debug, r=compiler-errors
Print def_id on EarlyBoundRegion debug

It's not the first time that I can't make sense out of the default debug print on `EarlyBoundRegion`. As I was working on #112682 I needed this.

I was doing some git archeology and found that we used to print everything dfbc9608ce/src/librustc/util/ppaux.rs (L425-L430) but we lost the ability in some refactor midway.
2023-06-22 06:29:34 +02:00
Matthias Krüger
3ba66df643
Rollup merge of #112906 - fmease:rustdoc-render-assoc-ty-body-before-where-clause, r=notriddle
rustdoc: render the body of associated types before the where-clause

Fixes #112903.
2023-06-22 06:29:33 +02:00
Matthias Krüger
cc93c5fca0
Rollup merge of #112876 - compiler-errors:check-subst-compat-in-OpaqueTypeCollector, r=oli-obk
Don't substitute a GAT that has mismatched generics in `OpaqueTypeCollector`

Fixes #111828

I didn't put up minimized UI tests for #112510 or #112873 because they'd minimize to literally the same code, but with different substs on the trait/impl. I don't think that warrants duplicate tests given the nature of the fix.

r? `@oli-obk`

----

Side-note: I checked, and this isn't fixed by #112652 -- I think we discussed whether or not that PR fixed it either intentionally or by accident. The code here isn't really touched by that PR either as far as I can tell?

Also, sorry, did some other drive-bys. Hope it doesn't make rebasing #112652 too difficult 😅
2023-06-22 06:29:33 +02:00
yukang
e7e1a39fa0 suggest importing for partial mod path in name resolving 2023-06-22 11:18:48 +08:00
Santiago Pastorino
3ef510ca80
Print def_id on EarlyBoundRegion debug 2023-06-21 19:34:21 -03:00
León Orell Valerian Liehr
b866113d19
rustdoc: render the assoc ty body before the where-clause 2023-06-21 21:53:55 +02:00
bors
065a1f5df9 Auto merge of #112900 - GuillaumeGomez:rollup-1blf4io, r=GuillaumeGomez
Rollup of 4 pull requests

Successful merges:

 - #112538 (Removed unnecessary &String -> &str, now that &String implements StableOrd as well)
 - #112868 (Liberate bound vars properly when suggesting missing async-fn-in-trait)
 - #112892 (resolve: Minor cleanup to `fn resolve_path_with_ribs`)
 - #112894 (Fix union fields display)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-21 19:48:41 +00:00
Guillaume Gomez
f5470af6a6
Rollup merge of #112894 - GuillaumeGomez:gui-fields-display, r=notriddle
Fix union fields display

![Screenshot from 2023-06-21 16-47-24](https://github.com/rust-lang/rust/assets/3050060/833b0fe6-7fb6-4371-86c3-d82fa0c3fe49)

So two bugs in this screenshot: no whitespace between field name and type name, both fields are on the same line. Both problems come from issues in the templates because all whitespace are removed if a askama "command" follows.

r? `@notriddle`
2023-06-21 20:00:51 +02:00
Guillaume Gomez
5ed75a9628
Rollup merge of #112868 - compiler-errors:liberate-afit-sugg, r=WaffleLapkin
Liberate bound vars properly when suggesting missing async-fn-in-trait

Fixes #112848
2023-06-21 20:00:50 +02:00
Michael Goulet
c4cd607100 Additional test demonstrating check for full trait ref 2023-06-21 16:41:52 +00:00
bors
006a26c0b5 Auto merge of #111684 - ChayimFriedman2:unused-offset-of, r=WaffleLapkin
Warn on unused `offset_of!()` result

The usage of `core::hint::must_use()` means that we don't get a specialized message. I figured out that since there are plenty of other methods that just have `#[must_use]` with no message it'll be fine, but it is a bit unfortunate that the error mentions `must_use` and not `offset_of!`.

Fixes #111669.
2023-06-21 16:40:54 +00:00
Michael Goulet
5344ed23fa Don't substitute a GAT that has mismatched generics in OpaqueTypeCollector 2023-06-21 16:33:17 +00:00
Michael Goulet
7563909a28 Liberate bound vars properly when suggesting missing AFIT 2023-06-21 16:32:26 +00:00
Guillaume Gomez
805edb0a4a Add test to prevent regression for fields display 2023-06-21 17:42:53 +02:00
bors
536635c89b Auto merge of #112890 - GuillaumeGomez:rollup-7e01q69, r=GuillaumeGomez
Rollup of 7 pull requests

Successful merges:

 - #99587 (Document memory orderings of `thread::{park, unpark}`)
 - #112836 ([rustdoc] partially fix invalid files creation)
 - #112853 (Add `lazy_type_alias` feature gate)
 - #112863 (Fix copy-paste typo in `eprint(ln)` docs)
 - #112883 (Make queries traceable again)
 - #112885 (Fix msg passed to span_bug)
 - #112886 (Revert 'Rename profile=user to profile=dist')

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-21 13:53:11 +00:00
Guillaume Gomez
009d72b3ae
Rollup merge of #112853 - GuillaumeGomez:type_alias_type, r=oli-obk
Add `lazy_type_alias` feature gate

Add the `type_alias_type` to be able to have the weak alias used without restrictions.

Part of #112792.

cc `@compiler-errors`
r? `@oli-obk`
2023-06-21 15:45:16 +02:00
Guillaume Gomez
e100df9e68
Rollup merge of #112836 - GuillaumeGomez:rustdoc-invalid-file-creation, r=notriddle
[rustdoc] partially fix invalid files creation

Part of #111249. It only removes generation for modules which shouldn't exist. For files, we need the compiler to keep re-export information alive for external items so we can actually have the right path to their location as it's currently not generating them correctly.

In case the item is inlined, it shouldn't (and neither should its children) get a file generated.

r? ```@notriddle```
2023-06-21 15:45:16 +02:00
Guillaume Gomez
53761e1222 Correctly handle Weak type aliases in rustdoc 2023-06-21 15:34:42 +02:00
Guillaume Gomez
3ad595a316 Add tests for invalid files generation 2023-06-21 15:21:32 +02:00
Guillaume Gomez
1af48beed7 Add rustdoc tests for lazy_type_alias 2023-06-21 13:45:00 +02:00
bors
38b44eb233 Auto merge of #112834 - oli-obk:mir_opts_considered_unsound, r=cjgillot
Disable two mir opts that are known to be unsound

closes #112460 (does not fix the underlying issue)

r? `@cjgillot`
2023-06-21 10:53:30 +00:00
Chayim Refael Friedman
592844cf88 Warn on unused offset_of!() result 2023-06-21 11:43:14 +03:00
Oli Scherer
c409f05636 Disable two mir opts that are known to be unsound 2023-06-21 07:41:09 +00:00
Pietro Albini
fd4726f740
remove needs-unwind attr for test with -Zpanic-abort-tests 2023-06-21 09:14:47 +02:00
Nilstrieb
904994e101
Rollup merge of #112830 - nnethercote:more-codegen-cleanups, r=oli-obk
More codegen cleanups

Some additional cleanups I found while looking closely at this code, following up from #112827.

r= `@oli-obk`
2023-06-21 07:37:03 +02:00
Nilstrieb
c6710d15f1
Rollup merge of #112790 - WaffleLapkin:syntactically, r=Nilstrieb
Syntactically accept `become` expressions (explicit tail calls experiment)

This adds `ast::ExprKind::Become`, implements parsing and properly gates the feature.

cc `@scottmcm`
2023-06-21 07:37:02 +02:00
Nicholas Nethercote
1da1348924 Remove Queries::ongoing_codegen.
There's no need to store it in `Queries`. We can just use a local
variable, because it's always used shortly after it's produced.

The commit also removes the `tcx.analysis()` call in `ongoing_codegen`,
because it's easy to ensure that's done beforehand.

All this makes the dataflow within `run_compiler` easier to follow, at
the cost of making one test slightly more verbose, which I think is a
good tradeoff.
2023-06-21 11:29:45 +10:00
Ibraheem Ahmed
4ceca09586 update failing ui tests 2023-06-20 19:46:01 -04:00
Jacob Pratt
abd0677d2f
Merge proc_macro_span_shrink and proc_macro_span 2023-06-20 19:40:26 -04:00
Jacob Pratt
8dc3b8559c
Fix tests 2023-06-20 19:40:26 -04:00
Michael Goulet
db235a07f7 Remove unnecessary call to select_from_obligation
The only regression is one ambiguity in the new trait solver, having to
do with two param-env candidates that may apply. I think this is fine,
since the error message already kinda sucks.
2023-06-20 23:33:02 +00:00
bors
a34ceade11 Auto merge of #112847 - bvanjoi:fix-112831, r=Nilstrieb
Revert #112758 and add test case

Fixes #112831.

Cannot unwrap `update_resolution` for `resolution.single_imports.remove(&Interned::new_unchecked(import));` because there is a relationship between the `Import` and `&NameBinding` in `NameResolution`. This issue caused by my unfamiliarity with the data structure and I apologize for it.

This PR had been reverted, and test case have been added.

r? `@Nilstrieb`
cc `@petrochenkov`
2023-06-20 15:52:44 +00:00
Pietro Albini
767c4b9ef1
add support for needs-dynamic-linking 2023-06-20 17:20:57 +02:00
bohan
09d4a823d5 test(resolve): update_resolution for remove single import 2023-06-20 22:54:12 +08:00
Guillaume Gomez
2368fa27d1
Rollup merge of #112819 - dtolnay:weirdderef, r=Nilstrieb
Disable feature(unboxed_closures, fn_traits) in weird-exprs

One shouldn't need a nightly compiler in order to ~~have fun~~ call a function many times.
2023-06-20 14:23:41 +02:00
Guillaume Gomez
0688182f9b
Rollup merge of #112794 - bjorn3:fix_lib_global_alloc, r=oli-obk
Fix linker failures when #[global_allocator] is used in a dependency

Fixes https://github.com/rust-lang/rust/issues/112715
2023-06-20 14:23:41 +02:00
Guillaume Gomez
73496fc5d5
Rollup merge of #112786 - lcnr:early-binder, r=Nilstrieb
change binders from tuple structs to named fields
2023-06-20 14:23:40 +02:00
Guillaume Gomez
6c5e212c17
Rollup merge of #112762 - chenyukang:yukang-fix-112507-argument-checking, r=compiler-errors
Sort the errors from arguments checking so that suggestions are handled properly

Fixes #112507

The algorithm of `find_issue` does not make sure the index comes out in order, which will make suggesting `remove` or `add` arguments broken in some cases.

Modifying the algorithm to obey order involves much more trivial change, so it's better to order the `errors` after iterations.
2023-06-20 14:23:40 +02:00
Guillaume Gomez
a318824b43
Rollup merge of #112720 - poliorcetics:rustdoc-item-type-color-same-as-item-color, r=notriddle,GuillaumeGomez
Rustdoc: search: color item type and reduce size to avoid clashing

- rustdoc: search: color item type same as item
- rustdoc: search: reduce item type size to 0.875rem to avoid clashing with path and item
2023-06-20 14:23:39 +02:00
bors
6fc0273b5a Auto merge of #112320 - compiler-errors:do-not-impl-via-obj, r=lcnr
Add `implement_via_object` to `rustc_deny_explicit_impl` to control object candidate assembly

Some built-in traits are special, since they are used to prove facts about the program that are important for later phases of compilation such as codegen and CTFE. For example, the `Unsize` trait is used to assert to the compiler that we are able to unsize a type into another type. It doesn't have any methods because it doesn't actually *instruct* the compiler how to do this unsizing, but this is later used (alongside an exhaustive match of combinations of unsizeable types) during codegen to generate unsize coercion code.

Due to this, these built-in traits are incompatible with the type erasure provided by object types. For example, the existence of `dyn Unsize<T>` does not mean that the compiler is able to unsize `Box<dyn Unsize<T>>` into `Box<T>`, since `Unsize` is a *witness* to the fact that a type can be unsized, and it doesn't actually encode that unsizing operation in its vtable as mentioned above.

The old trait solver gets around this fact by having complex control flow that never considers object bounds for certain built-in traits:
2f896da247/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs (L61-L132)

However, candidate assembly in the new solver is much more lovely, and I'd hate to add this list of opt-out cases into the new solver. Instead of maintaining this complex and hard-coded control flow, instead we can make this a property of the trait via a built-in attribute. We already have such a build attribute that's applied to every single trait that we care about: `rustc_deny_explicit_impl`. This PR adds `implement_via_object` as a meta-item to that attribute that allows us to opt a trait out of object-bound candidate assembly as well.

r? `@lcnr`
2023-06-20 08:42:37 +00:00
Alexis (Poliorcetics) Bourget
c3cdf8542d tests: add test for color of item kind 2023-06-20 08:28:56 +02:00
Michael Goulet
ca68cf0d46 Merge attrs, better validation 2023-06-20 04:38:55 +00:00
Michael Goulet
657d3f43a9 Add rustc_do_not_implement_via_object 2023-06-20 04:38:46 +00:00
David Tolnay
32b98ea2a9
Disable feature(unboxed_closures, fn_traits) in weird-exprs
One shouldn't need a nightly compiler in order to ~~have fun~~ call a
function many times.
2023-06-19 20:22:35 -07:00
Michael Goulet
3171c989ef
Rollup merge of #112781 - compiler-errors:new-solver-tait-overlaps-hidden, r=lcnr
Don't consider TAIT normalizable to hidden ty if it would result in impossible item bounds

See test for example where we shouldn't consider it possible to alias-relate a TAIT and hidden type.

r? `@lcnr`
2023-06-19 17:53:35 -07:00
Michael Goulet
be68e9e336
Rollup merge of #112596 - compiler-errors:missing-sig-with-rpitit, r=b-naber
Suggest correct signature on missing fn returning RPITIT/AFIT

Add `async` and unpeel the future's output type if the function is async

Fixes #108195
2023-06-19 17:53:34 -07:00
Michael Goulet
935452b619
Rollup merge of #112499 - tgross35:py-ruff-fixes, r=Mark-Simulacrum
Fix python linting errors

These were flagged by `ruff`, run using the config in https://github.com/rust-lang/rust/pull/112482
2023-06-19 17:53:34 -07:00
Michael Goulet
31d1fbf8d2
Rollup merge of #112232 - fee1-dead-contrib:match-eq-const-msg, r=b-naber
Better error for non const `PartialEq` call generated by `match`

Resolves #90237
2023-06-19 17:53:33 -07:00
bors
fe7454bf43 Auto merge of #112805 - matthiaskrgr:rollup-r5yrefu, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #109970 ([doc] `poll_fn`: explain how to `pin` captured state safely)
 - #112705 (Simplify `Span::source_callee` impl)
 - #112757 (Use BorrowFlag instead of explicit isize)
 - #112768 (Rewrite various resolve/diagnostics errors as translatable diagnostics)
 - #112777 (Continue folding in query normalizer on weak aliases)
 - #112780 (Treat TAIT equation as always ambiguous in coherence)
 - #112783 (Don't ICE on bound var in `reject_fn_ptr_impls`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-19 20:01:50 +00:00
Michael Goulet
32f83e18ab Better error message 2023-06-19 20:00:41 +00:00
Michael Goulet
dd620aa73a Don't ICE on unnormalized struct tail in layout computation 2023-06-19 20:00:41 +00:00
bjorn3
206b951803 Fix linker failures when #[global_allocator] is used in a dependency 2023-06-19 17:31:54 +00:00
Matthias Krüger
68d3e0e3bd
Rollup merge of #112783 - compiler-errors:nlb-fnptr-reject-ice, r=fee1-dead
Don't ICE on bound var in `reject_fn_ptr_impls`

We may try to use an impl like `impl<T: FnPtr> PartialEq {}` to satisfy a predicate like `for<T> T: PartialEq` -- don't ICE in that case.

Fixes #112735
2023-06-19 19:26:28 +02:00
Matthias Krüger
263635b917
Rollup merge of #112780 - compiler-errors:tait-is-ambig, r=lcnr
Treat TAIT equation as always ambiguous in coherence

Not sure why we weren't treating all TAIT equality as ambiguous -- this behavior combined with `DefineOpaqueTypes::No` leads to coherence overlap failures, since we incorrectly consider impls as not overlapping because the obligation `T: From<Foo>` doesn't hold.

Fixes #112765
2023-06-19 19:26:28 +02:00
Matthias Krüger
68f2f1e32c
Rollup merge of #112777 - compiler-errors:normalize-weak-more, r=oli-obk
Continue folding in query normalizer on weak aliases

Fixes #112752
Fixes #112731 (same root cause, so didn't make a test for it)
fixes #112776

r? ```@oli-obk```
2023-06-19 19:26:27 +02:00
Matthias Krüger
6de869fd23
Rollup merge of #112768 - NotStirred:translatable_diag/resolve1, r=WaffleLapkin
Rewrite various resolve/diagnostics errors as translatable diagnostics

additional question:

For trivial strings is it ever accepted to use `fluent_generated::foo` in a `label` for example? Or is an empty struct `Diagnostic` preferred?
2023-06-19 19:26:27 +02:00
bors
4051305389 Auto merge of #112238 - scottmcm:mir-add-unchecked, r=cjgillot
Promote unchecked integer math to MIR `BinOp`s

So slice indexing by a range gets down to one basic block, for example.

r? cjgillot
2023-06-19 17:14:21 +00:00
Tom Martin
2027e989bc
Remove unreachable and untested suggestion for invalid span enum derive(Default) 2023-06-19 16:22:21 +01:00
Michael Goulet
2e8af07a8a Don't consider TAIT normalizable to hidden ty if it would result in impossible item bounds 2023-06-19 14:49:56 +00:00
lcnr
0ceb7d5690 update tests 2023-06-19 15:39:55 +02:00
bors
689511047a Auto merge of #112366 - lukas-code:test, r=Nilstrieb
`#[test]` function signature verification improvements

This PR contains two improvements to the expansion of the `#[test]` macro.

The first one fixes https://github.com/rust-lang/rust/issues/112360 by correctly recovering item statements if the signature verification fails.

The second one forbids non-lifetime generics on `#[test]` functions. These were previously allowed if the function returned `()`, but always caused an inference error:

before:
```text
error[E0282]: type annotations needed
 --> src/lib.rs:2:1
  |
1 | #[test]
  | ------- in this procedural macro expansion
2 | fn foo<T>() {}
  | ^^^^^^^^^^^^^^ cannot infer type
```

after:
```text
error: functions used as tests can not have any non-lifetime generic parameters
 --> src/lib.rs:2:1
  |
2 | fn foo<T>() {}
  | ^^^^^^^^^^^^^^
```

Also includes some basic tests for test function signature verification, because I couldn't find any (???) in the test suite.
2023-06-19 13:39:46 +00:00
Maybe Waffle
d7713feb99 Syntatically accept become expressions 2023-06-19 12:54:34 +00:00
Scott McMurray
39788e07ba Promote unchecked_add/sub/mul/shl/shr to mir::BinOp 2023-06-19 01:47:03 -07:00
lcnr
be33ad8848 fix types in shim building 2023-06-19 09:06:32 +02:00
lcnr
c5943307ec add tests for unsound subtype handling 2023-06-19 09:01:29 +02:00
bors
8d1fa473dd Auto merge of #112724 - scottmcm:simpler-unchecked-shifts, r=Mark-Simulacrum
[libs] Simplify `unchecked_{shl,shr}`

There's no need for the `const_eval_select` dance here.  And while I originally wrote the `.try_into().unwrap_unchecked()` implementation here, it's kinda a mess in MIR -- this new one is substantially simpler, as shown by the old one being above the inlining threshold but the new one being below it in the `mir-opt/inline/unchecked_shifts` tests.

We don't need `u32::checked_shl` doing a dance through both `Result` *and* `Option` 🙃
2023-06-19 04:48:35 +00:00
Michael Goulet
29c74d5619 Don't ICE on bound var in reject_fn_ptr_impls 2023-06-19 02:52:03 +00:00
Michael Goulet
d43683f2e9 Treat TAIT equation as always ambiguous in coherence 2023-06-18 22:52:30 +00:00
Michael Goulet
493b18b653 Continue folding in query normalizer on weak aliases 2023-06-18 20:56:30 +00:00
Michael Goulet
90e51f110c
Rollup merge of #112537 - compiler-errors:dont-record-adjustments-twice, r=cjgillot
Don't record adjustments twice in `note_source_of_type_mismatch_constraint`

We call `lookup_method` a few times in `note_source_of_type_mismatch_constraint`, but that function has side-effects to the typeck results. Replace it with a less side-effect-y variant of the function for use in diagnostics.

Specifically the ICE in #112532 happens because we're recording deref adjustments twice for a call receiver, which causes `ExprUseVisitor` to be angry.

Fixes #112532
2023-06-18 13:17:05 -07:00
bors
939786223f Auto merge of #112636 - clubby789:no-capture-array-ref, r=cjgillot
Don't capture `&[T; N]` when contents isn't read

Fixes the check in #111831
Fixes #112607, although I decided to test the root cause rather than including the example in the issue as a test.
cc `@BoxyUwU`
2023-06-18 15:48:08 +00:00
yukang
0b20096eff sort the errors from arguments checking so that suggestions are handled properly 2023-06-18 18:44:14 +08:00
Deadbeef
89c24af133 Better error for non const PartialEq call generated by match 2023-06-18 05:24:38 +00:00
bors
a8a29070f0 Auto merge of #100036 - DrMeepster:box_free_free_box, r=oli-obk
Remove `box_free` lang item

This PR removes the `box_free` lang item, replacing it with `Box`'s `Drop` impl. Box dropping is still slightly magic because the contained value is still dropped by the compiler.
2023-06-17 16:10:57 +00:00
Matthias Krüger
981a2a2c00
Rollup merge of #112728 - Zalathar:spanview-charset, r=Nilstrieb
Add `<meta charset="utf-8">` to `-Zdump-mir-spanview` output

Without an explicit `<meta charset>` declaration, some browsers (e.g. Safari) won't detect the page encoding as UTF-8, causing unicode characters in the dump output to display incorrectly.
2023-06-17 12:43:32 +02:00
Matthias Krüger
63799ba549
Rollup merge of #112707 - GuillaumeGomez:back-in-history-fix, r=notriddle
[rustdoc] Fix invalid handling of "going back in history" when "go to only search result" setting is enabled

You can test the fix [here](https://rustdoc.crud.net/imperio/back-in-history-fix/lib2/index.html). Enable "Directly go to item in search if there is only one result", then search for `HasALongTraitWithParams` and finally go back to previous page. It should be back on the `index.html` page.

The reason for this bug is that the JS state is cached as is, so when we go back to the page, it resumes where it was left, somewhat (very weird), meaning the search is run again etc. The best way to handle this is to force the JS re-execution in this case so that it doesn't try to resume from where it left and then lead us back to the current page.

r? ``@notriddle``
2023-06-17 12:43:31 +02:00
Matthias Krüger
7051c84326
Rollup merge of #112683 - asquared31415:asm_clobber_ice, r=compiler-errors
fix ICE on specific malformed asm clobber_abi

fixes #112635
2023-06-17 12:43:30 +02:00
Zalathar
3eddb29555 Add <meta charset="utf-8"> to -Zdump-mir-spanview output 2023-06-17 18:31:35 +10:00
Trevor Gross
22d00dcd47 Apply changes to fix python linting errors 2023-06-16 20:56:01 -04:00
bors
0cc541e4b2 Auto merge of #108860 - oli-obk:tait_alias, r=compiler-errors
Add `AliasKind::Weak` for type aliases.

`type Foo<T: Debug> = Bar<T>;` does not check `T: Debug` at use sites of `Foo<NotDebug>`, because in contrast to a

```rust
trait Identity {
    type Identity;
}
impl<T: Debug> Identity for T {
    type Identity = T;
}
<NotDebug as Identity>::Identity
```

type aliases do not exist in the type system, but are expanded to their aliased type immediately when going from HIR to the type layer.

Similarly:

* a private type alias for a public type is a completely fine thing, even though it makes it a bit hard to write out complex times sometimes
* rustdoc expands the type alias, even though often times users use them for documentation purposes
* diagnostics show the expanded type, which is confusing if the user wrote a type alias and the diagnostic talks about another type that they don't know about.

For type alias impl trait, these issues do not actually apply in most cases, but sometimes you have a type alias impl trait like `type Foo<T: Debug> = (impl Debug, Bar<T>);`, which only really checks it for `impl Debug`, but by accident prevents `Bar<T>` from only being instantiated after proving `T: Debug`. This PR makes sure that we always check these bounds explicitly and don't rely on an implementation accident.

To not break all the type aliases out there, we only use it when the type alias contains an opaque type. We can decide to do this for all type aliases over an edition.

Or we can later extend this to more types if we figure out the back-compat concerns with suddenly checking such bounds.

As a side effect, easily allows fixing https://github.com/rust-lang/rust/issues/108617, which I did.

fixes https://github.com/rust-lang/rust/issues/108617
2023-06-17 00:33:29 +00:00
asquared31415
3dc793e625 fix ICE on specific malformed asm clobber_abi 2023-06-16 19:51:01 -04:00
Scott McMurray
3ec4eeddef [libs] Simplify unchecked_{shl,shr}
There's no need for the `const_eval_select` dance here.  And while I originally wrote the `.try_into().unwrap_unchecked()` implementation here, it's kinda a mess in MIR -- this new one is substantially simpler, as shown by the old one being above the inlining threshold but the new one being below it.
2023-06-16 16:03:19 -07:00
bors
670a0edaa9 Auto merge of #112716 - compiler-errors:rollup-h77daia, r=compiler-errors
Rollup of 7 pull requests

Successful merges:

 - #111074 (Relax implicit `T: Sized` bounds on `BufReader<T>`, `BufWriter<T>` and `LineWriter<T>`)
 - #112226 (std: available_parallelism using native netbsd api first)
 - #112474 (Support 128-bit enum variant in debuginfo codegen)
 - #112662 (`#[lang_item]` for `core::ptr::Unique`)
 - #112665 (Make assumption functions in new solver take `Binder<'tcx, Clause<'tcx>>`)
 - #112684 (Disable alignment checks on i686-pc-windows-msvc)
 - #112706 (Add `SyntaxContext::is_root`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-16 21:14:24 +00:00
DrMeepster
a5c6cb888e remove box_free and replace with drop impl 2023-06-16 13:41:06 -07:00
Michael Goulet
a5f8859937
Rollup merge of #112684 - saethlin:ignore-windows-alignment, r=wesleywiser
Disable alignment checks on i686-pc-windows-msvc

r? `@wesleywiser` Because you were in the Zulip discussion of this: https://rust-lang.zulipchat.com/#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202023-06-15

cc #112480
2023-06-16 12:53:23 -07:00
Michael Goulet
3eb8c2ae10
Rollup merge of #112474 - ldm0:ldm_enum_debuginfo_128_support, r=compiler-errors
Support 128-bit enum variant in debuginfo codegen

fixes #111600
2023-06-16 12:53:22 -07:00
Oli Scherer
f3b7dd6388 Add AliasKind::Weak for type aliases.
Only use it when the type alias contains an opaque type.

Also does wf-checking on such type aliases.
2023-06-16 19:39:48 +00:00
Guillaume Gomez
ea55d25465 Add regression test for #112676 2023-06-16 20:41:00 +02:00
bors
6bba061467 Auto merge of #112294 - saethlin:inline-me-maybe, r=oli-obk
Ignore the always part of #[inline(always)] in MIR inlining

`#[inline(always)]` is used in two cases: for functions that are so trivial it is always profitable to inline them, but also for functions which LLVM thinks are a bad inlining candidate, but which actually turn out to be profitable to inline. That second justification doesn't apply to the MIR inliner, so ignoring our cost estimation for these functions is not necessarily the right right thing to do.

This is basically a wash on non-check runs and a perf benefit in check runs. There are some notable regressions, and I think we might be able to claw those back by turning `#[inline(always)]` into a stronger hint. But I think this PR stands decently on its own as a tidy simplification.
2023-06-16 18:21:22 +00:00
Ben Kimock
c153f3a356 Ignore the always part of #[inline(always)] in MIR inlining 2023-06-16 11:36:02 -04:00
bors
6a94e87a54 Auto merge of #110688 - GuillaumeGomez:result-search-type, r=notriddle,jsha
rustdoc: Add search result item types after their name

Here what it looks like:

![Screenshot from 2023-04-22 15-16-58](https://user-images.githubusercontent.com/3050060/233789566-b5f3f625-3b78-4c56-a7ee-0a4f2d62e667.png)

The idea is to improve accessibility by providing this information directly in the text and not only in the text color. Currently we already use it for doc aliases and for primitive types, so I extended it to all types.

r? `@notriddle`
2023-06-16 15:02:22 +00:00
Ben Kimock
c54672e25f Disable alignment checks on i686-pc-windows-msvc 2023-06-16 09:06:12 -04:00
Dylan DPC
c2e109744d
Rollup merge of #112642 - compiler-errors:interp-lit-err, r=nnethercote
Handle interpolated literal errors

Not sure why it was doing a whole dance to re-match on the token kind when it seems like `Lit::from_token` does the right thing for both macro-arg and regular literals. Nothing seems to have regressed diagnostics-wise from the change, though.

Fixes #112622

r? ``@nnethercote``
2023-06-16 14:46:17 +05:30
Dylan DPC
64f6c00772
Rollup merge of #112443 - compiler-errors:next-solver-opportunistically-resolve-regions, r=lcnr
Opportunistically resolve regions in new solver

Use `opportunistic_resolve_var` during canonicalization to collapse some regions.

We have to start using `CanonicalVarValues::is_identity_modulo_regions`. We also have to modify that function to consider responses like `['static, ^0, '^1, ^2]` to be an "identity" response, since because we opportunistically resolve regions, there's no longer a 1:1 mapping between canonical var values and bound var indices in the response...

There's one nasty side-effect -- one test (`tests/ui/dyn-star/param-env-infer.rs`) starts to ICE because the certainty goes from `Yes` to `Maybe(Overflow)`... Not exactly sure why, though? Putting this up for discussion/investigation.

r? ```@lcnr```
2023-06-16 14:46:15 +05:30
Dylan DPC
b41db841e8
Rollup merge of #112399 - compiler-errors:closure-substs-root-universe, r=lcnr
Instantiate closure synthetic substs in root universe

In the UI test example, we end up generalizing an associated type (something like `<Map<Option<i32>, [closure upvars=?0]> as IntoIterator>::Item` generalizes into `<Map<Option<i32>, [closure upvars=?1]> as IntoIterator>::Item`) then assigning it to itself, emitting an alias-relate goal. This trivially holds via one of the normalizes-to candidates, instead of relating substs, so when closure analysis eventually sets `?0` to the actual upvars, `?1` never gets constrained. This ends up being reported as an ambiguity error during writeback.

Instead, we can take advantage of the fact that we *know* the closure substs live in the root universe. This will prevent them being generalized, since they always can be named, and the alias-relate above never gets emitted at all.

We can probably do this to a handful of other `next_ty_var` calls in typeck for variables that are clearly associated with the body of the program, but I wanted to limit this for now. Eventually, if we end up representing universes more faithfully like a tree or whatever, we can remove this and turn it back to just a call to `next_ty_var`.

Note: This is incredibly order-dependent -- we need to be assigning a type variable that was created *before* the closure substs, and we also need to actually have an unnormalized type at the time of the assignment. This currently seems easiest to trigger during call argument analysis just due to the fact that we instantiate the call's substs, normalize, THEN check args.

r? ```@lcnr```
2023-06-16 14:46:14 +05:30
Dylan DPC
c563296a4f
Rollup merge of #112163 - bvanjoi:fix-105231-2, r=compiler-errors
fix: inline `predicate_may_hold_fatal` and remove expect call in it

- Fixes #105231
- Discussion: https://github.com/rust-lang/rust/pull/111985#discussion_r1208888821

r? ``@compiler-errors``
2023-06-16 14:46:14 +05:30
bohan
b7921981d5 fix: inline predicate_may_hold_fatal 2023-06-16 11:09:53 +08:00
bors
c84d5e7078 Auto merge of #112346 - saethlin:no-comment, r=oli-obk
Remove comments from mir-opt MIR dumps

See https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Line.20numbers.20in.20mir-opt.20tests/near/363849874

In https://github.com/rust-lang/rust/pull/99780 there is mention that "there has been a zulip conversation about disabling line numbers with mixed opinions" which to me means that some people opposed this. I can't find the referenced conversation so... here we go.

The current situation is quite chaotic. It's not hard to find MIR diffs which contain

* Absolute line numbers
* Relative line numbers
* Substituted line numbers (LL)
For example: 408bbd0406/tests/mir-opt/inline/inline_shims.drop.Inline.diff (L10-L17)

And sometimes adding a comment at the top of a mir-opt test generates a diff in the test because a line number changed: https://github.com/rust-lang/rust/pull/98112/files#diff-b8cf4bcce95078e6a3faf075e9abf6864872fb28a64d95c04f04513b9e3bbd81

And irrelevant changes to the standard library can generate diffs in mir-opt tests: https://github.com/rust-lang/rust/pull/110694/files#diff-bf96b0e7c67b8b272814536888fd9428c314991e155beae1f0a2a67f0ac47b2c
769886cc35

I think we should, specifically in mir-opt tests, completely remove the comments, or insert placeholders for all line and column numbers.
2023-06-16 01:55:34 +00:00
Guillaume Gomez
6b9b55ac98
Rollup merge of #112654 - aliemjay:closure-output-normalize, r=compiler-errors
normalize closure output in equate_inputs_and_outputs

Fixes #112604
2023-06-15 22:04:57 +02:00
Guillaume Gomez
af955a647e
Rollup merge of #112614 - lukas-code:apit-unsized-suggestion, r=compiler-errors
tweak suggestion for argument-position `impl ?Sized`

fixes this invalid suggestion:
```text
help: consider removing the `?Sized` bound to make the type parameter `Sized`
  |
1 - fn foo(_: impl ?Sized) {}
1 + fn foo(_: impl ) {}
  |
```
2023-06-15 22:04:56 +02:00
Guillaume Gomez
d233522418
Rollup merge of #112529 - jieyouxu:block-expr-unused-must-use, r=oli-obk
Extend `unused_must_use` to cover block exprs

Given code like

```rust
#[must_use]
fn foo() -> i32 {
    42
}

fn warns() {
    {
        foo();
    }
}

fn does_not_warn() {
    {
        foo()
    };
}

fn main() {
    warns();
    does_not_warn();
}
```

### Before This PR

```
warning: unused return value of `foo` that must be used
 --> test.rs:8:9
  |
8 |         foo();
  |         ^^^^^
  |
  = note: `#[warn(unused_must_use)]` on by default
help: use `let _ = ...` to ignore the resulting value
  |
8 |         let _ = foo();
  |         +++++++

warning: 1 warning emitted
```

### After This PR

```
warning: unused return value of `foo` that must be used
 --> test.rs:8:9
  |
8 |         foo();
  |         ^^^^^
  |
  = note: `#[warn(unused_must_use)]` on by default
help: use `let _ = ...` to ignore the resulting value
  |
8 |         let _ = foo();
  |         +++++++

warning: unused return value of `foo` that must be used
  --> test.rs:14:9
   |
14 |         foo()
   |         ^^^^^
   |
help: use `let _ = ...` to ignore the resulting value
   |
14 |         let _ = foo();
   |         +++++++      +

warning: 2 warnings emitted
```

Fixes #104253.
2023-06-15 22:04:56 +02:00
Guillaume Gomez
db7d8374c1
Rollup merge of #112517 - fee1-dead-contrib:sus-op-no-borrow, r=compiler-errors
`suspicious_double_ref_op`: don't lint on `.borrow()`

closes #112489
2023-06-15 22:04:55 +02:00
Guillaume Gomez
ab314a57fa
Rollup merge of #112403 - nbdd0121:eh_frame, r=Nilstrieb
Prevent `.eh_frame` from being emitted for `-C panic=abort`

Since `CheckAlignment` pass is after the `AbortUnwindingCalls` pass, the `UnwindAction::Terminate` inserted in it has no chance to be converted to `UnwindAction::Unreachable` anymore, causing us to emit landing pads that are not necessary. Although these landing pads can themselves be eliminated by LLVM, `.eh_frame` sections are still generated. This causes trouble for Rust-for-Linux project recently.

This PR changes it to generate `UnwindAction::Terminate` when we opt for `-Cpanic=unwind`, and `UnwindAction::Unreachable` for `-Cpanic=abort`.

`@ojeda`
2023-06-15 22:04:55 +02:00
Ben Kimock
0a1fa411ed Remove comments from mir-opt MIR dumps 2023-06-15 15:19:11 -04:00
Vadim Petrochenkov
95a24c6ed4 privacy: Do not mark items reachable farther than their nominal visibility
This commit reverts a change made in #111425.
It was believed that this change was necessary for implementing type privacy lints, but #111801 showed that it was not necessary.
Quite opposite, the revert fixes some issues.
2023-06-15 21:25:47 +03:00
Vadim Petrochenkov
d326aed46f privacy: Feature gate new type privacy lints 2023-06-15 21:25:47 +03:00
Matthias Krüger
c0a089e118
Rollup merge of #112634 - mj10021:issue-112438-fix, r=compiler-errors
add InlineConst check

add check to close #112438
2023-06-15 17:52:38 +02:00
Matthias Krüger
82eb4a0208
Rollup merge of #112486 - jieyouxu:issue-112472, r=oli-obk
Fix suggestion for E0404 not dealing with multiple generics

Fixes #112472.
2023-06-15 17:52:36 +02:00
Matthias Krüger
9bc95a4bc9
Rollup merge of #112304 - GuillaumeGomez:re-exports, r=notriddle
Add chapter in rustdoc book for re-exports and add a regression test for `#[doc(hidden)]` behaviour

Fixes https://github.com/rust-lang/rust/issues/109449.
Fixes https://github.com/rust-lang/rust/issues/53417.

After the discussion in #109697, I made a few PRs to fix a few corner cases:
 * https://github.com/rust-lang/rust/pull/112178
 * https://github.com/rust-lang/rust/pull/112108
 * https://github.com/rust-lang/rust/pull/111997

With this I think I covered all cases. Only thing missing at this point was a chapter covering re-exports in the rustdoc book.

r? `@notriddle`
2023-06-15 17:52:36 +02:00
Matthias Krüger
f530016f50
Rollup merge of #111212 - nicklimmm:issue-107896-fix, r=pnkfelix
Add casting suggestion when assigning negative 2's complement bin or hex literal to a size compatible signed integer

Fixes #107896

The issue stated the case for `iX::MIN` variants. This PR extends the cases for other negative values (in the 2's complement).

Leveraged sign bits to detect such cases.

Example cases:
- <img width="845" alt="image" src="https://user-images.githubusercontent.com/65026286/236289682-19859f59-a9c5-48c5-b15f-78a935fbfcec.png">
- <img width="831" alt="image" src="https://user-images.githubusercontent.com/65026286/236289805-5b16488d-9138-4363-a1b6-a5c027c50aba.png">
- <img width="912" alt="image" src="https://user-images.githubusercontent.com/65026286/236290065-685a9777-034b-4def-83a8-cc4e20b1ed0c.png">
2023-06-15 17:52:35 +02:00
Ali MJ Al-Nasrawy
c75e6e0f6c normalize closure output before relation 2023-06-15 12:49:49 +00:00
clubby789
e72618a897 Don't capture &[T; N] when contents isn't read 2023-06-15 11:42:20 +00:00
James Dietz
b1f7ab2ea2 add test 2023-06-15 06:50:56 -04:00
许杰友 Jieyou Xu (Joe)
32ae8810fc
Fix suggestion for E0404 not dealing with multiple generics 2023-06-15 18:19:09 +08:00
Lukas Markeffsky
b6a3f126c0 change std::marker::Sized to just Sized 2023-06-15 12:01:38 +02:00
Lukas Markeffsky
ee7e717322 tweak suggestion for argument-position impl ?Sized 2023-06-15 12:00:57 +02:00
许杰友 Jieyou Xu (Joe)
72b3b58efc
Extend unused_must_use to cover block exprs 2023-06-15 17:59:13 +08:00
bors
4996b56ba9 Auto merge of #106343 - the8472:slice-iter-fold, r=scottmcm
optimize slice::Iter::fold

Fixes 2 of 4 cases from #106288

```
OLD: test slice::fold_to_last                                           ... bench:         248 ns/iter (+/- 3)
NEW: test slice::fold_to_last                                           ... bench:           0 ns/iter (+/- 0)
```
2023-06-15 09:38:53 +00:00
Michael Goulet
0d6da78b06 Always register sized obligation for argument 2023-06-15 03:18:21 +00:00
bors
314c39d2ea Auto merge of #112233 - notriddle:notriddle/search-unify, r=GuillaumeGomez
rustdoc-search: clean up type unification and "unboxing"

This PR redesigns parameter matching, return matching, and generics matching to use a single function that compares two lists of types.

It also makes the algorithms more consistent, so the "unboxing" behavior where `Vec<i32>` is considered a match for `i32` works inside generics, and not just at the top level.
2023-06-15 03:04:46 +00:00
Michael Goulet
9ef580fa6f Handle interpolated literal errors 2023-06-15 01:55:37 +00:00
bors
6ee4265ca6 Auto merge of #104455 - the8472:dont-drain-on-drop, r=Amanieu
Don't drain-on-drop in DrainFilter impls of various collections.

This removes drain-on-drop behavior from various unstable DrainFilter impls (not yet for HashSet/Map) because that behavior [is problematic](https://github.com/rust-lang/rust/issues/43244#issuecomment-641638196) (because it can lead to panic-in-drop when user closures panic) and may become forbidden if [this draft RFC passes](https://github.com/rust-lang/rfcs/pull/3288).

closes #101122

[ACP](https://github.com/rust-lang/libs-team/issues/136)

affected tracking issues
* #43244
* #70530
* #59618

Related hashbrown update: https://github.com/rust-lang/hashbrown/pull/374
2023-06-15 00:03:10 +00:00
The 8472
d90508f761 use indexed loop instead of ptr bumping
this seems to produce less IR
2023-06-14 22:22:41 +02:00
bors
8c74a5d27c Auto merge of #112625 - matthiaskrgr:rollup-jcobj3g, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #112584 (loongarch64-none*: Remove environment component from llvm target)
 - #112600 (Introduce a `Stable` trait to translate MIR to SMIR)
 - #112605 (Improve docs/clean up negative overlap functions)
 - #112611 (Error on unconstrained lifetime in RPITIT)
 - #112612 (Fix explicit-outlives-requirements lint span)
 - #112613 (Fix rustdoc-gui tests on Windows)
 - #112620 (Fix small typo)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-14 20:20:40 +00:00
bors
0b475c705f Auto merge of #112624 - matthiaskrgr:rollup-db6ta1b, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #98202 (Implement `TryFrom<&OsStr>` for `&str`)
 - #107619 (Specify behavior of HashSet::insert)
 - #109814 (Stabilize String::leak)
 - #111974 (Update runtime guarantee for `select_nth_unstable`)
 - #112109 (Don't print unsupported split-debuginfo modes with `-Zunstable-options`)
 - #112506 (Properly check associated consts for infer placeholders)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-14 17:25:04 +00:00
Matthias Krüger
77b307ff20
Rollup merge of #112613 - GuillaumeGomez:fix-gui-test-windows, r=notriddle
Fix rustdoc-gui tests on Windows

The browser-ui-test update contains fixes needed for backslash handling (they were not correctly escaped).

Since we have a mix of slash and backslash in some tests, I replaced `DOC_FOLDER` variable backslashes with slashes.

And finally it seemed like the unicode escaped wasn't much appreciated on Windows for some reason so I used the character directly.

cc `@klensy`
r? `@notriddle`
2023-06-14 18:10:32 +02:00
Matthias Krüger
41d5aeccec
Rollup merge of #112612 - sginnett:issue-105150, r=compiler-errors
Fix explicit-outlives-requirements lint span

Fixes #105150 which caused the span reported by the explicit-outlives-requirements lint to be incorrect when
1) the lint should suggest the entire where clause to be removed and
2) there are inline bounds present that are not inferable outlives requirements

In particular, this would cause rustfix to leave a dangling empty where clause.
2023-06-14 18:10:31 +02:00
Matthias Krüger
8aff1122c6
Rollup merge of #112611 - compiler-errors:unconstrained-lt-in-rpitit, r=oli-obk
Error on unconstrained lifetime in RPITIT

Fixes #109468

The only thing is that I had to split `tests/ui/impl-trait/in-trait/method-signature-matches.rs` into a bunch of different revisions because some error aren't being emitted if all the different examples are all together in one file 🤔

r? `@oli-obk` just because i know you'll review it, feel free to re-roll
2023-06-14 18:10:31 +02:00
Matthias Krüger
c1b4d075a2
Rollup merge of #112506 - compiler-errors:const-infer-ice, r=b-naber
Properly check associated consts for infer placeholders

We only reported an error if it was in a "suggestable" position (according to `is_suggestable_infer_ty`) -- this isn't correct for infer tys that can show up in other places in the constant's type, like behind a dyn trait.

fixes #112491
2023-06-14 18:10:30 +02:00
Guillaume Gomez
fced6383c2 Fix href attribute value check on Windows (DOC_PATH lacks an extra /) 2023-06-14 16:23:05 +02:00
bors
afa9fef709 Auto merge of #112418 - ferrocene:pa-mir-opt-panic, r=ozkanonur,saethlin
Add support for targets without unwinding in `mir-opt`, and improve `--bless` for it

The main goal of this PR is to add support for targets without unwinding support in the `mir-opt` test suite, by adding the `EMIT_MIR_FOR_EACH_PANIC_STRATEGY` comment. Similarly to 32bit vs 64bit, when that comment is present, blessed output files will have the `.panic-unwind` or `.panic-abort` suffix, and the right one will be chosen depending on the target's panic strategy.

The `EMIT_MIR_FOR_EACH_PANIC_STRATEGY` comment replaced all the `ignore-wasm32` comments in the `mir-opt` test suite, as those comments were added due to `wasm32` being a target without unwinding support. The comment was also added on other tests that were only executed on x86 but were still panic strategy dependent.

The `mir-opt` suite was then blessed, which caused a ton of churn as most of the existing output files had to be renamed and (mostly) duplicated with the abort strategy.

---

After [asking on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/mir-opt.20tests.20and.20panic.3Dabort), the main concern about this change is it'd make blessing the `mir-opt` suite even harder, as you'd need to both bless it with an unwinding target and an aborting target. This exacerbated the current situation, where you'd need to bless it with a 32bit and a 64bit target already.

Because of that, this PR also makes significant enhancements to `--bless` for the `mir-opt` suite, where it will automatically bless the suite four times with different targets, while requiring minimal cross-compilation.

To handle the 32bit vs 64bit blessing, there is now an hardcoded list of target mapping between 32bit and 64bit. The goal of the list is to find a related target that will *probably* work without requiring additional cross-compilation toolchains on the system. If a mapping is found, bootstrap will bless the suite with both targets, otherwise just with the current target.

To handle the panic strategy blessing (abort vs unwind), I had to resort to what I call "synthetic targets". For each of the target we're blessing (so either the current one, or a 32bit and a 64bit depending on the previous paragraph), bootstrap will extract the JSON spec of the target and change it to include `"panic-strategy": "abort"`. It will then build the standard library with this synthetic target, and bless the `mir-opt` suite with it.

As a result of these changes, blessing the `mir-opt` suite will actually bless it two or four times with different targets, ensuring all possible variants are actually blessed.

---

This PR is best reviewed commit-by-commit.

r? `@jyn514`
cc `@saethlin` `@oli-obk`
2023-06-14 14:20:59 +00:00
Guillaume Gomez
e4ee329865 Fix eBNF and handling of whitespace characters when not in a path 2023-06-14 14:22:17 +02:00
Guillaume Gomez
d1a76a9f50 Update rustdoc-gui test 2023-06-14 14:22:17 +02:00
Guillaume Gomez
7dc684f173 Add "vec new" test 2023-06-14 14:22:17 +02:00
Guillaume Gomez
b5f8258497 Update rustdoc-js-std tests 2023-06-14 14:22:17 +02:00
bors
7b0eac438a Auto merge of #112400 - WaffleLapkin:vtable_stats, r=compiler-errors
Collect VTable stats & add `-Zprint-vtable-sizes`

This is a bit hacky/buggy, but I'm not entirely sure how to fix it, so I want to ask reviewers for help...

To try this, use either of those:
- `cargo clean && RUSTFLAGS="-Zprint-vtable-sizes" cargo +toolchain b`
- `cargo clean && cargo rustc +toolchain -Zprint-vtable-sizes`
- `rustc +toolchain -Zprint-vtable-sizes ./file.rs`
2023-06-14 11:24:42 +00:00
Pietro Albini
f5d3de2abc
update codegent test to be independent of panic strategy 2023-06-14 12:52:02 +02:00
Pietro Albini
0526267ffd
mark relevant tests as requiring unwinding 2023-06-14 12:52:00 +02:00
Pietro Albini
5be14f5fda
ensure test harness test works on panic=abort targets 2023-06-14 12:51:02 +02:00
Guillaume Gomez
df9a46f60f Replace unicode value with character in shortcuts.goml test 2023-06-14 10:37:56 +02:00
bors
3ed2a10d17 Auto merge of #110662 - bryangarza:safe-transmute-reference-types, r=compiler-errors
Safe Transmute: Enable handling references

This patch enables support for references in Safe Transmute, by generating nested obligations during trait selection. Specifically, when we call `confirm_transmutability_candidate(...)`, we now recursively traverse the `rustc_transmute::Answer` tree and create obligations for all the `Answer` variants, some of which include multiple nested `Answer`s.
2023-06-14 08:26:22 +00:00
The 8472
114d5f221c s/drain_filter/extract_if/ for Vec, Btree{Map,Set} and LinkedList 2023-06-14 09:28:54 +02:00
Sam Ginnett
72531b7463 Fix explicit-outlives-requirements lint span 2023-06-13 23:04:00 -07:00
Michael Goulet
bc78d0cbf1 Error on unconstrained lifetime in RPITIT 2023-06-14 05:20:31 +00:00
Matthias Krüger
e3021b4a42
Rollup merge of #112571 - notriddle:notriddle/never-search, r=GuillaumeGomez
rustdoc-search: search never type with `!`

This feature extends rustdoc to support the syntax that most users will naturally attempt to use to search for diverging functions. Part of #60485

It's already possible to do this search with `primitive:never`, but that's not what the Rust language itself uses, so nobody will try it if they aren't told or helped along.
2023-06-14 06:25:49 +02:00
Matthias Krüger
269ea4bd6b
Rollup merge of #112520 - chenyukang:yukang-fix-112505, r=fee1-dead
Fix the overflow issue for transmute_generic_consts

Fixes #112505
2023-06-14 06:25:49 +02:00
Matthias Krüger
98f6e9644b
Rollup merge of #112495 - bvanjoi:fix-109153, r=petrochenkov
fix(resolve): update shadowed_glob more precision

- Fixes #109153
- Fixes #109962

## Why does it panic?

We use #109153 as an illustration.

The process of `resolve_imports` is:

| Iter | resolve     | resolution of **`(Mod(root), Ident(bar) in type ns)`** |
| -    | -           | -      |
| 0 | `use foo::*`   | `binding` -> foo::bar, `shallowed_glob` -> `None` |
| 1 | `use bar::bar` | `binding` -> foo::bar::bar, `shallowed_glob` -> foo::bar    |
| 2 | `use bar::*`   | `binding` -> foo::bar::bar, `shallowed_glob` -> foo::bar::bar::bar |

So during `finalize_import`, the `root::bar` in `use bar::bar` had been pointed to `foo::bar::bar::bar`, which is different from the `initial_module` valued of `foo::bar`, therefore, the panic had been triggered.

## Try to solve it

~I think #109153 should check-pass rather than throw an ambiguous error. Following this idea, there are two ways to solve this problem:~

~1. Give up the `initial_module` and update `import.imported_module` after each resolution update. However, I think this method may have too much impact.~
~2. Do not update the `shadowed_glob` when it is defined.~

~To be honest, I am not sure if this is the right way to solve this ICE. Perhaps there is a better resolution.~

Edit: we had made the `resolution.shadowed_glob` update more detailed.

r? `@petrochenkov`
2023-06-14 06:25:48 +02:00
Matthias Krüger
6fc50dacd4
Rollup merge of #112197 - compiler-errors:next-solver-erase, r=lcnr
Erase regions even if normalization fails in writeback (in new solver)

Or else we ICE during writeback on some programs that error
2023-06-14 06:25:48 +02:00
bors
6330daade9 Auto merge of #112062 - lukas-code:unsized-layout, r=wesleywiser
Make struct layout not depend on unsizeable tail

fixes (after backport) https://github.com/rust-lang/rust/issues/112048

Since unsizing `Ptr<Foo<T>>` -> `Ptr<Foo<U>` just copies the pointer and adds the metadata, the layout of `Foo` must not depend on niches in and alignment of the tail `T`.

Nominating for beta 1.71, because it will have this issue: `@rustbot` label beta-nominated
2023-06-13 22:34:59 +00:00
Michael Goulet
01377e8064 opportunistically resolve regions 2023-06-13 22:10:51 +00:00
Michael Goulet
7ff79cf4aa Move test 2023-06-13 21:54:11 +00:00
Michael Goulet
c92342d58d Erase regions even if normalization fails in writeback 2023-06-13 21:53:01 +00:00
Michael Goulet
dbee24d949 Suggest correct signature on missing fn returning RPITIT/AFIT 2023-06-13 20:41:15 +00:00
Wesley Wiser
b982f3a988 Add test case for unsizing with niche 2023-06-13 15:32:42 -04:00
bohan
f7330eb752 fix(resolve): update shadowed_glob more precision 2023-06-14 01:38:35 +08:00
bors
5683791ebb Auto merge of #112017 - Nemo157:unsafe-block-rustfix, r=eholk
Add MVP suggestion for `unsafe_op_in_unsafe_fn`

Rebase of https://github.com/rust-lang/rust/pull/99827

cc tracking issue https://github.com/rust-lang/rust/issues/71668

No real changes since the original PR, just migrated the new suggestion to use fluent messages and added a couple more testcases, AFAICT from the discussion there were no outstanding changes requested.
2023-06-13 15:57:59 +00:00
Maybe Waffle
af4631ad6e Add a test for -Zprint-vtable-sizes 2023-06-13 15:16:48 +00:00
Wim Looman
802c1d5979
Add test cases for suggestions with unsafe operations contained inside macros 2023-06-13 15:48:57 +02:00
Wim Looman
8f3e876e52
Add note about unsafe functions body not being unsafe 2023-06-13 15:48:57 +02:00
Wim Looman
62a712a8bb
Hide suggestion to wrap function in unsafe block 2023-06-13 15:48:55 +02:00