diff options
| author | bors <bors@rust-lang.org> | 2020-01-26 08:36:23 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-01-26 08:36:23 +0000 |
| commit | 3d8778d767f0dde6fe2bc9459f21ead8e124d8cb (patch) | |
| tree | 275bf8e6df726e09789e7143b3ee5e1ecb0baf46 /src/librustc_errors | |
| parent | fe1e81561aa1c0ba5779709d081107ea0bfa08e5 (diff) | |
| parent | 16709f032cfaa0b37a83bc798f0dd4a30d2b2c0c (diff) | |
| download | rust-3d8778d767f0dde6fe2bc9459f21ead8e124d8cb.tar.gz rust-3d8778d767f0dde6fe2bc9459f21ead8e124d8cb.zip | |
Auto merge of #68522 - estebank:impl-trait-sugg-2, r=oli-obk
Further improve `impl Trait`/`dyn Trait` suggestions After reading [_Returning Trait Objects_ by Bryce Fisher-Fleig](https://bryce.fisher-fleig.org/blog/returning-trait-objects/), [I noticed that](https://www.reddit.com/r/rust/comments/esueur/returning_trait_objects/ffczl4k/) #68195 had a few bugs due to not ignoring `ty::Error`. - Account for `ty::Error`. - Account for `if`/`else` and `match` blocks when pointing at return types and referencing their types. - Increase the multiline suggestion output from 6 lines to 20.
Diffstat (limited to 'src/librustc_errors')
| -rw-r--r-- | src/librustc_errors/emitter.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index b0e0cb611af..7218730538a 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -456,9 +456,14 @@ impl Emitter for SilentEmitter { fn emit_diagnostic(&mut self, _: &Diagnostic) {} } -/// maximum number of lines we will print for each error; arbitrary. +/// Maximum number of lines we will print for each error; arbitrary. pub const MAX_HIGHLIGHT_LINES: usize = 6; -/// maximum number of suggestions to be shown +/// Maximum number of lines we will print for a multiline suggestion; arbitrary. +/// +/// This should be replaced with a more involved mechanism to output multiline suggestions that +/// more closely mimmics the regular diagnostic output, where irrelevant code lines are elided. +pub const MAX_SUGGESTION_HIGHLIGHT_LINES: usize = 6; +/// Maximum number of suggestions to be shown /// /// Arbitrary, but taken from trait import suggestion limit pub const MAX_SUGGESTIONS: usize = 4; @@ -1521,7 +1526,7 @@ impl EmitterWriter { draw_col_separator_no_space(&mut buffer, 1, max_line_num_len + 1); let mut line_pos = 0; let mut lines = complete.lines(); - for line in lines.by_ref().take(MAX_HIGHLIGHT_LINES) { + for line in lines.by_ref().take(MAX_SUGGESTION_HIGHLIGHT_LINES) { // Print the span column to avoid confusion buffer.puts( row_num, |
