Commit Graph

230398 Commits

Author SHA1 Message Date
Matthias Krüger
ba6982b8a0
Rollup merge of #114060 - davidtwco:issue-113279, r=wesleywiser
abi: unsized field in union - assert to delay bug

Fixes #113279.

> Unions cannot have unsized fields, and as such, layout computation for
unions asserts that each union field is sized (as this would normally
have halted compilation earlier).
>
> However, if a generator ends up with an unsized local - a circumstance
in which an error will always have been emitted earlier, for example, if
attempting to dereference a `&str` - then the generator transform will
produce a union with an unsized field.
>
> Since https://github.com/rust-lang/rust/pull/110107, later passes will be run, such as constant propagation,
and can attempt layout computation on the generator, which will result
in layout computation of `str` in the context of it being a field of a
union - and so the aforementioned assertion would cause an ICE.
>
> It didn't seem appropriate to try and detect this case in the MIR body
and skip this specific pass; tainting the MIR body or delaying a bug
from the generator transform (or elsewhere) wouldn't prevent this either
(as neither would prevent the later pass from running); and tainting when
the deref of `&str` is reported, if that's possible, would unnecessarily
prevent potential other errors from being reported later in compilation,
and is very tailored to this specific case of getting a unsized type in
a generator.
>
> Given that this circumstance can only happen when an error should have
already been reported, the correct fix appears to be just changing the
assert to a delayed bug. This will still assert if there is some
circumstance where this occurs and no error has been reported, but it
won't crash the compiler in this instance.

While debugging this, I noticed a translation ICE in a delayed bug, so I fixed that too:

> During borrowck, the `MultiSpan` from a buffered diagnostic is cloned and
used to emit a delayed bug indicating a diagnostic was buffered - when
the buffered diagnostic is translated, then the cloned `MultiSpan` may
contain labels which can only render with the diagnostic's arguments, but
the delayed bug being emitted won't have those arguments. Adds a function
which clones `MultiSpan` without also cloning the contained labels, and
use this function when creating the buffered diagnostic delayed bug.
2023-07-25 19:21:39 +02:00
Matthias Krüger
de5228e489
Rollup merge of #114058 - chenyukang:yukang-fix-113981-crate-arg, r=fmease,oli-obk
Add help for crate arg when crate name is invalid

Fixes #113981
2023-07-25 19:21:38 +02:00
Matthias Krüger
b7a1ff2aaa
Rollup merge of #114052 - clubby789:suggest-option-asref, r=WaffleLapkin
Suggest `{Option,Result}::as_ref()` instead of `cloned()` in some cases

Fixes #114050

When we have an expr available that produces the type expectation, we can suggest appending `.as_ref()` to the span, instead of cloning the expr producing the mismatch
2023-07-25 19:21:38 +02:00
Matthias Krüger
99f404aa73
Rollup merge of #114051 - Enselic:const-local-var, r=cjgillot
Add regression test for invalid "unused const" in method

The warning can be reproduced with 1.63 but not with 1.64.

    $ rustc +1.63 tests/ui/lint/unused/const-local-var.rs
    warning: constant `F` is never used
      --> tests/ui/lint/unused/const-local-var.rs:14:9
       |
    14 |         const F: i32 = 2;
       |         ^^^^^^^^^^^^^^^^^
       |
       = note: `#[warn(dead_code)]` on by default
    $ rustc +1.64 tests/ui/lint/unused/const-local-var.rs

Add a regression test to prevent the problem from re-appearing.

Closes #69016
2023-07-25 19:21:38 +02:00
Matthias Krüger
91d1d7aa44
Rollup merge of #114043 - cathaysia:doc_lazy_lock, r=thomcc
docs(LazyLock): add example pass local LazyLock variable to struct
2023-07-25 19:21:37 +02:00
Matthias Krüger
8ecaf2ae57
Rollup merge of #114014 - davidtwco:issue-114010-env-rawstr, r=cjgillot
builtin_macros: expect raw strings too

Fixes #114010.

`expr_to_string` allows raw strings through so this code should be expected to handle those.
2023-07-25 19:21:37 +02:00
Matthias Krüger
24e34e2014
Rollup merge of #114008 - Zalathar:covfun-section-name, r=cjgillot
coverage: Obtain the `__llvm_covfun` section name outside a per-function loop

This section name is always constant for a given target, but obtaining it from LLVM requires a few intermediate allocations. There's no need to do so repeatedly from inside a per-function loop.
2023-07-25 19:21:36 +02:00
yukang
e0c479eea2 Add help for crate arg when crate name is invalid 2023-07-26 00:05:00 +08:00
David Wood
037b27430b
abi: unsized field in union - assert to delay bug
Unions cannot have unsized fields, and as such, layout computation for
unions asserts that each union field is sized (as this would normally
have halted compilation earlier).

However, if a generator ends up with an unsized local - a circumstance
in which an error will always have been emitted earlier, for example, if
attempting to dereference a `&str` - then the generator transform will
produce a union with an unsized field.

Since #110107, later passes will be run, such as constant propagation,
and can attempt layout computation on the generator, which will result
in layout computation of `str` in the context of it being a field of a
union - and so the aforementioned assertion would cause an ICE.

It didn't seem appropriate to try and detect this case in the MIR body
and skip this specific pass; tainting the MIR body or delaying a bug
from the generator transform (or elsewhere) wouldn't prevent this either
(as neither would prevent the later pass from running); and tainting when
the deref of `&str` is reported, if that's possible, would unnecessarily
prevent potential other errors from being reported later in compilation,
and is very tailored to this specific case of getting a unsized type in
a generator.

Given that this circumstance can only happen when an error should have
already been reported, the correct fix appears to be just changing the
assert to a delayed bug. This will still assert if there is some
circumstance where this occurs and no error has been reported, but it
won't crash the compiler in this instance.

Signed-off-by: David Wood <david@davidtw.co>
2023-07-25 15:50:39 +01:00
bors
4fc6b33474 Auto merge of #114011 - RalfJung:place-projection, r=oli-obk
interpret: Unify projections for MPlaceTy, PlaceTy, OpTy

For ~forever, we didn't really have proper shared code for handling projections into those three types. This is mostly because `PlaceTy` projections require `&mut self`: they might have to `force_allocate` to be able to represent a project part-way into a local.

This PR finally fixes that, by enhancing `Place::Local` with an `offset` so that such an optimized place can point into a part of a place without having requiring an in-memory representation. If we later write to that place, we will still do `force_allocate` -- for now we don't have an optimized path in `write_immediate` that would avoid allocation for partial overwrites of immediately stored locals. But in `write_immediate` we have `&mut self` so at least this no longer pollutes all our type signatures.

(Ironically, I seem to distantly remember that many years ago, `Place::Local` *did* have an `offset`, and I removed it to simplify things. I guess I didn't realize why it was so useful... I am also not sure if this was actually used to achieve place projection on `&self` back then.)

The `offset` had type `Option<Size>`, where `None` represent "no projection was applied". This is needed because locals *can* be unsized (when they are arguments) but `Place::Local` cannot store metadata: if the offset is `None`, this refers to the entire local, so we can use the metadata of the local itself (which must be indirect); if a projection gets applied, since the local is indirect, it will turn into a `Place::Ptr`. (Note that even for indirect locals we can have `Place::Local`: when the local appears in MIR, we always start with `Place::Local`, and only check `frame.locals` later. We could eagerly normalize to `Place::Ptr` but I don't think that would actually simplify things much.)

Having done all that, we can finally properly abstract projections: we have a new `Projectable` trait that has the basic methods required for projecting, and then all projection methods are implemented for anything that implements that trait. We can even implement it for `ImmTy`! (Not that we need that, but it seems neat.) The visitor can be greatly simplified; it doesn't need its own trait any more but it can use the `Projectable` trait. We also don't need the separate `Mut` visitor any more; that was required only to reflect that projections on `PlaceTy` needed `&mut self`.

It is possible that there are some more `&mut self` that can now become `&self`... I guess we'll notice that over time.

r? `@oli-obk`
2023-07-25 14:18:08 +00:00
clubby789
c83dfe9aed Suggest {Option,Result}::as_ref() instead of cloned() in some cases 2023-07-25 13:19:27 +00:00
Ralf Jung
d127600511 add some sanity checks in write_immediate_no_validate 2023-07-25 14:30:58 +02:00
Ralf Jung
4ea2bd1c8f bless more 2023-07-25 14:30:58 +02:00
Ralf Jung
14a674c88c interpret: read_discriminant: only return VariantIdx 2023-07-25 14:30:58 +02:00
Ralf Jung
a2bcafa500 interpret: refactor projection code to work on a common trait, and use that for visitors 2023-07-25 14:30:58 +02:00
bors
23405bb123 Auto merge of #113476 - fee1-dead-contrib:c-str-lit, r=petrochenkov
Reimplement C-str literals

This reverts #113334, cc `@fmease.`

While converting lexer tokens to ast Tokens in `rustc_parse`, we check the edition of the span of the token. If the edition < 2021, we split the token into two, one being the identifier and other being the str literal.
2023-07-25 12:04:34 +00:00
David Wood
516a56581e
clippy: env! invocations can't be b"" literals
Signed-off-by: David Wood <david@davidtw.co>
2023-07-25 11:56:54 +01:00
Martin Nordholts
5d32fd1b06 Add regression test for invalid unused const in method
The warning can be reproduced with 1.63 but not with 1.64.

    $ rustc +1.63 tests/ui/lint/unused/const-local-var.rs
    warning: constant `F` is never used
      --> tests/ui/lint/unused/const-local-var.rs:14:9
       |
    14 |         const F: i32 = 2;
       |         ^^^^^^^^^^^^^^^^^
       |
       = note: `#[warn(dead_code)]` on by default
    $ rustc +1.64 tests/ui/lint/unused/const-local-var.rs

Add a regression test to prevent the problem from re-appearing.
2023-07-25 12:49:19 +02:00
David Wood
75df62d4a2
builtin_macros: raw str in diagnostic output
If a raw string was used in the `env!` invocation, then it should also
be shown in the diagnostic messages as a raw string.

Signed-off-by: David Wood <david@davidtw.co>
2023-07-25 11:12:52 +01:00
Deadbeef
a0376e9ec2 extract common code 2023-07-25 09:24:12 +00:00
bors
ff8fe76c0e Auto merge of #112646 - vn971:document-thread-names-for-sgx-target, r=m-ou-se
Document thread names for SGX compilation target

`@raoulstrackx` `@Mkaynov` `@jethrogb`
2023-07-25 09:14:11 +00:00
bors
c026d6a400 Auto merge of #114020 - steffahn:hide-specialized-ToString-impls, r=thomcc
Hide `ToString` implementations that specialize the default one

The status quo is highly confusing, since the overlap is not apparent, and specialization is not a feature of Rust. This change addresses #87545; I'm not certain if it closes/fixes it entirely, since that issue might also be tracking the question of a *general* solution for hiding the documentation for specializing impls automatically.

Before
![Screenshot_20230724_234210](https://github.com/rust-lang/rust/assets/3986214/54bbe659-1790-4e95-a5d8-5426e710ceb8)

After
![Screenshot_20230724_234255](https://github.com/rust-lang/rust/assets/3986214/ee645d6e-c1c0-40c0-a0d3-a5c5f3dae65e)
2023-07-25 07:31:15 +00:00
bors
5b1dc9de77 Auto merge of #113980 - bvanjoi:fix-113953, r=petrochenkov
fix(resolve): skip panic when resolution is dummy

Fixes #113953

Skip the panic when the binding refers to a dummy node during the finalization.

r? `@petrochenkov`
2023-07-25 05:25:11 +00:00
DragonBillow
40dd5a337c
docs(LazyLock): add example pass local LazyLock variable to struct
Signed-off-by: DragonBillow <DragonBillow@outlook.com>
2023-07-25 12:21:30 +08:00
bors
d24c4da1d6 Auto merge of #113411 - unikraft:unikraft, r=wesleywiser
Add `x86_64-unikraft-linux-musl` target

This introduces `x86_64-unikraft-linux-musl` as the first Rust target for the [Unikraft] Unikernel Development Kit.

[Unikraft]: https://unikraft.org/

Unikraft imitates Linux and uses musl as libc.
It is extremely configurable, and does not even provide a `poll` implementation or a network stack, unless enabled by the end user who compiles the application.

Our approach for integrating the build process with `rustc` is to hide the build process as well as the actual final linking step behind a linker-shim (`kraftld`, see https://github.com/unikraft/kraftkit/issues/612).

## Tier 3 target policy

> - A tier 3 target must have a designated developer or developers (the "target
>   maintainers") on record to be CCed when issues arise regarding the target.
>   (The mechanism to track and CC such developers may evolve over time.)

I will be the target maintainer.

> - Targets must use naming consistent with any existing targets; for instance, a
>   target for the same CPU or OS as an existing Rust target should use the same
>   name for that CPU or OS. Targets should normally use the same names and
>   naming conventions as used elsewhere in the broader ecosystem beyond Rust
>   (such as in other toolchains), unless they have a very good reason to
>   diverge. Changing the name of a target can be highly disruptive, especially
>   once the target reaches a higher tier, so getting the name right is important
>   even for a tier 3 target.
>   - Target names should not introduce undue confusion or ambiguity unless
>     absolutely necessary to maintain ecosystem compatibility. For example, if
>     the name of the target makes people extremely likely to form incorrect
>     beliefs about what it targets, the name should be changed or augmented to
>     disambiguate it.
>   - If possible, use only letters, numbers, dashes and underscores for the name.
>     Periods (`.`) are known to cause issues in Cargo.

The target name `x86_64-unikraft-linux-musl` was derived from `x86_64-unknown-linux-musl`, setting Unikraft as vendor.
Unikraft exactly imitates Linux + musl.

> - Tier 3 targets may have unusual requirements to build or use, but must not
>   create legal issues or impose onerous legal terms for the Rust project or for
>   Rust developers or users.
>   - The target must not introduce license incompatibilities.
>   - Anything added to the Rust repository must be under the standard Rust
>     license (`MIT OR Apache-2.0`).
>   - The target must not cause the Rust tools or libraries built for any other
>     host (even when supporting cross-compilation to the target) to depend
>     on any new dependency less permissive than the Rust licensing policy. This
>     applies whether the dependency is a Rust crate that would require adding
>     new license exceptions (as specified by the `tidy` tool in the
>     rust-lang/rust repository), or whether the dependency is a native library
>     or binary. In other words, the introduction of the target must not cause a
>     user installing or running a version of Rust or the Rust tools to be
>     subject to any new license requirements.
>   - Compiling, linking, and emitting functional binaries, libraries, or other
>     code for the target (whether hosted on the target itself or cross-compiling
>     from another target) must not depend on proprietary (non-FOSS) libraries.
>     Host tools built for the target itself may depend on the ordinary runtime
>     libraries supplied by the platform and commonly used by other applications
>     built for the target, but those libraries must not be required for code
>     generation for the target; cross-compilation to the target must not require
>     such libraries at all. For instance, `rustc` built for the target may
>     depend on a common proprietary C runtime library or console output library,
>     but must not depend on a proprietary code generation library or code
>     optimization library. Rust's license permits such combinations, but the
>     Rust project has no interest in maintaining such combinations within the
>     scope of Rust itself, even at tier 3.
>   - "onerous" here is an intentionally subjective term. At a minimum, "onerous"
>     legal/licensing terms include but are *not* limited to: non-disclosure
>     requirements, non-compete requirements, contributor license agreements
>     (CLAs) or equivalent, "non-commercial"/"research-only"/etc terms,
>     requirements conditional on the employer or employment of any particular
>     Rust developers, revocable terms, any requirements that create liability
>     for the Rust project or its developers or users, or any requirements that
>     adversely affect the livelihood or prospects of the Rust project or its
>     developers or users.

No dependencies were added to Rust.
Requirements for linking are [Unikraft] and [KraftKit] (both BSD-3-Clause), but none of these are added to Rust.

[KraftKit]: https://github.com/unikraft/kraftkit

> - Neither this policy nor any decisions made regarding targets shall create any
>   binding agreement or estoppel by any party. If any member of an approving
>   Rust team serves as one of the maintainers of a target, or has any legal or
>   employment requirement (explicit or implicit) that might affect their
>   decisions regarding a target, they must recuse themselves from any approval
>   decisions regarding the target's tier status, though they may otherwise
>   participate in discussions.
>   - This requirement does not prevent part or all of this policy from being
>     cited in an explicit contract or work agreement (e.g. to implement or
>     maintain support for a target). This requirement exists to ensure that a
>     developer or team responsible for reviewing and approving a target does not
>     face any legal threats or obligations that would prevent them from freely
>     exercising their judgment in such approval, even if such judgment involves
>     subjective matters or goes beyond the letter of these requirements.

Understood.
I am not a member of a Rust team.

> - Tier 3 targets should attempt to implement as much of the standard libraries
>   as possible and appropriate (`core` for most targets, `alloc` for targets
>   that can support dynamic memory allocation, `std` for targets with an
>   operating system or equivalent layer of system-provided functionality), but
>   may leave some code unimplemented (either unavailable or stubbed out as
>   appropriate), whether because the target makes it impossible to implement or
>   challenging to implement. The authors of pull requests are not obligated to
>   avoid calling any portions of the standard library on the basis of a tier 3
>   target not implementing those portions.

Understood.
`std` is supported.

> - The target must provide documentation for the Rust community explaining how
>   to build for the target, using cross-compilation if possible. If the target
>   supports running binaries, or running tests (even if they do not pass), the
>   documentation must explain how to run such binaries or tests for the target,
>   using emulation if possible or dedicated hardware if necessary.

Building is described in the platform support doc.
It will be updated once proper `kraftld` support has landed.

> - Tier 3 targets must not impose burden on the authors of pull requests, or
>   other developers in the community, to maintain the target. In particular,
>   do not post comments (automated or manual) on a PR that derail or suggest a
>   block on the PR based on a tier 3 target. Do not send automated messages or
>   notifications (via any medium, including via ``@`)` to a PR author or others
>   involved with a PR regarding a tier 3 target, unless they have opted into
>   such messages.
>   - Backlinks such as those generated by the issue/PR tracker when linking to
>     an issue or PR are not considered a violation of this policy, within
>     reason. However, such messages (even on a separate repository) must not
>     generate notifications to anyone involved with a PR who has not requested
>     such notifications.

Understood.

> - Patches adding or updating tier 3 targets must not break any existing tier 2
>   or tier 1 target, and must not knowingly break another tier 3 target without
>   approval of either the compiler team or the maintainers of the other tier 3
>   target.
>   - In particular, this may come up when working on closely related targets,
>     such as variations of the same architecture with different features. Avoid
>     introducing unconditional uses of features that another variation of the
>     target may not have; use conditional compilation or runtime detection, as
>     appropriate, to let each target run code supported by that target.

I don't think this PR breaks anything.

r? compiler-team
2023-07-25 03:41:56 +00:00
bors
beef07fe8f Auto merge of #113958 - lukas-code:doc-links, r=GuillaumeGomez,petrochenkov
fix intra-doc links on nested `use` and `extern crate` items

This PR fixes two rustdoc ICEs that happen if there are any intra-doc links on nested `use` or `extern crate` items, for example:
```rust
/// Re-export [`fmt`] and [`io`].
pub use std::{fmt, io}; // "nested" use = use with braces

/// Re-export [`std`].
pub extern crate std;
```

Nested use items were incorrectly considered private and therefore didn't have their intra-doc links resolved. I fixed this by always resolving intra-doc links for nested `use` items that are declared `pub`.

<details>

During AST->HIR lowering, nested `use` items are desugared like this:
```rust
pub use std::{}; // "list stem"
pub use std::fmt;
pub use std::io;
```
Each of these HIR nodes has it's own effective visibility and the list stem is always considered private.
To check the effective visibility of an AST node, the AST node is mapped to a HIR node with `Resolver::local_def_id`, which returns the (private) list stem for nested use items.

</details>

For `extern crate`, there was a hack in rustdoc that stored the `DefId` of the crate itself in the cleaned item, instead of the `DefId` of the `extern crate` item. This made rustdoc look at the resolved links of the extern crate's crate root instead of the `extern crate` item. I've removed this hack and instead translate the `DefId` in the appropriate places.

As as side effect of fixing `extern crate`, i've turned
```rust
#[doc(masked)]
extern crate self as _;
```
into a no-op instead of hiding all trait impls. Proper verification for `doc(masked)` is included as a bonus.

fixes https://github.com/rust-lang/rust/issues/113896
2023-07-25 01:35:53 +00:00
bors
1821920cc8 Auto merge of #111362 - mj10021:issue-74838-update, r=cuviper
delete [allow(unused_unsafe)] from issue #74838

While looking into issue #111288 I noticed the following `#[allow(...)]` with a `FIXME` asking for it to be removed.  Deleting the `#[allow(...)]` does not seem to break anything, it seems like the lint has been updated for unsafe blocks in macros?
2023-07-24 23:20:05 +00:00
James Dietz
db4a153440 remove additional [allow(unused_unsafe)] 2023-07-24 17:56:38 -04:00
bors
31395ec382 Auto merge of #113687 - saethlin:inline-assertion-helpers, r=cuviper
Add #[inline] to core debug assertion helpers

These functions are called a lot and not inlined by default in a dev compiler. Adding `#[inline]` should improve things in a dev workflow and be irrelevant in the distributed library.
2023-07-24 21:29:35 +00:00
James Dietz
fe0ef9a689 delete [allow(...)] from issue #74838 2023-07-24 16:32:32 -04:00
bors
fd56162af0 Auto merge of #113921 - davidtwco:lint-ctypes-issue-113900, r=petrochenkov
lint/ctypes: only try normalize

Fixes #113900.

Now that this lint runs on any external-ABI fn-ptr, normalization won't always succeed, so use `try_normalize_erasing_regions` instead.
2023-07-24 19:40:01 +00:00
bohan
4cc3834a5c resolve: ensure compile failed when has dummy or ambiguous 2023-07-25 01:57:12 +08:00
bohan
02f1f6a8a8 fix(resolve): skip panic when resolution is dummy 2023-07-25 01:34:03 +08:00
bors
fc8a3e357a Auto merge of #114024 - matthiaskrgr:rollup-uhdbq64, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #113969 (add dynamic for smir)
 - #113985 (Use erased self type when autoderefing for trait error suggestion)
 - #113987 (Comment stuff in the new solver)
 - #113992 (arm-none fixups)
 - #113993 (Optimize format usage)
 - #113994 (Optimize format usage)
 - #114006 (Update sparc-unknown-none-elf platform README)
 - #114021 (Add missing documentation for `Session::time`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-24 17:13:24 +00:00
Martin Kröning
553804754a
unix::init: Don't use signal on Unikraft.
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2023-07-24 18:25:30 +02:00
Martin Kröning
7485e9c965
unix::init: Handle ENOSYS from poll on Unikraft.
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2023-07-24 18:25:30 +02:00
Martin Kröning
2b8a284d78
bootstrap: Don't bundle musl on Unikraft
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2023-07-24 18:25:30 +02:00
Martin Kröning
71ad5587a1
compiler: Add *-unikraft-linux-musl documentation
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2023-07-24 18:25:24 +02:00
Martin Kröning
bb77aa845b
compiler: Add x86_64-unikraft-linux-musl target
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2023-07-24 18:24:50 +02:00
Lukas Markeffsky
637ea3f746 validate doc(masked) 2023-07-24 18:04:35 +02:00
Matthias Krüger
a5164252ad
Rollup merge of #114021 - GuillaumeGomez:session-time-docs, r=lcnr
Add missing documentation for `Session::time`

r? `@lcnr`
2023-07-24 17:47:11 +02:00
Matthias Krüger
4ee3266da6
Rollup merge of #114006 - jonathanpallant:update-sparc-unknown-readme, r=Amanieu
Update sparc-unknown-none-elf platform README

Cherry picked a couple of commits that didn't quite make it in #113535
2023-07-24 17:47:11 +02:00
Matthias Krüger
3723b309c0
Rollup merge of #113994 - nyurik:parser-fmt-ref, r=davidtwco
Optimize format usage

Per #112156, using `&` in `format!` may cause a small perf delay, so I tried to clean up one module at a time format usage. This PR includes a few removals of the ref in format (they do compile locally without the ref), as well as a few format inlining for consistency.
2023-07-24 17:47:10 +02:00
Matthias Krüger
974a1c242f
Rollup merge of #113993 - nyurik:ref_format_errors, r=WaffleLapkin
Optimize format usage

Per #112156, using `&` in `format!` may cause a small perf delay, so I tried to clean up one module at a time format usage. This PR includes a few removals of the ref in format (they do compile locally without the ref), as well as a few format inlining for consistency.
2023-07-24 17:47:10 +02:00
Matthias Krüger
4d2f98d306
Rollup merge of #113992 - chrisnc:arm-none-fixups, r=oli-obk
arm-none fixups

- Remove "-unknown" from `llvm_target` for arm\*v7r-none-eabi\* targets.
- Remove redundant `c_enum_min_bits` option from the thumbv4t-none-eabi target.
- Fix comments about GCC/Clang's enum width for arm-none targets.

Previously part of #110482, which is a larger change to add a new target.
These nits were found along the way.
2023-07-24 17:47:09 +02:00
Matthias Krüger
2660d5d977
Rollup merge of #113987 - compiler-errors:comments, r=lcnr
Comment stuff in the new solver

r? `@lcnr`
2023-07-24 17:47:09 +02:00
Matthias Krüger
15c723433f
Rollup merge of #113985 - compiler-errors:issue-113951, r=estebank
Use erased self type when autoderefing for trait error suggestion

Let's not try to pass something from `skip_binder` into autoderef.

Fixes #113951
2023-07-24 17:47:08 +02:00
Matthias Krüger
60a5d2dbde
Rollup merge of #113969 - ericmarkmartin:smir-ty-dynamic, r=spastorino
add dynamic for smir

r? spastorino
2023-07-24 17:47:08 +02:00
Michael Goulet
3ad3bb64d9
lcnr's suggestions
Co-authored-by: lcnr <rust@lcnr.de>
2023-07-24 08:37:40 -07:00
bors
cb6ab9516b Auto merge of #113956 - fmease:rustdoc-fix-x-crate-rpitits, r=GuillaumeGomez,compiler-errors
rustdoc: handle cross-crate RPITITs correctly

Filter out the internal associated types synthesized during the desugaring of RPITITs, they really shouldn't show up in the docs.

This also fixes #113929 since we're no longer invoking `is_impossible_associated_item` (renamed from `is_impossible_method`) which cannot handle them (leading to an ICE). I don't think it makes sense to try to make `is_impossible_associated_item` handle this exotic kind of associated type (CC original author `@compiler-errors).`

@ T-rustdoc reviewers, currently I'm throwing out ITIT assoc tys before cleaning assoc tys at each usage-site. I'm thinking about making `clean_middle_assoc_item` return an `Option<_>` instead and doing the check inside of it to prevent any call sites from forgetting the check for ITITs. Since I wasn't sure if you would like that approach, I didn't go through with it. Let me know what you think.

<details><summary>Explanation on why <code>is_impossible_associated_item(itit_assoc_ty)</code> leads to an ICE</summary>

Given the following code:

```rs
pub trait Trait { fn def<T>() -> impl Default {} }
impl Trait for () {}
```

The generated associated type looks something like (simplified):

```rs
type {opaque#0}<T>: Default = impl Default; // the name is actually `kw::Empty` but this is the `def_path_str` repr
```

The query `is_impossible_associated_item` goes through all predicates of the associated item – in this case `<T as Sized>` – to check if they contain any generic parameters from the (generic) associated type itself. For predicates that don't contain any *own* generics, it does further processing, part of which is instantiating the predicate with the generic arguments of the impl block (which is only correct if they truly don't contain any own generics since they wouldn't get instantiated this way leading to an ICE).

It checks if `parent_def_id(T) == assoc_ty_def_id` to get to know if `T` is owned by the assoc ty. Unfortunately this doesn't work for ITIT assoc tys. In this case, the parent of `T` is `Trait::def` (!) which is the associated function (I'm pretty sure this is very intentional) which is of course not equal to the assoc ty `Trait::{opaque#0}`.

</details>

`@rustbot` label A-cross-crate-reexports
2023-07-24 15:19:00 +00:00