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:
commit
ef43cdee28
5 changed files with 93 additions and 2 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue