214 Commits

Author SHA1 Message Date
AnthonyMikh
515262cc13
Ascript type explicitly 2019-10-01 02:53:44 +03:00
AnthonyMikh
61bc38ecaa
Fix errors 2019-10-01 02:38:35 +03:00
AnthonyMikh
e5db5b34d7
(fmt) remove trailing whitespaces 2019-10-01 02:30:52 +03:00
AnthonyMikh
bb442881fc
Use pattern matching instead of indexing tuples 2019-10-01 01:12:36 +03:00
AnthonyMikh
55b54285c8
Simplify a conditional in collect_annotations
Also avoid excessive cloning
2019-10-01 01:08:51 +03:00
AnthonyMikh
9d73176978
Remove redundant .iter_mut() 2019-10-01 00:10:23 +03:00
AnthonyMikh
7a807c5b14
Simplify EmitterWriter::emit_suggestion_default
Make function return early if source map is not present
2019-10-01 00:01:22 +03:00
AnthonyMikh
21724eda05
Update doc comment for style_or_override 2019-09-30 23:50:58 +03:00
AnthonyMikh
7b4c5c62aa
Simplify EmitterWriter::get_max_line_num 2019-09-30 23:47:51 +03:00
AnthonyMikh
6b6a79b190
Simplify EmitterWriter::get_multispan_max_line_num 2019-09-30 23:43:24 +03:00
AnthonyMikh
7dc953b493
Simplify code for special case of annotation 2019-09-30 23:33:17 +03:00
AnthonyMikh
75a7c27a54
Revert "Simplify Unicode-aware trimming"
`taken` is actually used afterwards
2019-09-27 00:58:18 +03:00
AnthonyMikh
7a0725fdaf
Simplify style_or_override 2019-09-26 00:42:55 +03:00
AnthonyMikh
ea32862503
Use sort_by_key rather than sort_by 2019-09-26 00:38:36 +03:00
AnthonyMikh
f93827f9e4
Simplify Emitter::fix_multispan_in_std_macros
1. Rewrite `if let` into `match` to return earl and avoid indenting giant block 
2. Assign `spans_updated` only once
2019-09-26 00:31:16 +03:00
AnthonyMikh
9b447e2f9f
Unify order of variables in chained comparison 2019-09-25 23:46:33 +03:00
AnthonyMikh
aef169b4e6
Use Option::map_or where applicable 2019-09-25 23:41:27 +03:00
AnthonyMikh
d6327e8f12
Use map + sum instead of fold for computing Unicode width 2019-09-25 23:23:19 +03:00
AnthonyMikh
4fc5650d17
Simplify Unicode-aware trimming 2019-09-25 23:13:19 +03:00
AnthonyMikh
e9a93be53a
Use max instead of ifs 2019-09-25 23:08:09 +03:00
AnthonyMikh
2cb460e625
Use saturating_sub where applicable 2019-09-25 22:55:04 +03:00
hman523
a6da0e921b changed a line from an if else to std::cmp::max 2019-09-23 19:51:15 -05:00
hman523
fa2cfaf064 Fixed issue from #64447 2019-09-23 18:20:21 -05:00
bors
66bf391c3a Auto merge of #64272 - Mark-Simulacrum:parallel-handler, r=estebank
Refactor librustc_errors::Handler API

This should be reviewed by-commit.

The last commit moves all fields into an inner struct behind a single lock; this is done to prevent possible deadlocks in a multi-threaded compiler, as well as inconsistent state observation.
2019-09-23 06:38:23 +00:00
Tyler Mandry
ffee7bbf9a
Rollup merge of #64429 - afnanenayet:afnan/fix-failure-note-json-level, r=Mark-Simulacrum
Fix failure note `to_str` implementation

Serialize the level to something a little more useful for a failure note struct. This fixes #60425.
2019-09-17 14:10:48 -07:00
Mark Rousskov
cdd805506e Replace DiagnosticBuilder with Diagnostic when emitting error 2019-09-17 09:29:46 -04:00
Afnan Enayet
02c1b892c1
Fix failure note to_str implementation
* Serialize the level to something a little more useful for a failure note
  struct
* Update tests accordingly
2019-09-16 22:30:59 -07:00
Nicholas Nethercote
2fcd870711 Box DiagnosticBuilder.
It's a large type -- 176 bytes on 64-bit. And it's passed around and
returned from a lot of functions, including within PResult.

This commit boxes it, which reduces memory traffic. In particular,
`PResult` shrinks to 16 bytes in the best case; this reduces instruction
counts by up to 2% on various workloads.
2019-09-12 08:29:17 +10:00
Philipp Hansch
159d249705
annotate-snippet emitter: Deal with multispans from macros, too
This moves the two methods from the `EmitterWriter` impl to trait
default methods in the `Emitter` trait so that they can be re-used by
the `AnnotateSnippetEmitterWriter`.

Closes #61810
2019-09-05 21:31:12 +02:00
Mazdak Farrokhzad
586aeb4c9d
Rollup merge of #64058 - phansch:refactor_out_method, r=estebank
librustc_errors: Extract sugg/subst handling into method

An initial refactoring before working on #61809.

This moves the whole block into a method so that it can be reused in the
annotate-snippet emitter. The method is already used in the new emitter, but
there's no UI tests with suggestions included in this PR.

A first look at some UI tests with suggestions showed that there's some
more work to do in [annotate-snippet-rs][annotate-snippet-rs] before the new output is closer to the
current one, so I opted to do that in a second step.

r? @estebank

[annotate-snippet-rs]: https://github.com/rust-lang/annotate-snippets-rs
2019-09-03 14:27:01 +02:00
Philipp Hansch
84ccbe2076
librustc_errors: Extract sugg/subst handling into method
An initial refactoring before working on #61809.

This moves the whole block into a method so that it can be reused in the
annotate-snippet output. It's already used in the new emitter, but
there's no UI tests with suggestions included in this PR.

A first look at some UI tests with suggestions showed that there's some
more work to do in [annotate-snippet-rs][annotate-snippet-rs] before the
new output is closer to the current one.
2019-09-01 13:05:47 +02:00
Esteban Küber
84567190e0 Use saturating_sub 2019-08-31 13:42:53 -07:00
Esteban Küber
bf90154410 Tweak terminal width trimming
Properly account for left margin when setting terminal width through
CLI flag and don't trim code by default if we can't get the terminal's
dimensions.
2019-08-30 19:47:21 -07:00
Esteban Küber
78f62c6190 Account for rounding errors when deciding the diagnostic boundaries 2019-08-30 17:45:34 -07:00
Esteban Küber
21f2e93345 Add terminal_width debugging flag 2019-08-21 11:58:24 -07:00
Esteban Küber
9980796d6d Further unicode checks 2019-08-21 11:56:20 -07:00
Esteban Küber
de2e9fe2c4 Center trim on the span labels and handle unicode 2019-08-21 11:56:20 -07:00
Esteban Küber
45a6be5458 Fix tidy 2019-08-21 11:56:20 -07:00
Esteban Küber
f08b036cc7 Introduce term-size dependency and consider term width when trimming 2019-08-21 11:56:20 -07:00
Esteban Küber
266b878334 clean up 2019-08-21 11:52:38 -07:00
Esteban Küber
0e668e0496 Strip code to the left and right in diagnostics for long lines 2019-08-21 11:52:38 -07:00
Vadim Petrochenkov
3eafaae510 syntax: Make def-site span mandatory in ExpnInfo/MacroBacktrace/DiagnosticSpanMacroExpansion
We have to deal with dummy spans anyway

Remove def-site span from expander interfaces.
It's not used by the expansion infra, only by specific expanders, which can keep it themselves if they want it.
2019-07-11 00:12:07 +03:00
Jeremy Stucki
ec711767a7
Remove needless lifetimes 2019-07-03 10:01:02 +02:00
Igor Matuszewski
1af1f6277e Fix clippy::print_with_newline 2019-06-26 14:11:58 +02:00
Philipp Hansch
e3516a128e
librustc_errors: Add some more documentation 2019-06-10 11:46:32 +02:00
Philipp Hansch
df076b2d5e
librustc_errors: Rename AnnotateRs -> AnnotateSnippet
The proper name of the library is `annotate-snippet`, not `annotate-rs`,
this commit should get rid of any confusing `AnnotateRs` names.

1. Renames `annotate_rs_emitter.rs` to
   `annotate_snippet_emitter_writer.rs` so that the difference between the
   `Emitter` trait and the implementers is more clear.
2. Renames `AnnotateRsEmitterWriter` to `AnnotateSnippetEmitterWriter`
3. Renames `HumanReadableErrorType::AnnotateRs` to `HumanReadableErrorType::AnnotateSnippet`
2019-06-05 21:43:55 +02:00
Philipp Hansch
3f727aeeb7
Add new diagnostic writer using annotate-snippet library
This adds a new diagnostic writer `AnnotateRsEmitterWriter` that uses
the [`annotate-snippet`][as] library to print out the human readable
diagnostics.

The goal is to eventually switch over to using the library instead of
maintaining our own diagnostics output.

This commit does *not* add all the required features to the new
diagnostics writer. It is only meant as a starting point so that other
people can contribute as well.

[as]: https://github.com/rust-lang/annotate-snippets-rs
2019-06-04 18:46:00 +02:00
Philipp Hansch
96e3fb255b
librustc_errors: Move annotation collection to own impl
Extracted from work on #59346. This moves the annotation collection to
the `FileWithAnnotatedLines` impl to allow re-use in a separate
EmitterWriter.
2019-05-28 08:34:44 +02:00
Mazdak Farrokhzad
a89c62ca2b
Rollup merge of #61073 - phansch:remove_unused_annotation_style, r=matthewjasper
librustc_errors: Remove unused annotation style `OldSchoolNoteText`

I could not find any references to it and the `snippet` module does not
seem to be exported publicly, so I think it can be safely removed.

This was originally removed in 17bd76a51 and I'm not sure why it is still there.
2019-05-23 08:37:19 +02:00
Philipp Hansch
5ed42379e3
librustc_errors: Remove unused annotation style OldSchoolNoteText
I could not find any references to it and the `snippet` module does not
seem to be exported publicly, so I think it can be safely removed.
2019-05-23 08:01:38 +02:00