Commit graph

33 commits

Author SHA1 Message Date
Matthias Krüger
ad00e91887 remove redundant returns (clippy::needless_return) 2020-03-20 20:23:03 +01:00
Mazdak Farrokhzad
ffb3c2cb3d
Rollup merge of #69036 - eddyb:monoshim, r=nikomatsakis
rustc: don't resolve Instances which would produce malformed shims.

There are some `InstanceDef` variants (shims and drop "glue") which contain a `Ty`, and that `Ty` is used in generating the shim MIR. But if that `Ty` mentions any generic parameters, the generated shim would refer to them (but they won't match the `Substs` of the `Instance`), or worse, generating the shim would fail because not enough of the type is known.

Ideally we would always produce a "skeleton" of the type, e.g. `(_, _)` for dropping any tuples with two elements, or `Vec<_>` for dropping any `Vec` value, but that's a lot of work, and they would still not match the `Substs` of the `Instance` as it exists today, so `Instance` would probably need to change.

By making `Instance::resolve` return `None` in the still-generic cases, we get behavior similar to specialization, where a default can only be used if there are no more generic parameters which would allow a more specialized `impl` to match.

<hr/>

This was found while testing the MIR inliner with #68965, because it was trying to inline shims.

cc @rust-lang/wg-mir-opt
2020-03-19 06:57:28 +01:00
Mazdak Farrokhzad
4392a8b73c use direct imports for rustc::{lint, session}. 2020-03-16 02:52:06 +01:00
Eduard-Mihai Burtescu
51ea260ee7 rustc: don't resolve Instances which would produce malformed shims. 2020-03-15 23:13:40 +02:00
John Kåre Alsaker
8b16b023b1 Index HIR after creating TyCtxt 2020-03-14 22:52:30 +01:00
Camille GILLOT
1fcdc52f70 Make downstream crates compile. 2020-03-14 14:17:43 +01:00
Camille GILLOT
c1e3d556bf Move rustc_infer::traits to new crate rustc_trait_selection. 2020-03-14 14:15:50 +01:00
Matthias Krüger
7b1b08cfee remove lifetimes that can be elided (clippy::needless_lifetimes) 2020-03-12 20:03:09 +01:00
Matthias Krüger
83980aca20 Don't redundantly repeat field names (clippy::redundant_field_names) 2020-03-06 19:42:18 +01:00
bors
865b44a3e3 Auto merge of #69614 - estebank:ice-age, r=davidtwco
`delay_span_bug` when codegen cannot select obligation

Fix #69602, introduced in #60126 by letting the compiler continue past
type checking after encountering errors.
2020-03-06 08:24:48 +00:00
CAD97
b3777c952f Remove chalk integration 2020-03-02 18:11:53 -05:00
Esteban Küber
7b6f5ed956 delay_span_bug when codegen cannot select obligation
Fix #69602, introduced in #60126 by letting the compiler continue past
type checking after encountering errors.
2020-03-01 10:46:07 -08:00
Dylan MacKenzie
a0212ba40f Construct AssociatedItems from an iterator instead of a Vec 2020-02-19 12:55:59 -08:00
Dylan MacKenzie
7f3ec5e50b Make lookup of associated item by name O(log n) 2020-02-19 10:51:40 -08:00
Camille GILLOT
bee6a5ac12 Other crates. 2020-02-16 11:59:35 +01:00
Camille GILLOT
f07e889145 Make librustc_infer compile. 2020-02-16 11:49:29 +01:00
Camille GILLOT
0e652c5507 Move resolve_instance to rustc_ty. 2020-02-13 18:53:21 +01:00
bors
a1912f2e89 Auto merge of #68679 - matthewjasper:needs-type-op, r=varkor
Improve `ty.needs_drop`

* Handle cycles in `needs_drop` correctly
* Normalize types when computing `needs_drop`
* Move queries from rustc to rustc_ty
* Avoid query in simple cases

reopens #65918
2020-02-12 19:31:49 +00:00
matthewjasper
3eb5241884 Apply suggestions from code review
Co-Authored-By: varkor <github@varkor.com>
2020-02-09 10:49:39 +00:00
Jonas Schievink
66fd4e6ed8 Make associated_items query return a slice 2020-02-08 14:29:18 +01:00
Dylan DPC
f6bfdf4620
Rollup merge of #68837 - jonas-schievink:assoc-item-lookup-2, r=estebank
Make associated item collection a query

Before this change, every time associated items were iterated over (which rustc does *a lot* – this can probably be further optimized), there would be N+1 queries to fetch all assoc. items. Now there's just one after they've been computed once.
2020-02-06 15:37:43 +01:00
Jonas Schievink
4fc4b951f1 Make associated item lookup a query 2020-02-05 01:43:03 +01:00
bors
5b0caef54a Auto merge of #68377 - estebank:fn-obligations-spans, r=oli-obk
Tweak obligation error output

- Point at arguments or output when fn obligations come from them, or ident when they don't
- Point at `Sized` bound (fix #47990)
- When object unsafe trait uses itself in associated item suggest using `Self` (fix #66424, fix #33375, partially address #38376, cc #61525)
-  Point at reason in object unsafe trait with `Self` in supertraits or `where`-clause (cc #40533, cc #68377)
- On implicit type parameter `Sized` obligations, suggest `?Sized` (fix #57744, fix #46683)
2020-02-04 17:17:55 +00:00
Matthew Jasper
d20646b2d8 Address review comments
* Handle arrays with const-generic lengths
* Use closure for repeated code.
2020-02-02 21:46:29 +00:00
Matthew Jasper
d1965216a3 Improve needs_drop query
* Handle cycles in `needs_drop` correctly
* Normalize types when computing `needs_drop`
* Move queries from rustc to rustc_ty
2020-02-02 21:46:29 +00:00
Matthew Jasper
570c1613c1 Remove unnecessary features in rustc_ty 2020-02-02 21:46:29 +00:00
Esteban Küber
6870f79e9c Use more accurate failed predicate spans 2020-02-02 11:53:09 -08:00
Mark Rousskov
31dcdc9e13 Drop cfg(bootstrap) code 2020-01-31 12:31:09 -05:00
Matthias Krüger
ec61761e46 don't clone types that are copy, round two. 2020-01-27 01:18:18 +01:00
Dylan MacKenzie
d2aefbb286 Add ConstnessAnd that implements ToPredicate 2020-01-20 00:00:08 -08:00
Mazdak Farrokhzad
3ccb0f9b8f slice_patterns: remove internal uses of gate 2020-01-18 19:33:47 +01:00
Dylan MacKenzie
4743995ed3 Use named fields for hir::ItemKind::Impl 2020-01-17 16:14:29 -08:00
Camille GILLOT
9908a87367 Move to new crate rustc_ty. 2020-01-13 13:41:25 +01:00