about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
AgeCommit message (Collapse)AuthorLines
2022-11-23Rollup merge of #104724 - WaffleLapkin:to_def_idn't, r=compiler-errorsYuki Okushi-5/+9
Fix `ClosureKind::to_def_id` `Fn` and `FnOnce` were mixed up in https://github.com/rust-lang/rust/pull/99131.
2022-11-22Add size hints to early binder iterator adaptersMichael Goulet-0/+12
2022-11-22Use `tcx.require_lang_item` instead of unwrappingMaybe Waffle-3/+5
2022-11-22Fix `ClosureKind::to_def_id`Maybe Waffle-5/+9
2022-11-22Auto merge of #103578 - petrochenkov:nofict, r=nagisabors-66/+42
Unreserve braced enum variants in value namespace With this PR braced enum variants (`enum E { V { /*...*/ } }`) no longer take a slot in value namespace, so the special case mentioned in the note in https://github.com/rust-lang/rfcs/blob/master/text/1506-adt-kinds.md#braced-structs is removed. Report - https://github.com/rust-lang/rust/pull/103578#issuecomment-1292594900.
2022-11-22Auto merge of #104696 - matthiaskrgr:rollup-gi1pdb0, r=matthiaskrgrbors-1/+1
Rollup of 11 pull requests Successful merges: - #103396 (Pin::new_unchecked: discuss pinning closure captures) - #104416 (Fix using `include_bytes` in pattern position) - #104557 (Add a test case for async dyn* traits) - #104559 (Split `MacArgs` in two.) - #104597 (Probe + better error messsage for `need_migrate_deref_output_trait_object`) - #104656 (Move tests) - #104657 (Do not check transmute if has non region infer) - #104663 (rustdoc: factor out common button CSS) - #104666 (Migrate alias search result to CSS variables) - #104674 (Make negative_impl and negative_impl_exists take the right types) - #104692 (Update test's cfg-if dependency to 1.0) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-11-22Rollup merge of #104559 - nnethercote:split-MacArgs, r=petrochenkovMatthias Krüger-1/+1
Split `MacArgs` in two. `MacArgs` is an enum with three variants: `Empty`, `Delimited`, and `Eq`. It's used in two ways: - For representing attribute macro arguments (e.g. in `AttrItem`), where all three variants are used. - For representing function-like macros (e.g. in `MacCall` and `MacroDef`), where only the `Delimited` variant is used. In other words, `MacArgs` is used in two quite different places due to them having partial overlap. I find this makes the code hard to read. It also leads to various unreachable code paths, and allows invalid values (such as accidentally using `MacArgs::Empty` in a `MacCall`). This commit splits `MacArgs` in two: - `DelimArgs` is a new struct just for the "delimited arguments" case. It is now used in `MacCall` and `MacroDef`. - `AttrArgs` is a renaming of the old `MacArgs` enum for the attribute macro case. Its `Delimited` variant now contains a `DelimArgs`. Various other related things are renamed as well. These changes make the code clearer, avoids several unreachable paths, and disallows the invalid values. r? `@petrochenkov`
2022-11-22Split `MacArgs` in two.Nicholas Nethercote-1/+1
`MacArgs` is an enum with three variants: `Empty`, `Delimited`, and `Eq`. It's used in two ways: - For representing attribute macro arguments (e.g. in `AttrItem`), where all three variants are used. - For representing function-like macros (e.g. in `MacCall` and `MacroDef`), where only the `Delimited` variant is used. In other words, `MacArgs` is used in two quite different places due to them having partial overlap. I find this makes the code hard to read. It also leads to various unreachable code paths, and allows invalid values (such as accidentally using `MacArgs::Empty` in a `MacCall`). This commit splits `MacArgs` in two: - `DelimArgs` is a new struct just for the "delimited arguments" case. It is now used in `MacCall` and `MacroDef`. - `AttrArgs` is a renaming of the old `MacArgs` enum for the attribute macro case. Its `Delimited` variant now contains a `DelimArgs`. Various other related things are renamed as well. These changes make the code clearer, avoids several unreachable paths, and disallows the invalid values.
2022-11-21Auto merge of #104533 - oli-obk:method_callee, r=lcnrbors-20/+67
Clean up and harden various methods around trait substs r? `@lcnr`
2022-11-21Stop passing the self-type as a separate argument.Oli Scherer-14/+16
2022-11-21Remove some unnecessary slicingOli Scherer-7/+7
2022-11-21Add helper to create the trait ref for a lang itemOli Scherer-0/+10
2022-11-21Allow iterators instead of requiring slices that will get turned into iteratorsOli Scherer-9/+15
2022-11-21Remove an unnecessary query + subst roundOli Scherer-1/+1
2022-11-21Add a helper for replacing the self type in trait refsOli Scherer-0/+8
2022-11-21Assert that various types have the right amount of generic args and fix the ↵Oli Scherer-5/+27
sites that used the wrong amount
2022-11-21Reduce the amount of passed-around arguments that will get merged into one ↵Oli Scherer-4/+3
later anyway
2022-11-21Unreserve braced enum variants in value namespaceVadim Petrochenkov-66/+42
2022-11-21Auto merge of #104120 - mejrs:diag, r=davidtwcobors-12/+13
Match and enforce crate and slug names Some of these were in the wrong place or had a name that didn't match.
2022-11-21Add an always-ambiguous predicate to make sure that we don't accidentlally ↵Oli Scherer-0/+19
allow trait resolution to prove false things during coherence
2022-11-21Treat different opaque types of the same def id as equal during coherenceOli Scherer-10/+23
2022-11-21Allow opaque types in trait impl headers and rely on coherence to reject ↵Oli Scherer-13/+5
unsound cases
2022-11-21Auto merge of #104673 - matthiaskrgr:rollup-85f65ov, r=matthiaskrgrbors-52/+32
Rollup of 9 pull requests Successful merges: - #104420 (Fix doc example for `wrapping_abs`) - #104499 (rustdoc JSON: Use `Function` everywhere and remove `Method`) - #104500 (`rustc_ast`: remove `ref` patterns) - #104511 (Mark functions created for `raw-dylib` on x86 with DllImport storage class) - #104595 (Add `PolyExistentialPredicate` type alias) - #104605 (deduplicate constant evaluation in cranelift backend) - #104628 (Revert "Update CI to use Android NDK r25b") - #104662 (Streamline deriving on packed structs.) - #104667 (Revert formatting changes of a test) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-11-21Match crate and slug namesmejrs-12/+13
2022-11-21Rollup merge of #104605 - RalfJung:clf_consts, r=bjorn3Matthias Krüger-15/+0
deduplicate constant evaluation in cranelift backend The cranelift backend had two matches on `ConstantKind`, which can be avoided, and used this `eval_for_mir` that nothing else uses... this makes things more consistent with the (better-tested) LLVM backend. I noticed this because cranelift was the only user of `eval_for_mir`. However `try_eval_for_mir` still has one other user in `eval`... the odd thing is that the interpreter has its own `eval_mir_constant` which seems to duplicate the same functionality and does not use `try_eval_for_mir`. No idea what is happening here. r? ``@bjorn3`` Cc ``@lcnr``
2022-11-21Rollup merge of #104595 - compiler-errors:poly-existential-predicate, r=lcnrMatthias Krüger-37/+32
Add `PolyExistentialPredicate` type alias Wrapping `ExistentialPredicate`s in a binder is very common, and this alias already exists for the `PolyExistential{TraitRef,Projection}` types.
2022-11-21Auto merge of #103491 - cjgillot:self-rpit, r=oli-obkbors-57/+21
Support using `Self` or projections inside an RPIT/async fn I reuse the same idea as https://github.com/rust-lang/rust/pull/103449 to use variances to encode whether a lifetime parameter is captured by impl-trait. The current implementation of async and RPIT replace all lifetimes from the parent generics by `'static`. This PR changes the scheme ```rust impl<'a> Foo<'a> { fn foo<'b, T>() -> impl Into<Self> + 'b { ... } } opaque Foo::<'_a>::foo::<'_b, T>::opaque<'b>: Into<Foo<'_a>> + 'b; impl<'a> Foo<'a> { // OLD fn foo<'b, T>() -> Foo::<'static>::foo::<'static, T>::opaque::<'b> { ... } ^^^^^^^ the `Self` becomes `Foo<'static>` // NEW fn foo<'b, T>() -> Foo::<'a>::foo::<'b, T>::opaque::<'b> { ... } ^^ the `Self` stays `Foo<'a>` } ``` There is the same issue with projections. In the example, substitute `Self` by `<T as Trait<'b>>::Assoc` in the sugared version, and `Foo<'_a>` by `<T as Trait<'_b>>::Assoc` in the desugared one. This allows to support `Self` in impl-trait, since we do not replace lifetimes by `'static` any more. The same trick allows to use projections like `T::Assoc` where `Self` is allowed. The feature is gated behind a `impl_trait_projections` feature gate. The implementation relies on 2 tweaking rules for opaques in 2 places: - we only relate substs that correspond to captured lifetimes during TypeRelation; - we only list captured lifetimes in choice region computation. For simplicity, I encoded the "capturedness" of lifetimes as a variance, `Bivariant` vs `Invariant` for unused vs captured lifetimes. The `variances_of` query used to ICE for opaques. Impl-trait that do not reference `Self` or projections will have their variances as: - `o` (invariant) for each parent type or const; - `*` (bivariant) for each parent lifetime --> will not participate in borrowck; - `o` (invariant) for each own lifetime. Impl-trait that does reference `Self` and/or projections will have some parent lifetimes marked as `o` (as the example above), and participate in type relation and borrowck. In the example above, `variances_of(opaque) = ['_a: o, '_b: *, T: o, 'b: o]`. r? types cc `@compiler-errors` , as you asked about the issue with `Self` and projections.
2022-11-20Factor out conservative_is_privately_uninhabitedCameron Steffen-11/+16
2022-11-20Change to Ty::is_inhabited_fromCameron Steffen-51/+49
2022-11-20Fix typoCameron Steffen-1/+1
2022-11-20Rollup merge of #104564 - RalfJung:either, r=oli-obkMatthias Krüger-8/+12
interpret: use Either over Result when it is not representing an error condition r? `@oli-obk`
2022-11-20Fix doctest errors related to rustc_middlereez12g-2/+5
2022-11-19Rollup merge of #104593 - compiler-errors:rpitit-object-safety-spans, ↵Matthias Krüger-2/+8
r=fee1-dead Improve spans for RPITIT object-safety errors No reason why we can't point at the `impl Trait` that causes the object-safety violation. Also [drive-by: Add is_async fn to hir::IsAsync](https://github.com/rust-lang/rust/pull/104593/commits/c4165f3a965e258531928180195637455299c6f3), which touches clippy too.
2022-11-19Rollup merge of #104469 - estebank:long-types, r=oli-obkMatthias Krüger-23/+86
Make "long type" printing type aware and trim types in E0275 Instead of simple string cutting, use a custom printer to hide parts of long printed types. On E0275, check for type length before printing.
2022-11-19deduplicate constant evaluation in cranelift backendRalf Jung-15/+0
also sync LLVM and cranelift structure a bit
2022-11-19Rollup merge of #104566 - matthiaskrgr:clippy_perf_nov18, r=oli-obkDylan DPC-3/+1
couple of clippy::perf fixes
2022-11-19drive-by: PolyExistentialPredicateMichael Goulet-37/+32
2022-11-19Improve spans for RPITIT object-safety errorsMichael Goulet-2/+8
2022-11-18review commentEsteban Küber-5/+5
2022-11-18Only use `...` instead of `_` for type elisionEsteban Küber-5/+1
`_` might confuse people into believing that the type isn't known, while `...` is not used anywhere else for types and is not valid syntax, making it more likely to convey the right understanding.
2022-11-18On overflow errors, do not print out long typesEsteban Küber-0/+37
2022-11-18Make "long type" printing type awareEsteban Küber-24/+54
Instead of simple string cutting, use a custom printer to hide parts of long printed types.
2022-11-18Rollup merge of #104550 - RalfJung:typo, r=compiler-errorsMatthias Krüger-1/+1
fix a typo r? `@lcnr`
2022-11-18couple of clippy::perf fixesMatthias Krüger-3/+1
2022-11-18interpret: use Either over Result when it is not representing an error conditionRalf Jung-8/+12
2022-11-17Rollup merge of #104483 - oli-obk:santa-clauses-make-goals, r=compiler-errorsMatthias Krüger-9/+9
Convert predicates into Predicate in the Obligation constructor instead of having almost all callers do that. This reduces a bit of boilerplate, and also paves the way for my work towards https://github.com/rust-lang/compiler-team/issues/531 (as it makes it easier to accept both goals and clauses where right now it only accepts predicates).
2022-11-17fix a typoRalf Jung-1/+1
2022-11-17Auto merge of #104170 - cjgillot:hir-def-id, r=fee1-deadbors-58/+45
Record `LocalDefId` in HIR nodes instead of a side table This is part of an attempt to remove the `HirId -> LocalDefId` table from HIR. This attempt is a prerequisite to creation of `LocalDefId` after HIR lowering (https://github.com/rust-lang/rust/pull/96840), by controlling how `def_id` information is accessed. This first part adds the information to HIR nodes themselves instead of a table. The second part is https://github.com/rust-lang/rust/pull/103902 The third part will be to make `hir::Visitor::visit_fn` take a `LocalDefId` as last parameter. The fourth part will be to completely remove the side table.
2022-11-16Convert predicates into Predicate in the Obligation constructorOli Scherer-2/+2
2022-11-16Generalize the `ToPredicate` traitOli Scherer-8/+8
Its name is now not accurate anymore, but we'll adjust that later