about summary refs log tree commit diff
path: root/compiler/rustc_middle
AgeCommit message (Collapse)AuthorLines
2023-02-05emit `ConstEquate` in `TypeRelating<D>`Boxy-15/+15
2023-02-04Remove `OnHit` callback from query caches.Camille GILLOT-40/+20
This is not useful now that query results are `Copy`.
2023-02-04Auto merge of #107267 - cjgillot:keep-aggregate, r=oli-obkbors-12/+19
Do not deaggregate MIR This turns out to simplify a lot of things. I haven't checked the consequences for miri yet. cc `@JakobDegen` r? `@oli-obk`
2023-02-03Rollup merge of #107621 - compiler-errors:intern-external-constraints, r=lcnrMichael Goulet-0/+61
Intern external constraints in new solver Makes the query response `Copy`, fixing a few FIXMEs.
2023-02-03Make const/fn return params more suggestableMichael Goulet-5/+92
2023-02-03intern external constraintsMichael Goulet-0/+61
2023-02-03Rollup merge of #107585 - compiler-errors:fndef-sig-cycle, r=oli-obkDylan DPC-5/+18
Don't cause a cycle when formatting query description that references a FnDef When a function returns `-> _`, we use typeck to compute what the resulting type of the body _should_ be. If we call another query inside of typeck and hit a cycle error, we attempt to report the cycle error which requires us to compute all of the query descriptions for the stack. However, if one of the queries in that cycle has a query description that references this function as a FnDef type, we'll cause a *second* cycle error from within the cycle error reporting code, since rendering a FnDef requires us to compute its signature. This causes an unwrap to ICE, since during the *second* cycle reporting code, we try to look for a job that isn't in the active jobs list. We can avoid this by using `with_no_queries!` when computing these query descriptions. Fixes #107089 The only drawback is that the rendering of opaque types in cycles regresses a bit :| I'm open to alternate suggestions about how we may handle this...
2023-02-03Rollup merge of #106575 - estebank:issue-64008, r=pnkfelixMatthias Krüger-0/+22
Suggest `move` in nested closure when appropriate Fix #64008.
2023-02-02Put a DefId in AggregateKind.Camille GILLOT-12/+19
2023-02-02Tweak misleading commentMichael Goulet-1/+1
2023-02-02Suggest `move` in nested closure when appropriateEsteban Küber-0/+22
Fix #64008.
2023-02-02Don't cause a cycle when formatting query description that references a FnDefMichael Goulet-5/+18
2023-02-01Improve pretty-printing of `HirIdValidator` errorsArpad Borsos-19/+15
This now uses `node_to_string` for both missing and seen Ids, which includes the snippet of code for which the Id was allocated. Also removes the duplicated printing of `HirId`, as `node_to_string` includes that already. Similarly, changes all other users of `node_to_string` that do so, and changes the output of `node_to_string`, which is now "$hirid ($what `$span` in $path)".
2023-02-01Don't call with_reveal_all_normalized in evaluate when param-env has ↵Michael Goulet-6/+4
inference vars in it
2023-01-31Rollup merge of #107486 - compiler-errors:bound-ty-keep-name, r=oli-obkGuillaume Gomez-7/+21
Track bound types like bound regions When we instantiate bound types into placeholder types, we throw away the names for some reason. These names are particularly useful for error reporting once we have `for<T>` binders. r? types
2023-01-31Rollup merge of #107467 - WaffleLapkin:uneq, r=oli-obkGuillaume Gomez-8/+7
Improve enum checks Some light refactoring.
2023-01-31Auto merge of #106399 - estebank:type-err-span-label, r=nagisabors-144/+105
Modify primary span label for E0308 Looking at the reactions to https://hachyderm.io/`@ekuber/109622160673605438,` a lot of people seem to have trouble understanding the current output, where the primary span label on type errors talks about the specific types that diverged, but these can be deeply nested type parameters. Because of that we could see "expected i32, found u32" in the label while the note said "expected Vec<i32>, found Vec<u32>". This understandably confuses people. I believe that once people learn to read these errors it starts to make more sense, but this PR changes the output to be more in line with what people might expect, without sacrificing terseness. Fix #68220.
2023-01-31Review changesMaybe Waffle-2/+2
2023-01-30Track bound types like bound regionsMichael Goulet-7/+21
2023-01-30Fix unquoted projection types in labelEsteban Küber-1/+1
2023-01-30Mention fn coercion rules (needs to be expanded)Esteban Küber-1/+1
2023-01-30Hide lifetimes of `impl Trait` in force trimmed pathsEsteban Küber-3/+5
2023-01-30Do not mention lifetime names in force trimmed pathsEsteban Küber-0/+4
2023-01-30Don't show `for<'lt>` in force trimmed pathsEsteban Küber-3/+8
2023-01-30review commentsEsteban Küber-36/+43
2023-01-30Modify primary span label for E0308Esteban Küber-124/+67
The previous output was unintuitive to users.
2023-01-30Rollup merge of #107455 - tshepang:better-name, r=wesleywiserMatthias Krüger-3/+6
use a more descriptive name I found it hard to distinguish between the two method names. Also, the comment just repeats the `expect` string.
2023-01-30Use `Mutability::{is_mut, is_not}`Maybe Waffle-7/+3
2023-01-30Replace enum `==`s with `match`es where it makes senseMaybe Waffle-1/+4
2023-01-30Auto merge of #107463 - Dylan-DPC:rollup-6mq1li8, r=Dylan-DPCbors-0/+9
Rollup of 6 pull requests Successful merges: - #101569 (Don't re-export private/unstable ArgumentV1 from `alloc`.) - #106106 (Pass `branch.{branch}.remote=origin` to `git submodule update`) - #107146 (Make `unsizing_params_for_adt` into a query) - #107264 (Add option to include private items in library docs) - #107452 (Fix typo in `{Rc, Arc}::get_mut_unchecked` docs) - #107459 (end entry paragraph with a period (.)) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-01-30Rollup merge of #107146 - compiler-errors:unsizing-params, r=cjgillotDylan DPC-0/+9
Make `unsizing_params_for_adt` into a query Addresses a FIXME in confirmation. r? ``@ghost``
2023-01-30Auto merge of #104429 - nnethercote:more-deriving-on-packed-structs, r=RalfJungbors-9/+0
More deriving on packed structs See [here](https://github.com/rust-lang/rust/pull/104429#issuecomment-1320909245) for the t-lang nomination summary, and [here](https://github.com/rust-lang/rust/pull/104429#issuecomment-1360077895) for the approval. r? `@RalfJung`
2023-01-30use a more descriptive nameTshepang Mbambo-3/+6
2023-01-30Allow more deriving on packed structs.Nicholas Nethercote-9/+0
Currently, deriving on packed structs has some non-trivial limitations, related to the fact that taking references on unaligned fields is UB. The current approach to field accesses in derived code: - Normal case: `&self.0` - In a packed struct that derives `Copy`: `&{self.0}` - In a packed struct that doesn't derive `Copy`: `&self.0` Plus, we disallow deriving any builtin traits other than `Default` for any packed generic type, because it's possible that there might be misaligned fields. This is a fairly broad restriction. Plus, we disallow deriving any builtin traits other than `Default` for most packed types that don't derive `Copy`. (The exceptions are those where the alignments inherently satisfy the packing, e.g. in a type with `repr(packed(N))` where all the fields have alignments of `N` or less anyway. Such types are pretty strange, because the `packed` attribute is not having any effect.) This commit introduces a new, simpler approach to field accesses: - Normal case: `&self.0` - In a packed struct: `&{self.0}` In the latter case, this requires that all fields impl `Copy`, which is a new restriction. This means that the following example compiles under the old approach and doesn't compile under the new approach. ``` #[derive(Debug)] struct NonCopy(u8); #[derive(Debug) #[repr(packed)] struct MyType(NonCopy); ``` (Note that the old approach's support for cases like this was brittle. Changing the `u8` to a `u16` would be enough to stop it working. So not much capability is lost here.) However, the other constraints from the old rules are removed. We can now derive builtin traits for packed generic structs like this: ``` trait Trait { type A; } #[derive(Hash)] #[repr(packed)] pub struct Foo<T: Trait>(T, T::A); ``` To allow this, we add a `T: Copy` bound in the derived impl and a `T::A: Copy` bound in where clauses. So `T` and `T::A` must impl `Copy`. We can now also derive builtin traits for packed structs that don't derive `Copy`, so long as the fields impl `Copy`: ``` #[derive(Hash)] #[repr(packed)] pub struct Foo(u32); ``` This includes types that hand-impl `Copy` rather than deriving it, such as the following, that show up in winapi-0.2: ``` #[derive(Clone)] #[repr(packed)] struct MyType(i32); impl Copy for MyType {} ``` The new approach is simpler to understand and implement, and it avoids the need for the `unsafe_derive_on_repr_packed` check. One exception is required for backwards-compatibility: we allow `[u8]` fields for now. There is a new lint for this, `byte_slice_in_packed_struct_with_derive`.
2023-01-29Rollup merge of #107006 - b-naber:thir-tree, r=jackh726Matthias Krüger-0/+889
Output tree representation on thir-tree The current output of `-Zunpretty=thir-tree` is really cumbersome to work with, using an actual tree representation should make it easier to see what the thir looks like.
2023-01-29Auto merge of #106253 - nbdd0121:upcast, r=compiler-errorsbors-4/+3
Skip possible where_clause_object_safety lints when checking `multiple_supertrait_upcastable` Fix #106247 To achieve this, I lifted the `WhereClauseReferencesSelf` out from `object_safety_violations` and move it into `is_object_safe` (which is changed to a new query). cc `@dtolnay` r? `@compiler-errors`
2023-01-29Auto merge of #106227 - bryangarza:ctfe-limit, r=oli-obkbors-1/+16
Use stable metric for const eval limit instead of current terminator-based logic This patch adds a `MirPass` that inserts a new MIR instruction `ConstEvalCounter` to any loops and function calls in the CFG. This instruction is used during Const Eval to count against the `const_eval_limit`, and emit the `StepLimitReached` error, replacing the current logic which uses Terminators only. The new method of counting loops and function calls should be more stable across compiler versions (i.e., not cause crates that compiled successfully before, to no longer compile when changes to the MIR generation/optimization are made). Also see: #103877
2023-01-28Make unsizing_params_for_adt into a queryMichael Goulet-0/+9
2023-01-28Auto merge of #107303 - compiler-errors:intern-canonical-var-values, r=lcnrbors-45/+43
Intern `CanonicalVarValues` So that they are copy :sparkles:
2023-01-28Auto merge of #107206 - cjgillot:no-h2l-map, r=WaffleLapkinbors-48/+32
Remove HirId -> LocalDefId map from HIR. Having this map in HIR prevents the creating of new definitions after HIR has been built. Thankfully, we do not need it. Based on https://github.com/rust-lang/rust/pull/103902
2023-01-28Rename `is_object_safe` to `check_is_object_safe` to hint side effectsGary Guo-2/+2
2023-01-28Make `is_object_safe` a query and move lint_object_unsafe_trait call thereGary Guo-4/+3
2023-01-28Rollup merge of #107384 - Nilstrieb:bool-for-deletion, r=oli-obkMatthias Krüger-13/+0
Remove `BOOL_TY_FOR_UNIT_TESTING` It is not used anymore for unit testing.
2023-01-28Remove `HirId -> LocalDefId` map from HIR.Camille GILLOT-48/+32
2023-01-28Rollup merge of #107339 - aliemjay:covariant, r=lcnrMatthias Krüger-12/+2
internally change regions to be covariant Surprisingly, we consider the reference type `&'a T` to be contravaraint in its lifetime parameter. This is confusing and conflicts with the documentation we have in the reference, rustnomicon, and rustc-dev-guide. This also arguably not the correct use of terminology since we can use `&'static u8` in a place where `&' a u8` is expected, this implies that `&'static u8 <: &' a u8` and consequently `'static <: ' a`, hence covariance. Because of this, when relating two types, we used to switch the argument positions in a confusing way: `Subtype(&'a u8 <: &'b u8) => Subtype('b <: 'a) => Outlives('a: 'b) => RegionSubRegion('b <= 'a)` The reason for the current behavior is probably that we wanted `Subtype('b <: 'a)` and `RegionSubRegion('b <= 'a)` to be equivalent, but I don' t think this is a good reason since these relations are sufficiently different in that the first is a relation in the subtyping lattice and is intrinsic to the type-systems, while the the second relation is an implementation detail of regionck. This PR changes this behavior to use covariance, so.. `Subtype(&'a u8 <: &'b u8) => Subtype('a <: 'b) => Outlives('a: 'b) => RegionSubRegion('b <= 'a) ` Resolves #103676 r? `@lcnr`
2023-01-27Restrict amount of ignored locals.Camille GILLOT-3/+5
2023-01-27address reviewb-naber-10/+10
2023-01-27Compute generator saved locals on MIR.Camille GILLOT-2/+83
2023-01-27Remove unused importnils-1/+0
2023-01-27Remove `BOOL_TY_FOR_UNIT_TESTING`Nilstrieb-12/+0
It is not used anymore for unit testing.