about summary refs log tree commit diff
path: root/compiler/rustc_infer
AgeCommit message (Collapse)AuthorLines
2021-08-18Auto merge of #86700 - lqd:matthews-nll-hrtb-errors, r=nikomatsakisbors-6/+33
Matthew's work on improving NLL's "higher-ranked subtype error"s This PR rebases `@matthewjasper's` [branch](https://github.com/matthewjasper/rust/tree/nll-hrtb-errors) which has great work to fix the obscure higher-ranked subtype errors that are tracked in #57374. These are a blocker to turning full NLLs on, and doing some internal cleanups to remove some of the old region code. The goal is so `@nikomatsakis` can take a look at this early, and I'll then do my best to help do the changes and followup work to land this work, and move closer to turning off the migration mode. I've only updated the branch and made it compile, removed a warning or two. r? `@nikomatsakis` (Here's the [zulip topic to discuss this](https://rust-lang.zulipchat.com/#narrow/stream/122657-t-compiler.2Fwg-nll/topic/.2357374.3A.20improving.20higher-ranked.20subtype.20errors.20via.20.2386700) that Niko wanted)
2021-08-18Remove box syntax from rustc_inferest31-5/+4
2021-08-16Rollup merge of #88030 - fee1-dead:fixme, r=oli-obkMara Bos-1/+1
Assign FIXMEs to me and remove obsolete ones Also fixed capitalization of documentation We also don't need to transform predicates to be non-const since we basically ignore const predicates in non-const contexts. r? `````@oli-obk`````
2021-08-15Introduce hir::ExprKind::Let - Take 2Caio-18/+0
2021-08-15Report nicer errors for HRTB NLL errors from queriesMatthew Jasper-1/+17
2021-08-15Track causes for universes created during borrowckMatthew Jasper-1/+1
2021-08-15Show bound lifetimes when comparing types in diagnosticsMatthew Jasper-4/+15
2021-08-14Assign FIXMEs to me and remove obsolete onesDeadbeef-1/+1
Also fixed capitalization of documentation
2021-08-14Auto merge of #87375 - fee1-dead:move-constness-to-traitpred, r=oli-obkbors-1/+19
Try filtering out non-const impls when we expect const impls **TL;DR**: Associated types on const impls are now bounded; we now disallow calling a const function with bounds when the specified type param only has a non-const impl. r? `@oli-obk`
2021-08-13Point to where clause for GATsjackh726-4/+95
2021-08-13Pass constness to SelectionContextDeadbeef-0/+18
2021-08-13move Constness into TraitPredicateDeadbeef-1/+1
2021-08-06Document `with_opaque_type_inference`'s use cases.Oli Scherer-0/+4
2021-08-06Use existing type alias instead of manually writing itOli Scherer-4/+2
2021-08-06Store the `DefId` of the currently typechecked item in `InferCtxt`Oli Scherer-2/+21
This allows opaque type inference to check for defining uses without having to pass down that def id via function arguments to every method that could possibly cause an opaque type to be compared with a concrete type
2021-08-06Remove a field that is computed later anywayOli Scherer-23/+0
2021-08-06Move opaque type cache into `InferCtxt`Oli Scherer-0/+89
2021-08-03Do not suggest impl traits as type argumentsYuki Okushi-16/+4
2021-08-02Auto merge of #87628 - estebank:unmet-explicit-lifetime-bound, r=oli-obkbors-27/+97
Point at unmet explicit lifetime obligation bound r? `@oli-obk` Split off of #85799.
2021-08-02Rollup merge of #87673 - estebank:opaque-ty-mismatch, r=davidtwcoCameron Steffen-25/+43
Tweak opaque type mismatch error
2021-08-02Rollup merge of #86176 - nbdd0121:explicit-generic-args, r=jackh726Cameron Steffen-1/+1
Implement a `explicit_generic_args_with_impl_trait` feature gate Implements #83701 When this gate is enabled, explicit generic arguments can be specified even if `impl Trait` is used in argument position. Generic arguments can only be specified for explicit generic parameters but not for the synthetic type parameters from `impl Trait` So code like this will be accepted: ```rust #![feature(explicit_generic_args_with_impl_trait)] fn foo<T: ?Sized>(_f: impl AsRef<T>) {} fn main() { foo::<str>("".to_string()); } ```
2021-08-02Implement a `explicit_generic_args_with_impl_trait` feature gateGary Guo-1/+1
When this gate is enabled, explicit generic arguments can be specified even if `impl Trait` is used in argument position. Generic arguments can only be specified for explicit generic parameters but not for the synthetic type parameters from `impl Trait`
2021-07-31Tweak opaque type mismatch errorEsteban Küber-25/+43
2021-07-31Point at unmet explicit lifetime obligation boundEsteban Küber-27/+97
2021-07-29rfc3052: Remove authors field from Cargo manifestsJade-1/+0
Since RFC 3052 soft deprecated the authors field anyway, hiding it from crates.io, docs.rs, and making Cargo not add it by default, and it is not generally up to date/useful information, we should remove it from crates in this repo.
2021-07-24Auto merge of #86461 - crlf0710:rich_vtable, r=nikomatsakisbors-3/+3
Refactor vtable format for upcoming trait_upcasting feature. This modifies vtable format: 1. reordering occurrence order of methods coming from different traits 2. include `VPtr`s for supertraits where this vtable cannot be directly reused during trait upcasting. Also, during codegen, the vtables corresponding to these newly included `VPtr` will be requested and generated. For the cases where this vtable can directly used, now the super trait vtable has exactly the same content to some prefix of this one. r? `@bjorn3` cc `@RalfJung` cc `@rust-lang/wg-traits`
2021-07-22Rollup merge of #87281 - rust-lang:issue-81487, r=nikomatsakisGuillaume Gomez-0/+1
Normalize generic_ty before checking if bound is met Fixes #81487 r? `@nikomatsakis`
2021-07-22Auto merge of #87246 - rust-lang:placeholder-pretty, r=nikomatsakisbors-1/+1
When pretty printing, name placeholders as bound regions Split from #85499 When we see a placeholder that we are going to print, treat it as a bound var (and add it to a `for<...>`
2021-07-21Improve caching during trait evaluationAaron Hill-18/+22
Previously, we would 'forget' that we had `'static` regions in some place during trait evaluation. This lead to us producing `EvaluatedToOkModuloRegions` when we could have produced `EvaluatedToOk`, causing us to perform unnecessary work. This PR preserves `'static` regions when we canonicalize a predicate for `evaluate_obligation`, and when we 'freshen' a predicate during trait evaluation. Thie ensures that evaluating a predicate containing `'static` regions can produce `EvaluatedToOk` (assuming that we don't end up introducing any region dependencies during evaluation). Building off of this improved caching, we use `predicate_must_hold_considering_regions` during fulfillment of projection predicates to see if we can skip performing additional work. We already do this for trait predicates, but doing this for projection predicates lead to mixed performance results without the above caching improvements.
2021-07-21Rollup merge of #87206 - matthiaskrgr:clippy_collect, r=davidtwcoGuillaume Gomez-2/+2
avoid temporary vectors/reuse iterators Avoid collecting an interator just to re-iterate immediately. Rather reuse the previous iterator. (clippy::needless_collect)
2021-07-20Refactor vtable format.Charles Lew-3/+3
2021-07-20Auto merge of #87244 - jackh726:issue-71883, r=estebankbors-29/+136
Better diagnostics with mismatched types due to implicit static lifetime Fixes #78113 I think this is my first diagnostics PR...definitely happy to hear thoughts on the direction/implementation here. I was originally just trying to solve the error above, where the lifetime on a GAT was causing a cryptic "mismatched types" error. But as I was writing this, I realized that this (unintentionally) also applied to a different case: `wf-in-foreign-fn-decls-issue-80468.rs`. I'm not sure if this diagnostic should get a new error code, or even reuse an existing one. And, there might be some ways to make this even more generalized. Also, the error is a bit more lengthy and verbose than probably needed. So thoughts there are welcome too. This PR essentially ended up adding a new nice region error pass that triggers if a type doesn't match the self type of an impl which is selected because of a predicate because of an implicit static bound on that self type. r? `@estebank`
2021-07-19Better errors when we don't have implicit statics in trait objectsjackh726-31/+52
2021-07-19Better diagnostics when mismatched types due to implict static lifetimejackh726-14/+100
2021-07-19Normalize generic_ty before checking if bound is metjackh726-0/+1
2021-07-18Remove impl_trait_in_bindings handling on inference error reportingSantiago Pastorino-5/+2
2021-07-18When pretty printing, name placeholders as bound regionsjackh726-1/+1
2021-07-17Some perf optimizations and loggingjackh726-0/+1
2021-07-17avoid temporary vectorsMatthias Krüger-2/+2
Avoid collecting an interator just to re-iterate immediately. Rather reuse the previous iterator. (clippy::needless_collect)
2021-07-16Add initial implementation of HIR-based WF checking for diagnosticsAaron Hill-1/+6
During well-formed checking, we walk through all types 'nested' in generic arguments. For example, WF-checking `Option<MyStruct<u8>>` will cause us to check `MyStruct<u8>` and `u8`. However, this is done on a `rustc_middle::ty::Ty`, which has no span information. As a result, any errors that occur will have a very general span (e.g. the definintion of an associated item). This becomes a problem when macros are involved. In general, an associated type like `type MyType = Option<MyStruct<u8>>;` may have completely different spans for each nested type in the HIR. Using the span of the entire associated item might end up pointing to a macro invocation, even though a user-provided span is available in one of the nested types. This PR adds a framework for HIR-based well formed checking. This check is only run during error reporting, and is used to obtain a more precise span for an existing error. This is accomplished by individually checking each 'nested' type in the HIR for the type, allowing us to find the most-specific type (and span) that produces a given error. The majority of the changes are to the error-reporting code. However, some of the general trait code is modified to pass through more information. Since this has no soundness implications, I've implemented a minimal version to begin with, which can be extended over time. In particular, this only works for HIR items with a corresponding `DefId` (e.g. it will not work for WF-checking performed within function bodies).
2021-07-04remove unused OptionNiko Matsakis-18/+11
2021-06-25rustc_infer: Remove unused dependency rustc_astJosh Triplett-1/+0
Unused since commit 50e1ae15e9f3035b06bae00e1b1dc7a358546d3e ("Use ty::{IntTy,UintTy,FloatTy} in rustc").
2021-06-25rustc_infer: Remove unused dependency rustc_graphvizJosh Triplett-1/+0
Unused since commit 7d73e4cc47f295e5b68fa7aa86688cabfd3c7eea ("Remove ReScope").
2021-06-17Auto merge of #86164 - FabianWolff:issue-86053, r=davidtwcobors-25/+34
Handle C-variadic arguments properly when reporting region errors This pull request fixes #86053. The issue is that for a C-variadic function ```rust #![feature(c_variadic)] unsafe extern "C" fn foo(_: (), ...) {} ``` `foo`'s signature will contain only the first parameter (and have `c_variadic` set to `true`), whereas its body has a second argument (a `hir::Pat` for the `...`). The code for reporting region errors iterates over the body's parameters and tries to fetch the corresponding parameter from the signature; this causes an out-of-bounds ICE for the `...` (though not in the example above, because there are no region errors to report). I have simply restricted the iteration over the body parameters to exclude `...`, which is fine because `...` cannot cause a region error.
2021-06-14Use the now available implementation of `IntoIterator` for arraysLeSeulArtichaut-1/+1
2021-06-09Handle C-variadic arguments properly when reporting region errorsFabian Wolff-25/+34
2021-06-07Suggest a trailing comma if a 1-tuple is expectedFabian Wolff-1/+28
2021-06-06Add variance-related information to lifetime error messagesAaron Hill-14/+60
2021-06-04Rollup merge of #85850 - bjorn3:less_feature_gates, r=jyn514Yuki Okushi-2/+0
Remove unused feature gates The first commit removes a usage of a feature gate, but I don't expect it to be controversial as the feature gate was only used to workaround a limitation of rust in the past. (closures never being `Clone`) The second commit uses `#[allow_internal_unstable]` to avoid leaking the `trusted_step` feature gate usage from inside the index newtype macro. It didn't work for the `min_specialization` feature gate though. The third commit removes (almost) all feature gates from the compiler that weren't used anyway.
2021-06-02Restrict access to crate_name.Camille GILLOT-1/+1
Also remove original_crate_name, which had the exact same implementation