Commit Graph

36007 Commits

Author SHA1 Message Date
Urgau
05f77d1b79 Update unexpected_cfgs lint for Cargo new check-cfg config 2024-05-16 20:58:22 +02:00
Matthias Krüger
e3864db418
Rollup merge of #125172 - tgross35:f16-f128-as-casting, r=compiler-errors
Fix assertion when attempting to convert `f16` and `f128` with `as`

These types are currently rejected for `as` casts by the compiler. Remove this incorrect check and add codegen tests for all conversions involving these types.
2024-05-16 16:22:46 +02:00
Matthias Krüger
a8a3117041
Rollup merge of #125170 - compiler-errors:uplift-fn-sig-2, r=lcnr
Uplift `FnSig` into `rustc_type_ir` (redux)

Since the last one got so messed up with `try` build.

https://github.com/rust-lang/rust/pull/125157#issuecomment-2113158408

r? lcnr
2024-05-16 16:22:46 +02:00
Michael Goulet
d3e510eb9d Don't ICE because recomputing overflow goals during find_best_leaf_obligation causes inference side-effects 2024-05-16 10:00:11 -04:00
Michael Goulet
312ba4da3c Uplift FnSig 2024-05-16 09:52:01 -04:00
Trevor Gross
488ddd3bbc Fix assertion when attempting to convert f16 and f128 with as
These types are currently rejected for `as` casts by the compiler.
Remove this incorrect check and add codegen tests for all conversions
involving these types.
2024-05-16 04:07:02 -05:00
bors
b71e8cbaf2 Auto merge of #124987 - workingjubilee:macro-metavar-expr-with-a-shorter-len, r=c410-f3r,joshtriplett,joshtriplett
Rename `${length()}` to `${len()}`

Implements the rename suggested in https://github.com/rust-lang/rust/pull/122808#issuecomment-2047722187
> I brought this up in the doc PR but it belongs here – `length` should probably be renamed `len` before stabilization. The latter is de facto standard in the standard library, whereas the former is only used in a single unstable API. These metafunctions aren’t library items of course, but should presumably still be consistent with established names.

r? `@c410-f3r`
2024-05-16 00:26:20 +00:00
León Orell Valerian Liehr
601e5d199f
Rollup merge of #125154 - FractalFir:fnabi_doc, r=compiler-errors
Small improvements to the documentaion of FnAbi

I have updated the documentation of  `FnAbi`.

The `arg` and `ret` fields are no longer LLVM types, but Rust types(`ArgAbi` contains a `TyAndLayout` and a `PassMode`), so I changed the documentation to reflect that.

Besides that, I also added documentation to other fields, and added a clarification about the differences between `FnAbi` and `FnSig`, since this is not something that is immediately obvious.
2024-05-15 22:01:20 +02:00
Michał Kostrubiec
257d222e4b Improved the documentation of the FnAbi struct 2024-05-15 20:32:27 +02:00
bors
ade234d574 Auto merge of #125144 - fmease:rollup-4uft293, r=fmease
Rollup of 6 pull requests

Successful merges:

 - #124307 (Optimize character escaping.)
 - #124975 (Use an helper to move the files)
 - #125027 (Migrate `run-make/c-link-to-rust-staticlib` to `rmake`)
 - #125038 (Invert comparison in `uN::checked_sub`)
 - #125104 (Migrate `run-make/no-cdylib-as-rdylib` to `rmake`)
 - #125137 (MIR operators: clarify Shl/Shr handling of negative offsets)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-15 12:43:34 +00:00
León Orell Valerian Liehr
8d38f2fb11
Rollup merge of #125137 - RalfJung:mir-sh, r=scottmcm
MIR operators: clarify Shl/Shr handling of negative offsets

"made unsigned" was not fully clear (made unsigned how? by using `abs`? no), so let's say "re-interpreted as an unsigned value of the same size" instead.

r? `@scottmcm`
2024-05-15 14:21:39 +02:00
bors
3cb0030fe9 Auto merge of #123413 - petrochenkov:delegmulti2, r=fmease
delegation: Implement list delegation

```rust
reuse prefix::{a, b, c};
```

Using design described in https://github.com/rust-lang/rfcs/pull/3530#issuecomment-2020869823 (the lists are desugared at macro expansion time).
List delegations are expanded eagerly when encountered, similarly to `#[cfg]`s, and not enqueued for later resolution/expansion like regular macros or glob delegation (https://github.com/rust-lang/rust/pull/124135).

Part of https://github.com/rust-lang/rust/issues/118212.
2024-05-15 10:35:31 +00:00
Ralf Jung
0afd50e852 MIR operators: clarify Shl/Shr handling of negative offsets 2024-05-15 10:25:39 +02:00
Matthias Krüger
5f1a120ee5
Rollup merge of #125135 - chenyukang:yukang-fix-116502, r=compiler-errors
Fix the dedup error because of spans from suggestion

Fixes #116502

I believe this kind of issue is supposed resolved by #118057, but the `==` in `span` respect syntax context, here we should only care that they point to the same bytes of source text, so should use `source_equal`.
2024-05-15 07:16:49 +02:00
Matthias Krüger
f7c2934420
Rollup merge of #125132 - mejrs:diag, r=compiler-errors
Add `on_unimplemented" typo suggestions
2024-05-15 07:16:48 +02:00
Matthias Krüger
a8ff937b07
Rollup merge of #125108 - Zalathar:info-bitmap-bytes, r=nnethercote
coverage: `CoverageIdsInfo::mcdc_bitmap_bytes` is never needed

This code for recalculating `mcdc_bitmap_bytes` in a query doesn't provide any benefit, because its result won't have changed from the value in `FunctionCoverageInfo` that was computed during the MIR instrumentation pass.

Extracted from #124571, to avoid having this held up by unrelated issues with condition count checks.

`@rustbot` label +A-code-coverage
2024-05-15 07:16:48 +02:00
Matthias Krüger
03ff673dcc
Rollup merge of #124990 - fmease:expand-weak-aliases-within-cts, r=compiler-errors
Also expand weak alias tys inside consts inside `expand_weak_alias_tys`

Ever since #121344 has been merged, I couldn't let go of the fear that I might've slipped a tiny bug into rustc (:P).

Checking the type flags of the `Const` is strictly more correct than only checking the ones of the `Const`'s `Ty`. I don't think it's possible to trigger an ICE rn (i.e., one of the two `bug!("unexpected weak alias type")` I added in branches where `expand_weak_alias_tys` should've expanded *all* weak alias tys) because presently const exprs aren't allowed to capture late-bound vars. To be future-proof however, we should iron this out.

A possible reproducer would be the following if I'm not mistaken (currently fails to compile due to the aforementioned restriction):

```rs
#![feature(lazy_type_alias, adt_const_params, generic_const_exprs)]

type F = for<'a> fn(A<{ S::<Weak<'a>>(loop {}) }>) -> &'a ();

type A<const N: S<Weak<'static>>> = ();

#[derive(PartialEq, Eq, std::marker::ConstParamTy)]
struct S<T>(T);

type Weak<'a> = &'a ();
```

Whether a late-bound region should actually be considered constrained by a const expr is a separate question — one which we don't need to answer until / unless we actually allow them in such contexts (probable answer: only inside the return exprs of a block but not inside the stmts).

r? oli-obk (he's not available rn but that's fine) or types or compiler
2024-05-15 07:16:47 +02:00
yukang
75895f59b0 Fix the dedup error because of spans from suggestion 2024-05-15 10:28:44 +08:00
bors
0160bff4b1 Auto merge of #125084 - Jules-Bertholet:fix-125058, r=Nadrieril
`rustc_hir_typeck`: Account for `skipped_ref_pats` in `expr_use_visitor`

Fixes #125058

r? `@Nadrieril`

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

`@rustbot` label A-edition-2024 A-patterns
2024-05-15 00:04:28 +00:00
Vadim Petrochenkov
c30b41012d delegation: Implement list delegation
```rust
reuse prefix::{a, b, c}
```
2024-05-15 02:32:59 +03:00
mejrs
18d7411719 Add `on_unimplemented" typo suggestions 2024-05-15 00:49:33 +02:00
bors
ac385a5af6 Auto merge of #125120 - compiler-errors:rollup-mnjybwv, r=compiler-errors
Rollup of 7 pull requests

Successful merges:

 - #119838 (style-guide: When breaking binops handle multi-line first operand better)
 - #124844 (Use a proper probe for shadowing impl)
 - #125047 (Migrate `run-make/issue-14500` to new `rmake.rs` format)
 - #125080 (only find segs chain for missing methods when no available candidates)
 - #125088 (Uplift `AliasTy` and `AliasTerm`)
 - #125100 (Don't do post-method-probe error reporting steps if we're in a suggestion)
 - #125118 (Use new utility functions/methods in run-make tests)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-14 14:40:20 +00:00
Michael Goulet
d59f430eec
Rollup merge of #125100 - compiler-errors:faster, r=nnethercote
Don't do post-method-probe error reporting steps if we're in a suggestion

Currently in method probing, if we fail to pick a method, then we reset and try to collect relevant candidates for method errors:

34582118af/compiler/rustc_hir_typeck/src/method/probe.rs (L953-L993)

However, we do method lookups via `lookup_method_for_diagnostic` and only care about the result if the method probe was a *success*.

Namely, we don't need to do a bunch of other lookups on failure, since we throw away these results anyways, such as an expensive call to:

34582118af/compiler/rustc_hir_typeck/src/method/probe.rs (L959)

And:
34582118af/compiler/rustc_hir_typeck/src/method/probe.rs (L985)

---

This PR also renames some methods so it's clear that they're for diagnostics.

r? `@nnethercote`
2024-05-14 09:55:30 -04:00
Michael Goulet
712e7c37f7
Rollup merge of #125088 - compiler-errors:uplift-alias-ty, r=lcnr
Uplift `AliasTy` and `AliasTerm`

Follow-up from #125076.

r? lcnr
2024-05-14 09:55:29 -04:00
Michael Goulet
8c64acdbdc
Rollup merge of #125080 - bvanjoi:fix-124946, r=nnethercote
only find segs chain for missing methods when no available candidates

Fixes #124946

This PR includes two changes:
- Extracting the lookup for the missing method in chains into a single function.
- Calling this function only when there are no candidates available.
2024-05-14 09:55:29 -04:00
Michael Goulet
0458d8a53b
Rollup merge of #124844 - compiler-errors:shadow-probe, r=lcnr
Use a proper probe for shadowing impl

r? lcnr
2024-05-14 09:55:28 -04:00
bohan
ade33b02f2 only find segs chain for missing methods when no available candidates 2024-05-14 20:28:55 +08:00
bors
bdfd941f4d Auto merge of #123816 - tgross35:f16-f128-mangling, r=michaelwoerister
Add v0 symbol mangling for `f16` and `f128`

As discussed at <https://github.com/rust-lang/rust/pull/122106>, use the crate encoding to represent new primitives.
2024-05-14 12:17:26 +00:00
Trevor Gross
809b84edba Add v0 symbol mangling for f16 and f128
As discussed at <https://github.com/rust-lang/rust/pull/122106>, use the
crate encoding to represent new primitives.
2024-05-14 06:11:25 -04:00
bors
31026b7fe3 Auto merge of #125023 - morr0ne:linux-none-target, r=Nilstrieb
Add x86_64-unknown-linux-none target

Adds a freestanding linux binary with no libc dependency. This is useful for writing programs written only in rust. It is also essential for writing low level stuff like libc or a dynamic linker.

Tier 3 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 designed maintainer for this target

>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.

The target triple is consistent with other targets

>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.

There is no confusion with other targets since it explicitly adds "none" at the end instead of omitting the environment

>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 does not introduce any unusual requirement

>The target must not introduce license incompatibilities.

There are no license incompatibilities

> Anything added to the Rust repository must be under the standard Rust license (MIT OR Apache-2.0).

Everything added is under that license

>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.

There are no new dependencies

>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.

There is no proprietary dependencies

>"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 such terms exist for this target

>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

>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.

The target already implements core. It might be possible in the future to add support for alloc and std by leveraging crates such as [origin](https://github.com/sunfishcode/origin/) and [rustix](https://github.com/bytecodealliance/rustix)

> 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.

I believe the proper docs are added

>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.

No other targets are effected

>Tier 3 targets must be able to produce assembly using at least one of rustc's supported backends from any host target.

The same backends used by other linux targets work without issues
2024-05-14 10:07:49 +00:00
bors
c45e831d8f Auto merge of #124228 - compiler-errors:lint-overcaptures, r=oli-obk
Warn against changes in opaque lifetime captures in 2024

Adds a (mostly[^1]) machine-applicable lint `IMPL_TRAIT_OVERCAPTURES` which detects cases where we will capture more lifetimes in edition 2024 than in edition <= 2021, which may lead to erroneous borrowck errors.

This lint is gated behind the `precise_capturing` feature gate and marked `Allow` for now.

[^1]: Except when there are APITs -- I may work on that soon

r? oli-obk
2024-05-14 07:44:16 +00:00
Zalathar
c81be68fb4 coverage: Remove confusing comments from CoverageKind
These comments appear to be inspired by the similar comments on
`CounterIncrement` and `ExpressionUsed`. But those comments refer to specific
simplification steps performed during coverage codegen, and there is no
corresponding step for the MC/DC coverage statements.

If these statements do not survive optimization, they will simply not
participate in code generation, just like any other statement.
2024-05-14 17:05:00 +10:00
Zalathar
bfadc3a9b9 coverage: CoverageIdsInfo::mcdc_bitmap_bytes is never needed
This code for recalculating `mcdc_bitmap_bytes` doesn't provide any benefit,
because its result won't have changed from the value in `FunctionCoverageInfo`
that was computed during the MIR instrumentation pass.
2024-05-14 16:41:04 +10:00
Michael Goulet
dbd2ca6478 Use a proper probe for shadowing impl 2024-05-13 23:58:33 -04:00
Michael Goulet
052de1da4f And finally add tests 2024-05-13 23:57:56 -04:00
Michael Goulet
1529c661e4 Warn against redundant use<...> 2024-05-13 23:57:56 -04:00
Michael Goulet
f3fb727b08 Don't suggest using use<> syntax to capture APITs 2024-05-13 23:57:56 -04:00
Michael Goulet
6afe1352d9 Suggest adding use<> syntax 2024-05-13 23:57:56 -04:00
Michael Goulet
554becc180 Add some commenting 2024-05-13 23:57:56 -04:00
Michael Goulet
d57e57ca1f Implement initial IMPL_TRAIT_OVERCAPTURES lint 2024-05-13 23:47:35 -04:00
bors
fba5f44bd8 Auto merge of #125098 - jhpratt:rollup-2qm4gga, r=jhpratt
Rollup of 4 pull requests

Successful merges:

 - #116675 ([ptr] Document maximum allocation size)
 - #124997 (Fix ICE while casting a type with error)
 - #125072 (Add test for dynamic dispatch + Pin::new soundness)
 - #125090 (Migrate fuchsia docs from `pm` to `ffx`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-14 03:19:44 +00:00
Michael Goulet
9f8cdb286e Remove to_term 2024-05-13 22:45:01 -04:00
Michael Goulet
1ad28a6f53 Uplift AliasTy 2024-05-13 22:45:01 -04:00
Michael Goulet
2e4c90c3f7 Don't do post-method-probe error reporting steps if we're in a suggestion 2024-05-13 22:05:11 -04:00
Jacob Pratt
18d9c039bb
Rollup merge of #124997 - gurry:124848-ice-should-be-sized, r=Nadrieril
Fix ICE while casting a type with error

Fixes #124848

The ICE originates here: f9a3fd9661/compiler/rustc_hir_typeck/src/cast.rs (L143) The underlying cause is that a type with error, `MyType` was involved in a cast. During cast checks the below method `pointer_kind` was called: f9a3fd9661/compiler/rustc_hir_typeck/src/cast.rs (L87-L91) Thanks to the changes in PR #123491, `type_is_sized_modulo_regions` in `pointer_kind` returned `false` which caused control to reach the `span_bug` here: f9a3fd9661/compiler/rustc_hir_typeck/src/cast.rs (L143) resulting in an ICE.

This PR fixes the issue by changing the `span_bug` to a `span_delayed_bug`.
2024-05-13 21:14:15 -04:00
bors
9105c57b7f Auto merge of #124256 - nnethercote:rm-NtIdent-NtLifetime, r=petrochenkov
Remove `NtIdent` and `NtLifetime`

This is one part of the bigger "remove `Nonterminal` and `TokenKind::Interpolated`" change drafted in #114647. More details in the individual commit messages.

r? `@petrochenkov`
2024-05-14 01:10:38 +00:00
Jules Bertholet
fe8f66e4bc
rustc_hir_typeck: Account for skipped_ref_pats in expr_use_visitor
Fixes #125058
2024-05-13 18:36:49 -04:00
bors
34582118af Auto merge of #125076 - compiler-errors:alias-term, r=lcnr
Split out `ty::AliasTerm` from `ty::AliasTy`

Splitting out `AliasTerm` (for use in project and normalizes goals) and `AliasTy` (for use in `ty::Alias`)

r? lcnr
2024-05-13 22:20:43 +00:00
Nicholas Nethercote
95e519ecbf Remove NtIdent and NtLifetime.
The extra span is now recorded in the new `TokenKind::NtIdent` and
`TokenKind::NtLifetime`. These both consist of a single token, and so
there's no operator precedence problems with inserting them directly
into the token stream.

The other way to do this would be to wrap the ident/lifetime in invisible
delimiters, but there's a lot of code that assumes an interpolated
ident/lifetime fits in a single token, and changing all that code to work with
invisible delimiters would have been a pain. (Maybe it could be done in a
follow-up.)

This change might not seem like much of a win, but it's a first step toward the
much bigger and long-desired removal of `Nonterminal` and
`TokenKind::Interpolated`. That change is big and complex enough that it's
worth doing this piece separately. (Indeed, this commit is based on part of a
late commit in #114647, a prior attempt at that big and complex change.)
2024-05-14 08:19:58 +10:00
Michael Goulet
fa84018c2e Apply nits 2024-05-13 16:55:58 -04:00