about summary refs log tree commit diff
path: root/src/librustc_infer
AgeCommit message (Collapse)AuthorLines
2020-06-15Suggest substituting `'static` lifetime in impl/dyn `Trait + 'static` return ↵Esteban Küber-8/+56
types
2020-06-15Auto merge of #73369 - RalfJung:rollup-hl8g9zf, r=RalfJungbors-1/+1
Rollup of 10 pull requests Successful merges: - #72707 (Use min_specialization in the remaining rustc crates) - #72740 (On recursive ADT, provide indirection structured suggestion) - #72879 (Miri: avoid tracking current location three times) - #72938 (Stabilize Option::zip) - #73086 (Rename "cyclone" to "apple-a7" per changes in upstream LLVM) - #73104 (Example about explicit mutex dropping) - #73139 (Add methods to go from a nul-terminated Vec<u8> to a CString) - #73296 (Remove vestigial CI job msvc-aux.) - #73304 (Revert heterogeneous SocketAddr PartialEq impls) - #73331 (extend network support for HermitCore) Failed merges: r? @ghost
2020-06-15Rollup merge of #72707 - matthewjasper:rustc_min_spec, r=oli-obkRalf Jung-1/+1
Use min_specialization in the remaining rustc crates This adds a lot of `transmute` calls to replace the unsound uses of specialization. It's ugly, but at least it's honest about what's going on. cc #71420, @RalfJung
2020-06-15Auto merge of #73367 - RalfJung:rollup-4ewvk9b, r=RalfJungbors-1/+1
Rollup of 10 pull requests Successful merges: - #71824 (Check for live drops in constants after drop elaboration) - #72389 (Explain move errors that occur due to method calls involving `self`) - #72556 (Fix trait alias inherent impl resolution) - #72584 (Stabilize vec::Drain::as_slice) - #72598 (Display information about captured variable in `FnMut` error) - #73336 (Group `Pattern::strip_*` method together) - #73341 (_match.rs: fix module doc comment) - #73342 (Fix iterator copied() documentation example code) - #73351 (Update E0446.md) - #73353 (structural_match: non-structural-match ty closures) Failed merges: r? @ghost
2020-06-15Auto merge of #72080 - matthewjasper:uniform-impl-trait, r=nikomatsakisbors-4/+3
Clean up type alias impl trait implementation - Removes special case for top-level impl trait - Removes associated opaque types - Forbid lifetime elision in let position impl trait. This is consistent with the behavior for inferred types. - Handle lifetimes in type alias impl trait more uniformly with other parameters cc #69323 cc #63063 Closes #57188 Closes #62988 Closes #69136 Closes #73061
2020-06-11Explain move errors that occur due to method calls involving `self`Aaron Hill-1/+1
2020-06-11Rollup merge of #73182 - Aaron1011:feature/call-fn-span, r=matthewjasperDylan DPC-2/+2
Track span of function in method calls, and use this in #[track_caller] Fixes #69977 When we parse a chain of method calls like `foo.a().b().c()`, each `MethodCallExpr` gets assigned a span that starts at the beginning of the call chain (`foo`). While this is useful for diagnostics, it means that `Location::caller` will return the same location for every call in a call chain. This PR makes us separately record the span of the function name and arguments for a method call (e.g. `b()` in `foo.a().b().c()`). This `Span` is passed through HIR lowering and MIR building to `TerminatorKind::Call`, where it is used in preference to `Terminator.source_info.span` when determining `Location::caller`. This new span is also useful for diagnostics where we want to emphasize a particular method call - for an example, see https://github.com/rust-lang/rust/pull/72389#discussion_r436035990
2020-06-11Rename `TyKind::Def` to `OpaqueDef`Matthew Jasper-1/+2
2020-06-11Remove associated opaque typesMatthew Jasper-3/+1
They're unused now.
2020-06-10Track span of function in method calls, and use this in #[track_caller]Aaron Hill-2/+2
Fixes #69977 When we parse a chain of method calls like `foo.a().b().c()`, each `MethodCallExpr` gets assigned a span that starts at the beginning of the call chain (`foo`). While this is useful for diagnostics, it means that `Location::caller` will return the same location for every call in a call chain. This PR makes us separately record the span of the function name and arguments for a method call (e.g. `b()` in `foo.a().b().c()`). This `Span` is passed through HIR lowering and MIR building to `TerminatorKind::Call`, where it is used in preference to `Terminator.source_info.span` when determining `Location::caller`. This new span is also useful for diagnostics where we want to emphasize a particular method call - for an example, see https://github.com/rust-lang/rust/pull/72389#discussion_r436035990
2020-06-10Use min_specialization in the remaining rustc cratesMatthew Jasper-1/+1
2020-06-09Fix more clippy warningsMatthias Krüger-3/+2
Fixes more of: clippy::unused_unit clippy::op_ref clippy::useless_format clippy::needless_return clippy::useless_conversion clippy::bind_instead_of_map clippy::into_iter_on_ref clippy::redundant_clone clippy::nonminimal_bool clippy::redundant_closure clippy::option_as_ref_deref clippy::len_zero clippy::iter_cloned_collect clippy::filter_next
2020-06-09Auto merge of #72114 - anyska:vtable-rename, r=nikomatsakisbors-4/+4
Rename traits::Vtable to ImplSource. Originally suggested by @eddyb. r? @nikomatsakis
2020-06-07store `ObligationCause` on the heapBastian Kauschke-5/+7
2020-06-06Auto merge of #72927 - petrochenkov:rustc, r=Mark-Simulacrumbors-2/+2
Rename all remaining compiler crates to use the `rustc_foo` pattern libarena -> librustc_arena libfmt_macros -> librustc_parse_format libgraphviz -> librustc_graphviz libserialize -> librustc_serialize Closes https://github.com/rust-lang/rust/issues/71177 in particular.
2020-06-05Rename traits::Vtable to ImplSource.Ana-Maria Mihalache-4/+4
2020-06-05Add FIXME to comment regarding local patternsNathan Corbyn-1/+1
Co-authored-by: Bastian Kauschke <bastian_kauschke@hotmail.de>
2020-06-05Make `need_type_info_err` more conservativeNathan Corbyn-2/+15
2020-06-02Rename the crates in source codeVadim Petrochenkov-1/+1
2020-06-02Make things build againVadim Petrochenkov-2/+2
2020-06-02change WellFormed predicate to GenericArgBastian Kauschke-8/+2
2020-06-02add WellFormedConst predicateBastian Kauschke-1/+7
2020-05-30Tweak wording and spans of `'static` `dyn Trait`/`impl Trait` requirementsEsteban Küber-21/+26
2020-05-30Consider all possible one letter lifetimes in suggestionEsteban Küber-3/+3
2020-05-30Account for enclosing item when suggesting new lifetime nameEsteban Küber-13/+33
2020-05-30Tweak type parameter errors to reduce verbosityEsteban Küber-11/+23
2020-05-30review comment: tweak wording and account for span overlapEsteban Küber-4/+18
2020-05-30Account for returned `dyn Trait` evaluating to `'static` lifetimeEsteban Küber-52/+32
Provide a suggestion for `dyn Trait + '_` when possible.
2020-05-30Improve output of argument anonymous borrow missing annotation involving ↵Esteban Küber-8/+18
opaque return type Go from ``` error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements --> file8.rs:22:5 | 22 | / move || { 23 | | *dest = g.get(); 24 | | } | |_____^ | note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the function body at 18:1... --> file8.rs:18:1 | 18 | / fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a 19 | | where 20 | | G: Get<T> 21 | | { ... | 24 | | } 25 | | } | |_^ note: ...so that the types are compatible --> file8.rs:22:5 | 22 | / move || { //~ ERROR cannot infer an appropriate lifetime 23 | | *dest = g.get(); 24 | | } | |_____^ = note: expected `&mut T` found `&mut T` note: but, the lifetime must be valid for the lifetime `'a` as defined on the function body at 18:8... --> file8.rs:18:8 | 18 | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a | ^^ note: ...so that return value is valid for the call --> file8.rs:18:45 | 18 | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a | ^^^^^^^^^^^^^^^^^^^^^^^ ``` to ``` error[E0621]: explicit lifetime required in the type of `dest` --> file8.rs:18:45 | 18 | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a | ------ ^^^^^^^^^^^^^^^^^^^^^^^ lifetime `'a` required | | | help: add explicit lifetime `'a` to the type of `dest`: `&'a mut T` ```
2020-05-30Account for missing lifetime in opaque return typeEsteban Küber-69/+113
When encountering an opaque closure return type that needs to bound a lifetime to the function's arguments, including borrows and type params, provide appropriate suggestions that lead to working code. Get the user from ```rust fn foo<G, T>(g: G, dest: &mut T) -> impl FnOnce() where G: Get<T> { move || { *dest = g.get(); } } ``` to ```rust fn foo<'a, G: 'a, T>(g: G, dest: &'a mut T) -> impl FnOnce() +'a where G: Get<T> { move || { *dest = g.get(); } } ```
2020-05-30Rollup merge of #72162 - cuviper:extend_one, r=Mark-SimulacrumYuki Okushi-0/+9
Add Extend::{extend_one,extend_reserve} This adds new optional methods on `Extend`: `extend_one` add a single element to the collection, and `extend_reserve` pre-allocates space for the predicted number of incoming elements. These are used in `Iterator` for `partition` and `unzip` as they shuffle elements one-at-a-time into their respective collections.
2020-05-29Add Extend::{extend_one,extend_reserve}Josh Stone-0/+9
This adds new optional methods on `Extend`: `extend_one` add a single element to the collection, and `extend_reserve` pre-allocates space for the predicted number of incoming elements. These are used in `Iterator` for `partition` and `unzip` as they shuffle elements one-at-a-time into their respective collections.
2020-05-29Rollup merge of #67460 - estebank:named-lts, r=nikomatsakisRalf Jung-10/+101
Tweak impl signature mismatch errors involving `RegionKind::ReVar` lifetimes Fix #66406, fix #72106. ``` error: `impl` item signature doesn't match `trait` item signature --> $DIR/trait-param-without-lifetime-constraint.rs:14:5 | LL | fn get_relation(&self) -> To; | ----------------------------- expected `fn(&Article) -> &ProofReader` ... LL | fn get_relation(&self) -> &ProofReader { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&Article) -> &ProofReader` | = note: expected `fn(&Article) -> &ProofReader` found `fn(&Article) -> &ProofReader` help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait` --> $DIR/trait-param-without-lifetime-constraint.rs:10:31 | LL | fn get_relation(&self) -> To; | ^^ consider borrowing this type parameter in the trait ``` r? @nikomatsakis
2020-05-28Account for `Self` as a type paramEsteban Küber-3/+7
2020-05-27review comments: change wording and visual outputEsteban Küber-47/+16
2020-05-27Fix rebaseEsteban Küber-3/+4
2020-05-28Auto merge of #72494 - lcnr:predicate-cleanup, r=nikomatsakisbors-36/+30
Pass more `Copy` types by value. There are a lot of locations where we pass `&T where T: Copy` by reference, which should both be slightly less performant and less readable IMO. This PR currently consists of three fairly self contained commits: - passes `ty::Predicate` by value and stops depending on `AsRef<ty::Predicate>`. - changes `<&List<_>>::into_iter` to iterate over the elements by value. This would break `List`s of non copy types. But as the only list constructor requires `T` to be copy anyways, I think the improved readability is worth this potential future restriction. - passes `mir::PlaceElem` by value. Mir currently has quite a few copy types which are passed by reference, e.g. `Local`. As I don't have a lot of experience working with MIR, I mostly did this to get some feedback from people who use MIR more frequently - tries to reuse `ty::Predicate` in case it did not change in some places, which should hopefully fix the regression caused by #72055 r? @nikomatsakis for the first commit, which continues the work of #72055 and makes adding `PredicateKind::ForAll` slightly more pleasant. Feel free to reassign though
2020-05-27fix rebaseEsteban Küber-1/+1
2020-05-27fix rebaseEsteban Küber-4/+2
2020-05-27Modify wordingEsteban Küber-11/+72
2020-05-27fix rebaseEsteban Küber-3/+3
2020-05-27review comment: use FxIndexSetEsteban Küber-3/+3
2020-05-27review commentsEsteban Küber-40/+18
2020-05-27Tweak output for mismatched impl itemEsteban Küber-13/+43
Detect type parameter that might require lifetime constraint. Do not name `ReVar`s in expected/found output. Reword text suggesting to check the lifetimes.
2020-05-27Name `RegionKind::ReVar` lifetimes in diagnosticsEsteban Küber-5/+55
2020-05-27Auto merge of #71996 - Marwes:detach_undo_log, r=nikomatsakisbors-21/+34
perf: Revert accidental inclusion of a part of #69218 This was accidentally included in #69464 after a rebase and given how much `inflate` and `keccak` stresses the obligation forest seems like a likely culprit to the regression in those benchmarks. (It is necessary in #69218 as obligation forest needs to accurately track the root variables or unifications will get lost)
2020-05-24perf: Add inline on commonly used methods added in 69464Markus Westerlind-21/+34
Reclaims most of the regression in inflate
2020-05-23fix Predicate perf regressionBastian Kauschke-18/+12
2020-05-23iterate List by valueBastian Kauschke-6/+5
2020-05-23take predicates by value instead of by referenceBastian Kauschke-15/+16