diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2020-03-26 21:44:06 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-26 21:44:06 +0100 |
| commit | ef43cdee2867a8a50ef9b421e82ae31afd28fe7f (patch) | |
| tree | cd8afb882f517976a1caf94e1c27a69a82f1e519 /src/librustc_parse/parser | |
| parent | c640b95662acf89a0e716cb0b849c29bff55000f (diff) | |
| parent | 91c68c5faed0cf6f61274678d8e1cf8d43f0d4f6 (diff) | |
| download | rust-ef43cdee2867a8a50ef9b421e82ae31afd28fe7f.tar.gz rust-ef43cdee2867a8a50ef9b421e82ae31afd28fe7f.zip | |
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.
Diffstat (limited to 'src/librustc_parse/parser')
| -rw-r--r-- | src/librustc_parse/parser/item.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/librustc_parse/parser/item.rs b/src/librustc_parse/parser/item.rs index cc88464d774..6b7a9ec658d 100644 --- a/src/librustc_parse/parser/item.rs +++ b/src/librustc_parse/parser/item.rs @@ -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 } |
