about summary refs log tree commit diff
path: root/src/test/ui/regions
AgeCommit message (Collapse)AuthorLines
2020-10-06Separate bounds and predicates for associated/opaque typesMatthew Jasper-59/+23
2020-09-02pretty: trim paths of unique symbolsDan Aloni-19/+19
If a symbol name can only be imported from one place for a type, and as long as it was not glob-imported anywhere in the current crate, we can trim its printed path and print only the name. This has wide implications on error messages with types, for example, shortening `std::vec::Vec` to just `Vec`, as long as there is no other `Vec` importable anywhere. This adds a new '-Z trim-diagnostic-paths=false' option to control this feature. On the good path, with no diagnosis printed, we should try to avoid issuing this query, so we need to prevent trimmed_def_paths query on several cases. This change also relies on a previous commit that differentiates between `Debug` and `Display` on various rustc types, where the latter is trimmed and presented to the user and the former is not.
2020-08-30Auto merge of #75867 - estebank:async-lt-sugg-fix, r=matthewjasperbors-12/+36
Account for async functions when suggesting new named lifetime Fix #75850.
2020-08-23Account for async functions when suggesting new named lifetimeEsteban Küber-12/+36
Fix #75850.
2020-08-22Use smaller def span for functionsAaron Hill-24/+8
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-04Replace `Memoryblock` with `NonNull<[u8]>`Tim Diekmann-2/+2
2020-07-28Remove in-place allocation and revert to separate methods for zeroed allocationsTim Diekmann-4/+2
Fix docs
2020-07-23Auto merge of #74509 - matthewjasper:empty-verify, r=nikomatsakisbors-0/+101
Use `ReEmpty(U0)` as the implicit region bound in typeck Fixes #74429 r? @nikomatsakis
2020-07-22Further tweak wording of E0759 and introduce E0767Esteban Küber-14/+14
2020-07-22Detect when `'static` obligation might come from an `impl`Esteban Küber-23/+5
Address #71341.
2020-07-20Use `ReEmpty(U0)` as the implicit region bound in typeckMatthew Jasper-0/+101
2020-07-14Suggest boxing or borrowing unsized fieldsEsteban Küber-4/+4
2020-07-10Tweak wordingYuki Okushi-19/+19
2020-07-10Add a help to use `in_band_lifetimes` in nightlyYuki Okushi-0/+33
2020-06-22WIP bless test and compare-mode=nllNiko Matsakis-27/+111
2020-06-22move leak-check to during coherence, candidate evalNiko Matsakis-12/+6
In particular, it no longer occurs during the subtyping check. This is important for enabling lazy normalization, because the subtyping check will be producing sub-obligations that could affect its results. Consider an example like for<'a> fn(<&'a as Mirror>::Item) = fn(&'b u8) where `<T as Mirror>::Item = T` for all `T`. We will wish to produce a new subobligation like <'!1 as Mirror>::Item = &'b u8 This will, after being solved, ultimately yield a constraint that `'!1 = 'b` which will fail. But with the leak-check being performed on subtyping, there is no opportunity to normalize `<'!1 as Mirror>::Item` (unless we invoke that normalization directly from within subtyping, and I would prefer that subtyping and unification are distinct operations rather than part of the trait solving stack). The reason to keep the leak check during coherence and trait evaluation is partly for backwards compatibility. The coherence change permits impls for `fn(T)` and `fn(&T)` to co-exist, and the trait evaluation change means that we can distinguish those two cases without ambiguity errors. It also avoids recreating #57639, where we were incorrectly choosing a where clause that would have failed the leak check over the impl which succeeds. The other reason to keep the leak check in those places is that I think it is actually close to the model we want. To the point, I think the trait solver ought to have the job of "breaking down" higher-ranked region obligation like ``!1: '2` into into region obligations that operate on things in the root universe, at which point they should be handed off to polonius. The leak check isn't *really* doing that -- these obligations are still handed to the region solver to process -- but if/when we do adopt that model, the decision to pass/fail would be happening in roughly this part of the code. This change had somewhat more side-effects than I anticipated. It seems like there are cases where the leak-check was not being enforced during method proving and trait selection. I haven't quite tracked this down but I think it ought to be documented, so that we know what precisely we are committing to. One surprising test was `issue-30786.rs`. The behavior there seems a bit "fishy" to me, but the problem is not related to the leak check change as far as I can tell, but more to do with the closure signature inference code and perhaps the associated type projection, which together seem to be conspiring to produce an unexpected signature. Nonetheless, it is an example of where changing the leak-check can have some unexpected consequences: we're now failing to resolve a method earlier than we were, which suggests we might change some method resolutions that would have been ambiguous to be successful. TODO: * figure out remainig test failures * add new coherence tests for the patterns we ARE disallowing
2020-06-22rewrite leak check to be based on universesNiko Matsakis-18/+7
In the new leak check, instead of getting a list of placeholders to track, we look for any placeholder that is part of a universe which was created during the snapshot. We are looking for the following error patterns: * P1: P2, where P1 != P2 * P1: R, where R is in some universe that cannot name P1 This new leak check is more precise than before, in that it accepts this patterns: * R: P1, even if R cannot name P1, because R = 'static is a valid sol'n * R: P1, R: P2, as above Note that this leak check, when running during subtyping, is less efficient than before in some sense because it is going to check and re-check all the universes created since the snapshot. We're going to move when the leak check runs to try and correct that.
2020-06-15Change E0758 to E0759 to avoid conflict with #72912Esteban Küber-10/+10
2020-06-15small tweaksEsteban Küber-5/+5
2020-06-15Register new eror codeEsteban Küber-1/+5
2020-06-15review comments: wordingEsteban Küber-17/+17
2020-06-15Tweak wording and add error codeEsteban Küber-20/+20
2020-06-15Tweak output for overlapping required/captured spansEsteban Küber-36/+6
2020-06-15Move overlapping span to a noteEsteban Küber-24/+36
2020-06-15Reduce verbosity of suggestion message and mention lifetime in labelEsteban Küber-12/+12
2020-06-15When `'static` is explicit, suggest constraining argument with itEsteban Küber-79/+110
2020-06-15Rollup merge of #72598 - Aaron1011:feature/fnmut-capture-span, r=nikomatsakisRalf Jung-2/+6
Display information about captured variable in `FnMut` error Fixes #69446 When we encounter a region error involving an `FnMut` closure, we display a specialized error message. However, we currently do not tell the user which upvar was captured. This makes it difficult to determine the cause of the error, especially when the closure is large. This commit records marks constraints involving closure upvars with `ConstraintCategory::ClosureUpvar`. When we decide to 'blame' a `ConstraintCategory::Return`, we additionall store the captured upvar if we found a `ConstraintCategory::ClosureUpvar` in the path. When generating an error message, we point to relevant spans if we have closure upvar information available. We further customize the message if an `async` closure is being returned, to make it clear that the captured variable is being returned indirectly.
2020-05-30Tweak wording and spans of `'static` `dyn Trait`/`impl Trait` requirementsEsteban Küber-12/+6
2020-05-30Tweak type parameter errors to reduce verbosityEsteban Küber-161/+24
2020-05-30Update nll testsEsteban Küber-5/+5
2020-05-30review comment: tweak wording and account for span overlapEsteban Küber-1/+1
2020-05-30Account for returned `dyn Trait` evaluating to `'static` lifetimeEsteban Küber-19/+30
Provide a suggestion for `dyn Trait + '_` when possible.
2020-05-27fix rebaseEsteban Küber-4/+4
2020-05-27Tweak output for mismatched impl itemEsteban Küber-7/+7
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-7/+7
2020-05-27Fix spacing of expected/found notes without a labelEsteban Küber-30/+30
2020-05-25Display information about captured variable in `FnMut` errorAaron Hill-2/+6
Fixes #69446 When we encounter a region error involving an `FnMut` closure, we display a specialized error message. However, we currently do not tell the user which upvar was captured. This makes it difficult to determine the cause of the error, especially when the closure is large. This commit records marks constraints involving closure upvars with `ConstraintCategory::ClosureUpvar`. When we decide to 'blame' a `ConstraintCategory::Return`, we additionall store the captured upvar if we found a `ConstraintCategory::ClosureUpvar` in the path. When generating an error message, we point to relevant spans if we have closure upvar information available. We further customize the message if an `async` closure is being returned, to make it clear that the captured variable is being returned indirectly.
2020-05-22Update testsMatthew Jasper-227/+59
2020-05-11Fix hang in lexical_region_resolveMatthew Jasper-0/+7
2020-04-11rustc: Add a warning count upon completionRoccoDev-1/+1
2020-04-02Auto merge of #70362 - TimDiekmann:alloc-overhaul, r=Amanieubors-8/+8
Overhaul of the `AllocRef` trait to match allocator-wg's latest consens; Take 2 GitHub won't let me reopen #69889 so I make a new PR. In addition to #69889 this fixes the unsoundness of `RawVec::into_box` when using allocators supporting overallocating. Also it uses `MemoryBlock` in `AllocRef` to unify `_in_place` methods by passing `&mut MemoryBlock`. Additionally, `RawVec` now checks for `size_of::<T>()` again and ignore every ZST. The internal capacity of `RawVec` isn't used by ZSTs anymore, as `into_box` now requires a length to be specified. r? @Amanieu fixes rust-lang/wg-allocators#38 fixes rust-lang/wg-allocators#41 fixes rust-lang/wg-allocators#44 fixes rust-lang/wg-allocators#51
2020-03-30Add long error code for error E0226Julien Philippon-2/+2
2020-03-28Make fields in `MemoryBlock` publicTim Diekmann-1/+1
2020-03-26Remove alignment from `MemoryBlock`Tim Diekmann-5/+2
2020-03-26Fix issues from review and unsoundness of `RawVec::into_box`Tim Diekmann-4/+7
2020-03-26Overhaul of the `AllocRef` trait to match allocator-wg's latest consensTim Diekmann-7/+7
2020-03-17Update tests for erasing regions in typeckMatthew Jasper-21/+43
2020-03-03Rollup merge of #69609 - TimDiekmann:excess, r=AmanieuYuki Okushi-7/+7
Remove `usable_size` APIs This removes the usable size APIs: - remove `usable_size` (obv) - change return type of allocating methods to include the allocated size - remove `_excess` API r? @Amanieu closes rust-lang/wg-allocators#17
2020-03-03Remove `usable_size` APIsTim Diekmann-7/+7
2020-02-29Rename `syntax` to `rustc_ast` in source codeVadim Petrochenkov-1/+1