Commit Graph

310 Commits

Author SHA1 Message Date
Aleksey Kladov
28ce23fe8b simplify and avoid allocation 2019-04-23 00:05:06 +03:00
Aleksey Kladov
c29a98e40d remove obsolete and incorrect comment 2019-04-23 00:03:57 +03:00
bors
4530c528ba Auto merge of #59700 - matklad:simplify, r=eddyb
Simplify doc comment lexing

is_doc_comment function checks the first four chars, but this is
redundant, `doc_comment` local var has the same info.
2019-04-20 17:59:15 +00:00
Mazdak Farrokhzad
c89bc54d4f Rollup merge of #59128 - oli-obk:colorful_json, r=mark-i-m,eddyb
Emit ansi color codes in the `rendered` field of json diagnostics

cc @ljedrz

Implemented for https://github.com/rust-lang/rust/pull/56595#issuecomment-447645115 (x.py clippy)
2019-04-17 10:31:30 +02:00
Mazdak Farrokhzad
2e7be1ed6c Rollup merge of #59687 - matklad:shebang, r=petrochenkov
cleanup shebang handling in the lexer
2019-04-05 12:46:49 +02:00
Aleksey Kladov
606e0aff81 Simplify doc comment lexing
is_doc_comment function checks the first four chars, but this is
redundant, `doc_comment` local var has the same info.
2019-04-04 19:51:13 +03:00
Aleksey Kladov
fdb8752850 cleanup shebang handling in the lexer 2019-04-04 13:31:53 +03:00
Aleksey Kladov
1763aea7ba make StringReader methods private 2019-04-03 18:33:54 +03:00
Aleksey Kladov
555309d933 make StringReader fields private 2019-04-03 18:20:50 +03:00
Oliver Scherer
0a842e8c7a Update more unit test to new API 2019-04-02 16:14:59 +02:00
Esteban Küber
a8120d660a Tweak incorrect escaped char diagnostic 2019-03-20 11:45:25 -07:00
Vadim Petrochenkov
6ad55b3dec syntax: Introduce Ident::can_be_raw 2019-03-16 23:13:15 +03:00
Mazdak Farrokhzad
ad7b650815 Rollup merge of #58876 - estebank:numeric-lifetime, r=petrochenkov
Parse lifetimes that start with a number and give specific error

Fix #58786.
2019-03-13 03:33:36 +01:00
Esteban Küber
f690821d58 review comments 2019-03-09 11:08:51 -08:00
Esteban Küber
0a505a71d3 Parse lifetimes that start with a number and give specific error 2019-03-08 16:56:31 -08:00
Esteban Küber
bc9b936290 Fix with_emitter callers 2019-03-07 11:15:47 -08:00
Patrick McCarter
c34aac7b17 help suggestion when trying to delimit string literals with directed unicode quotes #58436 2019-02-16 19:56:30 -05:00
Mazdak Farrokhzad
0bc8f6f3f4 Rollup merge of #58273 - taiki-e:rename-dependency, r=matthewjasper
Rename rustc_errors dependency in rust 2018 crates

I think this is a better solution than `use rustc_errors as errors` in `lib.rs` and `use crate::errors` in modules.

Related: rust-lang/cargo#5653

cc #58099

r? @Centril
2019-02-13 04:37:04 +01:00
Taiki Endo
c360ba285c Cleanup imports 2019-02-13 00:31:51 +09:00
Taiki Endo
3216c7656a Rename rustc_errors dependency in rust 2018 crates 2019-02-13 00:28:52 +09:00
Alexander Regueiro
c3e182cf43 rustc: doc comments 2019-02-10 23:42:32 +00:00
Esteban Küber
7451cd8dc0 Deduplicate mismatched delimiter errors
Delay unmatched delimiter errors until after the parser has run to
deduplicate them when parsing and attempt recovering intelligently.
2019-02-07 01:41:30 -08:00
Taiki Endo
7bb082d27f libsyntax => 2018 2019-02-07 02:33:01 +09:00
Andy Russell
0897ffc28f remove _with_applicability from suggestion fns 2019-01-26 23:07:55 -05:00
bors
846ea58cd5 Auto merge of #56884 - euclio:codeblock-diagnostics, r=QuietMisdreavus
rustdoc: overhaul code block lexing errors

Fixes #53919.

This PR moves the reporting of code block lexing errors from rendering time to an early pass, so we can use the compiler's error reporting mechanisms. This dramatically improves the diagnostics in this situation: we now de-emphasize the lexing errors as a note under a warning that has a span and suggestion instead of just emitting errors at the top level.

Additionally, this PR generalizes the markdown -> source span calculation function, which should allow other rustdoc warnings to use better spans in the future.

Last, the PR makes sure that the code block is always emitted in the docs, even if it fails to highlight correctly.

Of note:
- The new pass unfortunately adds another pass over the docs to gather the doc blocks for syntax-checking. I wonder if this could be combined with the pass that looks for testable blocks? I'm not familiar with that code, so I don't know how feasible that is.
- `pulldown_cmark` doesn't make it easy to find the spans of the code blocks, so the code that calculates the spans is a little nasty. It works for all the test cases I threw at it, but I wouldn't be surprised if an edge case would break it. Should have a thorough review.
- This PR worsens the state of #56885, since those certain fatal lexing errors are now emitted before docs get generated at all.
2019-01-20 19:01:38 +00:00
Yuki Okushi
6e59c64326 Revert change 2019-01-20 14:53:16 +09:00
Yuki Okushi
c502a79fa1 [WIP] Improve error behavior 2019-01-20 04:37:29 +09:00
Yuki Okushi
bde3795d46 Continue cheking 2019-01-18 05:22:00 +09:00
Yuki Okushi
ec8db2a944 Cancel process 2019-01-16 09:28:06 +09:00
Andy Russell
8c93798e9f rustdoc: check code block syntax in early pass 2019-01-14 21:21:21 -05:00
Esteban Küber
d8610b31ec Continue evaluating after parsing incorrect binary literal 2019-01-11 19:56:41 -08:00
Esteban Küber
30961c958d Do not use unicode character in diagnostic help 2018-12-31 10:00:08 -08:00
Esteban Küber
b416f1398f Use structured suggestion for braceless unicode escape squence 2018-12-31 09:44:58 -08:00
Mark Rousskov
2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
Alexander Regueiro
ee89c088b0 Various minor/cosmetic improvements to code 2018-12-07 23:53:34 +00:00
bors
1839c144bc Auto merge of #54517 - mcr431:53956-panic-on-include_bytes-of-own-file, r=michaelwoerister
53956 panic on include bytes of own file

fix #53956

When using `include_bytes!` on a source file in the project, compiler would panic on subsequent compilations because `expand_include_bytes` would overwrite files in the source_map with no source. This PR changes `expand_include_bytes` to check source_map and use the already existing src, if any.
2018-12-06 01:36:51 +00:00
Matthew Russo
f0f8aa9e05 adds DocTest filename variant, refactors doctest_offset out of source_map, fixes remaining test failures 2018-12-04 19:52:42 -05:00
Shotaro Yamada
11af6f66cb Use iterator and pattern APIs instead of char_at 2018-12-04 09:27:24 +09:00
Jason Langenauer
cd20be5091 Update outdated code comments in StringReader 2018-11-26 21:21:17 +01:00
Eric Huss
7f4bc2247a Clean up some non-mod-rs stuff. 2018-11-14 18:55:41 -08:00
bors
6d69fe7a2f Auto merge of #54861 - rep-nop:find_main_in_doctest, r=estebank
rustdoc: Replaces fn main search and extern crate search with proper parsing during doctests.

Fixes #21299.
Fixes #33731.

Let me know if there's any additional changes you'd like made!
2018-11-04 01:43:40 +00:00
QuietMisdreavus
0fe6aae49a buffer errors from initial tokenization when parsing 2018-11-01 11:57:29 -05:00
David Lavati
6c9f6a1afd Rename other occs of (Code/File)Map to Source(Map/File) #51574 2018-10-29 21:26:13 +01:00
Guillaume Gomez
322e46916e Add a sentence before rustc errors 2018-09-29 18:34:49 +02:00
Guillaume Gomez
f7240e1c74 Improve error display for codeblocks in rustdoc 2018-09-29 18:14:34 +02:00
Esteban Küber
014a56ca9c Don't compute padding of braces unless they are unmatched 2018-09-09 14:55:46 -07:00
Esteban Küber
008aa5a24e Provide more context for unenclosed delimiters
* When encountering EOF, point at the last opening brace that does not
   have the same indentation level as its close delimiter.
 * When encountering the wrong type of close delimiter, point at the
   likely correct open delimiter to give a better idea of what went
   wrong.
2018-09-05 03:43:24 -07:00
Eduard-Mihai Burtescu
93f3f5b155 Use FxHash{Map,Set} instead of the default Hash{Map,Set} everywhere in rustc. 2018-08-28 17:04:04 +03:00
Donato Sciarra
6138c82803 fix tidy errors 2018-08-19 23:01:01 +02:00
Donato Sciarra
062bfbf39b mv codemap source_map 2018-08-19 23:01:01 +02:00