Rollup merge of #70428 - Centril:move-to-mod, r=petrochenkov

`error_bad_item_kind`: add help text

For example, this adds:
```
    = help: consider moving the `use` import out to a nearby module scope
```
r? @petrochenkov @estebank

Fixes https://github.com/rust-lang/rust/issues/37205.
This commit is contained in:
Dylan DPC 2020-03-26 21:44:06 +01:00 committed by GitHub
commit ef43cdee28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 93 additions and 2 deletions

View file

@ -908,8 +908,10 @@ impl<'a> Parser<'a> {
fn error_bad_item_kind<T>(&self, span: Span, kind: &ItemKind, ctx: &str) -> Option<T> {
let span = self.sess.source_map().guess_head_span(span);
let msg = format!("{} is not supported in {}", kind.descr(), ctx);
self.struct_span_err(span, &msg).emit();
let descr = kind.descr();
self.struct_span_err(span, &format!("{} is not supported in {}", descr, ctx))
.help(&format!("consider moving the {} out to a nearby module scope", descr))
.emit();
None
}