5275 Commits

Author SHA1 Message Date
bors
e466296627 Auto merge of #141762 - compiler-errors:witnesser, r=lcnr
Unify `CoroutineWitness` sooner in typeck, and stall coroutine obligations based off of `TypingEnv`

* Stall coroutine obligations based off of `TypingMode` in the old solver.
* Eagerly assign `TyKind::CoroutineWitness` to the witness arg of coroutines during typeck, rather than deferring them to the end of typeck.

r? lcnr

This is part of https://github.com/rust-lang/rust/issues/143017.
2025-07-17 20:02:22 +00:00
Michael Goulet
216cdb7b22 Eagerly unify coroutine witness in old solver 2025-07-17 17:42:28 +00:00
Michael Goulet
72bc11d146 Unstall obligations by looking for coroutines in old solver 2025-07-17 17:38:23 +00:00
Michael Goulet
96171dc78f Check if type has coroutines before visiting 2025-07-17 17:38:23 +00:00
bors
9cd918bcbb Auto merge of #143879 - fee1-dead-contrib:push-lrlpoouyqqry, r=fmease
parse `const trait Trait`

r? oli-obk or anyone from project-const-traits

cc `@rust-lang/project-const-traits`
2025-07-17 15:54:33 +00:00
Deadbeef
69326878ee parse const trait Trait 2025-07-17 18:06:26 +08:00
Matthias Krüger
14b6ac4d6d
Rollup merge of #143431 - xizheyin:143392, r=compiler-errors
Use relative visibility when noting sealed trait to reduce false positive

Fixes rust-lang/rust#143392

I used relative visibility instead of just determining if it's public or not.

r? compiler
2025-07-17 10:41:44 +02:00
bors
f8f6997469 Auto merge of #144044 - fmease:rollup-kg413pt, r=fmease
Rollup of 15 pull requests

Successful merges:

 - rust-lang/rust#142304 (tests: Add `RUST_BACKTRACE` and `-Cpanic` revisions to `panic-main.rs` test)
 - rust-lang/rust#143388 (Various refactors to the LTO handling code)
 - rust-lang/rust#143409 (Enable xgot feature for mips64 musl targets)
 - rust-lang/rust#143592 (UWP: link ntdll functions using raw-dylib)
 - rust-lang/rust#143595 (add `const_make_global`; err for `const_allocate` ptrs if didn't call)
 - rust-lang/rust#143678 (Added error for invalid char cast)
 - rust-lang/rust#143820 (Fixed a core crate compilation failure when enabling the `optimize_for_size` feature on some targets)
 - rust-lang/rust#143829 (Trim `BorrowedCursor` API)
 - rust-lang/rust#143851 (ci cleanup: rustdoc-gui-test now installs browser-ui-test)
 - rust-lang/rust#143856 (Linting public reexport of private dependencies)
 - rust-lang/rust#143895 (Dont collect assoc ty item bounds from trait where clause for host effect predicates)
 - rust-lang/rust#143922 (Improve path segment joining)
 - rust-lang/rust#143964 (Fix handling of SCRIPT_ARG in docker images)
 - rust-lang/rust#144002 (Update poison.rs)
 - rust-lang/rust#144016 (trait_sel: `MetaSized` always holds temporarily)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-07-17 05:24:30 +00:00
León Orell Valerian Liehr
d5a471c07e
Rollup merge of #144016 - davidtwco:sized-hierarchy-temp-pseudo-revert, r=lcnr
trait_sel: `MetaSized` always holds temporarily

As a temporary measure while a proper fix for `tests/ui/sized-hierarchy/incomplete-inference-issue-143992.rs` is implemented, make `MetaSized` obligations always hold. In effect, temporarily reverting the `sized_hierarchy` feature. This is a small change that can be backported.

cc rust-lang/rust#143992
r? ```@lcnr```
2025-07-17 03:58:36 +02:00
Nicholas Nethercote
6414352bff Use join_path_syms in one more place.
This one is a bit marginal, because the segments are a mix of symbols
and strings.
2025-07-17 08:37:20 +10:00
David Wood
8d64937dc2
trait_sel: MetaSized always holds temporarily
As a temporary measure while a proper fix for
`tests/ui/sized-hierarchy/incomplete-inference-issue-143992.rs`
is implemented, make `MetaSized` obligations always hold. In effect,
temporarily reverting the `sized_hierarchy` feature. This is a small
change that can be backported.
2025-07-16 12:35:44 +00:00
tiif
7356ff7517 Implement other logics 2025-07-15 13:48:30 +00:00
tiif
1e5c7b2877 Add the core logic in old and new solvers 2025-07-15 13:48:30 +00:00
Samuel Tardieu
8fcef5674a
Rollup merge of #143901 - compiler-errors:region-constraint-nits, r=lcnr
Region constraint nits

Couple miscellaneous region constraints that have a bit to do with rust-lang/rust#143545 but stand on their own.
2025-07-14 18:05:47 +02:00
Michael Goulet
f6f2f83043 Simplify make_query_region_constraints 2025-07-13 19:22:17 +00:00
Camille GILLOT
21fd82adbc Retire hir::*ItemRef. 2025-07-13 13:50:01 +00:00
Camille GILLOT
277b0ecf34 Remove hir::AssocItemKind. 2025-07-13 13:50:00 +00:00
bors
b1d2f2c64c Auto merge of #140717 - mejrs:diagnostic_lints, r=oli-obk
Split up the `unknown_or_malformed_diagnostic_attributes` lint

This splits up the lint into the following lint group:
- `unknown_diagnostic_attributes` - triggers if the attribute is unknown to the current compiler
- `misplaced_diagnostic_attributes` - triggers if the attribute exists but it is not placed on the item kind it's meant for
- `malformed_diagnostic_attributes` - triggers if the attribute's syntax or options are invalid
- `malformed_diagnostic_format_literals` - triggers if the format string literal is invalid, for example if it has unpaired curly braces or invalid parameters
- this pr doesn't create it, but future lints for things like deprecations can also go here.

This PR does not start emitting lints in places that previously did not.

## Motivation

I want to have finer control over what `unknown_or_malformed_diagnostic_attributes` does

I have a project with fairly low msrv that is/will have a lower msrv than future diagnostic attributes. So lints will be emitted when I or others compile it on a lower msrv.

At this time, there are two options to silence these lints:

-  `#[allow(unknown_or_malformed_diagnostic_attributes)]` - this risks diagnostic regressions if I (or others) mess up using the attribute, or if the attribute's syntax ever changes.
- write a build script to detect the compiler version and emit cfgs, and then conditionally enable the attribute:
    ```rust
    #[cfg_attr(rust_version_99, diagnostic::new_attr_in_rust_99(thing = ..))]`
    struct Foo;
    ```
    or conditionally `allow`  the lint:
    ```rust
   // lib.rs
   #![cfg_attr(not(current_rust), allow(unknown_or_malformed_diagnostic_attributes))]
   ```

I like to avoid using build scripts if I can, so the following works much better for me. That is what this PR will let me do in the future:
```rust
    #[allow(unknown_diagnostic_attribute, reason = "attribute came out in rust 1.99 but msrv is 1.70")]
    #[diagnostic::new_attr_in_rust_99(thing = ..)]`
    struct Foo;
2025-07-13 01:11:56 +00:00
bors
855e0fe46e Auto merge of #142911 - mejrs:unsized, r=compiler-errors
Remove support for dynamic allocas

Followup to rust-lang/rust#141811
2025-07-11 05:27:32 +00:00
Trevor Gross
58e5c2629d
Rollup merge of #143742 - estebank:borrow-suggestion, r=compiler-errors
Rework borrowing suggestions to use `Expr` instead of just `Span`

In the suggestion machinery for borrowing expressions and types, always use the available obligation `Span` to find the appropriate `Expr` to perform appropriateness checks no the `ExprKind` instead of on the textual snippet corresponding to the `Span`. (We were already doing this, but only for a subset of cases.) This now better handles situations where parentheses and `<>` are needed for correct syntax (`&(foo + bar)`, `(&foo).bar()`, `<&Foo>::bar()`, etc.).

Unify the logic for the case where `&` *and* `&mut` are appropriate with the logic for only one of those cases. (Instead of having two branches for emitting the suggestion, we now have a single one, using `Diag::multipart_suggestions` always.)

Handle the case when `S::foo()` should have been `<&S>::foo()` (instead of suggesting the prior `&S::foo()`. Fix rust-lang/rust#143393.

Make `Diag::multipart_suggestions` always verbose. CC rust-lang/rust#141973.
2025-07-10 20:20:40 -04:00
mejrs
a7bf5c4fa2 Split up the unknown_or_malformed_diagnostic_attributes lint 2025-07-11 01:24:24 +02:00
Matthias Krüger
b4089bf417
Rollup merge of #143640 - oli-obk:const-fn-traits, r=compiler-errors
Constify `Fn*` traits

r? `@compiler-errors` `@fee1-dead`

this should unlock a few things. A few `const_closures` tests have broken even more than before, but that feature is marked as incomplete anyway

cc rust-lang/rust#67792
2025-07-10 20:28:49 +02:00
Esteban Küber
7dfc3e9af4 Rework borrowing suggestions to use Expr instead of just Span
In the suggestion machinery for borrowing expressions and types, always use the available obligation `Span` to find the appropriate `Expr` to perform appropriateness checks no the `ExprKind` instead of on the textual snippet corresponding to the `Span`.

Unify the logic for the case where `&` *and* `&mut` are appropriate with the logic for only one of those cases.

Handle the case when `S::foo()` should have been `<&S>::foo()` (instead of suggesting the prior `&S::foo()`.
2025-07-10 17:23:29 +00:00
bors
e43d139a82 Auto merge of #143538 - compiler-errors:instantiate-auto-trait, r=lcnr
Instantiate auto trait/`Copy`/`Clone`/`Sized` before computing constituent types binder

This makes the binder logic w.r.t. coroutines a bit simpler.

r? lcnr
2025-07-09 19:38:39 +00:00
Trevor Gross
5f9a70ec9f
Rollup merge of #143532 - compiler-errors:mut-ref-sugg, r=davidtwco
More carefully consider span context when suggesting remove `&mut`

Use `find_ancestor_inside` to compute a relative span that is macro-aware, rather than falling back to using BytePos arithmetic which is wrong for `&mut`.

Fixes https://github.com/rust-lang/rust/issues/143523
2025-07-08 22:50:29 -05:00
Trevor Gross
f1517ddae8
Rollup merge of #143499 - compiler-errors:predicates-of-crate, r=davidtwco
Don't call `predicates_of` on a dummy obligation cause's body id

See the test for a brief explanation

Fixes rust-lang/rust#143481.
2025-07-08 22:50:28 -05:00
mejrs
25eb3829e5 Error on moving unsized values rather than ICE'ing 2025-07-08 22:37:12 +02:00
Matthias Krüger
38bfba6124
Rollup merge of #143620 - Muscraft:remove-newline, r=compiler-errors
fix: Remove newline from multiple crate versions note

While working on getting `annotate-snippets` to match `rustc`, `annotate-snippets` was adding an extra new line after [this line](a2d45f73c7/tests/run-make/crate-loading/multiple-dep-versions.stderr (L9)) for [`run-make/crate-loading/multiple-dep-versions.rs`](a2d45f73c7/tests/run-make/crate-loading/multiple-dep-versions.rs). I found out this was because there was an explicit `\n` in the message that `annotate-snippets` was respecting, while `rustc` was [skipping it](2f8eeb2bba/compiler/rustc_errors/src/emitter.rs (L1542)). After talking with ```@estebank,``` I was told to remove the newline from the error message.

r? ```@estebank```
2025-07-08 19:29:41 +02:00
Michael Goulet
bbb409cc68 Instantiate binder for Copy/Clone/Sized eagerly 2025-07-08 16:35:06 +00:00
Michael Goulet
8d2d4eb89a Instantiate auto trait before computing higher-ranked constituent types 2025-07-08 16:33:38 +00:00
Oli Scherer
b1d45f6b3e Remove const_eval_select hack 2025-07-08 15:49:00 +00:00
Oli Scherer
543c860ea6 Constify Fn* traits 2025-07-08 14:36:43 +00:00
Matthias Krüger
b29f039ae3
Rollup merge of #143571 - lcnr:has_nested-bb, r=compiler-errors
remove `has_nested` from builtin candidates

it's no longer necessary

r? types
2025-07-08 03:09:57 +02:00
Scott Schafer
62951c2e07
fix: Remove newline from multiple crate versions note 2025-07-07 18:54:23 -06:00
Matthias Krüger
00a4418158
Rollup merge of #132469 - estebank:issue-132041, r=Nadrieril
Do not suggest borrow that is already there in fully-qualified call

When encountering `&str::from("value")` do not suggest `&&str::from("value")`.

Fix #132041.
2025-07-07 19:55:31 +02:00
lcnr
3ddcf8b94c remove has_nested 2025-07-07 11:19:58 +02:00
Jubilee Young
0a4f87a144 compiler: rename {ast,hir}::BareFn* to FnPtr*
Fix some comments and related types and locals where it is obvious, e.g.
- bare_fn -> fn_ptr
- LifetimeBinderKind::BareFnType -> LifetimeBinderKind::FnPtrType

Co-authored-by: León Orell Valerian Liehr <me@fmease.dev>
2025-07-06 15:03:08 -07:00
Michael Goulet
b63f920ccf More carefully consider span context when suggesting remove &mut 2025-07-06 17:36:35 +00:00
Michael Goulet
995eeeb54c Don't call predicates_of on a dummy obligation cause's body id 2025-07-05 17:47:28 +00:00
xizheyin
4a261a1513 Use relative visibility when noting sealed trait to reduce false positive
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-05 04:13:52 +08:00
Michael Goulet
dc8cac8e8d Nits 2025-07-04 18:26:09 +00:00
Michael Goulet
0ad96c1e1f Fix elided lifetimes in rustdoc 2025-07-04 18:26:09 +00:00
Michael Goulet
d79b669b09 Fix pretty printing of placeholder types 2025-07-04 18:26:09 +00:00
Michael Goulet
42c9bfd2b9 Remove Symbol for Named LateParam/Bound variants 2025-07-04 18:14:22 +00:00
Matthias Krüger
18b374d5a7
Rollup merge of #143308 - compiler-errors:no-pointer-like, r=oli-obk
Remove `PointerLike` trait

r? oli-obk
2025-07-04 16:22:35 +02:00
Jacob Pratt
9de211b95a
Rollup merge of #143307 - compiler-errors:fast-path-nitpicks, r=lcnr
Fast path nitpicks

Miscellaneous commits that I didn't really want to fold into anything else.

Fixes one theoretical bug with the fast path not considering polarity for `T: !Sized` bounds.
2025-07-04 05:47:24 +02:00
Michael Goulet
e2e3f5809b Remove PointerLike trait 2025-07-03 20:03:49 +00:00
Esteban Küber
7603adc381 Rework logic and provide structured suggestion 2025-07-03 16:14:20 +00:00
Jana Dönszelmann
0aaac883de
Rollup merge of #143038 - Qelxiros:142676-private-dependency-traits, r=tgross35
avoid suggesting traits from private dependencies

fixes rust-lang/rust#142676
fixes rust-lang/rust#138191

r? ``@tgross35``
2025-07-03 13:29:36 +02:00
Jana Dönszelmann
5026d0cd8e
Rollup merge of #142876 - JonathanBrouwer:target_feature_parser, r=oli-obk
Port `#[target_feature]` to new attribute parsing infrastructure

Ports `target_feature` to the new attribute parsing infrastructure for https://github.com/rust-lang/rust/issues/131229#issuecomment-2971353197

r? ``@jdonszelmann``
2025-07-03 13:29:36 +02:00