about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection
AgeCommit message (Collapse)AuthorLines
2022-11-24Also check that fn pointer candidates don't have escaping bound varsMichael Goulet-1/+4
2022-11-24Assert that we don't capture escaping bound vars in Fn trait selectionMichael Goulet-13/+20
2022-11-24Rollup merge of #104822 - spastorino:selctx-new-instead-of-with_query_mode, ↵Matthias Krüger-8/+3
r=lcnr with_query_mode -> new r? ```@lcnr```
2022-11-24Rollup merge of #104820 - spastorino:remove-normalize_projection_type, ↵Matthias Krüger-60/+13
r=jackh726 Remove normalize_projection_type r? ``@lcnr``
2022-11-24Use infcx.partially_normalize_associated_types_inSantiago Pastorino-28/+25
2022-11-24Auto merge of #104321 - Swatinem:async-gen, r=oli-obkbors-54/+156
Avoid `GenFuture` shim when compiling async constructs Previously, async constructs would be lowered to "normal" generators, with an additional `from_generator` / `GenFuture` shim in between to convert from `Generator` to `Future`. The compiler will now special-case these generators internally so that async constructs will *directly* implement `Future` without the need to go through the `from_generator` / `GenFuture` shim. The primary motivation for this change was hiding this implementation detail in stack traces and debuginfo, but it can in theory also help the optimizer as there is less abstractions to see through. --- Given this demo code: ```rust pub async fn a(arg: u32) -> Backtrace { let bt = b().await; let _arg = arg; bt } pub async fn b() -> Backtrace { Backtrace::force_capture() } ``` I would get the following with the latest stable compiler (on Windows): ``` 4: async_codegen::b::async_fn$0 at .\src\lib.rs:10 5: core::future::from_generator::impl$1::poll<enum2$<async_codegen::b::async_fn_env$0> > at /rustc/897e37553bba8b42751c67658967889d11ecd120\library\core\src\future\mod.rs:91 6: async_codegen::a::async_fn$0 at .\src\lib.rs:4 7: core::future::from_generator::impl$1::poll<enum2$<async_codegen::a::async_fn_env$0> > at /rustc/897e37553bba8b42751c67658967889d11ecd120\library\core\src\future\mod.rs:91 ``` whereas now I get a much cleaner stack trace: ``` 3: async_codegen::b::async_fn$0 at .\src\lib.rs:10 4: async_codegen::a::async_fn$0 at .\src\lib.rs:4 ```
2022-11-24with_query_mode -> newSantiago Pastorino-8/+3
2022-11-24Remove normalize_projection_typeSantiago Pastorino-60/+13
2022-11-24Avoid `GenFuture` shim when compiling async constructsArpad Borsos-54/+156
Previously, async constructs would be lowered to "normal" generators, with an additional `from_generator` / `GenFuture` shim in between to convert from `Generator` to `Future`. The compiler will now special-case these generators internally so that async constructs will *directly* implement `Future` without the need to go through the `from_generator` / `GenFuture` shim. The primary motivation for this change was hiding this implementation detail in stack traces and debuginfo, but it can in theory also help the optimizer as there is less abstractions to see through.
2022-11-24Rollup merge of #104742 - WaffleLapkin:forbidden-SUPER-deref, r=compiler-errorsMatthias Krüger-12/+0
Make `deref_into_dyn_supertrait` lint the impl and not the usage Proposed by ``@compiler-errors`` in https://github.com/rust-lang/rust/issues/89460#issuecomment-1320806785 r? ``@crlf0710``
2022-11-24Rollup merge of #104594 - compiler-errors:dyn-star-rcvr, r=eholk,estebankMatthias Krüger-7/+6
Properly handle `Pin<&mut dyn* Trait>` receiver in codegen This ensures we can actually await a `dyn* Future`, which seems important for async fn in dyn trait. Also, disable `dyn*` trait upcasting. It's not exactly complete right now, and can cause strange ICEs for no reason -- nobody's using it either. I thought it was cute to implement when I did it, but I didn't think about how it interacts structurally with `CoerceUnsized` correctly. Fixes #104794, presumably removing `dyn*` upcasting and its `CoerceUnsized` issues does the trick.
2022-11-24Auto merge of #104610 - ouz-a:revert-overflow, r=compiler-errorsbors-16/+0
Reverts check done by #100757 As my `fix` caused more issues than it resolved it's better to revert it. ( #103274 #104322 https://github.com/rust-lang/rust/issues/104606) r? `@compiler-errors` Reopens #95134
2022-11-24Disable dyn* upcastingMichael Goulet-7/+6
2022-11-24Auto merge of #104507 - WaffleLapkin:asderefsyou, r=wesleywiserbors-1/+1
Use `as_deref` in compiler (but only where it makes sense) This simplifies some code :3 (there are some changes that are not exacly `as_deref`, but more like "clever `Option`/`Result` method use")
2022-11-23Add `Mutability::{is_mut,is_not}`Maybe Waffle-2/+2
2022-11-23Make `deref_into_dyn_supertrait` lint the impl and not the usageMaybe Waffle-12/+0
2022-11-23Rollup merge of #104509 - spastorino:use-obligation-ctxt, r=lcnrDylan DPC-41/+30
Use obligation ctxt instead of dyn TraitEngine r? `@lcnr`
2022-11-23Rollup merge of #104269 - compiler-errors:hang-in-where-clause-sugg, r=lcnrDylan DPC-4/+6
Fix hang in where-clause suggestion with `predicate_can_apply` Using `predicate_may_hold` during error reporting causes an evaluation overflow, which (because we use `evaluate_obligation_no_overflow`) then causes the predicate to need to be re-evaluated locally, which results in a hang. ... but since the "add a where clause" suggestion is best-effort, just throw any overflow errors. No need for 100% accuracy. r? `@lcnr` who has been thinking about overflows... Let me know if you want more context about this issue, and as always, feel free to reassign. Fixes #104225
2022-11-23Call fully_solve_obligations instead of repeating codeSantiago Pastorino-6/+11
2022-11-23Use ObligationCtxt intead of dyn TraitEngineSantiago Pastorino-41/+25
2022-11-23Drive-by: Don't manually call evaluate_obligation_no_overflowMichael Goulet-3/+2
2022-11-23Do not need to account for overflow in predicate_can_applyMichael Goulet-1/+4
2022-11-22Rollup merge of #103488 - oli-obk:impl_trait_for_tait, r=lcnrManish Goregaokar-41/+29
Allow opaque types in trait impl headers and rely on coherence to reject unsound cases r? ````@lcnr```` fixes #99840
2022-11-22Use `tcx.require_lang_item` instead of unwrappingMaybe Waffle-1/+1
2022-11-22Auto merge of #104696 - matthiaskrgr:rollup-gi1pdb0, r=matthiaskrgrbors-48/+37
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 #104674 - spastorino:negative-impl-tcx, r=lcnrMatthias Krüger-16/+10
Make negative_impl and negative_impl_exists take the right types r? `@lcnr`
2022-11-22Rollup merge of #104597 - ↵Matthias Krüger-32/+27
compiler-errors:need_migrate_deref_output_trait_object-msg, r=eholk Probe + better error messsage for `need_migrate_deref_output_trait_object` 1. Use `InferCtxt::probe` in `need_migrate_deref_output_trait_object` -- that normalization *could* technically do type inference as a side-effect, and this is a lint, so it should have no side-effects. 2. Return the trait-ref so we format the error message correctly. See the UI test change -- `(dyn A + 'static)` is not a trait.
2022-11-21Stop passing the self-type as a separate argument.Oli Scherer-68/+46
2022-11-21Remove a redundant assertOli Scherer-6/+0
2022-11-21For lcnrOli Scherer-0/+1
2022-11-21Add helper to create the trait ref for a lang itemOli Scherer-18/+14
2022-11-21Use iterators instead of slices at more sitesOli Scherer-5/+6
2022-11-21Allow iterators instead of requiring slices that will get turned into iteratorsOli Scherer-31/+25
2022-11-21Add a helper for replacing the self type in trait refsOli Scherer-25/+5
2022-11-21Assert that various types have the right amount of generic args and fix the ↵Oli Scherer-85/+74
sites that used the wrong amount
2022-11-21Split out the actual predicate solving code into a separate functionOli Scherer-9/+17
2022-11-21Check that type_implements_trait actually is passed the right amount of ↵Oli Scherer-3/+11
generic params
2022-11-21Add an always-ambiguous predicate to make sure that we don't accidentlally ↵Oli Scherer-0/+10
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-40/+18
2022-11-21Allow opaque types in trait impl headers and rely on coherence to reject ↵Oli Scherer-3/+3
unsound cases
2022-11-21negative_impl_exists should take an InferCtxtSantiago Pastorino-8/+7
2022-11-21negative_impl should take a TyCtxtSantiago Pastorino-8/+3
2022-11-21Rollup merge of #104595 - compiler-errors:poly-existential-predicate, r=lcnrMatthias Krüger-2/+2
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-20Auto merge of #98914 - fee1-dead-contrib:min-deref-patterns, r=compiler-errorsbors-1/+1
Minimal implementation of implicit deref patterns for Strings cc `@compiler-errors` `@BoxyUwU` https://github.com/rust-lang/lang-team/issues/88 #87121 ~~I forgot to add a feature gate, will do so in a minute~~ Done
2022-11-19revert-overflowouz-a-16/+0
2022-11-19Rollup merge of #104593 - compiler-errors:rpitit-object-safety-spans, ↵Matthias Krüger-6/+15
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-11/+59
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-19Auto merge of #103509 - compiler-errors:opaques-w-bound-vars-r-hard, r=oli-obkbors-2/+2
Revert "Normalize opaques with escaping bound vars" This caused a perf regression in #103423, cc `@skyzh` this should fix #103423. reverts #100980 r? `@oli-obk`
2022-11-19Rollup merge of #104554 - BoxyUwU:less_unchecked_pls, r=lcnrDylan DPC-18/+19
Use `ErrorGuaranteed::unchecked_claim_error_was_emitted` less there are only like 3 or 4 call sites left after this but it wasnt obvious to me how to remove them
2022-11-19Rollup merge of #104411 - lcnr:bivariance-nll, r=compiler-errorsDylan DPC-7/+19
nll: correctly deal with bivariance fixes #104409 when in a bivariant context, relating stuff should always trivially succeed. Also changes the mir validator to correctly deal with higher ranked regions. r? types cc ``@RalfJung``