Commit Graph

48659 Commits

Author SHA1 Message Date
bohan
e9080948c6 consider glob imports in cfg suggestion 2025-05-28 00:59:47 +08:00
León Orell Valerian Liehr
db21caf5ba Drive-by: Delete dead TyCtxtEnsureOk::const_eval_poly 2025-05-27 18:58:51 +02:00
León Orell Valerian Liehr
a83f8d02ea Always evaluate free lifetime-generic constants
Co-authored-by: Michael Goulet <michael@errs.io>
2025-05-27 18:58:51 +02:00
Matthew Jasper
f6520673fc Warn on non-crate level text direction lints 2025-05-27 16:16:34 +00:00
Matthew Jasper
e5bfd02c5e Avoid including text direction codepoints in lint messages 2025-05-27 15:57:41 +00:00
Matthew Jasper
65bdb31a97 Report text_direction_codepoint_in_literal when parsing
- The lint is now reported in code that gets removed/modified/duplicated
  by macro expansion.
- Spans are more accurate
- Fixes #140281
2025-05-27 15:57:41 +00:00
bjorn3
026baa1c6f Do not get proc_macro from the sysroot in rustc
With the stage0 refactor the proc_macro version found in the sysroot
will no longer always match the proc_macro version that proc-macros get
compiled with by the rustc executable that uses this proc_macro. This
will cause problems as soon as the ABI of the bridge gets changed to
implement new features or change the way existing features work.

To fix this, this commit changes rustc crates to depend directly on the
local version of proc_macro which will also be used in the sysroot that
rustc will build.
2025-05-27 15:49:28 +00:00
yukang
d5d4cecee9 Suggest mut when possbile for temporary value dropped while borrowed 2025-05-27 22:19:56 +08:00
Mu001999
f83ecd8270 Refactor the two-phase check for impls and impl items 2025-05-27 22:03:21 +08:00
Michael Goulet
905fc0a008 Make some assertions in solver into debug assertions 2025-05-27 13:46:41 +00:00
Zalathar
3f526eeec4 coverage: Revert "unused local file IDs" due to empty function names
This reverts commit 3b22c21dd8, reversing
changes made to 5f292eea6d.
2025-05-27 23:33:29 +10:00
Michael Goulet
5f3ae06db0 Fix some var names 2025-05-27 11:14:47 +00:00
Michael Goulet
29c3babd7c Rename unpack to kind 2025-05-27 11:14:45 +00:00
klensy
e6312c9232 bump fluent-* crates 2025-05-27 14:11:14 +03:00
Michael Goulet
d7e961a4c9 Rollup merge of #141635 - fee1-dead-contrib:push-lmyymwotrspk, r=oli-obk
further dedup `WalkItemKind` for `mut_visit` and `visit`

also some drive-by fixes.

r? oli-obk
2025-05-27 13:01:44 +02:00
Michael Goulet
f0ee1d7100 Rollup merge of #141623 - folkertdev:va-arg-explicit-types, r=workingjubilee
use custom types to clarify arguments to `emit_ptr_va_arg`

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

split out of https://github.com/rust-lang/rust/pull/141622

r? ``@workingjubilee``
``@rustbot`` label: +F-c_variadic
2025-05-27 13:01:43 +02:00
Michael Goulet
2de2e652ad Rollup merge of #141599 - nnethercote:rm-Box-into_inner, r=fmease,chenyukang
Remove an unnecessary use of `Box::into_inner`.

r? ```@chenyukang```
2025-05-27 13:01:42 +02:00
Michael Goulet
9d46af12e0 Rollup merge of #141584 - compiler-errors:typing-env-synthetic-body, r=lcnr
Support `opaque_types_defined_by` for `SyntheticCoroutineBody`

We create a synthetic MIR body for the `AsyncFnOnce` impl for async closures. That body goes through all passes that a regular body does, including promotion.

Promotion sometimes requires computing that the type of an rvalue is `Freeze`, which requires computing the typing env of a body. This requires calling `opaque_types_defined_by` on the body's def id, which leads to an ICE today since we don't expect that query to be called for synthetic bodies.

While we could fix this by, for example, computing the typeck root of the body before calling a `TypingEnv` constructor, I think it's appropriate to do a more general fix here since I think it's reasonable that other passes might do analysis too.

Fixes rust-lang/rust#141466

r? ```@lcnr``` or ```@oli-obk```
2025-05-27 13:01:40 +02:00
Michael Goulet
fb4cc991c0 Rollup merge of #141582 - RalfJung:cleanup, r=bjorn3
intrinsics, ScalarInt: minor cleanup

Taken out of https://github.com/rust-lang/rust/pull/141507 while we resolve technical disagreements in that PR.

r? ``@bjorn3``
2025-05-27 13:01:39 +02:00
Michael Goulet
fbac805425 Rollup merge of #141580 - oli-obk:early-dyn-catches-the-incompat, r=compiler-errors
Use more detailed spans in dyn compat errors within bodies

Within bodies we can employ the full dyn compat check query instead of only doing the minimal hir ty lowerer one. This in turn gives us better spans and also silences many follow-up duplicate or bogus errors.

alternative to https://github.com/rust-lang/rust/pull/141439, tho I think I could turn the delayed bug from that one into a bug now instead of having an error code path.

r? `@compiler-errors`
cc `@fmease`
2025-05-27 13:01:38 +02:00
Michael Goulet
7acdffb6e4 Rollup merge of #141563 - nnethercote:rm-noop, r=petrochenkov
Remove out-of-date `noop_*` names.

`mut_visit.rs` has a single function with a `noop_` prefix: `noop_filter_map_expr`. This commit renames as `walk_filter_map_expr` which is consistent with other functions in this file.

The commit also removes out-of-date comments that refer to `noop_*` methods.

r? `@petrochenkov`
2025-05-27 13:01:37 +02:00
Michael Goulet
a0d77f37f3 Rollup merge of #141536 - Urgau:ambi_wide_ptr-cmp-diag, r=fee1-dead
Improve `ambiguous_wide_pointer_comparisons` lint compare diagnostics

This PR improves the `ambiguous_wide_pointer_comparisons` lint compare diagnostics: `cmp`/`partial_cmp`, but also the operators `<`/`>`/`>=`/`<=`, by:
1. removing the reference to `std::ptr::addr_eq` which only works for equality
2. and adding an `#[expect]` suggestion for keeping the current behavior

Fixes rust-lang/rust#141510
2025-05-27 13:01:36 +02:00
Michael Goulet
77e35944af Rollup merge of #140591 - Kivooeo:new-fix-five, r=davidtwco
Fix malformed suggestion for E0061 when method is a macro token in macro context

fixes #140512

before
```rust
3  -         <Self>::$method(8)
3  +         <Self>::<Self>::$method(8, /* u8 */)
```
now
```rust
3  |         <Self>::$method(8, /* u8 */)
   |                          ++++++++++
```
2025-05-27 13:01:35 +02:00
Nicholas Nethercote
89c21f7c1a Remove out-of-date noop_* names.
`mut_visit.rs` has a single function with a `noop_` prefix:
`noop_filter_map_expr`. This commit renames as `walk_filter_map_expr`
which is consistent with other functions in this file.

The commit also removes out-of-date comments that refer to `noop_*`
methods.
2025-05-27 19:16:11 +10:00
Oli Scherer
3fff727e87 Use more detailed spans in dyn compat errors within bodies 2025-05-27 08:18:11 +00:00
Folkert de Vries
c7c0194d98 move asm parsing code into rustc_parse 2025-05-27 09:44:10 +02:00
Folkert de Vries
e3bbbeeafd support #[cfg(...)] on arguments to the asm! macros 2025-05-27 09:44:04 +02:00
Deadbeef
e0d4cf38f4 further dedup WalkItemKind for mut_visit and visit
also some drive-by fixes.
2025-05-27 14:54:02 +08:00
Deadbeef
7fdf35ed1c remove visit_mt from ast::mut_visit
doesn't look like anyone is using it.
2025-05-27 14:24:18 +08:00
Nicholas Nethercote
991c91fdaa Reduce P<T> to a typedef of Box<T>.
Keep the `P` constructor function for now, to minimize immediate churn.

All the `into_inner` calls are removed, which is nice.
2025-05-27 13:29:24 +10:00
bors
d76fe15402 Auto merge of #140790 - quininer:mac-xray, r=wesleywiser,jieyouxu
Enable xray support for Mac

https://github.com/rust-lang/rust/issues/102921

Upstream has supported Mac for a while, let's enable it.

I've tested it on M4 and it generates nop sled correctly.

* https://maskray.me/blog/2023-06-18-port-llvm-xray-to-apple-systems
* https://github.com/llvm/llvm-project/blob/llvmorg-20.1.4/clang/lib/Driver/XRayArgs.cpp#L31

try-job: x86_64-apple-1
try-job: aarch64-apple
2025-05-26 23:44:21 +00:00
Nicholas Nethercote
ec8baa5d43 Avoid fold/flat_map.
This pattern of iterating over scopes and drops occurs multiple times in
this file, with slight variations. All of them use `for` loops except
this one. This commits changes it for consistency.
2025-05-27 09:28:39 +10:00
Nicholas Nethercote
84bb48fc88 Factor out some repeated code in build_exit_tree. 2025-05-27 09:28:39 +10:00
Nicholas Nethercote
bf4532c05d Rename DropTree::drops as DropTree::drop_nodes.
Because `Scope` also has a field named `drops`, and I found having two
fields with the same name made this code harder to read.
2025-05-27 09:28:39 +10:00
Nicholas Nethercote
df09feddfa Remove DropNodeKey::kind.
It's not needed, because `next` and `local` fields uniquely identify the
drop. This is a ~2% speed win on the very large program in #134404, and
it's also a tiny bit simpler.
2025-05-27 09:28:39 +10:00
Folkert de Vries
7fe8263285 use custom types to clarify arguments to emit_ptr_va_arg 2025-05-27 01:24:19 +02:00
Diggory Blake
fdb660e851 Limit the size of cgu names when using the -Zhuman-readable-cgu-names option
Prior to this change, cgu names could be generated which would result in
filenames longer than the limit imposed by the OS.
2025-05-26 23:29:26 +01:00
bors
2805e1dc4c Auto merge of #141605 - jieyouxu:rollup-3gjqh5l, r=jieyouxu
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#140898 (minor improvements on running miri)
 - rust-lang/rust#141392 (Avoid obligation construction dance with query region constraints)
 - rust-lang/rust#141431 (Emit dummy open drop for unsafe binder)
 - rust-lang/rust#141433 (Properly analyze captures from unsafe binders)
 - rust-lang/rust#141439 (Deduplicate dyn compatibility violations due to coercion)
 - rust-lang/rust#141449 (further deduplicate ast visitor code)
 - rust-lang/rust#141513 (interpret: add allocation parameters to `AllocBytes`)
 - rust-lang/rust#141516 (speed up charsearcher for ascii chars)
 - rust-lang/rust#141526 (add a dedicated section for compiler environment variables in the unstable book)
 - rust-lang/rust#141550 (Fix `unused_braces` lint suggestion when encountering attributes)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-05-26 20:30:06 +00:00
lcnr
0830ce036f assert we never incorrectly canonicalize envs 2025-05-26 19:57:48 +00:00
lcnr
c56efaedfa add additional TypeFlags fast paths 2025-05-26 19:57:48 +00:00
Urgau
93f3db25c0 Expose rustc_lint::decorate_builtin_lint for use in rustdoc 2025-05-26 21:51:09 +02:00
Urgau
e33fe611f5 Add custom trait for emitting lint within cfg_matches 2025-05-26 21:51:09 +02:00
许杰友 Jieyou Xu (Joe)
bca4279457 Rollup merge of #141550 - Urgau:unused_braces-attrs, r=chenyukang
Fix `unused_braces` lint suggestion when encountering attributes

This PR fixes the `unused_braces` lint suggestion when encountering attributes by not removing them in the suggestion.

Fixes rust-lang/rust#141549
2025-05-27 01:29:22 +08:00
许杰友 Jieyou Xu (Joe)
afb57cadda Rollup merge of #141513 - nia-e:allocbytes-extend, r=RalfJung
interpret: add allocation parameters to `AllocBytes`

Necessary for a better implementation of [rust-lang/miri#4343](https://github.com/rust-lang/miri/pull/4343). Also included here is the code from that PR, adapted to this new interface for the sake of example and so that CI can run on them; the Miri changes can be reverted and merged separately, though.

r? `@RalfJung`
2025-05-27 01:29:20 +08:00
许杰友 Jieyou Xu (Joe)
be778ed1f8 Rollup merge of #141449 - fee1-dead-contrib:push-qkosmtkqztkk, r=oli-obk
further deduplicate ast visitor code

Previous PR: #141249

Tracking issue: #127615

r? `@oli-obk`
2025-05-27 01:29:19 +08:00
许杰友 Jieyou Xu (Joe)
92b07de1ca Rollup merge of #141439 - compiler-errors:dyn-compatible-coerce, r=oli-obk
Deduplicate dyn compatibility violations due to coercion

Don't unnecessarily emit dyn compatibility violations due to coercion to a non-dyn-compatible target type.

For us to even have that target type, we would have had to write `dyn Trait` somewhere in source, and that would have led to us *already* emitting a dyn compatibility violation when checking that user written type is WF.

r? oli-obk
2025-05-27 01:29:19 +08:00
许杰友 Jieyou Xu (Joe)
9f93c48ddc Rollup merge of #141433 - compiler-errors:unsafe-binder-captures, r=oli-obk
Properly analyze captures from unsafe binders

We need to represent the unsafe binder unwrap as an adjustment in HIR. Pretty straightforward b/c we already represent it as a projection elem in MIR.

Fixes #141418
Fixes #141417

r? oli-obk
2025-05-27 01:29:18 +08:00
许杰友 Jieyou Xu (Joe)
0e710d0883 Rollup merge of #141431 - compiler-errors:open-drop, r=oli-obk
Emit dummy open drop for unsafe binder

Fixes rust-lang/rust#141394

We can't taint the body in wfcheck when we have a `T: Copy` bound failure, so we end up binding MIR here. Emit a dummy open drop so that drop elaboration doesn't fail.

r? oli-obk
2025-05-27 01:29:18 +08:00
许杰友 Jieyou Xu (Joe)
aa9978229e Rollup merge of #141392 - compiler-errors:query-outlives, r=lcnr
Avoid obligation construction dance with query region constraints

And some renaming...
2025-05-27 01:29:17 +08:00
bors
40d2563ea2 Auto merge of #141500 - compiler-errors:rerun-cache-2, r=lcnr
Don't rerun goals if none of their vars have changed

r? `@ghost`

Alternative to rust-lang/rust#141488. I'm pretty sure that we don't need to re-run the goal at all if the inputs don't change... 🤔
2025-05-26 17:02:43 +00:00