Commit graph

2950 commits

Author SHA1 Message Date
Matthias Krüger
1a7d2b9219
Rollup merge of #138109 - Kohei316:feat/rust-doc-precise-capturing-arg, r=aDotInTheVoid,compiler-errors
make precise capturing args in rustdoc Json typed

close #137616

This PR includes below changes.

- Add `rustc_hir::PreciseCapturingArgKind` which allows the query system to return a arg's data.
- Add `rustdoc::clean::types::PreciseCapturingArg` and change to use it.
- Add `rustdoc-json-types::PreciseCapturingArg` and change to use it.
- Update `tests/rustdoc-json/impl-trait-precise-capturing.rs`.
- Bump `rustdoc_json_types::FORMAT_VERSION`.
2025-03-13 11:28:26 +01:00
bors
8536f201ff Auto merge of #138416 - Manishearth:rollup-fejor9p, r=Manishearth
Rollup of 12 pull requests

Successful merges:

 - #134076 (Stabilize `std::io::ErrorKind::InvalidFilename`)
 - #137504 (Move methods from Map to TyCtxt, part 4.)
 - #138175 (Support rmeta inputs for --crate-type=bin --emit=obj)
 - #138259 (Disentangle `ForwardGenericParamBan` and `ConstParamTy` ribs)
 - #138280 (fix ICE in pretty-printing `global_asm!`)
 - #138318 (Rustdoc: remove a bunch of `@ts-expect-error` from main.js)
 - #138331 (Use `RUSTC_LINT_FLAGS` more)
 - #138357 (merge `TypeChecker` and `TypeVerifier`)
 - #138394 (remove unnecessary variant)
 - #138403 (Delegation: one more ICE fix for `MethodCall` generation)
 - #138407 (Delegation: reject C-variadics)
 - #138409 (Use sa_sigaction instead of sa_union.__su_sigaction for AIX)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-13 01:37:26 +00:00
Michael Goulet
7a08d0368f Add an opt-out in pretty printing for RTN rendering 2025-03-12 19:42:18 +00:00
bors
249cb84316 Auto merge of #138414 - matthiaskrgr:rollup-9ablqdb, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #137314 (change definitely unproductive cycles to error)
 - #137701 (Convert `ShardedHashMap` to use `hashbrown::HashTable`)
 - #138269 (uefi: fs: Implement FileType, FilePermissions and FileAttr)
 - #138331 (Use `RUSTC_LINT_FLAGS` more)
 - #138345 (Some autodiff cleanups)
 - #138387 (intrinsics: remove unnecessary leading underscore from argument names)
 - #138390 (fix incorrect tracing log)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-12 17:27:43 +00:00
Manish Goregaokar
9d1b62c109
Rollup merge of #138407 - Bryanskiy:delegation-variadic, r=petrochenkov
Delegation: reject C-variadics

The explanation is contained in attached issues.

Fixes https://github.com/rust-lang/rust/issues/127443
Fixes https://github.com/rust-lang/rust/issues/127413

r? `@petrochenkov`
2025-03-12 10:19:34 -07:00
Manish Goregaokar
245d3a90ca
Rollup merge of #138331 - nnethercote:use-RUSTC_LINT_FLAGS-more, r=onur-ozkan,jieyouxu
Use `RUSTC_LINT_FLAGS` more

An alternative to the failed #138084.

Fixes #138106.

r? `````@jieyouxu`````
2025-03-12 10:19:30 -07:00
Manish Goregaokar
f88f27aff0
Rollup merge of #137504 - nnethercote:remove-Map-4, r=Zalathar
Move methods from Map to TyCtxt, part 4.

A follow-up to https://github.com/rust-lang/rust/pull/137350.

r? ```@Zalathar```
2025-03-12 10:19:26 -07:00
Matthias Krüger
d93ef397ce
Rollup merge of #138331 - nnethercote:use-RUSTC_LINT_FLAGS-more, r=onur-ozkan,jieyouxu
Use `RUSTC_LINT_FLAGS` more

An alternative to the failed #138084.

Fixes #138106.

r? ````@jieyouxu````
2025-03-12 17:59:08 +01:00
bors
aaa2d47dae Auto merge of #138083 - nnethercote:rm-NtItem-NtStmt, r=petrochenkov
Remove `NtItem` and `NtStmt`

Another piece of #124141.

r? `@petrochenkov`
2025-03-12 14:18:36 +00:00
Bryanskiy
ccdba16f42 Delegation: reject C-variadics 2025-03-12 17:14:51 +03:00
Nicholas Nethercote
256c27e748 Move methods from Map to TyCtxt, part 4.
Continuing the work from #137350.

Removes the unused methods: `expect_variant`, `expect_field`,
`expect_foreign_item`.

Every method gains a `hir_` prefix.
2025-03-12 08:55:37 +11:00
bors
c625102320 Auto merge of #138366 - matthiaskrgr:rollup-cn16m7q, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #137715 (Allow int literals for pattern types with int base types)
 - #138002 (Disable CFI for weakly linked syscalls)
 - #138051 (Add support for downloading GCC from CI)
 - #138231 (Prevent ICE in autodiff validation by emitting user-friendly errors)
 - #138245 (stabilize `ci_rustc_if_unchanged_logic` test for local environments)
 - #138256 (Do not feed anon const a type that references generics that it does not have)
 - #138284 (Do not write user type annotation for const param value path)
 - #138296 (Remove `AdtFlags::IS_ANONYMOUS` and `Copy`/`Clone` condition for anonymous ADT)
 - #138352 (miri native_calls: ensure we actually expose *mutable* provenance to the memory FFI can access)
 - #138354 (remove redundant `body`  arguments)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-11 21:17:18 +00:00
Matthias Krüger
4ff58c9103
Rollup merge of #138256 - compiler-errors:anon-const-ty, r=BoxyUwU
Do not feed anon const a type that references generics that it does not have

Fixes #137865

See the comment I left in the code. We could alternatively give these anon consts the generics from the parent, but that would be moving in a GCE-esque direction that we may not want. Open to tweaks here.

r? BoxyUwU
2025-03-11 19:35:31 +01:00
bors
6650252439 Auto merge of #128440 - oli-obk:defines, r=lcnr
Add `#[define_opaques]` attribute and require it for all type-alias-impl-trait sites that register a hidden type

Instead of relying on the signature of items to decide whether they are constraining an opaque type, the opaque types that the item constrains must be explicitly listed.

A previous version of this PR used an actual attribute, but had to keep the resolved `DefId`s in a side table.

Now we just lower to fields in the AST that have no surface syntax, instead a builtin attribute macro fills in those fields where applicable.

Note that for convenience referencing opaque types in associated types from associated methods on the same impl will not require an attribute. If that causes problems `#[defines()]` can be used to overwrite the default of searching for opaques in the signature.

One wart of this design is that closures and static items do not have generics. So since I stored the opaques in the generics of functions, consts and methods, I would need to add a custom field to closures and statics to track this information. During a T-types discussion we decided to just not do this for now.

fixes #131298
2025-03-11 18:13:31 +00:00
Jakub Beránek
03a79a77ac
Rollup merge of #138315 - matthiaskrgr:nextback, r=fmease
use next_back() instead of last() on DoubleEndedIterator
2025-03-11 13:30:55 +01:00
Oli Scherer
cb4751d4b8 Implement #[define_opaque] attribute for functions. 2025-03-11 12:05:02 +00:00
Nicholas Nethercote
ff0a5fe975 Remove #![warn(unreachable_pub)] from all compiler/ crates.
It's no longer necessary now that `-Wunreachable_pub` is being passed.
2025-03-11 13:14:21 +11:00
bors
90384941aa Auto merge of #138302 - matthiaskrgr:rollup-an2up80, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #136395 (Update to rand 0.9.0)
 - #137279 (Make some invalid codegen attr errors structured/translatable)
 - #137585 (Update documentation to consistently use 'm' in atomic synchronization example)
 - #137926 (Add a test for `-znostart-stop-gc` usage with LLD)
 - #138074 (Support `File::seek` for Hermit)
 - #138238 (Fix dyn -> param suggestion in struct ICEs)
 - #138270 (chore: Fix some comments)
 - #138286 (triagebot.toml: Don't label `test/rustdoc-json` as A-rustdoc-search (…)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-11 00:55:25 +00:00
Matthias Krüger
dcf6137b5c use next_back() instead of last() on DoubleEndedIterator 2025-03-10 19:03:51 +01:00
Matthias Krüger
44ec67fffb
Rollup merge of #138306 - jieyouxu:revert-workspace-lints, r=Noratrieb
Revert "Use workspace lints for crates in `compiler/` #138084"

Revert <https://github.com/rust-lang/rust/pull/138084> to buy time to consider options that avoids breaking downstream usages of cargo on distributed `rustc-src` artifacts, where such cargo invocations fail due to inability to inherit `lints` from workspace root manifest's `workspace.lints` (this is only valid for the source rust-lang/rust workspace, but not really the distributed `rustc-src` artifacts). The problem is that the `rustc-src` component doesn't include the root `Cargo.toml` manifest.

This breakage was reported in https://github.com/rust-lang/rust/issues/138304.

This reverts commit 48caf81484, reversing changes made to c6662879b2.

cc `@RalfJung`

r? `@nnethercote` (sorry, I didn't consider this being a thing 💀)
2025-03-10 15:57:22 +01:00
Michael Goulet
bc4f0bb486 Pass InferCtxt to InlineAsmCtxt to properly taint on error
Split up some of the tests bc tainting causes some errors to become
suppressed
2025-03-10 14:28:09 +00:00
morine0122
112f7b01a1 make precise capturing args in rustdoc Json typed 2025-03-10 21:40:09 +09:00
许杰友 Jieyou Xu (Joe)
063ef18fdc Revert "Use workspace lints for crates in compiler/ #138084"
Revert <https://github.com/rust-lang/rust/pull/138084> to buy time to
consider options that avoids breaking downstream usages of cargo on
distributed `rustc-src` artifacts, where such cargo invocations fail due
to inability to inherit `lints` from workspace root manifest's
`workspace.lints` (this is only valid for the source rust-lang/rust
workspace, but not really the distributed `rustc-src` artifacts).

This breakage was reported in
<https://github.com/rust-lang/rust/issues/138304>.

This reverts commit 48caf81484, reversing
changes made to c6662879b2.
2025-03-10 18:12:47 +08:00
Matthias Krüger
1ae083ddd5
Rollup merge of #138238 - compiler-errors:dyn-suggestion-in-struct, r=nnethercote
Fix dyn -> param suggestion in struct ICEs

Makes the logic from #138042 a bit less ICEy and more clean. Also fixes an incorrect suggestion when the struct already has generics. I'll point out the major changes and observations in the code.

Fixes #138229
Fixes #138211

r? nnethercote since you reviewed the original pr, or re-roll if you don't want to review this
2025-03-10 09:32:14 +01:00
Michael Goulet
ed6dfddfeb Do not feed anon const a type that references generics that it does not have 2025-03-09 20:03:13 +00:00
Matthias Krüger
48caf81484
Rollup merge of #138084 - nnethercote:workspace-lints, r=jieyouxu
Use workspace lints for crates in `compiler/`

This is nicer and hopefully less error prone than specifying lints via bootstrap.

r? ``@jieyouxu``
2025-03-09 10:34:50 +01:00
Michael Goulet
ceb040135d Fix suggestion when there are generics, inline some things 2025-03-08 20:44:57 +00:00
Michael Goulet
bca0ab8d7a Rework maybe_suggest_add_generic_impl_trait 2025-03-08 20:40:59 +00:00
Jacob Pratt
9aac24d68a
Rollup merge of #138173 - compiler-errors:incoherent-negative-impl, r=oli-obk
Delay bug for negative auto trait rather than ICEing

Fixes #138149

r? oli-obk
2025-03-07 21:57:53 -05:00
Nicholas Nethercote
8a3e03392e Remove #![warn(unreachable_pub)] from all compiler/ crates.
(Except for `rustc_codegen_cranelift`.)

It's no longer necessary now that `unreachable_pub` is in the workspace
lints.
2025-03-08 08:41:43 +11:00
Nicholas Nethercote
beba32cebb Specify rust lints for compiler/ crates via Cargo.
By naming them in `[workspace.lints.rust]` in the top-level
`Cargo.toml`, and then making all `compiler/` crates inherit them with
`[lints] workspace = true`. (I omitted `rustc_codegen_{cranelift,gcc}`,
because they're a bit different.)

The advantages of this over the current approach:
- It uses a standard Cargo feature, rather than special handling in
  bootstrap. So, easier to understand, and less likely to get
  accidentally broken in the future.
- It works for proc macro crates.

It's a shame it doesn't work for rustc-specific lints, as the comments
explain.
2025-03-08 08:41:09 +11:00
Matthias Krüger
e70adad70a
Rollup merge of #138042 - xizheyin:issue-135759, r=nnethercote
Suggest struct or union to add generic that impls trait

Fixes #135759

cc ```@tdittr```
2025-03-07 19:15:35 +01:00
Michael Goulet
bbc80a819b Delay bug for negative auto trait rather than ICEing 2025-03-07 17:20:57 +00:00
Nicholas Nethercote
7943932384 Pass Option<Symbol> to def_path_data/create_def methods.
It's clearer than using `kw::Empty` to mean `None`.
2025-03-07 20:53:00 +11:00
Nicholas Nethercote
293fe0a966 Increase recursion_limit in numerous crates.
This is temporarily needed for `x doc compiler` to work. They can be
removed once the `Nonterminal` is removed (#124141).
2025-03-07 14:51:07 +11:00
Michael Goulet
1c3733aa69
Rollup merge of #137808 - jswrenn:droppy-unsafe-fields, r=nnethercote
Do not require that unsafe fields lack drop glue

Instead, we adopt the position that introducing an `unsafe` field itself carries a safety invariant: that if you assign an invariant to that field weaker than what the field's destructor requires, you must ensure that field is in a droppable state in your destructor.

See:
- https://github.com/rust-lang/rfcs/pull/3458#discussion_r1971676100
- 502113897

Tracking Issue: #132922
2025-03-06 12:22:19 -05:00
Michael Goulet
00132141c7
Rollup merge of #137764 - compiler-errors:always-applicable-negative-impl, r=lcnr
Ensure that negative auto impls are always applicable

r? lcnr (or reassign if you dont want to review)

https://github.com/rust-lang/rust/issues/68318#issuecomment-2689265030
2025-03-06 12:22:16 -05:00
Michael Goulet
aab7b145d0
Rollup merge of #137565 - compiler-errors:macro-ex, r=estebank
Try to point of macro expansion from resolver and method errors if it involves macro var

In the case that a macro caller passes an identifier into a macro generating a path or method expression, point out that identifier in the context of the *macro* so it's a bit more clear how the macro is involved in causing the error.

r? ``````````@estebank`````````` or reassign
2025-03-06 12:22:13 -05:00
Oli Scherer
e8f7a382be Remove the Option part of range ends in the HIR 2025-03-06 10:47:40 +00:00
Oli Scherer
0e7b283573 Avoid having to handle an Option in the type system 2025-03-06 10:03:11 +00:00
Oli Scherer
4f2b108816 Prefer a two value enum over bool 2025-03-06 10:03:11 +00:00
许杰友 Jieyou Xu (Joe)
6c60abf51a
Rollup merge of #137633 - compiler-errors:no-implied-bounds-hack-unless-bevy, r=lcnr
Only use implied bounds hack if bevy, and use deeply normalize in implied bounds hack

Consolidates the implied bounds computation mode into a single function, which deeply normalizes, and if it's in **compat** mode (for bevy), it extracts outlives bounds from the infcx.

Previously, we were using the implied bounds compat mode in two cases:
1. During WF, if it detects `ParamSet`
2. EVERYWHERE ELSE (lol) -- e.g. borrowck, predicate entailment, etc.

While I think this is fine, and the net effect was just that we emitted fewer diagnostics, it makes me uncomfortable that all crates were using the supposed "compat" code.

Fixes #137767
2025-03-05 21:46:42 +08:00
许杰友 Jieyou Xu (Joe)
5df9a9f45c
Rollup merge of #137298 - compiler-errors:mir-wf, r=lcnr
Check signature WF when lowering MIR body

Alternative to #137233.

https://github.com/rust-lang/rust/pull/137233#issuecomment-2667879143

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

We do this check in `mir_drops_elaborated_and_const_checked` and not during `mir_promoted` because that may result in borrowck cycles if WF requires looking into an opaque hidden type. This causes some TAIT tests to fail unnecessarily.

r? lcnr

try-job: test-various
2025-03-05 21:46:39 +08:00
xizheyin
d7ed32b0c0
Suggest struct or union to add generic that impls trait
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-03-05 16:03:56 +08:00
Jubilee
b3d7c1483d
Rollup merge of #137913 - compiler-errors:struct-field-default-generic, r=BoxyUwU
Allow struct field default values to reference struct's generics

Right now, the default field value feature (https://github.com/rust-lang/rust/issues/132162) lowers anon consts whose types may reference ADT params that the const doesn't inherit.

This PR fixes this, so that these defaults can reference ADTs' generics, and sets the `generics_of` parenting up correctly.

There doesn't seem to be a good reason not to support this, since the anon const has a well-defined type from the field, and the anon const doesn't interact with the type system like generic parameter defaults do.

r? `````@boxyuwu````` or reassign

I could also make this into an error if this seems problematic (https://github.com/rust-lang/rust/compare/master...compiler-errors:rust:default-field-value-implicit-param?expand=1)...... but I'd rather make this work and register an open question on the tracking issue about validating that this is well-vetted.

Fixes #137896
2025-03-04 19:37:01 -08:00
Michael Goulet
d759958131 Only use implied bounds hack if bevy, and use deeply normalize in implied bounds hack 2025-03-04 18:18:48 +00:00
Michael Goulet
05a80608b3 Make rustdoc tests use always applicable negative auto impls 2025-03-04 18:04:07 +00:00
Michael Goulet
3d62b279dd Ensure that negative auto impls are always applicable 2025-03-04 17:45:18 +00:00
Noah Lev
177e7ff548 mgca: Lower all const paths as ConstArgKind::Path
When `#![feature(min_generic_const_args)]` is enabled, we now lower all
const paths in generic arg position to `hir::ConstArgKind::Path`. We
then lower assoc const paths to `ty::ConstKind::Unevaluated` since we
can no longer use the anon const expression lowering machinery. In the
process of implementing this, I factored out `hir_ty_lowering` code that
is now shared between lowering assoc types and assoc consts.

This PR also introduces a `#[type_const]` attribute for trait assoc
consts that are allowed as const args. However, we still need to
implement code to check that assoc const definitions satisfy
`#[type_const]` if present (basically is it a const path or a
monomorphic anon const).
2025-03-04 10:11:13 -05:00
Michael Goulet
3e5fddc95e Allow struct field default values to reference struct's generics 2025-03-04 01:00:55 +00:00