about summary refs log tree commit diff
path: root/compiler/rustc_middle
AgeCommit message (Collapse)AuthorLines
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-3/+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
2022-11-16cleanup and dedupe CTFE and Miri error reportingRalf Jung-25/+12
2022-11-15Auto merge of #102570 - cjgillot:deagg-debuginfo, r=oli-obkbors-0/+64
Perform simple scalar replacement of aggregates (SROA) MIR opt This is a re-open of https://github.com/rust-lang/rust/pull/85796 I copied the debuginfo implementation (first commit) from `@eddyb's` own SROA PR. This pass replaces plain field accesses by simple locals when possible. To be eligible, the replaced locals: - must not be enums or unions; - must not be used whole; - must not have their address taken. The storage and deinit statements are duplicated on each created local. cc `@tmiasko` who reviewed the former version of this PR.
2022-11-15Introduce composite debuginfo.Camille GILLOT-0/+64
2022-11-15Auto merge of #104054 - RalfJung:byte-provenance, r=oli-obkbors-812/+990
interpret: support for per-byte provenance Also factors the provenance map into its own module. The third commit does the same for the init mask. I can move it in a separate PR if you prefer. Fixes https://github.com/rust-lang/miri/issues/2181 r? `@oli-obk`
2022-11-15Auto merge of #104437 - matthiaskrgr:rollup-n5jdg9v, r=matthiaskrgrbors-9/+69
Rollup of 9 pull requests Successful merges: - #103439 (Show note where the macro failed to match) - #103734 (Adjust stabilization version to 1.65.0 for wasi fds) - #104148 (Visit attributes of trait impl items during AST validation) - #104241 (Move most of unwind's build script to lib.rs) - #104258 (Deduce closure signature from a type alias `impl Trait`'s supertraits) - #104296 (Walk types more carefully in `ProhibitOpaqueTypes` visitor) - #104309 (Slightly improve error message for invalid identifier) - #104316 (Simplify suggestions for errors in generators.) - #104339 (Add `rustc_deny_explicit_impl`) Failed merges: - #103484 (Add `rust` to `let_underscore_lock` example) r? `@ghost` `@rustbot` modify labels: rollup
2022-11-15Rollup merge of #104258 - compiler-errors:tait-closure-deduce, r=oli-obkMatthias Krüger-9/+69
Deduce closure signature from a type alias `impl Trait`'s supertraits r? `@oli-obk` Basically pass the TAIT's bounds through the same method that we're using to deduce a signature from infer var closure bounds. Does this need a new FCP? I see it as a logical extension of #101834, but happy to rfcbot a new one if it does.
2022-11-15Auto merge of #101168 - jachris:dataflow-const-prop, r=oli-obkbors-4/+12
Add new MIR constant propagation based on dataflow analysis The current constant propagation in `rustc_mir_transform/src/const_prop.rs` fails to handle many cases that would be expected from a constant propagation optimization. For example: ```rust let x = if true { 0 } else { 0 }; ``` This pull request adds a new constant propagation MIR optimization pass based on the existing dataflow analysis framework. Since most of the analysis is not unique to constant propagation, a generic framework has been extracted. It works on top of the existing framework and could be reused for other optimzations. Closes #80038. Closes #81605. ## Todo ### Essential - [x] [Writes to inactive enum variants](https://github.com/rust-lang/rust/pull/101168#pullrequestreview-1089493974). Resolved by rejecting the registration of places with downcast projections for now. Could be improved by flooding other variants if mutable access to a variant is observed. - [X] Handle [`StatementKind::CopyNonOverlapping`](https://github.com/rust-lang/rust/pull/101168#discussion_r957774914). Resolved by flooding the destination. - [x] Handle `UnsafeCell` / `!Freeze` correctly. - [X] Overflow propagation of `CheckedBinaryOp`: Decided to not propagate if overflow flag is `true` (`false` will still be propagated) - [x] More documentation in general. - [x] Arguments for correctness, documentation of necessary assumptions. - [x] Better performance, or alternatively, require `-Zmir-opt-level=3` for now. ### Extra - [x] Add explicit unreachability, i.e. upgrading the lattice from $\mathbb{P} \to \mathbb{V}$ to $\set{\bot} \cup (\mathbb{P} \to \mathbb{V})$. - [x] Use storage statements to improve precision. - [ ] Consider opening issue for duplicate diagnostics: https://github.com/rust-lang/rust/pull/101168#issuecomment-1276609950 - [ ] Flood moved-from places with $\bot$ (requires some changes for places with tracked projections). - [ ] Add downcast projections back in. - [ ] [Algebraic simplifications](https://github.com/rust-lang/rust/pull/101168#discussion_r957967878) (possibly with a shared API; done by old const prop). - [ ] Propagation through slices / arrays. - [ ] Find other optimizations that are done by old `const_prop.rs`, but not by this one.
2022-11-14Give precendence to regions from member constaints when inferring concrete ↵Camille GILLOT-6/+5
types.
2022-11-14Rollup merge of #104378 - compiler-errors:chalk-up, r=jackh726Matthias Krüger-1/+1
Bump chalk to v0.87 1. Removes `ReEmpty` from chalk 2. Adds support for the `std::marker::Tuple` trait
2022-11-14Rollup merge of #104349 - rustaceanclub:master, r=oli-obkMatthias Krüger-2/+2
fix some typos in comments
2022-11-14Drop `relate_opaque_item_substs`.Camille GILLOT-23/+12
2022-11-14assert that we are (de)seiralizing ProvenanceMap correctlyRalf Jung-13/+13
2022-11-14Remove redundant graphviz escapingJannis Christopher Köhl-4/+3
2022-11-14Manually implement `Encodable` for ProvenanceMap to avoid serializing an ↵Oli Scherer-1/+16
always-none option