Commit Graph

8385 Commits

Author SHA1 Message Date
Matthias Krüger
935535d14f
Rollup merge of #137837 - fee1-dead-contrib:push-pvqvwuvrnwsy, r=compiler-errors
Update `const_conditions` and `explicit_implied_const_bounds` docs

Move documentation to query definitions, and add docs to `explicit_implied_const_bounds`.

r? project-const-traits
2025-03-01 16:03:20 +01:00
Matthias Krüger
c03756a56b
Rollup merge of #137800 - BoxyUwU:param_env_docs, r=compiler-errors
Remove `ParamEnv::without_caller_bounds`

This doesn't really do anything that `ParamEnv::empty` doesn't do nowadays as `ParamEnv` *only* stores caller bounds since other information has been moved out into `TypingMode`

r? ```@compiler-errors``` ```@lcnr```
2025-03-01 11:34:02 +01:00
Matthias Krüger
1d9992d4d2
Rollup merge of #137763 - compiler-errors:ty-nits, r=BoxyUwU
Use `mk_ty_from_kind` a bit less, clean up lifetime handling in borrowck

r? ``@BoxyUwU``

Pulled out of my attempt to turn that `*const dyn Tr + '_` casting into a lint (which failed lmao)
2025-03-01 11:34:00 +01:00
Matthias Krüger
415b207b7f
Rollup merge of #137617 - BoxyUwU:generic_const_parameter_types, r=lcnr
Introduce `feature(generic_const_parameter_types)`

Allows to define const generic parameters whose type depends on other generic parameters, e.g. `Foo<const N: usize, const ARR: [u8; N]>;`

Wasn't going to implement for this for a while until we could implement it with `bad_inference.rs` resolved but apparently the project simd folks would like to be able to use this for some intrinsics and the inference issue isn't really a huge problem there aiui. (cc ``@workingjubilee`` )
2025-03-01 11:33:58 +01:00
Deadbeef
2f4b9ddf89 Update const_conditions and explicit_implied_const_bounds docs
Move documentation to query definitions, and add docs to
`explicit_implied_const_bounds`.
2025-03-01 12:58:14 +08:00
Matthias Krüger
3cd89f2718
Rollup merge of #137689 - compiler-errors:coroutine, r=lcnr
Use `Binder<Vec<Ty>>` instead of `Vec<Binder<Ty>>` in both solvers for sized/auto traits/etc.

It's more conceptually justified IMO, especially when binders get implications.

r? lcnr
2025-03-01 05:49:53 +01:00
Boxy
df5b279ca9 Introduce feature(generic_const_parameter_types) 2025-02-28 20:43:15 +00:00
许杰友 Jieyou Xu (Joe)
30cb0282be
Rollup merge of #137780 - samueltardieu:push-kxorztnkqnsz, r=lcnr
Fix typo in query expansion documentation
2025-02-28 21:42:05 +08:00
许杰友 Jieyou Xu (Joe)
585e9031f2
Rollup merge of #137748 - samueltardieu:push-kozpqrxpkxkk, r=lqd
Fix method name in `TyCtxt::hir_crate()` documentation

Fix #137745
2025-02-28 21:42:03 +08:00
许杰友 Jieyou Xu (Joe)
a9f3f02ed7
Rollup merge of #137712 - meithecatte:extract-binding-mode, r=oli-obk
Clean up TypeckResults::extract_binding_mode

- Remove the `Option` from the result type, as `None` is never returned.
- Document the difference from the `BindingMode` in `PatKind::Binding`.
2025-02-28 21:42:00 +08:00
lcnr
ef771b8450 review 2025-02-28 12:16:48 +01:00
lcnr
46faf4bed6 rework cycle handling
A cycle was previously coinductive if all steps were coinductive.
Change this to instead considerm cycles to be coinductive if they
step through at least one where-bound of an impl of a coinductive
trait goal.
2025-02-28 12:16:47 +01:00
Samuel Tardieu
786fc1b0a7 Fix typo in query expansion documentation 2025-02-28 10:33:56 +01:00
bors
cb08599451 Auto merge of #137710 - matthiaskrgr:rollup-3vmxxu9, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #136542 ([`compiletest`-related cleanups 4/7] Make the distinction between root build directory vs test suite specific build directory in compiletest less confusing)
 - #136579 (Fix UB in ThinVec::flat_map_in_place)
 - #136688 (require trait impls to have matching const stabilities as the traits)
 - #136846 (Make `AssocOp` more like `ExprKind`)
 - #137304 (add `IntoBounds::intersect` and `RangeBounds::is_empty`)
 - #137455 (Reuse machinery from `tail_expr_drop_order` for `if_let_rescope`)
 - #137480 (Return unexpected termination error instead of panicing in `Thread::join`)
 - #137694 (Spruce up `AttributeKind` docs)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-28 03:52:52 +00:00
Michael Goulet
371c073ecf Use mk_ty_from_kind a bit less, clean up lifetime handling in borrowck 2025-02-28 01:27:08 +00:00
bors
e6059f5222 Auto merge of #137669 - DianQK:fn-atts-virtual, r=saethlin
Don't infer attributes of virtual calls based on the function body

Fixes (after backport) #137646.
Since we don't know the exact implementation of the virtual call, it might write to parameters, we can't infer the readonly attribute.
2025-02-28 00:31:26 +00:00
Samuel Tardieu
059c0abeee Fix method name in TyCtxt::hir_crate() documentation 2025-02-27 23:47:37 +01:00
Maja Kądziołka
5765005a7f
Clean up TypeckResults::extract_binding_mode
- Remove the `Option` from the result type, as `None` is never returned.
- Document the difference from the `BindingMode` in `PatKind::Binding`.
2025-02-27 10:19:12 +01:00
Matthias Krüger
25db95ec4a
Rollup merge of #137455 - compiler-errors:drop-lint-dtor, r=oli-obk
Reuse machinery from `tail_expr_drop_order` for `if_let_rescope`

Namely, it defines its own `extract_component_with_significant_dtor` which is a bit more accurate than `Ty::has_significant_drop`, since it has a hard-coded list of types from the ecosystem which are opted out of the lint.[^a]

Also, since we extract the dtors themselves, adopt the same *label* we use in `tail_expr_drop_order` to point out the destructor impl. This makes it much clear what's actually being dropped, so it should be clearer to know when it's a false positive.

This conflicts with #137444, but I will rebase whichever lands first.

[^a]: Side-note, it's kinda a shame that now there are two functions that presumably do the same thing. But this isn't my circus, nor are these my monkeys.
2025-02-27 08:56:39 +01:00
Matthias Krüger
4ecca4c09c
Rollup merge of #136846 - nnethercote:make-AssocOp-more-like-ExprKind, r=spastorino
Make `AssocOp` more like `ExprKind`

This is step 1 of [MCP 831](https://github.com/rust-lang/compiler-team/issues/831).

r? ``@estebank``
2025-02-27 08:56:37 +01:00
DianQK
8089fce101
Don't infer attributes of virtual calls based on the function body 2025-02-27 12:57:26 +08:00
Nicholas Nethercote
ceafbad81f Introduce AssocOp::Binary.
It mirrors `ExprKind::Binary`, and contains a `BinOpKind`. This makes
`AssocOp` more like `ExprKind`. Note that the variants removed from
`AssocOp` are all named differently to `BinOpToken`, e.g. `Multiply`
instead of `Mul`, so that's an inconsistency removed.

The commit adds `precedence` and `fixity` methods to `BinOpKind`, and
calls them from the corresponding methods in `AssocOp`. This avoids the
need to create an `AssocOp` from a `BinOpKind` in a bunch of places, and
`AssocOp::from_ast_binop` is removed.

`AssocOp::to_ast_binop` is also no longer needed.

Overall things are shorter and nicer.
2025-02-27 09:53:17 +11:00
Boxy
b3330f8182 Remove ParamEnv::without_caller_bounds 2025-02-26 19:41:53 +00:00
Michael Goulet
864cca80b0 Print out destructor 2025-02-26 19:03:29 +00:00
León Orell Valerian Liehr
46eb43e71b
Rollup merge of #137671 - meithecatte:discoverable-dump-mir, r=Nadrieril
Make -Z unpretty=mir suggest -Z dump-mir as well for discoverability

While debugging something else, I got quite annoyed with `-Z unpretty=mir` showing me post-processed MIR instead of the one just after it is built. I ended up asking on Zulip and got pointed to `-Z dump-mir`. While this feature is documented in the rustc dev guide, I think it'd be good if the possibility of making use of it was staring you in the face while you need it.
2025-02-26 19:03:59 +01:00
León Orell Valerian Liehr
5da5c37387
Rollup merge of #137201 - estebank:structured-errors-long-ty, r=oli-obk
Teach structured errors to display short `Ty<'_>`

Make it so that in every structured error annotated with `#[derive(Diagnostic)]` that has a field of type `Ty<'_>`, the printing of that value into a `String` will look at the thread-local storage `TyCtxt` in order to shorten to a length appropriate with the terminal width. When this happen, the resulting error will have a note with the file where the full type name was written to.

```
error[E0618]: expected function, found `((..., ..., ..., ...), ..., ..., ...)``
 --> long.rs:7:5
  |
6 | fn foo(x: D) { //~ `x` has type `(...
  |        - `x` has type `((..., ..., ..., ...), ..., ..., ...)`
7 |     x(); //~ ERROR expected function, found `(...
  |     ^--
  |     |
  |     call expression requires function
  |
  = note: the full name for the type has been written to 'long.long-type-14182675702747116984.txt'
  = note: consider using `--verbose` to print the full type name to the console
```

Follow up to and response to the comments on #136898.

r? ``@oli-obk``
2025-02-26 19:03:55 +01:00
Michael Goulet
ad74788670 Use bound_coroutine_witnesses in old solver 2025-02-26 17:32:53 +00:00
Michael Goulet
8282181e42 Use Binder<Vec<T>> instead of Vec<Binder<T>> in new solver 2025-02-26 17:32:26 +00:00
bors
ac91805f31 Auto merge of #137354 - FractalFir:intern_with_cap, r=FractalFir
Change interners to start preallocated with an increased capacity

Inspired by https://github.com/rust-lang/rust/issues/137005.

Added a `with_capacity` function to `InternedSet`. Changed the `CtxtInterners` to start with `InternedSets` preallocated with a capacity.

This *does* increase memory usage at very slightly(by ~1 MB at the start), altough that increase quickly disaperars for larger crates(since they require such capacity anyway).

A local perf run indicates this improves compiletimes for small crates(like `ripgrep`), without a negative effect on larger ones.
2025-02-26 13:01:45 +00:00
Maja Kądziołka
b8c7e8aa72
Make -Z unpretty=mir suggest -Z dump-mir as well 2025-02-26 13:07:12 +01:00
León Orell Valerian Liehr
51085b21ce
Rollup merge of #137601 - davidtwco:deduplicate-type-has-metadata, r=fmease,bjorn3
ssa/mono: deduplicate `type_has_metadata`

The implementation of the `type_has_metadata` function is duplicated in `rustc_codegen_ssa` and `rustc_monomorphize`, so move this to `rustc_middle`.
2025-02-26 04:15:05 +01:00
León Orell Valerian Liehr
292c003ce7
Rollup merge of #137529 - klensy:unused3, r=lcnr
remove few unused args
2025-02-26 04:15:04 +01:00
Esteban Küber
d12ecaed55 Teach structured errors to display short Ty
Make it so that every structured error annotated with `#[derive(Diagnostic)]` that has a field of type `Ty<'_>`, the printing of that value into a `String` will look at the thread-local storage `TyCtxt` in order to shorten to a length appropriate with the terminal width. When this happen, the resulting error will have a note with the file where the full type name was written to.

```
error[E0618]: expected function, found `((..., ..., ..., ...), ..., ..., ...)``
 --> long.rs:7:5
  |
6 | fn foo(x: D) { //~ `x` has type `(...
  |        - `x` has type `((..., ..., ..., ...), ..., ..., ...)`
7 |     x(); //~ ERROR expected function, found `(...
  |     ^--
  |     |
  |     call expression requires function
  |
  = note: the full name for the type has been written to 'long.long-type-14182675702747116984.txt'
  = note: consider using `--verbose` to print the full type name to the console
```
2025-02-25 16:56:03 +00:00
klensy
8467a76581 remove unused field from VariantDef::new and convert debug to instrument 2025-02-25 14:43:58 +03:00
bors
ad27045c31 Auto merge of #137571 - tgross35:rollup-i1tcnv1, r=tgross35
Rollup of 8 pull requests

Successful merges:

 - #134655 (Stabilize `hash_extract_if`)
 - #135933 (Explain how Vec::with_capacity is faithful)
 - #136668 (Stabilize `core::str::from_utf8_mut` as `const`)
 - #136775 (Update `String::from_raw_parts` safety requirements)
 - #137109 (stabilize extract_if)
 - #137349 (Implement `read_buf` for zkVM stdin)
 - #137493 (configure.py: don't instruct user to run nonexistent program)
 - #137516 (remove some unnecessary rustc_const_unstable)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-25 05:41:34 +00:00
bors
f5729cfed3 Auto merge of #137573 - compiler-errors:rollup-noq9yhp, r=compiler-errors
Rollup of 11 pull requests

Successful merges:

 - #136522 (Remove `feature(dyn_compatible_for_dispatch)` from the compiler)
 - #137289 (Consolidate and improve error messaging for `CoerceUnsized` and `DispatchFromDyn`)
 - #137321 (Correct doc about `temp_dir()` behavior on Android)
 - #137417 (rustc_target: Add more RISC-V atomic-related features)
 - #137489 (remove `#[rustc_intrinsic_must_be_overridde]`)
 - #137530 (DWARF mixed versions with LTO on MIPS)
 - #137543 (std: Fix another new symlink test on Windows)
 - #137548 (Pass correct `TypingEnv` to `InlineAsmCtxt`)
 - #137550 (Don't immediately panic if dropck fails without returning errors)
 - #137552 (Update books)
 - #137556 (rename simd_shuffle_generic → simd_shuffle_const_generic)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-25 02:24:40 +00:00
Michael Goulet
8f729e9cff
Rollup merge of #137489 - RalfJung:no-more-rustc_intrinsic_must_be_overridden, r=oli-obk
remove `#[rustc_intrinsic_must_be_overridde]`

In https://github.com/rust-lang/rust/pull/135031, we gained support for just leaving away the body. Now that the bootstrap compiler got bumped, stop using the old style and remove support for it.

r? `@oli-obk`

There are a few more mentions of this attribute in RA code that I didn't touch; Cc `@rust-lang/rust-analyzer`
2025-02-24 19:21:47 -05:00
Michał Kostrubiec
7d2cfcab9d Changed interners to start with preallocated capacity 2025-02-25 01:17:01 +01:00
Trevor Gross
57ce16ca27
Rollup merge of #137109 - bend-n:knife, r=oli-obk
stabilize extract_if

Tracking issue: #43244
Closes: #43244
FCP completed: https://github.com/rust-lang/rust/issues/43244#issuecomment-2523595704
2025-02-24 18:46:35 -05:00
bors
7d8c6e781d Auto merge of #135726 - jdonszelmann:attr-parsing, r=oli-obk
New attribute parsing infrastructure

Another step in the plan outlined in https://github.com/rust-lang/rust/issues/131229

introduces infrastructure for structured parsers for attributes, as well as converting a couple of complex attributes to have such structured parsers.

This PR may prove too large to review. I left some of my own comments to guide it a little. Some general notes:

- The first commit is basically standalone. It just preps some mostly unrelated sources for the rest of the PR to work. It might not have enormous merit on its own, but not negative merit either. Could be merged alone, but also doesn't make the review a whole lot easier. (but it's only +274 -209)
- The second commit is the one that introduces new infrastructure. It's the important one to review.
- The 3rd commit uses the new infrastructure showing how some of the more complex attributes can be parsed using it. Theoretically can be split up, though the parsers in this commit are the ones that really test the new infrastructure and show that it all works.
- The 4th commit fixes up rustdoc and clippy. In the previous 2 they didn't compile yet while the compiler does. Separated them out to separate concerns and make the rest more palatable.
- The 5th commit blesses some test outputs. Sometimes that's just because a diagnostic happens slightly earlier than before, which I'd say is acceptable. Sometimes a diagnostic is now only emitted once where it would've been twice before (yay! fixed some bugs). One test I actually moved from crashes to fixed, because it simply doesn't crash anymore. That's why this PR  Closes #132391. I think most choices I made here are generally reasonable, but let me know if you disagree anywhere.
- The 6th commit adds a derive to pretty print attributes
- The 7th removes smir apis for attributes, for the time being. The api will at some point be replaced by one based on `rustc_ast_data_structures::AttributeKind`

In general, a lot of the additions here are comments. I've found it very important to document new things in the 2nd commit well so other people can start using it.

Closes #132391
Closes #136717
2025-02-24 23:07:24 +00:00
Jana Dönszelmann
7e0f5b5016
Introduce new-style attribute parsers for several attributes
note: compiler compiles but librustdoc and clippy don't
2025-02-24 14:31:17 +01:00
Jana Dönszelmann
115b3b03b0
Change span field accesses to method calls 2025-02-24 14:22:31 +01:00
David Wood
5afa6a111b
ssa/mono: deduplicate type_has_metadata
The implementation of the `type_has_metadata` function is duplicated in
`rustc_codegen_ssa` and `rustc_monomorphize`, so move this to
`rustc_middle`.
2025-02-24 08:08:23 +00:00
Ralf Jung
6eea027aa9 remove support for rustc_intrinsic_must_be_overridden from the compiler 2025-02-24 07:53:59 +01:00
Nicholas Nethercote
4183c08511 Fix some use items that import more than necessary. 2025-02-24 09:30:42 +11:00
Nicholas Nethercote
1eddb158f9 Move impl blocks out of rustc_middle/src/mir/syntax.rs.
As the comment at the top says, this file is not supposed to contain any
code. But some has crept in. This commit moves it out.
2025-02-24 09:16:10 +11:00
bendn
c39f33baae
stabilize extract_if 2025-02-23 21:11:12 +07:00
bors
b880760977 Auto merge of #137237 - cuviper:stage0, r=Mark-Simulacrum
Master bootstrap update

https://forge.rust-lang.org/release/process.html#master-bootstrap-update-tuesday

r? `@Mark-Simulacrum`
2025-02-23 11:12:56 +00:00
Jacob Pratt
d41520052e
Rollup merge of #137458 - compiler-errors:render-fn, r=fmease
Fix missing self subst when rendering `impl Fn*<T>` with no output type

r? `@fmease` or reassign

Fixes #133597
cc #137456
2025-02-23 02:44:20 -05:00
Jacob Pratt
7f14d2eba4
Rollup merge of #137334 - compiler-errors:edition-2024-fresh-2, r=saethlin,traviscross
Greatly simplify lifetime captures in edition 2024

Remove most of the `+ Captures` and `+ '_` from the compiler, since they are now unnecessary with the new edition 2021 lifetime capture rules. Use some `+ 'tcx` and `+ 'static` rather than being overly verbose with precise capturing syntax.
2025-02-23 02:44:18 -05:00