Commit Graph

211 Commits

Author SHA1 Message Date
Michael Goulet
89d0e7c033 Fix ProvenVia for global where clauses 2025-04-05 16:23:25 +00:00
bors
17ffbc81a3 Auto merge of #138785 - lcnr:typing-mode-borrowck, r=compiler-errors,oli-obk
add `TypingMode::Borrowck`

Shares the first commit with #138499, doesn't really matter which PR to land first 😊 😁

Introduces `TypingMode::Borrowck` which unlike `TypingMode::Analysis`, uses the hidden type computed by HIR typeck as the initial value of opaques instead of an unconstrained infer var. This is a part of https://github.com/rust-lang/types-team/issues/129.

Using this new `TypingMode` is unfortunately a breaking change for now, see tests/ui/impl-trait/non-defining-uses/as-projection-term.rs. Using an inference variable as the initial value results in non-defining uses in the defining scope. We therefore only enable it if with `-Znext-solver=globally` or `-Ztyping-mode-borrowck`

To do that the PR contains the following changes:
- `TypeckResults::concrete_opaque_type` are already mapped to the definition of the opaque type
  - writeback now checks that the non-lifetime parameters of the opaque are universal
  - for this, `fn check_opaque_type_parameter_valid` is moved from `rustc_borrowck` to `rustc_trait_selection`
- we add a new `query type_of_opaque_hir_typeck` which, using the same visitors as MIR typeck, attempts to merge the hidden types from HIR typeck from all defining scopes
  - done by adding a `DefiningScopeKind` flag to toggle between using borrowck and HIR typeck
  - the visitors stop checking that the MIR type matches the HIR type. This is trivial as the HIR type are now used as the initial hidden types of the opaque. This check is useful as a safeguard when not using `TypingMode::Borrowck`, but adding it to the new structure is annoying and it's not soundness critical, so I intend to not add it back.
- add a `TypingMode::Borrowck`  which behaves just like `TypingMode::Analysis` except when normalizing opaque types
   - it uses `type_of_opaque_hir_typeck(opaque)` as the initial value after replacing its regions with new inference vars
   - it uses structural lookup in the new solver

fixes #112201, fixes #132335, fixes #137751

r? `@compiler-errors` `@oli-obk`
2025-04-04 19:54:42 +00:00
Bryanskiy
581c5fbc40 Initial support for auto traits with default bounds 2025-04-03 14:59:39 +03:00
lcnr
509a144eed add TypingMode::Borrowck 2025-04-03 11:13:10 +02:00
lcnr
cb275d4f26 simplify Interner opaque types API 2025-04-01 23:24:28 +02:00
Michael Goulet
14804d1ed1 Implement lint against using Interner and InferCtxtLike in random compiler crates 2025-03-26 04:39:38 +00:00
Michael Goulet
251455bcc5 Allow WellFormed goals to be returned from relating in new solver 2025-03-24 16:57:06 +00:00
Michael Goulet
220851cc75 Do not rely on type_var_origin in OrphanCheckErr::NonLocalInputType 2025-03-20 02:17:14 +00:00
Michael Goulet
6438b9eca8 Use {Decodable,Encodable}_NoContext in type_ir 2025-03-15 06:34:36 +00:00
Michael Goulet
e5a2220327 Fold visit into ty 2025-03-15 06:34:36 +00:00
Michael Goulet
dc0cdfd753 Squash fold into ty 2025-03-15 06:34:36 +00: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
Matthias Krüger
d55e2e4333
Rollup merge of #137314 - lcnr:cycles-with-unknown-kind, r=compiler-errors
change definitely unproductive cycles to error

builds on top of #136824 by adding a third variant to `PathKind` for paths which may change to be coinductive in the future but must not be so right now. Most notably, impl where-clauses of not yet coinductive traits.

With this, we can change cycles which are definitely unproductive to a proper error. This fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/114. This does not affect stable as we keep these cycles as ambiguous during coherence.

r? ````````@compiler-errors```````` ````````@nikomatsakis````````
2025-03-12 17:59:06 +01: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
许杰友 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
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
许杰友 Jieyou Xu (Joe)
257b4947ed
Rollup merge of #137728 - Darksonn:no-tuple-unsize, r=oli-obk
Remove unsizing coercions for tuples

See https://github.com/rust-lang/rust/issues/42877#issuecomment-2686010847 and below comments for justification.

Tracking issue: #42877
Fixes: #135217
2025-03-05 21:46:44 +08:00
lcnr
18809a2b12 keep inductive cycles as ambig in coherence 2025-03-05 10:06:43 +01:00
lcnr
01795b14f0 change definitely non-productive cycles to error 2025-03-05 10:06:43 +01:00
Matthias Krüger
b6c1b635f7
Rollup merge of #137776 - nnethercote:rustc_transmute-cleanups, r=jswrenn
Some `rustc_transmute` cleanups

A number of small things that can be removed.

r? ``@jswrenn``
2025-03-01 11:34:01 +01: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
lcnr
ef771b8450 review 2025-02-28 12:16:48 +01:00
lcnr
7eb677e7eb normalizing where-clauses is also coinductive, add tests 2025-02-28 12:16:47 +01:00
lcnr
933d45fe8f fix typo 2025-02-28 12:16:47 +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
Nicholas Nethercote
785e21d382 Remove allow(unused_variables) for rustc_transmute.
This was hiding some genuine sins, including unused arguments in
numerous functions/methods (incl. trait methods), and some unnecessary
computation.
2025-02-28 17:31:31 +11:00
Alice Ryhl
44cccae02a Delete tuple unsizing 2025-02-27 10:26:33 +00: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
Matthias Krüger
37e0d138cf
Rollup merge of #137333 - compiler-errors:edition-2024-fresh, r=Nadrieril
Use `edition = "2024"` in the compiler (redux)

Most of this is binding mode changes, which I fixed by running `x.py fix`.

Also adds some miscellaneous `unsafe` blocks for new unsafe standard library functions (the setenv ones), and a missing `unsafe extern` block in some enzyme codegen code, and fixes some precise capturing lifetime changes (but only when they led to errors).

cc ``@ehuss`` ``@traviscross``
2025-02-22 11:36:43 +01:00
Michael Goulet
76d341fa09 Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
Michael Goulet
241a602d27 Make sure we don't overrun the stack in canonicalizer 2025-02-21 18:24:05 +00:00
Michael Goulet
b78c626a95 Make fewer crates depend on rustc_ast_ir 2025-02-19 07:06:54 +00:00
bors
f44efbf9e1 Auto merge of #137235 - matthiaskrgr:rollup-2kjua2t, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #135711 (Do not ICE on default_field_value const with lifetimes)
 - #136599 (librustdoc: more usages of `Joined::joined`)
 - #136876 (Locking documentation updates)
 - #137000 (Deeply normalize item bounds in new solver)
 - #137126 (fix docs for inherent str constructors)
 - #137161 (Pattern Migration 2024: fix incorrect messages/suggestions when errors arise in macro expansions)
 - #137191 (Update mdbook and move error_index_generator)
 - #137203 (Improve MIR modification)
 - #137206 (Make E0599 a structured error)
 - #137218 (misc `layout_of` cleanup)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-18 21:08:58 +00:00
lcnr
f910684616 don't ICE for alias-relate goals with error term 2025-02-18 10:30:37 +01:00
Michael Goulet
2cdb7fac95 Prefer param-env candidates even when alias's trait bound isn't proven via param-env 2025-02-17 16:59:17 +00:00
lcnr
059288ed44 adjust derive_error 2025-02-13 23:49:09 +01:00
lcnr
05bd5ced2d rework pointee handling for the new rigid alias approach 2025-02-13 20:19:11 +00:00
lcnr
de273e459e normalizes-to rework rigid alias handling 2025-02-13 20:19:11 +00:00
Michael Goulet
d0564fda65 Use BikeshedGuaranteedNotDrop in unsafe binder type WF too 2025-02-13 03:45:07 +00:00
Michael Goulet
516afd557c Implement and use BikeshedGuaranteedNoDrop for union/unsafe field validity 2025-02-13 03:45:04 +00:00
bjorn3
1fcae03369 Rustfmt 2025-02-08 22:12:13 +00:00
Matthias Krüger
b4c4913abb
Rollup merge of #136664 - WaffleLapkin:un-map_or-true, r=compiler-errors
replace one `.map_or(true, ...)` with `.is_none_or(...)`

Randomly found while going through some of my old branches.
2025-02-07 18:26:29 +01:00
Waffle Lapkin
d4914a7719
replace one .map_or(true, ...) with .is_none_or(...) 2025-02-06 23:15:41 +01:00
Matthias Krüger
ae1410e2d8
Rollup merge of #136069 - yotamofek:next-solver-slice, r=compiler-errors
Simplify slice indexing in next trait solver

Unless I'm missing something:
- no need to explicitly specify the end of the slice as the end of the index range
- the `assert` is redundant since the indexing will panic for the same condition

I think this change simplifies it a bit. Also replaced the `for` loop of `push`es with a call to `extend` with an iterator. Might improve performance since it knows how many elements will be added beforehand and can pre-reserve room?

r? `@compiler-errors` , I think
2025-02-06 21:56:25 +01:00
Michael Goulet
4e763c2297 Pass spans around new solver 2025-02-05 18:32:06 +00:00
Michael Goulet
fd1110ce6a Remove span from delegate 2025-02-05 18:18:11 +00:00
Lukas Markeffsky
10fc0b159e introduce ty::Value
Co-authored-by: FedericoBruzzone <federico.bruzzone.i@gmail.com>
2025-01-30 17:47:44 +01:00
Michael Goulet
3f8ce7c973 Do not assume child bound assumptions for rigid alias 2025-01-28 19:08:50 +00:00