Commit graph

224 commits

Author SHA1 Message Date
bors
f433fa46b0 Auto merge of #139845 - Zalathar:rollup-u5u5y1v, r=Zalathar
Rollup of 17 pull requests

Successful merges:

 - #138374 (Enable contracts for const functions)
 - #138380 (ci: add runners for vanilla LLVM 20)
 - #138393 (Allow const patterns of matches to contain pattern types)
 - #139517 (std: sys: process: uefi: Use NULL stdin by default)
 - #139554 (std: add Output::exit_ok)
 - #139660 (compiletest: Add an experimental new executor to replace libtest)
 - #139669 (Overhaul `AssocItem`)
 - #139671 (Proc macro span API redesign: Replace proc_macro::SourceFile by Span::{file, local_file})
 - #139750 (std/thread: Use default stack size from menuconfig for NuttX)
 - #139772 (Remove `hir::Map`)
 - #139785 (Let CStrings be either 1 or 2 byte aligned.)
 - #139789 (do not unnecessarily leak auto traits in item bounds)
 - #139791 (drop global where-bounds before merging candidates)
 - #139798 (normalize: prefer `ParamEnv` over `AliasBound` candidates)
 - #139822 (Fix: Map EOPNOTSUPP to ErrorKind::Unsupported on Unix)
 - #139833 (Fix some HIR pretty-printing problems)
 - #139836 (Basic tests of MPMC receiver cloning)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-04-15 08:02:23 +00:00
Stuart Cook
b21c5cd025
Rollup merge of #139798 - lcnr:where-bounds-gt-alias-bound, r=compiler-errors
normalize: prefer `ParamEnv` over `AliasBound` candidates

cc https://github.com/rust-lang/trait-system-refactor-initiative/issues/175 not the only issue affecting bevy sadly

r? ``@compiler-errors``
2025-04-15 15:47:30 +10:00
Stuart Cook
e8c9dcc79e
Rollup merge of #139791 - lcnr:ignore-global-where-bounds, r=compiler-errors
drop global where-bounds before merging candidates

fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/172

r? ```@compiler-errors```
2025-04-15 15:47:30 +10:00
Yotam Ofek
4b63362f3d Use newtype_index!-generated types more idiomatically 2025-04-14 16:17:06 +00:00
lcnr
9c88eb6c43 normalize: prefer ParamEnv over AliasBound 2025-04-14 14:46:48 +02:00
lcnr
ce9d8678ca do not leak auto traits in item bounds 2025-04-14 13:26:13 +02:00
lcnr
2c2c9df653 drop global where-bounds before merging candidates 2025-04-14 12:59:22 +02:00
bors
9d28fe3976 Auto merge of #139000 - compiler-errors:rigid-missing-item, r=lcnr
Rigidly project missing item due to guaranteed impossible sized predicate

This is a somewhat involved change, but it amounts to treating missing impl items due to guaranteed impossible where clauses (dyn/str/slice sized, cc #135480) as *rigid projections* rather than projecting to an error term, since that was preventing either reporting a proper error (in an empty param env) *or* successfully type checking the code (in the presence of trivially false where clauses).

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

r? `@lcnr` `@oli-obk`
2025-04-10 04:03:59 +00:00
Michael Goulet
6cd724bb43 Make unnormalizable item ambiguous in coherence 2025-04-09 20:31:58 +00:00
Michael Goulet
830aeb6102 Use a query rather than recomputing the tail repeatedly 2025-04-09 20:26:58 +00:00
Michael Goulet
ccdfd310be Mark GAT WC as GoalSource::AliasWellFormed so that we recurse into them in error reporting 2025-04-09 20:26:57 +00:00
Michael Goulet
27836e1e57 Rigidly project missing item due to guaranteed impossible sized predicate 2025-04-09 20:26:57 +00:00
Boxy
c93005ee65 update cfgs 2025-04-09 12:29:59 +01:00
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