about summary refs log tree commit diff
path: root/compiler/rustc_middle
AgeCommit message (Collapse)AuthorLines
2023-10-31Rollup merge of #117438 - cjgillot:deterministic-error, r=oli-obkMatthias Krüger-2/+4
Do not ICE on constant evaluation failure in GVN. Fixes https://github.com/rust-lang/rust/issues/117362
2023-10-31Do not ICE on constant evaluation failure in GVN.Camille GILLOT-2/+4
2023-10-31Auto merge of #117377 - dtolnay:deprecatedsince, r=cjgillotbors-52/+20
Store #[deprecated] attribute's `since` value in parsed form This PR implements the first followup bullet listed in https://github.com/rust-lang/rust/pull/117148#issue-1960240108. We centralize error handling to the attribute parsing code in `compiler/rustc_attr/src/builtin.rs`, and thereby remove some awkward error codepaths from later phases of compilation that had to make sense of these #\[deprecated\] attributes, namely `compiler/rustc_passes/src/stability.rs` and `compiler/rustc_middle/src/middle/stability.rs`.
2023-10-30Add method for checking if deprecation is a rustc versionDavid Tolnay-1/+1
2023-10-30Descriptive variant name deprecation versions outside the standard libraryDavid Tolnay-1/+3
2023-10-30Some more coroutine renamingsMichael Goulet-1/+1
2023-10-30Represent absence of 'since' attribute as a variant of DeprecatedSinceDavid Tolnay-5/+5
2023-10-30Add a DeprecatedSince::Err variant for versions that fail to parseDavid Tolnay-9/+10
2023-10-30Auto merge of #117415 - matthiaskrgr:rollup-jr2p1t2, r=matthiaskrgrbors-2/+3
Rollup of 7 pull requests Successful merges: - #116862 (Detect when trait is implemented for type and suggest importing it) - #117389 (Some diagnostics improvements of `gen` blocks) - #117396 (Don't treat closures/coroutine types as part of the public API) - #117398 (Correctly handle nested or-patterns in exhaustiveness) - #117403 (Poison check_well_formed if method receivers are invalid to prevent typeck from running on it) - #117411 (Improve some diagnostics around `?Trait` bounds) - #117414 (Don't normalize to an un-revealed opaque when we hit the recursion limit) r? `@ghost` `@rustbot` modify labels: rollup
2023-10-30Rollup merge of #117389 - oli-obk:gen_fn, r=compiler-errorsMatthias Krüger-2/+3
Some diagnostics improvements of `gen` blocks These are leftovers from https://github.com/rust-lang/rust/pull/116447
2023-10-30Rollup merge of #117357 - tmiasko:terminate, r=wesleywiserGuillaume Gomez-1/+1
Rename a few remaining references to abort terminator Follow up to e3f2edc75bf2becb57d7d770bba20606da1c4224
2023-10-30Rollup merge of #117317 - RalfJung:track-caller, r=oli-obkGuillaume Gomez-0/+52
share some track_caller logic between interpret and codegen Also move the code that implements the track_caller intrinsics out of the core interpreter engine -- it's just a helper creating a const-allocation, doesn't need to be part of the interpreter core.
2023-10-30Rollup merge of #117068 - nnethercote:clean-up-Cargo-toml, r=wesleywiserGuillaume Gomez-7/+8
Clean up `compiler/rustc*/Cargo.toml` Mostly by sorting dependencies, plus some other minor things. r? ``@wesleywiser``
2023-10-30Move deprecation_in_effect to inherent method on DeprecationDavid Tolnay-16/+3
2023-10-30Add a custom panic message for resuming `gen` blocks after they panickedOli Scherer-2/+3
2023-10-29Store version of `deprecated` attribute in structured formDavid Tolnay-34/+12
2023-10-30Clean up `rustc_*/Cargo.toml`.Nicholas Nethercote-7/+8
- Sort dependencies and features sections. - Add `tidy` markers to the sorted sections so they stay sorted. - Remove empty `[lib`] sections. - Remove "See more keys..." comments. Excluded files: - rustc_codegen_{cranelift,gcc}, because they're external. - rustc_lexer, because it has external use. - stable_mir, because it has external use.
2023-10-29Ignore RPIT duplicated lifetimes in opaque_types_defined_byMichael Goulet-1/+1
2023-10-29Auto merge of #116270 - cjgillot:gvn-aggregate, r=oli-obk,RalfJungbors-0/+50
See through aggregates in GVN This PR is extracted from https://github.com/rust-lang/rust/pull/111344 The first 2 commit are cleanups to avoid repeated work. I propose to stop removing useless assignments as part of this pass, and let a later `SimplifyLocals` do it. This makes tests easier to read (among others). The next 3 commits add a constant folding mechanism to the GVN pass, presented in https://github.com/rust-lang/rust/pull/116012. ~This pass is designed to only use global allocations, to avoid any risk of accidental modification of the stored state.~ The following commits implement opportunistic simplifications, in particular: - projections of aggregates: `MyStruct { x: a }.x` gets replaced by `a`, works with enums too; - projections of arrays: `[a, b][0]` becomes `a`; - projections of repeat expressions: `[a; N][x]` becomes `a`; - transform arrays of equal operands into a repeat rvalue. Fixes https://github.com/rust-lang/miri/issues/3090 r? `@oli-obk`
2023-10-29Auto merge of #117336 - workingjubilee:rollup-6negquv, r=workingjubileebors-49/+37
Rollup of 4 pull requests Successful merges: - #117170 (Add support for i586-unknown-netbsd as target.) - #117259 (Declare rustc_target's dependency on object/macho) - #117322 (change default output mode of `BootstrapCommand`) - #117325 (Small ty::print cleanups) r? `@ghost` `@rustbot` modify labels: rollup
2023-10-29Auto merge of #116447 - oli-obk:gen_fn, r=compiler-errorsbors-0/+29
Implement `gen` blocks in the 2024 edition Coroutines tracking issue https://github.com/rust-lang/rust/issues/43122 `gen` block tracking issue https://github.com/rust-lang/rust/issues/117078 This PR implements `gen` blocks that implement `Iterator`. Most of the logic with `async` blocks is shared, and thus I renamed various types that were referring to `async` specifically. An example usage of `gen` blocks is ```rust fn foo() -> impl Iterator<Item = i32> { gen { yield 42; for i in 5..18 { if i.is_even() { continue } yield i * 2; } } } ``` The limitations (to be resolved) of the implementation are listed in the tracking issue
2023-10-29Rename a few remaining references to abort terminatorTomasz Miąsko-1/+1
Follow up to e3f2edc75bf2becb57d7d770bba20606da1c4224
2023-10-28Remove needless `allow`sNilstrieb-5/+0
2023-10-28Move macros to usageNilstrieb-40/+40
2023-10-28Remove needless print ctx defsNilstrieb-7/+0
2023-10-28share the track_caller handling within a mir::BodyRalf Jung-0/+34
2023-10-28interpret: call caller_location logic the same way codegen does, and share ↵Ralf Jung-0/+18
some code
2023-10-28Rollup merge of #117256 - dtolnay:currentversion, r=compiler-errorsJubilee-15/+12
Parse rustc version at compile time This PR eliminates a couple awkward codepaths where it was not clear how the compiler should proceed if its own version number is incomprehensible. https://github.com/rust-lang/rust/blob/dab715641e96a61a534587fda9de1128b75b34dc/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs#L385 https://github.com/rust-lang/rust/blob/dab715641e96a61a534587fda9de1128b75b34dc/compiler/rustc_attr/src/builtin.rs#L630 We can guarantee that every compiled rustc comes with a working version number, so the ICE codepaths above shouldn't need to be written.
2023-10-27Apply suggestions from code reviewCamille Gillot-4/+7
Co-authored-by: Ralf Jung <post@ralfj.de>
2023-10-27Propagate half-open ranges through THIRNadrieril-23/+49
2023-10-27Abstract over `PatRange` boundary valueNadrieril-45/+256
2023-10-27Rollup merge of #117246 - estebank:issue-117209, r=petrochenkovMatthias Krüger-0/+28
Fix ICE: Restrict param constraint suggestion When encountering an associated item with a type param that could be constrained, do not look at the parent item if the type param comes from the associated item. Fix #117209, fix #89868.
2023-10-27Account for type param from other item in `note_and_explain`Esteban Küber-0/+28
Fix #89868.
2023-10-27Fuse `gen` blocksOli Scherer-2/+3
2023-10-27Basic generators workOli Scherer-2/+3
2023-10-27Make `gen` blocks implement the `Iterator` traitOli Scherer-0/+15
2023-10-27Rollup merge of #117241 - compiler-errors:auto-trait-leak-cycle, r=oli-obkMatthias Krüger-0/+1
Stash and cancel cycle errors for auto trait leakage in opaques We don't need to emit a traditional cycle error when we have a selection error that explains what's going on but in more detail. We may want to augment this error to actually point out the cycle, now that the cycle error is not being emitted. We could do that by storing the set of opaques that was in the `CyclePlaceholder` that gets returned from `type_of_opaque`. r? `@oli-obk` cc `@estebank` #117235
2023-10-26Parse rustc version at compile timeDavid Tolnay-15/+12
2023-10-26Stash and cancel cycle errors for auto trait leakage in opaquesMichael Goulet-0/+1
2023-10-26Replace type flag HAS_TY_GENERATOR with HAS_TY_COROUTINELeón Orell Valerian Liehr-2/+2
2023-10-26Auto merge of #112875 - compiler-errors:negative-coherence-rework, r=lcnrbors-0/+1
Rework negative coherence to properly consider impls that only partly overlap This PR implements a modified negative coherence that handles impls that only have partial overlap. It does this by: 1. taking both impl trait refs, instantiating them with infer vars 2. equating both trait refs 3. taking the equated trait ref (which represents the two impls' intersection), and resolving any vars 4. plugging all remaining infer vars with placeholder types these placeholder-plugged trait refs can then be used normally with the new trait solver, since we no longer have to worry about the issue with infer vars in param-envs. We use the **new trait solver** to reason correctly about unnormalized trait refs (due to deferred projection equality), since this avoid having to normalize anything under param-envs with infer vars in them. This PR then additionally: * removes the `FnPtr` knowable hack by implementing proper negative `FnPtr` trait bounds for rigid types. --- An example: Consider these two partially overlapping impls: ``` impl<T, U> PartialEq<&U> for &T where T: PartialEq<U> {} impl<F> PartialEq<F> for F where F: FnPtr {} ``` Under the old algorithm, we would take one of these impls and replace it with infer vars, then try unifying it with the other impl under identity substitutions. This is not possible in either direction, since it either sets `T = U`, or tries to equate `F = &?0`. Under the new algorithm, we try to unify `?0: PartialEq<?0>` with `&?1: PartialEq<&?2>`. This gives us `?0 = &?1 = &?2` and thus `?1 = ?2`. The intersection of these two trait refs therefore looks like: `&?1: PartialEq<&?1>`. After plugging this with placeholders, we get a trait ref that looks like `&!0: PartialEq<&!0>`, with the first impl having substs `?T = ?U = !0` and the second having substs `?F = &!0`[^1]. Then we can take the param-env from the first impl, and try to prove the negated where clause of the second. We know that `&!0: !FnPtr` never holds, since it's a rigid type that is also not a fn ptr, we successfully detect that these impls may never overlap. [^1]: For the purposes of this example, I just ignored lifetimes, since it doesn't really matter.
2023-10-26Add hir::GeneratorKind::GenOli Scherer-0/+12
2023-10-25Rollup merge of #117175 - oli-obk:gen_fn_split, r=compiler-errorsMatthias Krüger-2/+6
Rename AsyncCoroutineKind to CoroutineSource pulled out of https://github.com/rust-lang/rust/pull/116447 Also refactors the printing infra of `CoroutineSource` to be ready for easily extending it with a `Gen` variant for `gen` blocks
2023-10-25Rollup merge of #117008 - compiler-errors:canonical, r=lcnrMatthias Krüger-93/+29
Uplift `Canonical` to `rustc_type_ir` I plan on moving the new trait solver's canonicalizer into either `rustc_type_ir` or a child crate. One dependency on this is lifting `Canonical<V>` to `rustc_type_ir` so we can actually name the canonicalized values. I may also later lift `CanonicalVarInfo` into the new trait solver. I can't really tell what other changes need to be done, but I'm just putting this up sooner than later since I'm almost certain it'll need to be done regardless of other design choices. There are a couple of warts introduced by this PR, since we no longer can define inherent `Canonical` impls in `rustc_middle` -- see the changes to: * `compiler/rustc_trait_selection/src/traits/query/normalize.rs` * `compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs` r? lcnr
2023-10-25Rename has_provance and tweaks comments.Camille GILLOT-8/+11
2023-10-25Refactor away the need for some `descr` methods.Oli Scherer-2/+6
Instead we use `Display` impls and their `alternate` render scheme to decide whether we want backticks or not.
2023-10-25Add a IsIdentity extension trait for CanonicalUserTypeMichael Goulet-5/+9
2023-10-25Uplift Canonical to rustc_type_irMichael Goulet-91/+23
2023-10-25Rollup merge of #117136 - compiler-errors:defid-list, r=oli-obkMatthias Krüger-1/+11
Intern `LocalDefId` list from `opaque_types_defined_by` query r? oli-obk
2023-10-25Valtrees for primitive types are fine.Camille GILLOT-2/+3