]> git.lizzy.rs Git - rust.git/commit - src/tools/rustfmt
Rollup merge of #79851 - camelid:better-error-for-default-fn, r=davidtwco
authorTyler Mandry <tmandry@gmail.com>
Fri, 11 Dec 2020 05:33:10 +0000 (21:33 -0800)
committerGitHub <noreply@github.com>
Fri, 11 Dec 2020 05:33:10 +0000 (21:33 -0800)
commitdc90573454775538702f27dedd458f7c7eb31124
tree381b4a228867b29f76db1f76aa23b34d1cc23d97
parent17ec4b8258b3f59ded7b2cfae8484be976c658af
parent4e21942ba4d435c3211677ad42ddc528fff97857
Rollup merge of #79851 - camelid:better-error-for-default-fn, r=davidtwco

Clarify the 'default is only allowed on...' error

Code like

    impl Foo {
        default fn foo() {}
    }

will trigger the error

    error: `default` is only allowed on items in `impl` definitions
     --> src/lib.rs:5:5
      |
    5 |     default fn foo() {}
      |     -------^^^^^^^^^
      |     |
      |     `default` because of this

but that's very confusing! I *did* put it on an item in an impl!

So this commit changes the message to

    error: `default` is only allowed on items in trait impls
     --> src/lib.rs:5:5
      |
    5 |     default fn foo() {}
      |     -------^^^^^^^^^
      |     |
      |     `default` because of this