Commit Graph

28850 Commits

Author SHA1 Message Date
Nicholas Nethercote
e3d8bbbfe2 Simplify support traits.
First, both `AstPrinterSupport` and `HirPrinterSupport` have a `sess`
method. This commit introduces a `Sess` trait and makes the support
traits be subtraits of `Sess`, to avoid some duplication.

Second, both support traits have a `pp_ann` method that isn't needed if
we enable `trait_upcasting`. This commit removes those methods.

(Both of these traits will be removed in a subsequent commit, as will
the `trait_upcasting` use.)
2023-10-13 06:20:11 +11:00
Nicholas Nethercote
d5e7c5f3cc Remove unused PrinterSupport::hir_map method. 2023-10-13 06:20:11 +11:00
Nicholas Nethercote
1467ba06b6 Remove PpAstTreeMode.
It's simpler to distinguish the two AST modes directly in `PpMode`.
2023-10-13 06:20:11 +11:00
Nicholas Nethercote
87090a97e3 Remove an outdated comment.
`phase_3_run_analysis_passes` no longer exists, and AFAICT this code has
been refactored so much since this comment was written that it no longer
has any useful meaning.
2023-10-13 06:20:11 +11:00
Nicholas Nethercote
c5cfcdc4ac Remove unnecessary call to call_with_pp_support_hir.
The callback is trivial and no pp support is actually needed. This makes
the `HirTree` case more like the `AstTree` case above.
2023-10-13 06:20:11 +11:00
Nicholas Nethercote
ef8701a4a0 Rename some things.
- Rename `pprust` as `pprust_ast`, to align with `pprust_hir`.
- Rename `PrinterSupport` as `AstPrinterSupport`, to align with
  `HirPrinterSupport`.
2023-10-13 06:20:11 +11:00
bors
df4379b4eb Auto merge of #116510 - scottmcm:no-1-simd-v2, r=compiler-errors
Copy 1-element arrays as scalars, not vectors

For `[T; 1]` it's silly to copy as `<1 x T>` when we can just copy as `T`.

Inspired by https://github.com/rust-lang/rust/issues/101210#issuecomment-1732470941, which pointed out that `Option<[u8; 1]>` was codegenning worse than `Option<u8>`.

(I'm not sure *why* LLVM doesn't optimize out `<1 x u8>`, but might as well just not emit it in the first place in this codepath.)

---

I think I bit off too much in #116479; let me try just the scalar case first.

r? `@ghost`
2023-10-12 18:45:01 +00:00
Urgau
001a65c4b0 check-cfg: only print the list of expected names once 2023-10-12 18:39:35 +02:00
Urgau
dcfc484b09 check-cfg: mention the unexpected name and value in the primary message 2023-10-12 18:39:04 +02:00
Urgau
72815dc08f check-cfg: adjust expected names and values when useful 2023-10-12 18:39:04 +02:00
Matthias Krüger
4832811b0d
Rollup merge of #116654 - Zalathar:reloop-traversal, r=oli-obk
coverage: Clarify loop-edge detection and graph traversal

This is a collection of improvements to two semi-related pieces of code:

- The code in `counters` that detects which graph edges don't exit a loop, and would therefore be good candidates to have their coverage computed as an expression rather than having a physical counter.
- The code in `graph` that traverses the coverage BCB graph in a particular order, and tracks loops and loop edges along the way (which is relevant to the above).

I was originally only planning to make the `graph` changes, but there was going to be a lot of indentation churn in `counters` anyway, and once I started looking I noticed a lot of opportunities for simplification.

---

`@rustbot` label +A-code-coverage
2023-10-12 18:36:44 +02:00
Matthias Krüger
5f90bee663
Rollup merge of #116642 - weiznich:diagnostic_on_unimplemented_improvements, r=compiler-errors
Handle several `#[diagnostic::on_unimplemented]` attributes correctly

This PR fixes an issues where rustc would ignore subsequent `#[diagnostic::on_unimplemented]` attributes. The [corresponding RFC](https://rust-lang.github.io/rfcs/3368-diagnostic-attribute-namespace.html) specifies that the first matching instance of each option is used. Invalid attributes are linted and otherwise ignored.
2023-10-12 18:36:44 +02:00
Matthias Krüger
4b1867a9ee
Rollup merge of #116625 - nnethercote:rustc_hir_pretty, r=fee1-dead
`rustc_hir_pretty` cleanups

Just some improvements I found while looking through this code.

r? ``@fee1-dead``
2023-10-12 18:36:43 +02:00
bors
19149d1ea9 Auto merge of #116649 - nnethercote:improve-print_tts-precursors, r=petrochenkov
Token cleanups

Some precursors to #114571 that are worth merging even if the main part of #114571 doesn't get merged.

r? `@petrochenkov`
2023-10-12 13:10:14 +00:00
Zalathar
d99ab97b02 coverage: Simplify adding BCB successors to the traversal worklists 2023-10-12 22:37:58 +11:00
Zalathar
59f4f1c89d coverage: Don't store loop backedges in the traversal context
As long as we store the loop header BCB, we can look up its incoming loop
backedges as needed.
2023-10-12 21:41:13 +11:00
Zalathar
15360b3bc8 coverage: Store a graph reference in the graph traversal struct
Having to keep passing in a graph reference was a holdover from when the graph
was partly mutated during traversal. As of #114354 that is no longer necessary,
so we can simplify the traversal code by storing a graph reference as a field
in `TraverseCoverageGraphWithLoops`.
2023-10-12 21:41:13 +11:00
Zalathar
ea3fb7bc2c coverage: Use a VecDeque for loop traversal worklists
The previous code was storing the worklist in a vector, and then selectively
adding items to the start or end of the vector. That's a perfect use-case for a
double-ended queue.

This change also reveals that the existing code was a bit confused about which
end of the worklist is the front or back. For now, items are always removed
from the front of the queue (instead of the back), and code that adds items to
the queue has been flipped, to preserve the existing behaviour.
2023-10-12 21:41:13 +11:00
Zalathar
d1920c5181 coverage: Rename next_bcb to just bcb
This is the only BCB that `TraverseCoverageGraphWithLoops::next` works with, so
calling it `next_bcb` just makes the code less clear.
2023-10-12 21:41:13 +11:00
Zalathar
a7ae2a6e6c coverage: Simplify the detection of reloop edges to be given expressions 2023-10-12 21:41:13 +11:00
bors
4f05e95452 Auto merge of #116628 - gurry:116293-dup-note.rs, r=petrochenkov
Fix duplicate note on internal feature gates with associated issues

Fixes #116293

Note sure if I should add tests because the issue occurs only for feature gates having associated issues and that set of feature gates will change unpredictably leading to an unnecessary churn in tests.
2023-10-12 07:57:51 +00:00
bors
3d575a2f2e Auto merge of #113487 - estebank:sugg-113174, r=oli-obk
Use structured suggestion for #113174

When encountering a for loop that is rejected by the borrow checker because it is being advanced within its body, provide a structured suggestion for `while let Some(pat) = iter.next()`.
2023-10-12 02:34:07 +00:00
Gurinder Singh
66e643d0f8 Fix duplicate note on internal feature gate
The BuiltinInternalFeatures gate already has a struct level #[note]
attribute. The additional note field in it caused a duplicate to be
displayed when it was set to Some(...) which happened when the
feature had an associated issue
2023-10-12 07:22:41 +05:30
Nicholas Nethercote
66c2b77a4a Rename tt_prepend_space as space_between.
And reorder the arguments. I find it easier to think about this way.
2023-10-12 08:50:42 +11:00
Nicholas Nethercote
33aff5b152 Use TokenStream::token_alone in one place. 2023-10-12 08:46:16 +11:00
Nicholas Nethercote
bb9c2f50c3 Reorder an expression to improve readability. 2023-10-12 08:46:15 +11:00
Nicholas Nethercote
becf4942a2 Rename Token::is_op as Token::is_punct.
For consistency with `proc_macro::Punct`.
2023-10-12 08:46:15 +11:00
Georg Semmler
232aaeba7c
Handle several #[diagnostic::on_unimplemented] attributes correctly
This PR fixes an issues where rustc would ignore subsequent
`#[diagnostic::on_unimplemented]` attributes. The [corresponding
RFC](https://rust-lang.github.io/rfcs/3368-diagnostic-attribute-namespace.html)
specifies that the first matching instance of each option is used.
Invalid attributes are linted and otherwise ignored.
2023-10-11 22:01:59 +02:00
bors
475c71da07 Auto merge of #116640 - matthiaskrgr:rollup-xt9r5ir, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #116219 (Relate alias ty with variance)
 - #116315 (Do not check for impossible predicates in const-prop lint.)
 - #116436 (Structurally normalize for closure)
 - #116597 (Prevent showing methods from blanket impls of not available foreign traits to show up in the search results)
 - #116627 (small cleanup)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-11 19:02:49 +00:00
Esteban Küber
9d2eb66e1a Use structured suggestion for #113174
When encountering a for loop that is rejected by the borrow checker
because it is being advanced within its body, provide a structured
suggestion for `while let Some(pat) = iter.next()`.
2023-10-11 18:26:44 +00:00
Matthias Krüger
8374805d67
Rollup merge of #116627 - fee1-dead-contrib:cleanup, r=spastorino
small cleanup

this is exactly the same as the `lower_param_bounds` function, so use that instead
2023-10-11 20:08:22 +02:00
Matthias Krüger
3712ea82f3
Rollup merge of #116436 - compiler-errors:structurally-normalize-for-closure, r=lcnr
Structurally normalize for closure

Fixes some signature deduction problems in the new trait solver (and in the case of async, an ICE).

r? lcnr
2023-10-11 20:08:21 +02:00
Matthias Krüger
9b7e0af80d
Rollup merge of #116315 - cjgillot:cpl-clean, r=petrochenkov
Do not check for impossible predicates in const-prop lint.

The enclosing query already checks for them, and replaces the body with a single `unreachable` if they are indeed impossible.
2023-10-11 20:08:20 +02:00
Matthias Krüger
8ddc0df1f1
Rollup merge of #116219 - compiler-errors:relate-alias-ty-with-variance, r=lcnr
Relate alias ty with variance

In the new solver, turns out that the subst-relate branch of the alias-relate predicate was relating args invariantly even for opaques, which have variance 💀.

This change is a bit more invasive, but I'd rather not special-case it [here](aeaa5c30e5/compiler/rustc_trait_selection/src/solve/alias_relate.rs (L171-L190)) and then have it break elsewhere. I'm doing a perf run to see if the extra call to `def_kind` is that expensive, if it is, I'll reconsider.

r? ``@lcnr``
2023-10-11 20:08:20 +02:00
bors
c1691db366 Auto merge of #113218 - lqd:polonius-scopes, r=jackh726
Compute NLL loan scopes using the polonius model

For a *location-insensitive* analysis (that is, without expressiveness improvements for users yet), this PR implements loans going out of scope using reachability and liveness, rather than checking if the issuing region's values contain a given CFG point. This is equivalent to NLL scopes and computes the same data.

r? `@matthewjasper`

A couple of notes:
- there are some assumptions about SCC representatives, placeholders, free regions, and member constraints that I believe hold, and they're documented in the code
- this passes all the UI tests with `-Zpolonius=next` -- the perf is [not terrible](https://github.com/rust-lang/rust/pull/112432#issuecomment-1749685862) and there are a bunch of ways to improve it in the future.
- there's a fixme left, hopefully Matthew you know a clean way to get the information it mentions.
2023-10-11 16:46:03 +00:00
Oğuz Ağcayazı
1d9481fdc8 implement get_filename/lines for span 2023-10-11 17:55:57 +03:00
bors
3c23df4935 Auto merge of #115937 - oli-obk:spurious_unreachable_pattern, r=Nadrieril
Prevent spurious `unreachable pattern` lints

But it means we'll get more `non-exhaustive` patterns

fixes https://github.com/rust-lang/rust/issues/78057

r? `@Nadrieril` `@RalfJung`
2023-10-11 14:49:49 +00:00
Oli Scherer
eca786cd14 Remember the ErrorReported used to silence follow up errors instead of recreating it with delay_span_bug 2023-10-11 12:49:57 +00:00
Oli Scherer
e83467c3b8 Avoid emitting the non_exhaustive error if other errors already occurred 2023-10-11 12:49:57 +00:00
Oli Scherer
d1fd11f3f9 Prevent spurious unreachable pattern lints
Means you'll get more `non-exhaustive` patterns
2023-10-11 12:49:57 +00:00
bors
5aa23be6b6 Auto merge of #116014 - lqd:mcp510-2-electric-boogaloo, r=petrochenkov
Implement `-Clink-self-contained=-linker` opt out

This implements the `-Clink-self-contained` opt out necessary to switch to lld by changing rustc's defaults instead of cargo's.

Components that are enabled and disabled on the CLI are recorded, for the purpose of being merged with the ones which the target spec will declare (I'll open another PR for that tomorrow, for easier review).

For MCP510, we now check whether using the self-contained linker is disabled on the CLI. Right now it would only be sensible to with `-Zgcc-ld=lld` (and I'll add some checks that we don't both enable and disable a component on the CLI in a future PR), but the goal is to simplify adding the check of the target's enabled components here in the follow-up PRs.

r? `@petrochenkov`
2023-10-11 12:11:39 +00:00
bors
71704c4f84 Auto merge of #116623 - Nadrieril:validate-range-endpoints, r=oli-obk
Fix overflow checking in range patterns

When a range pattern contains an overflowing literal, if we're not careful we might not notice the overflow and use the wrapped value. This makes for confusing error messages because linting against overflowing literals is only done in a later pass. So when a range is invalid we check for overflows to provide a better error.

This check didn't use to handle negative types; this PR fixes that. First commit adds tests, second cleans up without changing behavior, third does the fix.

EDIT: while I was at it, I fixed a small annoyance about the span of the overflow lint on negated literals.

Fixes https://github.com/rust-lang/rust/issues/94239
2023-10-11 10:07:19 +00:00
Deadbeef
50b6f46f71 small cleanup 2023-10-11 08:25:43 +00:00
bors
6d05c430d2 Auto merge of #115948 - notriddle:notriddle/logo-lockup, r=fmease
rustdoc: show crate name beside smaller logo

*Blocked on https://github.com/rust-lang/cargo/pull/12800*

## Summary

In this PR, the crate name and version are always shown in the sidebar, even in subpages, and the lateral navigation is always shown in the sidebar, even in modules.

Clicking the crate name does the same thing clicking the logo always did: take you to the crate root (the crate's home page, at least within Rustdoc).

The Rust logo is also no longer shown by default for non-Rust docs.

### Screenshots

<details><summary>Before</summary>

| | Macro | Module |
|--|-------|--------|
| In crate | ![image](https://github.com/rust-lang/rust/assets/1593513/d5db0a46-2bb6-44a2-a3aa-2d915ecb8595) |![image](https://github.com/rust-lang/rust/assets/1593513/61f8c1ee-c298-4e2c-b791-18ecb79ab83b)
| In module[^1] | ![image](https://github.com/rust-lang/rust/assets/1593513/73abca59-0b69-4650-a1e2-7278ca34795c) | ![image](https://github.com/rust-lang/rust/assets/1593513/0baf02c2-2ec7-4674-80e5-a6a74a973376)

[^1]: This PR also includes a bug fix for derive macros not showing up in the lateral navigation part of the sidebar

</details>

#### Whole sidebar screenshots

| | Macro | Module |
|--|-------|--------|
| In crate | ![image](https://github.com/rust-lang/rust/assets/1593513/75d1bd07-41f7-4f11-ba24-fd5476e0586a) | ![image](https://github.com/rust-lang/rust/assets/1593513/52960259-2b65-4131-b380-01826f0a0eb7)
| In module | ![image](https://github.com/rust-lang/rust/assets/1593513/06e57928-8cb0-41bd-b152-be16cc53e5ec) | ![image](https://github.com/rust-lang/rust/assets/1593513/37291c69-2a07-4467-a382-d9b029084a47)

#### Different logo configurations

|         | Short crate name | Long crate name |
|---------|------------------|-----------------|
| Root    | ![short-root]    | ![long-root]
| Subpage | ![short-subpage] | ![long-subpage]

[short-root]: https://github.com/rust-lang/rust/assets/1593513/9e2b4fa8-f581-4106-b562-1e0372c13f79
[short-subpage]: https://github.com/rust-lang/rust/assets/1593513/8331cdb8-fa13-4671-a1e2-dcc1cdca7451
[long-root]: https://github.com/rust-lang/rust/assets/1593513/7d377fec-0f1d-4343-9f82-0e35a8f58056
[long-subpage]: https://github.com/rust-lang/rust/assets/1593513/3b3094a4-63c9-477c-8c15-b6075837df30

##### Without a logo

![image](https://github.com/rust-lang/rust/assets/1593513/66672b79-6c59-4be8-a527-25ef6f0b04ab)

### Preview pages

https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rocket/rocket/index.html

https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rocket/rocket_sync_db_pools/index.html

https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rust-compiler/index.html

https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rust/std/index.html

https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rocket/tokio/index.html

## Motivation

This improves visual information density (the construct with the logo and crate name is *shorter* than the logo on its own, because it's not square) and navigation clarity (we can now see what clicking the Rust logo does, specifically).

Compare this with the layout at [Phoenix's Hexdocs] (which is what this proposal is closely based on), the old proposal on [Internals Discourse] (which always says "Rust standard library" in the sidebar, but doesn't do the side-by-side layout).

[Phoenix's Hexdocs]: https://hexdocs.pm/phoenix/1.7.7/overview.html
[Internals Discourse]: https://internals.rust-lang.org/t/poc-of-a-new-design-for-the-generated-rustdoc/11018

## Guide-level explanation

This PR cleans up some of the sidebar navigation.

It makes the logo in the desktop sidebar a bit smaller, and puts the crate name and version next to it (either beside it, or below it, depending on if there's space), making it clearer what clicking on it does: click the crate name to open the crate's home page. It also removes the Rust logo from non-official-Rust crates, again to make the navigation and supply chain clearer (since the crate name has been added, the logo is no longer necessary for navigation).

It adds a bit more clarifying information for lateral navigation. On items that don't add their own sidebar items, it just shows its siblings directly below the crate name and logo, but for other items, it shows "In crate alloc" instead of just "In alloc". It also shows the lateral navigation tools on module pages, making modules consistent with every other item.

## Drawbacks

While this actually takes up less screen real estate than the old layout on desktop, it takes up more HTML. It's also a bit more visually complex.

## Rationale and alternatives

I could do what the Internals POC did and keep the vertically stacked layout all the time, instead of doing a horizontal stack where possible. It would take up more screen real estate, though.

## Prior art

This design is lifted almost verbatim from Hexdocs. It seems to work for them. [`opentelemetry_process_propagator`], for example, has a long application name.

[`opentelemetry_process_propagator`]: https://hexdocs.pm/opentelemetry_process_propagator/OpentelemetryProcessPropagator.html

## Unresolved questions

Maybe we should encourage crate authors to include their own logo more often? It certainly helps give people a better sense of "place." This seems to be blocked on coming up with an API to do it without requiring them to host the file somewhere.

## Future possibilities

Beyond this, plenty of other changes could be made to improve the layout, like

* Fix things so that clicking an item in the sidebar doesn't cause it to scroll back to the top.
  * The [Internals demo](https://utherii.github.io/new.html) does this right: clicking an item in the sidebar changes the content area, but the sidebar itself does not change. This is nice, because clicking is cheap and I can skim the opening few paragraphs while browsing.
  * The layout of the docs sidebar causes trouble to implement this, because it's different on different pages, but at least fix this on the file browser.
* Come up with a less cluttered way to do disclosure. There's a lot of `[-]` on the page.
  * We don't lack ideas to fix this one. We have *too many*.
* Do a better job of separating local navigation (vec::Vec links to vec::IntoIter) and the table of contents (vec::Vec links to vec::Vec::new).
  * A possibility: add a Back arrow next to the "In [module]" header?
    ![image](https://github.com/rust-lang/rust/assets/1593513/e969faf7-7722-457a-b8c6-8d962e9e1e23)
* Give readers more control of how much rustdoc shows them, and giving doc authors more control of how much it generates. Basically, https://github.com/rust-lang/rust/pull/115660 is great, let's do it too.

But those are mostly orthogonal, not future possibilities unlocked by this change.
2023-10-11 06:28:36 +00:00
Nadrieril
dcdddb7a60 Fix span of overflow lint for negated literals 2023-10-11 04:55:55 +02:00
Nadrieril
1baf8bf54d Fix range overflow checking 2023-10-11 04:55:55 +02:00
Nadrieril
1e1174b034 Rework error handling when lowering range endpoints 2023-10-11 04:54:49 +02:00
bors
36cbf944b3 Auto merge of #116621 - aliemjay:rollup-0e2of3c, r=aliemjay
Rollup of 4 pull requests

Successful merges:

 - #95967 (Add explicit-endian String::from_utf16 variants)
 - #116530 (delay a bug when encountering an ambiguity in MIR typeck)
 - #116611 (Document `diagnostic_namespace` feature)
 - #116612 (Remove unused dominator iterator)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-11 01:49:27 +00:00
Ali MJ Al-Nasrawy
88a929ba32
Rollup merge of #116612 - tmiasko:rm-dom-iter, r=cjgillot
Remove unused dominator iterator
2023-10-11 03:53:18 +03:00
Ali MJ Al-Nasrawy
a7042a94a3
Rollup merge of #116530 - aliemjay:ice-on-ambiguity, r=compiler-errors
delay a bug when encountering an ambiguity in MIR typeck

We shouldn't have any trait selection ambiguities in MIR typeck.

See https://github.com/rust-lang/rust/pull/114586#issuecomment-1751967321

r? `@oli-obk` `@compiler-errors` `@lcnr`
2023-10-11 03:53:17 +03:00
bors
dcf89f43a5 Auto merge of #116578 - antoyo:subtree-update_cg_gcc_2023-10-09, r=bjorn3
subtree update cg_gcc 2023/10/09
2023-10-11 00:04:04 +00:00
Nicholas Nethercote
7d35902c62 Fiddle with State functions.
Remove and inline `new_from_input`, because it has a single call site.
And move `attrs` into the earlier `impl` block.
2023-10-11 10:46:55 +11:00
Nicholas Nethercote
494bc8514a Tweak comments.
- Remove an out-of-date comment. (There is no `PpAnn` implementation for `hir::Crate`.)
- Remove a low-value comment.
- And break a very long comment.
2023-10-11 10:46:33 +11:00
Chris Wailes
6efc71c920 Add the V (vector) extension to the riscv64-linux-android target spec
This feature has been enabled and tested internally in the Android
project.
2023-10-10 16:26:26 -07:00
Nicholas Nethercote
664b1858aa Remove many unneeded pubs. 2023-10-11 09:28:06 +11:00
bors
d627cf07ce Auto merge of #113915 - cjgillot:ssa-call, r=tmiasko
Also consider call and yield as MIR SSA.

The SSA analysis on MIR only considered `Assign` statements as defining a SSA local.
This PR adds assignments as part of a `Call` or `Yield` terminator in that category.

This mainly allows to perform CopyProp on a call return place.

The only subtlety is in the dominance property: the assignment is only complete at the beginning of the target block.
2023-10-10 20:37:55 +00:00
Tomasz Miąsko
b61a6d59e4 Remove unused dominator iterator 2023-10-10 21:39:59 +02:00
Guillaume Gomez
100713ef08
Rollup merge of #116560 - ouz-a:efficient_ids, r=oli-obk
In smir use `FxIndexMap` to store indexed ids

Previously we used `vec` for storing indexed types, which is fine for small cases but will lead to huge performance issues when we use `smir` for real world cases.

Addresses https://github.com/rust-lang/project-stable-mir/issues/35

r? ``@oli-obk``
2023-10-10 18:44:46 +02:00
Guillaume Gomez
0e5e04b89a
Rollup merge of #116250 - estebank:closure-arg-inference-span, r=petrochenkov
On type error of closure call argument, point at earlier calls that affected inference

Mitigate part of  https://github.com/rust-lang/rust/issues/71209.

When we encounter a type error on a specific argument of a closure call argument, where the closure's definition doesn't have a type specified, look for other calls of the closure to try and find the specific call that cased that argument to be inferred of the expected type.

```
error[E0308]: mismatched types
  --> $DIR/unboxed-closures-type-mismatch.rs:30:18
   |
LL |         identity(1u16);
   |         -------- ^^^^ expected `u8`, found `u16`
   |         |
   |         arguments to this function are incorrect
   |
note: expected because the closure was earlier called with an argument of type `u8`
  --> $DIR/unboxed-closures-type-mismatch.rs:29:18
   |
LL |         identity(1u8);
   |         -------- ^^^ expected because this argument is of type `u8`
   |         |
   |         in this closure call
note: closure parameter defined here
  --> $DIR/unboxed-closures-type-mismatch.rs:28:25
   |
LL |         let identity = |x| x;
   |                         ^
help: change the type of the numeric literal from `u16` to `u8`
   |
LL |         identity(1u8);
   |                   ~~
```
2023-10-10 18:44:44 +02:00
bors
5b88d659f8 Auto merge of #116598 - matthiaskrgr:rollup-6xra4jx, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #116586 (use env variable to control thread ids in rustc_log)
 - #116589 (coverage: Unbox and simplify `bcb_filtered_successors`)
 - #116595 (-Zmir-enable-passes: document that this may enable unsound passes)
 - #116596 (reorder files in solve)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-10 13:29:09 +00:00
Matthias Krüger
da42858b14
Rollup merge of #116596 - lcnr:normalize-subdir, r=compiler-errors
reorder files in solve

r? `@compiler-errors`
2023-10-10 14:07:48 +02:00
Matthias Krüger
de4980cf44
Rollup merge of #116595 - RalfJung:mir-enable-passes, r=oli-obk
-Zmir-enable-passes: document that this may enable unsound passes

also add some comments explaining why MIR opts are marked as unsound
2023-10-10 14:07:48 +02:00
Matthias Krüger
f4de82c2b3
Rollup merge of #116589 - Zalathar:successors, r=oli-obk
coverage: Unbox and simplify `bcb_filtered_successors`

This is a small cleanup in the coverage instrumentor's graph-building code.

---
This function already has access to the MIR body, so instead of taking a reference to a terminator, it's simpler and easier to pass in a basic block index.

There is no need to box the returned iterator if we instead add appropriate lifetime captures, and make `short_circuit_preorder` generic over the type of iterator it expects.

We can also greatly simplify the function's implementation by observing that the only difference between its two cases is whether we take all of a BB's successors, or just the first one.

---

`@rustbot` label +A-code-coverage
2023-10-10 14:07:47 +02:00
Matthias Krüger
0bc5696dd9
Rollup merge of #116586 - SparrowLii:parallel_log, r=oli-obk
use env variable to control thread ids in rustc_log

Currently, when parallel rustc is enabled, even if the number of threads is 1, the thread ID will be included before all the logs.
E.g.
`WARN rustc_mir_build::thir::pattern::const_to_pat ...`
=>
`2:rustcWARN rustc_mir_build::thir::pattern::const_to_pat ...`
This makes the logs confusing and results in inconsistent UI test results for serial and parallel rustc. Therefore I think we should let users decide whether thread id information is needed through explicit control.
2023-10-10 14:07:47 +02:00
bors
061c33051a Auto merge of #116551 - RalfJung:nondet-nan, r=oli-obk
miri: make NaN generation non-deterministic

This implements the [LLVM semantics for NaN generation](https://llvm.org/docs/LangRef.html#behavior-of-floating-point-nan-values). I will soon submit an RFC to make this also officially the Rust semantics, but it has been our de-facto semantics for a long time so there's no reason Miri has to wait for that RFC. This PR just better aligns Miri with codegen.

This PR does that just for the operations that have MIR primitives; a future PR will adjust the intrinsics.
2023-10-10 11:42:27 +00:00
Oğuz Ağcayazı
0bcb058fb1 add new wrapper for FxIndexMap 2023-10-10 13:18:31 +03:00
lcnr
c70ef36f2c reorder files in solve 2023-10-10 09:55:22 +00:00
bors
5c37696f60 Auto merge of #116409 - Zalathar:span-extraction, r=oli-obk
coverage: Separate initial span extraction from span processing

One of the main subtasks of coverage instrumentation is looking through MIR to determine a list of source code spans that require coverage counters.

That task is in turn subdivided into a few main steps:
- Getting the initial spans from MIR statements/terminators
- Processing the list of spans to merge or truncate nearby spans as necessary
- Grouping the processed spans by their corresponding coverage graph node

---

This PR enforces a firmer separation between the first two steps (span extraction and span processing), which ends up slightly simplifying both steps, since they don't need to deal with state that is only meaningful for the other step.

---

`@rustbot` label +A-code-coverage
2023-10-10 09:55:15 +00:00
Ralf Jung
d805b265db add some comments explaining why MIR opts are marked as unsound 2023-10-10 11:17:27 +02:00
Ralf Jung
2de454637f -Zmir-enable-passes: document that this may enable unsound passes 2023-10-10 11:08:47 +02:00
bors
091bb74e7e Auto merge of #116548 - nnethercote:assert-long-condition, r=matthewjasper
Improve handling of assertion failures with very long conditions

It's not perfectly clear what the best behaviour is here, but I think this is an improvement.

r? `@matthewjasper`
cc `@m-ou-se`
2023-10-10 08:02:20 +00:00
Zalathar
5d629457fd coverage: Unbox and simplify bcb_filtered_successors
This function already has access to the MIR body, so instead of taking a
reference to a terminator, it's simpler and easier to pass in a basic block
index.

There is no need to box the returned iterator if we instead add appropriate
lifetime captures, since `short_circuit_preorder` is now generic over the type
of iterator it expects.

We can also greatly simplify the function's implementation by observing that
the only difference between its two cases is whether we take all of a BB's
successors, or just the first one.
2023-10-10 18:45:29 +11:00
Zalathar
f214497d22 coverage: Replace ShortCircuitPreorder with a single function
Instead of defining a named struct, we can use `std::iter::from_fn` and store
intermediate state in a closure.
2023-10-10 18:44:16 +11:00
bors
84d44dd1d8 Auto merge of #116366 - estebank:issue-103982, r=oli-obk
Suggest labeling block if `break` is in bare block

Fix #103982.
2023-10-10 06:04:08 +00:00
Nicholas Nethercote
b6b11c72c9 Rejig some top-level rustc_hir_pretty functions.
There are several that are unused and can be removed.

And there are some calls to `to_string`, which can be expressed more
nicely as a `foo_to_string` call, and then `to_string` need not be
`pub`. (This requires adding `pat_to_string`).
2023-10-10 14:08:12 +11:00
Zalathar
6c44425e98 coverage: Remove enum CoverageStatement
This enum was mainly needed to track the precise origin of a span in MIR, for
debug printing purposes. Since the old debug code was removed in #115962, we
can replace it with just the span itself.
2023-10-10 13:39:23 +11:00
Zalathar
4b471df25d coverage: Disconnect span extraction from CoverageSpansGenerator
By performal initial span extraction in a separate free function, we can remove
some accidental complexity from the main generator code.
2023-10-10 13:39:23 +11:00
Zalathar
972ab8863d coverage: Move initial MIR span extraction into a submodule 2023-10-10 13:39:23 +11:00
SparrowLii
2dcc828863 use env variable to control thread ids in rustc_log 2023-10-10 09:39:47 +08:00
Esteban Küber
d23dc2093c Account for macros 2023-10-09 22:48:10 +00:00
Nicholas Nethercote
7528fdc4c4 Don't escape_debug the condition of assert!.
The assertion in `assert-long-condition.rs` used to be fail like this, all on
one line:
```
thread 'main' panicked at 'assertion failed: 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18\n                                + 19 + 20 + 21 + 22 + 23 + 24 + 25 == 0', tests/ui/macros/assert-long-condition.rs:7:5
```
The `\n` and subsequent indent is because the condition is pretty-printed, and
the pretty-printer inserts a newline. Printing the newline in this way is
arguably reasonable given that the message appears within single quotes, which
is very similar to a string literal.

However, after the assertion printing improvements that were released in 1.73,
the assertion now fails like this:
```
thread 'main' panicked at tests/ui/macros/assert-long-condition.rs:7:5:
assertion failed: 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18\n                                + 19 + 20 + 21 + 22 + 23 + 24 + 25 == 0
```
Now that there are no single quotes around the pretty-printed condition, the
`\n` is quite strange.

This commit gets rid of the `\n`, by removing the `escape_debug` done on the
pretty-printed message. This results in the following:
```
thread 'main' panicked at tests/ui/macros/assert-long-condition.rs:7:5:
assertion failed: 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18
                                + 19 + 20 + 21 + 22 + 23 + 24 + 25 == 0
```
The overly-large indent is still strange, but that's a separate pretty-printing issue.

This change helps with #108341.
2023-10-10 09:08:11 +11:00
Antoni Boucher
06c5ac4761 Use IntoDynSyncSend 2023-10-09 17:13:35 -04:00
bors
59edd67056 Auto merge of #116497 - compiler-errors:impl-span, r=cjgillot
Extend `impl`'s `def_span` to include its where clauses

Typically, we highlight the def-span of an impl in a diagnostic due to either:
1. coherence error
2. trait evaluation cycle
3. invalid implementation of built-in trait

I find that an impl's where clauses are very often required to understanding why these errors come about, which is unfortunate since where clauses may be located on different lines and don't show up in the error. This PR expands the def-span of impls to include these where clauses.

r? cjgillot since you've touched this code a while back to make some spans shorter, but you can also reassign to wg-diagnostics or compiler if you're busy or have no strong opinions.
2023-10-09 21:03:41 +00:00
Antoni Boucher
2cbac9c636 Fix checks 2023-10-09 16:03:05 -04:00
Antoni Boucher
30290c8b41 Merge commit '11a0cceab966e5ff1058ddbcab5977e8a1d6d290' into subtree-update_cg_gcc_2023-10-09 2023-10-09 15:53:34 -04:00
Esteban Küber
daac011459 Suggest labeling block if break is in bare block
Fix #103982.
2023-10-09 19:24:05 +00:00
bjorn3
f0b5820fa5 Fix review comments 2023-10-09 18:39:43 +00:00
bjorn3
7f5af72e64 Remove interior mutability from CguReuseTracker 2023-10-09 18:39:43 +00:00
bjorn3
e9fa2ca6ad Remove cgu_reuse_tracker from Session
This removes a bit of global mutable state
2023-10-09 18:39:41 +00:00
bjorn3
3dfd9dfe7c Remove an LTO dependent cgu_reuse_tracker.set_actual_reuse call 2023-10-09 18:38:51 +00:00
bjorn3
6b9ee90c2c Reuse determine_cgu_reuse from cg_ssa in cg_clif 2023-10-09 18:38:50 +00:00
Matthias Krüger
ea5cac02e8
Rollup merge of #116556 - bjorn3:sync_cg_clif-2023-10-09, r=bjorn3
Sync rustc_codegen_cranelift

The highlights this time are improved simd and inline asm support, `is_x86_feature_detected!()` returning the actual cpu features when inline asm support is enabled and a couple of bug fixes.

r? ```@ghost```

```@rustbot``` label +A-codegen +A-cranelift +T-compiler +subtree-sync
2023-10-09 16:26:02 +02:00
Matthias Krüger
148f5c1bdf
Rollup merge of #116549 - DaniPopes:miropts-let-chains, r=oli-obk
Simplify some mir passes by using let chains
2023-10-09 16:26:02 +02:00
Matthias Krüger
2266e79421
Rollup merge of #116543 - ouz-a:crate_return_vec, r=oli-obk
In smir `find_crates` returns `Vec<Crate>` instead of `Option<Crate>`

Addresses https://github.com/rust-lang/project-stable-mir/issues/40

r? `@oli-obk`
2023-10-09 16:26:01 +02:00
Matthias Krüger
374c885f4a
Rollup merge of #116537 - gurry:116473-ice-sugg-overlap, r=compiler-errors
Fix suggestion span involving wrongly placed generic arg on variant

Fixes #116473

The span computation was wrong. It went from the end of the variant to the end of the (wrongly placed) args. However, the variant lived in a different expansion and this resulted in a nonsensical span that overlaps with another and thereby leads to the ICE.

In the fix I've changed span computation to not be based on the location of the variant, but purely on the location of the args. I simply extend the start of the args span 2 positions to the left and that includes the `::` and that's all we need apparently.

This approach produces a correct span regardless of which macro/expansion the args reside in and where the variant is.
2023-10-09 16:26:01 +02:00
Matthias Krüger
389747c41d
Rollup merge of #115882 - aliemjay:diag-name-region-1, r=compiler-errors
improve the suggestion of `generic_bound_failure`

- Fixes #115375
- suggest the bound in the correct scope: trait or impl header vs assoc item. See `tests/ui/suggestions/lifetimes/type-param-bound-scope.rs`
- don't suggest a lifetime name that conflicts with the other late-bound regions of the function:
```rust
type Inv<'a> = *mut &'a ();
fn check_bound<'a, T: 'a>(_: T, _: Inv<'a>) {}
fn test<'a, T>(_: &'a str, t: T, lt: Inv<'_>) { // suggests a new name `'a`
    check_bound(t, lt); //~ ERROR
}
```
2023-10-09 16:26:00 +02:00
Michael Goulet
592163fb71 Extend impl's def_span to include where clauses 2023-10-09 11:47:02 +00:00
Oğuz Ağcayazı
77df2cd9a5 spans are now indexmapped 2023-10-09 13:03:58 +03:00
Oğuz Ağcayazı
5f079dd2ff alloc id is indexmapped 2023-10-09 12:58:41 +03:00
Oğuz Ağcayazı
0f27c1b5b5 defids are indexmapped 2023-10-09 12:56:14 +03:00
bjorn3
169055f2ff Merge commit '81dc066758ec150b43822d4a0c84aae20fe10f40' into sync_cg_clif-2023-10-09 2023-10-09 08:52:46 +00:00
Oğuz Ağcayazı
4ff6e87a8c return crates instead of a crate 2023-10-09 10:33:23 +03:00
Ralf Jung
08deb0daed float-to-float casts also have non-deterministic NaN results 2023-10-09 08:30:34 +02:00
bors
093b9d5b29 Auto merge of #116533 - cjgillot:skip-trivial-mir, r=oli-obk
Do not run optimizations on trivial MIR.

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

The bug was introduced in https://github.com/rust-lang/rust/pull/110728, which put the check too early in the query chain.

cc `@oli-obk` `@ouz-a`
2023-10-09 06:00:23 +00:00
Ralf Jung
615d738abe ensure unary minus propagates NaN payloads exactly 2023-10-09 07:37:24 +02:00
DaniPopes
47ebffabb8
Simplify some mir passes by using let chains 2023-10-09 05:22:31 +02:00
Michael Howell
c6e6ecb1af rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
Gurinder Singh
23a3b9e449 Fix suggestion span involving wrongly placed generic arg on enum variants
When the variant and the (wrongly placed) args are at separate
source locations such as being in different macos or one in a macro and
the other somwhere outside of it, the arg spans we computed spanned
the entire distance between such locations and were hence invalid.
.
2023-10-09 08:04:00 +05:30
bors
1f48cbc3f8 Auto merge of #116096 - cjgillot:debuginfo-fndef-size, r=nikic
Make FnDef 1-ZST in LLVM debuginfo.

Discussed in https://rust-lang.zulipchat.com/#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/LLVM.20HEAD.20llvm.2Edbg.2Edeclare.2Falloca.20size.20mismatch

r? `@nikic`
2023-10-09 02:08:13 +00:00
bors
37fda989ea Auto merge of #116468 - nnethercote:rustc_serialize, r=Mark-Simulacrum
Streamline `rustc_serialize`

r? `@Mark-Simulacrum`
2023-10-09 00:03:52 +00:00
Rémy Rakic
13948747d0 consistency check for self-contained linking components CLI options
emit an error if components are both enabled and disabled on the CLI
2023-10-08 21:57:39 +00:00
Rémy Rakic
6f54cbf754 add IntoIterator impl for self-contained linking components 2023-10-08 21:57:39 +00:00
Rémy Rakic
5b9aa26401 implement opt out -Clink-self-contained=-linker
record both enabled and disabled components so that they can be merged
with the ones that the target spec will define
2023-10-08 21:57:39 +00:00
Rémy Rakic
2ce46f8e8c move single component parsing to dedicated function
this will prevent parsing when expecting more than a single component
to be parsed, and prepare for the symetric variant-to-name function to
be added
2023-10-08 21:57:39 +00:00
Rémy Rakic
acc3b61c5e move LinkSelfContainedComponents to rustc_target 2023-10-08 21:57:38 +00:00
Rémy Rakic
71285c1da0 prepare stabilization of modern linker-flavors
fix a few comments
2023-10-08 21:57:36 +00:00
Ralf Jung
6796c5765d miri: make NaN generation non-deterministic 2023-10-08 20:35:46 +02:00
Camille GILLOT
098fc9715e Make FnDef 1-ZST in LLVM debuginfo. 2023-10-08 16:42:45 +00:00
Camille GILLOT
37f080edbc Also consider call and yield as MIR SSA. 2023-10-08 16:05:26 +00:00
bors
bf9a1c8a19 Auto merge of #116515 - petrochenkov:nolegflavor, r=lqd
linker: Remove unstable legacy CLI linker flavors
2023-10-08 15:18:22 +00:00
bors
4f4a413fe6 Auto merge of #116454 - tmiasko:small-dominators, r=cjgillot
Generalize small dominators optimization

* Use small dominators optimization from 640ede7b0a more generally.
* Merge `DefLocation` and `LocationExtended` since they serve the same purpose.
2023-10-08 12:38:14 +00:00
Camille GILLOT
005ec2e51c Do not run optimizations on trivial MIR. 2023-10-08 12:09:06 +00:00
bors
1e3c8f196b Auto merge of #116183 - cjgillot:debug-dse-always, r=oli-obk
Always preserve DebugInfo in DeadStoreElimination.

This is a version of #106852 that does not check the current crate's debuginfo flag, and always attempts to preserve debuginfo.

I haven't figured out how to handle mixing debuginfo levels for std, the one for the test, and the one for the CI target just right to merge #106852, so this can at least fix the debuginfo issue.

Fixes https://github.com/rust-lang/rust/issues/103655
2023-10-08 10:50:33 +00:00
Ali MJ Al-Nasrawy
a8830631b9 remove trailing dots 2023-10-08 10:06:17 +00:00
Ali MJ Al-Nasrawy
996ffcb718 always show and explain sub region 2023-10-08 09:59:51 +00:00
Ali MJ Al-Nasrawy
5be0b2283a improve the suggestion of generic_bound_failure 2023-10-08 09:56:57 +00:00
Ali MJ Al-Nasrawy
710c073acb delay a bug when encountering an ambiguity in MIR typeck 2023-10-08 09:14:12 +00:00
bors
ab039f79b8 Auto merge of #116514 - petrochenkov:nogccld, r=lqd
linker: Remove `-Zgcc-ld` option

It is subsumed by `-Clinker-flavor=*-lld-cc -Clink-self-contained=+linker` options now.

r? `@lqd`
2023-10-08 09:04:57 +00:00
Vadim Petrochenkov
b563595c6e linker: Remove -Zgcc-ld option
It is subsumed by `-Clinker-flavor=*-lld-cc -Clink-self-contained=+linker` options now
2023-10-08 10:05:25 +03:00
bors
e08de86036 Auto merge of #116487 - tamird:avoid-unwrap-absolute, r=bjorn3
compiler: env/path handling fixes

Please see individual commits. r? `@bjorn3` cf. #116426
2023-10-08 05:24:16 +00:00
bors
1516ca1bc0 Auto merge of #116486 - van-ema:master, r=nikic
Fix to register analysis passes with -Zllvm-plugins at link-time

This PR fixes an unexpected behavior of the `-Zllvm-plugins` flag. It allows to run an out-of-tree pass as part of LTO.
However, analysis passes are registered before the plugin is loaded. As a result an analysis pass, which is passed as a plugin, is not registered. This causes the LLVM PassManager to fail when the analysis pass is queried from a transformation pass  [(here)](https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/IR/PassManager.h#L776).

This fix mimics the bahavior in [LLVM LTOBackend.cpp](https://github.com/llvm/llvm-project/blob/main/llvm/lib/LTO/LTOBackend.cpp#L273) by loading the plugin before the analysis passes are registered.

Tested with rustc 1.60 and 1.65 and LLVM-13.0.1.
2023-10-08 03:36:37 +00:00
bors
cf21a0823b Auto merge of #116437 - nnethercote:rustc_features, r=Nilstrieb
Clean up `rustc_features`

Plenty more to be done, but this is a decent start.

r? `@Nilstrieb`
2023-10-07 19:11:17 +00:00
Vadim Petrochenkov
7ecb09d05c linker: Remove unstable legacy CLI linker flavors 2023-10-07 21:57:53 +03:00
bors
935a091a78 Auto merge of #116330 - RalfJung:dont-key-on-allocid, r=oli-obk
remove Key impls for types that involve an AllocId

I don't understand how but somehow that leads to issues like https://github.com/rust-lang/rust/issues/83085? Anyway removing unused impls doesn't seem like a bad idea. The concerning part is that of course nothing will stop us from having such impls again in the future, alongside re-introducing bugs like #83085.

r? `@oli-obk`
2023-10-07 15:21:05 +00:00
bors
91db3bdc8c Auto merge of #116310 - Enselic:check_fn_args_move_size, r=oli-obk
rustc_monomorphize: Introduce check_fn_args_move_size()

This is in preparation of improving diagnostics of "large moves into functions", a.k.a. passing args.

Note: This PR consists of two self-contained commits that can be reviewed independently.

For https://github.com/rust-lang/rust/issues/83518

Also see https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/arg.20Spans.20for.20TerminatorKind.3A.3ACall.3F

r? `@oli-obk` who is E-mentor
2023-10-07 13:33:19 +00:00
bors
48e24629e9 Auto merge of #115583 - RalfJung:packed-unsized, r=lcnr
fix detecting references to packed unsized fields

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

This is a breaking change, but permitted as a soundness fix.
2023-10-07 10:57:18 +00:00
bors
d087c6fae2 Auto merge of #116457 - RalfJung:try_eval_scalar_int, r=cjgillot
fix fast-path for try_eval_scalar_int

Cc https://github.com/rust-lang/rust/pull/116281 `@Nadrieril`
2023-10-07 08:58:23 +00:00
Martin Nordholts
56e4715fc6 rustc_monomorphize: Introduce check_fn_args_move_size()
So that we later can improve the accuracy of diagnostics.
2023-10-07 10:29:37 +02:00
Martin Nordholts
41d24ccb49 rustc_monomorphize: Move limit check into check_move_size()
And rename to check_operand_move_size(). Later we will introduce
check_fn_args_move_size().
2023-10-07 10:29:16 +02:00
Scott McMurray
ae9cec5839 Copy 1-element arrays as scalars, not vectors
For `[T; 1]` it's silly to copy as `<1 x T>` when we can just copy as `T`.
2023-10-07 00:10:32 -07:00
Jubilee
0d68e416a5
Rollup merge of #116400 - estebank:issue-78585, r=WaffleLapkin
Detect missing `=>` after match guard during parsing

```
error: expected one of `,`, `:`, or `}`, found `.`
  --> $DIR/missing-fat-arrow.rs:25:14
   |
LL |         Some(a) if a.value == b {
   |                               - while parsing this struct
LL |             a.value = 1;
   |             -^ expected one of `,`, `:`, or `}`
   |             |
   |             while parsing this struct field
   |
help: try naming a field
   |
LL |             a: a.value = 1;
   |             ++
help: you might have meant to start a match arm after the match guard
   |
LL |         Some(a) if a.value == b => {
   |                                 ++
```

Fix #78585.
2023-10-06 16:37:47 -07:00
Jubilee
6d1c3a40cb
Rollup merge of #116277 - RalfJung:post-mono, r=oli-obk
dont call mir.post_mono_checks in codegen

It seems like all tests are still passing when I remove this... let's see what CI says.
2023-10-06 16:37:46 -07:00
bors
960754090a Auto merge of #116492 - matthiaskrgr:rollup-xzfhmq1, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #114564 (Attempt to describe the intent behind the `From` trait further)
 - #116297 (add some docs to hooks/mod.rs)
 - #116423 (Fix typo in attrs.rs)
 - #116466 (`rustc_transmute` cleanups)
 - #116474 (Assorted small cleanups)
 - #116481 (Reuse existing `Some`s in `Option::(x)or`)
 - #116484 (Minor doc clarification in Once::call_once)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-06 20:51:40 +00:00
Matthias Krüger
9796dfdd56
Rollup merge of #116474 - nnethercote:rustc_assorted, r=spastorino
Assorted small cleanups

r? `@spastorino`
2023-10-06 21:17:50 +02:00
Matthias Krüger
25fbd133ea
Rollup merge of #116466 - nnethercote:rustc_transmute, r=oli-obk
`rustc_transmute` cleanups

Just some things I found while poking around this code.

r? `@oli-obk`
2023-10-06 21:17:49 +02:00
Matthias Krüger
fdb136a83f
Rollup merge of #116297 - RalfJung:hooks, r=oli-obk
add some docs to hooks/mod.rs

r? `@oli-obk`
2023-10-06 21:17:48 +02:00
bors
94bc9c737e Auto merge of #114811 - estebank:impl-ambiguity, r=wesleywiser
Show more information when multiple `impl`s apply

- When there are `impl`s without type params, show only those (to avoid showing overly generic `impl`s).
```
error[E0283]: type annotations needed
  --> $DIR/multiple-impl-apply.rs:34:9
   |
LL |     let y = x.into();
   |         ^     ---- type must be known at this point
   |
note: multiple `impl`s satisfying `_: From<Baz>` found
  --> $DIR/multiple-impl-apply.rs:14:1
   |
LL | impl From<Baz> for Bar {
   | ^^^^^^^^^^^^^^^^^^^^^^
...
LL | impl From<Baz> for Foo {
   | ^^^^^^^^^^^^^^^^^^^^^^
   = note: required for `Baz` to implement `Into<_>`
help: consider giving `y` an explicit type
   |
LL |     let y: /* Type */ = x.into();
   |          ++++++++++++
```

- Lower the importance of `T: Sized`, `T: WellFormed` and coercion errors, to prioritize more relevant errors. The pre-existing deduplication logic deals with hiding redundant errors better that way, and we show errors with more metadata that is useful to the user.

- Show `<SelfTy as Trait>::assoc_fn` suggestion in more cases.
```
error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
  --> $DIR/cross-return-site-inference.rs:38:16
   |
LL |     return Err(From::from("foo"));
   |                ^^^^^^^^^^ cannot call associated function of trait
   |
help: use a fully-qualified path to a specific available implementation
   |
LL |     return Err(</* self type */ as From>::from("foo"));
   |                +++++++++++++++++++     +
```

Fix #88284.
2023-10-06 18:44:32 +00:00
Ralf Jung
fa248cd9e6 add some comments explaining how the required_consts stuff fits together 2023-10-06 18:25:23 +02:00
Camille GILLOT
27d6a57e58 Preserve DebugInfo in DeadStoreElimination. 2023-10-06 15:46:11 +00:00
bors
64fa0c34d7 Auto merge of #115304 - Enselic:trailing-gt, r=cjgillot
Allow file names to end with '>'

The [`rustc_span::FileName`](https://doc.rust-lang.org/stable/nightly-rustc/rustc_span/enum.FileName.html) enum already differentiates between real files and "fake" files such as `<anon>`. We do not need to artificially forbid real file names from ending in `>`.

Closes #73419
2023-10-06 14:57:09 +00:00