about summary refs log tree commit diff
path: root/src/librustc_mir/borrow_check
AgeCommit message (Collapse)AuthorLines
2020-08-30mv compiler to compiler/mark-21578/+0
2020-08-27Auto merge of #75933 - Aaron1011:feature/closure-move-err, r=oli-obkbors-4/+23
Point to a move-related span when pointing to closure upvars Fixes #75904 When emitting move/borrow errors, we may point into a closure to indicate why an upvar is used in the closure. However, we use the 'upvar span', which is just an arbitrary usage of the upvar. If the upvar is used in multiple places (e.g. a borrow and a move), we may end up pointing to the borrow. If the overall error is a move error, this can be confusing. This PR tracks the span that caused an upvar to become captured by-value instead of by-ref (assuming that it's not a `move` closure). We use this span instead of the 'upvar' span when we need to point to an upvar usage during borrow checking.
2020-08-26Auto merge of #75893 - Dylan-DPC:fix/offset-to-u64, r=oli-obkbors-3/+3
change offset from u32 to u64 References #71696 r? @oli-obk (closed the earlier pr because the rebase got messed up)
2020-08-26Point to a move-related span when pointing to closure upvarsAaron Hill-4/+23
Fixes #75904 When emitting move/borrow errors, we may point into a closure to indicate why an upvar is used in the closure. However, we use the 'upvar span', which is just an arbitrary usage of the upvar. If the upvar is used in multiple places (e.g. a borrow and a move), we may end up pointing to the borrow. If the overall error is a move error, this can be confusing. This PR tracks the span that caused an upvar to become captured by-value instead of by-ref (assuming that it's not a `move` closure). We use this span instead of the 'upvar' span when we need to point to an upvar usage during borrow checking.
2020-08-25Auto merge of #75302 - Aaron1011:feature/partial-move-diag, r=estebankbors-25/+68
Be consistent when describing a move as a 'partial' in diagnostics When an error occurs due to a partial move, we would use the world "partial" in some parts of the error message, but not in others. This commit ensures that we use the word 'partial' in either all or none of the diagnostic messages. Additionally, we no longer describe a move out of a `Box` via `*` as a 'partial move'. This was a pre-existing issue, but became more noticable when the word 'partial' is used in more places.
2020-08-25cleanupDPC-1/+1
2020-08-24hir: consistent use and naming of lang itemsDavid Wood-11/+9
This commit adjusts the naming of various lang items so that they are consistent and don't include prefixes containing the target or "LangItem". In addition, lang item variants are no longer exported from the `lang_items` module. Signed-off-by: David Wood <david@davidtw.co>
2020-08-23 change offset from u32 to u64DPC-2/+2
2020-08-22Use smaller def span for functionsAaron Hill-1/+1
Currently, the def span of a funtion encompasses the entire function signature and body. However, this is usually unnecessarily verbose - when we are pointing at an entire function in a diagnostic, we almost always want to point at the signature. The actual contents of the body tends to be irrelevant to the diagnostic we are emitting, and just takes up additional screen space. This commit changes the `def_span` of all function items (freestanding functions, `impl`-block methods, and `trait`-block methods) to be the span of the signature. For example, the function ```rust pub fn foo<T>(val: T) -> T { val } ``` now has a `def_span` corresponding to `pub fn foo<T>(val: T) -> T` (everything before the opening curly brace). Trait methods without a body have a `def_span` which includes the trailing semicolon. For example: ```rust trait Foo { fn bar(); }``` the function definition `Foo::bar` has a `def_span` of `fn bar();` This makes our diagnostic output much shorter, and emphasizes information that is relevant to whatever diagnostic we are reporting. We continue to use the full span (including the body) in a few of places: * MIR building uses the full span when building source scopes. * 'Outlives suggestions' use the full span to sort the diagnostics being emitted. * The `#[rustc_on_unimplemented(enclosing_scope="in this scope")]` attribute points the entire scope body. * The 'unconditional recursion' lint uses the full span to show additional context for the recursive call. All of these cases work only with local items, so we don't need to add anything extra to crate metadata.
2020-08-20Auto merge of #75562 - oli-obk:const_prop_no_aggregates, r=wesleywiserbors-1/+1
Check that we don't use `Rvalue::Aggregate` after the deaggregator fixes #75481 r? @wesleywiser cc @RalfJung (modified the validator)
2020-08-18Moved coverage counter injection from BasicBlock to Statement.Rich Kadel-1/+5
2020-08-18Validate the MIR of all optimizations in the mir-opt directoryOliver Scherer-1/+1
2020-08-15replaced log with tracingGurpreet Singh-1/+1
2020-08-13merge `as_local_hir_id` with `local_def_id_to_hir_id`Bastian Kauschke-14/+14
2020-08-09rustc_mir: use IndexSet in PlaceholderIndicesJosh Stone-8/+7
2020-08-09rustc_mir: use IndexMap in BorrowSetJosh Stone-36/+45
2020-08-08Be consistent when describing a move as a 'partial' in diagnosticsAaron Hill-25/+68
When an error occurs due to a partial move, we would use the world "partial" in some parts of the error message, but not in others. This commit ensures that we use the word 'partial' in either all or none of the diagnostic messages. Additionally, we no longer describe a move out of a `Box` via `*` as a 'partial move'. This was a pre-existing issue, but became more noticable when the word 'partial' is used in more places.
2020-08-08fix clippy::needless_return: remove unneeded return statementsMatthias Krüger-1/+1
2020-07-27introduce PredicateAtomBastian Kauschke-6/+6
2020-07-27this might be unqualified, but at least it's now quantifiedBastian Kauschke-1/+1
2020-07-27split ignore_qualifiersBastian Kauschke-2/+2
2020-07-27`PredicateKint` -> `PredicateKind`, the beginning of the endBastian Kauschke-9/+9
2020-07-27progressBastian Kauschke-13/+9
2020-07-27convert trivial predicatesBastian Kauschke-7/+7
2020-07-24Rollup merge of #74661 - SNCPlay42:lifetime-names-refactor, r=estebankManish Goregaokar-89/+92
Refactor `region_name`: add `RegionNameHighlight` This PR does not change any diagnostics itself, rather it enables further code changes, but I would like to get approval for the refactoring first before making use of it. In `rustc_mir::borrow_check::diagnostics::region_name`, there is code that allows for, when giving a synthesized name like `'1` to an anonymous lifetime, pointing at e.g. the exact '`&`' that introduces the lifetime. This PR decouples that code from the specific case of arguments, adding a new enum `RegionNameHighlight`, enabling future changes to use it in other places. This allows: * We could change the other `AnonRegionFrom*` variants to use `RegionNameHighlight` to precisely point at where lifetimes are introduced in other locations when they have type annotations, e.g. a closure return `|...| -> &i32`. * Because of how async functions are lowered this affects async functions as well, see #74072 * for #74597, we could add a second, optional `RegionNameHighlight` to the `AnonRegionFromArgument` variant that highlights a lifetime in the return type of a function when, due to elision, this is the same as the argument lifetime. * in https://github.com/rust-lang/rust/issues/74497#issuecomment-6606229707 I noticed that a diagnostic was trying to introduce a lifetime `'2` in the opaque type `impl std::future::Future`. The code for the case of arguments has [code to handle cases like this](https://github.com/rust-lang/rust/blob/bbebe7351fcd29af1eb9a35e315369b15887ea09/src/librustc_mir/borrow_check/diagnostics/region_name.rs#L365) but not the others. This refactoring would allow the same code path to handle this. * It might be appropriate to add another variant of `RegionNameHighlight` to say something like `lifetime '1 appears in the opaque type impl std::future::Future`. These are quite a few changes so I thought I would make sure the refactoring is OK before I start making changes that rely on it. :)
2020-07-23rename arguments to highlight_if_we_can_match_hir_tySNCPlay42-7/+6
2020-07-23move highlight_if_we_can_match_hir_ty callSNCPlay42-6/+5
out of highlight_if_we_can_match_hir_ty_from_argument, which is then renamed
2020-07-22decouple highlight_if_we_cannot_match_hir_tySNCPlay42-10/+10
2020-07-22clean up give_name_if_anonymous_region_appears_in_argumentsSNCPlay42-18/+9
2020-07-22rename functionsSNCPlay42-7/+7
2020-07-22change returns to RegionNameHighlightSNCPlay42-38/+29
2020-07-22extract RegionNameHighlightSNCPlay42-23/+40
2020-07-22add RegionName::spanSNCPlay42-13/+19
2020-07-21fetch -> lookupBastian Kauschke-1/+1
2020-07-21remove some const arg in ty dep path boilerplateBastian Kauschke-7/+7
2020-07-17Rename TypeckTables to TypeckResults.Valentin Lazureanu-15/+10
2020-07-15WithOptConstParam::dummy -> WithOptConstParam::unknownBastian Kauschke-1/+1
2020-07-15ty_def_id -> def_id_for_type_ofBastian Kauschke-1/+1
2020-07-15improve namingBastian Kauschke-8/+8
2020-07-15update const arg queriesBastian Kauschke-5/+5
2020-07-15const generics work!Bastian Kauschke-52/+67
2020-07-15continue mir pipelineBastian Kauschke-2/+2
2020-07-15ConstKind::UnevaluatedBastian Kauschke-2/+2
2020-07-15Add and use more static symbols.Nicholas Nethercote-6/+4
Note that the output of `unpretty-debug.stdout` has changed. In that test the hash values are normalized from a symbol numbers to small numbers like "0#0" and "0#1". The increase in the number of static symbols must have caused the original numbers to contain more digits, resulting in different pretty-printing prior to normalization.
2020-07-09Rollup merge of #74070 - eddyb:forall-tcx-providers, r=nikomatsakisManish Goregaokar-1/+1
Use for<'tcx> fn pointers in Providers, instead of having Providers<'tcx>. In order to work around normalization-under-HRTB (for `provide!` in `rustc_metadata`), we ended up with this: ```rust struct Providers<'tcx> { type_of: fn(TyCtxt<'tcx>, DefId) -> Ty<'tcx>, // ... } ``` But what I initially wanted to do, IIRC, was this: ```rust struct Providers { type_of: for<'tcx> fn(TyCtxt<'tcx>, DefId) -> Ty<'tcx>, // ... } ``` This PR moves to the latter, for the simple reason that only the latter allows keeping a `Providers` value, or a subset of its `fn` pointer fields, around in a `static` or `thread_local!`, which can be really useful for custom drivers that override queries. (@jyn514 and I came across a concrete usecase of that in `rustdoc`) The `provide!` macro in `rustc_metadata` is fixed by making the query key/value types available as type aliases under `ty::query::query_{keys,values}`, not just associated types (this is the first commit). r? @nikomatsakis
2020-07-05Use for<'tcx> fn pointers in Providers, instead of having Providers<'tcx>.Eduard-Mihai Burtescu-1/+1
2020-07-04instantiate_opaque_types LocalDefIdBastian Kauschke-6/+6
2020-07-01Rollup merge of #73806 - Aaron1011:feature/approx-universal-upper, r=estebankManish Goregaokar-2/+39
Use an 'approximate' universal upper bound when reporting region errors Fixes #67765 When reporting errors during MIR region inference, we sometimes use `universal_upper_bound` to obtain a named universal region that we can display to the user. However, this is not always possible - in a case like `fn foo<'a, 'b>() { .. }`, the only upper bound for a region containing `'a` and `'b` is `'static`. When displaying diagnostics, it's usually better to display *some* named region (even if there are multiple involved) rather than fall back to a generic error involving `'static`. This commit adds a new `approx_universal_upper_bound` method, which uses the lowest-numbered universal region if the only alternative is to return `'static`.
2020-06-30change `skip_binder` to use T by valueBastian Kauschke-2/+2
2020-06-30stop taking references in RelateBastian Kauschke-1/+1