about summary refs log tree commit diff
path: root/src/test/ui/async-await
AgeCommit message (Collapse)AuthorLines
2020-10-05don't refer to async as 'generators'SNCPlay42-0/+68
and give return of async fn a better span
2020-10-01Auto merge of #77354 - ecstatic-morse:const-checking-moar-errors, r=oli-obkbors-12/+1
Overhaul const-checking diagnostics The primary purpose of this PR was to remove `NonConstOp::STOPS_CONST_CHECKING`, which causes any additional errors found by the const-checker to be silenced. I used this flag to preserve diagnostic parity with `qualify_min_const_fn.rs`, which has since been removed. However, simply removing the flag caused a deluge of errors in some cases, since an error would be emitted any time a local or temporary had a wrong type. To remedy this, I added an alternative system (`DiagnosticImportance`) to silence additional error messages that were likely to distract the user from the underlying issue. When an error of the highest importance occurs, all less important errors are silenced. When no error of the highest importance occurs, all less important errors are emitted after checking is complete. Following the suggestions from the important error is usually enough to fix the less important errors, so this should lead to better UX most of the time. There's also some unrelated diagnostics improvements in this PR isolated in their own commits. Splitting them out would be possible, but a bit of a pain. This isn't as tidy as some of my other PRs, but it should *only* affect diagnostics, never whether or not something passes const-checking. Note that there are a few trivial exceptions to this, like banning `Yield` in all const-contexts, not just `const fn`. As always, meant to be reviewed commit-by-commit. r? `@oli-obk`
2020-09-30Auto merge of #77069 - sexxi-goose:closure_print_2, r=nikomatsakisbors-2/+2
pretty.rs: Update Closure and Generator print More detailed outline: https://github.com/rust-lang/project-rfc-2229/pull/17 Closes: https://github.com/rust-lang/project-rfc-2229/issues/11 r? `@nikomatsakis` cc `@eddyb` `@davidtwco` `@estebank`
2020-09-29`delay_span_bug` if const-checking an `async` functionDylan MacKenzie-12/+1
This errors during AST lowering. Any errors we emit here are just noise.
2020-09-28pretty.rs: Update Closure and Generator printAman Arora-2/+2
Co-authored-by: Dhruv Jauhar <dhruvjhr@gmail.com> Co-authored-by: Logan Mosier <logmosier@gmail.com>
2020-09-26Call `type_of` for opaque types later in compilationMatthew Jasper-1/+1
This ensures that various wf checks have already been done before we typeck item bodies.
2020-09-25Move from {{closure}}#0 syntax to {closure#0} for (def) path componentsmarmeladema-2/+2
2020-09-22Suggest async {} for async || {}Andy Weiss-0/+1
Fixes #76011 This adds support for adding help diagnostics to the feature gating checks and then uses it for the async_closure gate to add the extra bit of help information as described in the issue.
2020-09-02pretty: trim paths of unique symbolsDan Aloni-119/+118
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-27Auto merge of #72784 - csmoe:issue-61076, r=estebankbors-4/+95
Await on mismatched future types Closes #61076 This PR suggests to `await` on: 1. `async_fn().bar() => async_fn().await.bar()` 2. `async_fn().field => async_fn().await.field` 3. ` if let x = async() {} => if let x = async().await {}` r? @tmandry @estebank
2020-08-26suggest await on unexpected typescsmoe-11/+40
2020-08-25Auto merge of #75302 - Aaron1011:feature/partial-move-diag, r=estebankbors-4/+4
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-25suggest await before methodcsmoe-6/+21
2020-08-25suggest await on field accesscsmoe-40/+33
2020-08-25append more test cases for issue 61076csmoe-4/+58
2020-08-22Use smaller def span for functionsAaron Hill-16/+4
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-08Be consistent when describing a move as a 'partial' in diagnosticsAaron Hill-4/+4
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-04tweak error messageBastian Kauschke-3/+3
2020-07-27mv std libs to library/mark-1/+1
2020-07-22Further tweak wording of E0759 and introduce E0767Esteban Küber-2/+2
2020-07-14Remove redundant explanatory `note` for type parametersEsteban Küber-1/+0
2020-07-14Suggest borrowing in more unsized fn param casesEsteban Küber-1/+4
2020-07-14Remove `Sized` `on_unimplemented` noteEsteban Küber-1/+0
2020-07-01Rollup merge of #73345 - petrochenkov:nointerp, r=Aaron1011Manish Goregaokar-3/+3
expand: Stop using nonterminals for passing tokens to attribute and derive macros Make one more step towards fully token-based expansion and fix issues described in https://github.com/rust-lang/rust/issues/72545#issuecomment-640276791. Now `struct S;` is passed to `foo!(struct S;)` and `#[foo] struct S;` in the same way - as a token stream `struct S ;`, rather than a single non-terminal token `NtItem` which is then broken into parts later. The cost is making pretty-printing of token streams less pretty. Some of the pretty-printing regressions will be recovered by keeping jointness with each token, which we will need to do anyway. Unfortunately, this is not exactly the same thing as https://github.com/rust-lang/rust/pull/73102. One more observable effect is how `$crate` is printed in the attribute input. Inside `NtItem` was printed as `crate` or `that_crate`, now as a part of a token stream it's printed as `$crate` (there are good reasons for these differences, see https://github.com/rust-lang/rust/pull/62393 and related PRs). This may break old proc macros (custom derives) written before the main portion of the proc macro API (macros 1.2) was stabilized, those macros did `input.to_string()` and reparsed the result, now that result can contain `$crate` which cannot be reparsed. So, I think we should do this regardless, but we need to run crater first. r? @Aaron1011
2020-07-01Rollup merge of #73806 - Aaron1011:feature/approx-universal-upper, r=estebankManish Goregaokar-0/+28
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-07-01expand: Stop using nonterminals for passing tokens to attribute and derive ↵Vadim Petrochenkov-3/+3
macros
2020-06-28Update testsDylan MacKenzie-12/+2
2020-06-27Use an 'approximate' universal upper bound when reporting region errorsAaron Hill-0/+28
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-25Adds a clearer message for when the async keyword is missing from a functionNell Shamrell-8/+11
Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
2020-06-15Change E0758 to E0759 to avoid conflict with #72912Esteban Küber-2/+2
2020-06-15small tweaksEsteban Küber-5/+1
2020-06-15Register new eror codeEsteban Küber-0/+1
2020-06-15Use note for requirement source spanEsteban Küber-1/+5
2020-06-15review comments: wordingEsteban Küber-1/+1
2020-06-15Tweak wording and add error codeEsteban Küber-3/+3
2020-06-15Reduce verbosity of suggestion message and mention lifetime in labelEsteban Küber-1/+1
2020-06-15Rollup merge of #72598 - Aaron1011:feature/fnmut-capture-span, r=nikomatsakisRalf Jung-0/+41
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-06-12Rollup merge of #73225 - tmandry:issue-73050, r=oli-obkDylan DPC-0/+12
Allow inference regions when relating consts As first noticed by @eddyb, `super_relate_consts` doesn't need to check for inference vars since `eval` does it already (and handles lifetimes correctly by erasing them). Fixes #73050 r? @oli-obk
2020-06-10Allow inference regions when relating constsTyler Mandry-0/+12
Fixes #73050
2020-06-08Add regression test for #73137Dylan MacKenzie-0/+42
Co-authored-by: Aaron1011 <aa1ronham@gmail.com>
2020-06-08Revert #71956Dylan MacKenzie-1/+1
2020-06-05Rollup merge of #72260 - csmoe:issue-69276, r=estebankDylan DPC-2/+3
Spell out `Self` in async function return Closes #69276 r? @tmandry
2020-06-04resolve error code e0760csmoe-2/+2
2020-05-30Tweak wording and spans of `'static` `dyn Trait`/`impl Trait` requirementsEsteban Küber-8/+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-1/+1
Provide a suggestion for `dyn Trait + '_` when possible.
2020-05-26Don't bail out of trait selection when predicate references an errorAaron Hill-0/+50
Fixes #72590 With PR #70551, observing a `ty::Error` guarantees that compilation is going to fail. Therefore, there are no soundness impliciations to continuing on when we encounter a `ty::Error` - we can only affect whether or not additional error messags are emitted. By not bailing out, we avoid incorrectly determining that types are `!Sized` when a type error is present, which allows us to avoid emitting additional spurious error messages. The original comment mentioned this code being shared by coherence - howver, this change resulted in no diagnostic changes in any of the existing tests.
2020-05-25Display information about captured variable in `FnMut` errorAaron Hill-0/+41
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-25Rollup merge of #72450 - csmoe:issue-72442, r=oli-obkDylan DPC-0/+40
Fix ice-#72442 Closes #72442 Closes #72426 r? @oli-obk
2020-05-22bless issue-72442csmoe-1/+16