1. 13 1月, 2021 34 次提交
  2. 12 1月, 2021 6 次提交
    • O
      Coverage computation needs access to the MIR, too · 53e3a235
      oli 提交于
      53e3a235
    • B
      Auto merge of #80517 - wabain:issue-77880-infer-error-try-conversion-msg, r=davidtwco · 497c9a25
      bors 提交于
      Enhance type inference errors involving the `?` operator
      
      This patch adds a special-cased note on type inference errors when the error span points to a `?` return. It also makes the primary label for such errors "cannot infer type of `?` error" in cases where before we would have only said "cannot infer type".
      
      One beneficiary of this change is async blocks, where we can't explicitly annotate the return type and so may not generate any other help (#77880); this lets us at least print the error type we're converting from and anything we know about the type we can't fully infer. More generally, it signposts that an implicit conversion is happening that may have impeded type inference the user was expecting. We already do something similar for [mismatched type errors](https://github.com/rust-lang/rust/blob/2987785df3d46d5ff144a5c67fbb8f5cca798d78/src/test/ui/try-block/try-block-bad-type.stderr#L7).
      
      The check for a relevant `?` operator is built into the existing HIR traversal which looks for places that could be annotated to resolve the error. That means we could identify `?` uses anywhere in the function that output the type we can't infer, but this patch just sticks to adding the note if the primary span given for the error has the operator; if there are other expressions where the type occurs and one of them is selected for the error instead, it's more likely that the `?` operator's implicit conversion isn't the sole cause of the inference failure and that adding an additional diagnostic would just be noise. I added a ui test for one such case.
      
      The data about the `?` conversion is passed around in a `UseDiagnostic` enum that in theory could be used to add more of this kind of note in the future. It was also just easier to pass around than something with a more specific name. There are some follow-up refactoring commits for the code that generates the error label, which was already pretty involved and made a bit more complicated by this change.
      497c9a25
    • B
      Auto merge of #80499 - matthiaskrgr:red_clos, r=estebank · fc9944fe
      bors 提交于
      remove redundant closures (clippy::redundant_closure)
      fc9944fe
    • B
      Auto merge of #80939 - JohnTitor:rollup-pymns4q, r=JohnTitor · b6b46165
      bors 提交于
      Rollup of 8 pull requests
      
      Successful merges:
      
       - #79757 (Replace tabs earlier in diagnostics)
       - #80600 (Add `MaybeUninit` method `array_assume_init`)
       - #80880 (Move some tests to more reasonable directories)
       - #80897 (driver: Use `atty` instead of rolling our own)
       - #80898 (Add another test case for #79808)
       - #80917 (core/slice: remove doc comment about scoped borrow)
       - #80927 (Replace a simple `if let` with the `matches` macro)
       - #80930 (fix typo in trait method mutability mismatch help)
      
      Failed merges:
      
      r? `@ghost`
      `@rustbot` modify labels: rollup
      b6b46165
    • Y
      Rollup merge of #80930 - euclio:trait-method-mutability-help, r=estebank · 139daf56
      Yuki Okushi 提交于
      fix typo in trait method mutability mismatch help
      139daf56
    • Y
      Rollup merge of #80927 - LingMan:matches, r=estebank · 8c342da2
      Yuki Okushi 提交于
      Replace a simple `if let` with the `matches` macro
      
      `@rustbot` modify labels +C-cleanup +T-compiler
      8c342da2