Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Error when trait bound not satisfied for function argument should point at argument #41781

Closed

Description

@jdm
trait T {}

fn function<U: T>(u: U) {}

fn main() {
    function(0u32);
}

This yields:

error[E0277]: the trait bound `u32: T` is not satisfied
 --> <anon>:6:5
  |
6 |     function(0u32);
  |     ^^^^^^^^ the trait `T` is not implemented for `u32`
  |
  = note: required by `function`

error: aborting due to previous error

When there are multiple arguments, this is much less helpful than if the span pointed at the argument in question.

Activity

  1. added
    A-diagnostics
    T-compiler
    on May 6, 2017
  2. added
    C-enhancement
    on Jul 27, 2017
  3. added
    WG-diagnostics
    on Dec 13, 2017
  4. estebank commented on Mar 15, 2018

    @estebank
    Contributor

    Current output:

    error[E0277]: the trait bound `u32: T` is not satisfied
     --> src/main.rs:6:5
      |
    6 |     function(0u32);
      |     ^^^^^^^^ the trait `T` is not implemented for `u32`
      |
    note: required by `function`
     --> src/main.rs:3:1
      |
    3 | fn function<U: T>(u: U) {}
      | ^^^^^^^^^^^^^^^^^^^^^^^
    
  5. added a commit that references this issue on Sep 20, 2019
  6. added a commit that references this issue on Sep 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsC-enhancementT-compilerWG-diagnostics

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions