Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
fed12fa
Remove mentions of removed `offset_to` method
phil-opp Jun 19, 2019
c9c73f5
Refer to `add` method instead of `offset`
phil-opp Jul 17, 2019
3dca17e
Disallow duplicate lifetime parameters with legacy hygiene
matthewjasper Jul 28, 2019
8876b3b
Resolve const parameters with modern hygiene
matthewjasper Jul 28, 2019
dfad725
Recover 'for ( $pat in $expr ) $block'.
Centril Jul 24, 2019
1b11860
Use chaining for diagnosics in parser.
Centril Jul 24, 2019
56b39fb
Add 'span_to_snippet' shortcut.
Centril Jul 24, 2019
18bf9dd
Properly check the defining scope of existential types
Aaron1011 Jul 28, 2019
8811b9c
Fix formatting
Aaron1011 Jul 28, 2019
3e98c3a
Rename test and add comment
Aaron1011 Jul 28, 2019
e2ee2a3
Move ui/{existential-type -> existential_types}.
Centril Jul 29, 2019
b2a5d99
Move ui/existential_type.rs -> ui/existential_type/existential_type-p…
Centril Jul 29, 2019
b779f45
Add test for #53678.
Centril Jul 29, 2019
1e927d8
Add test for #60407.
Centril Jul 29, 2019
a54dd23
Add test for #60564.
Centril Jul 29, 2019
0cdd693
vxworks: Remove Linux-specific comments.
josephlr Jul 29, 2019
60680d4
ci: Skip installing SWIG/xz on OSX
alexcrichton Jul 29, 2019
c56d8a8
Add links to None in Option doc
tesuji Jul 29, 2019
624c5da
impl Debug for Chars
max-sixty Jul 26, 2019
3325ff6
comments from @lzutao
max-sixty Jul 29, 2019
8d7fb87
std: Fix a failing `fs` test on Windows
alexcrichton Jul 29, 2019
870efe3
Add very simple edition check to tidy; and add missing edition = 2018s.
crlf0710 Jul 28, 2019
15bc63e
Add syntactic test for rest patterns.
Centril Jul 29, 2019
0fb9295
Add another test for const parameter (non) hygiene.
matthewjasper Jul 29, 2019
6c7613b
Add semantic test for rest patterns.
Centril Jul 29, 2019
b5bea25
Rollup merge of #61965 - phil-opp:patch-4, r=scottmcm
Centril Jul 30, 2019
3602987
Rollup merge of #62928 - Centril:recover-parens-around-for-head, r=es…
Centril Jul 30, 2019
51e50ed
Rollup merge of #63000 - max-sixty:chars-display, r=alexcrichton
Centril Jul 30, 2019
652f13d
Rollup merge of #63083 - matthewjasper:parameter-hygiene, r=petrochenkov
Centril Jul 30, 2019
4413068
Rollup merge of #63087 - crlf0710:tidy_2018, r=Mark-Simulacrum
Centril Jul 30, 2019
f3750e3
Rollup merge of #63093 - Aaron1011:fix/existential-closure, r=cramertj
Centril Jul 30, 2019
09eb0b1
Rollup merge of #63096 - Centril:existential-type-add-tests, r=varkor
Centril Jul 30, 2019
cc4a8d7
Rollup merge of #63099 - josephlr:vxworks, r=alexcrichton
Centril Jul 30, 2019
3ef6f6d
Rollup merge of #63106 - alexcrichton:remove-swig-osx, r=pietroalbini
Centril Jul 30, 2019
a03caec
Rollup merge of #63108 - lzutao:option-xor-typo, r=jonas-schievink
Centril Jul 30, 2019
2becb62
Rollup merge of #63109 - alexcrichton:disable-windows-fs-test, r=sfac…
Centril Jul 30, 2019
91c10f8
Rollup merge of #63111 - Centril:rest-pat-tests, r=estebank
Centril Jul 30, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add 'span_to_snippet' shortcut.
  • Loading branch information
Centril committed Jul 28, 2019
commit 56b39fba563a7ae5ca39eae80b9e26e9890522cf
12 changes: 6 additions & 6 deletions src/libsyntax/parse/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::ThinVec;
use crate::util::parser::AssocOp;
use errors::{Applicability, DiagnosticBuilder, DiagnosticId};
use rustc_data_structures::fx::FxHashSet;
use syntax_pos::{Span, DUMMY_SP, MultiSpan};
use syntax_pos::{Span, DUMMY_SP, MultiSpan, SpanSnippetError};
use log::{debug, trace};
use std::mem;

Expand Down Expand Up @@ -199,6 +199,10 @@ impl<'a> Parser<'a> {
&self.sess.span_diagnostic
}

crate fn span_to_snippet(&self, span: Span) -> Result<String, SpanSnippetError> {
self.sess.source_map().span_to_snippet(span)
}

crate fn expected_ident_found(&self) -> DiagnosticBuilder<'a> {
let mut err = self.struct_span_err(
self.token.span,
Expand Down Expand Up @@ -719,8 +723,6 @@ impl<'a> Parser<'a> {
path.span = ty_span.to(self.prev_span);

let ty_str = self
.sess
.source_map()
.span_to_snippet(ty_span)
.unwrap_or_else(|_| pprust::ty_to_string(&ty));
self.diagnostic()
Expand Down Expand Up @@ -891,7 +893,7 @@ impl<'a> Parser<'a> {
err.span_label(await_sp, "while parsing this incorrect await expression");
err
})?;
let expr_str = self.sess.source_map().span_to_snippet(expr.span)
let expr_str = self.span_to_snippet(expr.span)
.unwrap_or_else(|_| pprust::expr_to_string(&expr));
let suggestion = format!("{}.await{}", expr_str, if is_question { "?" } else { "" });
let sp = lo.to(expr.span);
Expand Down Expand Up @@ -940,8 +942,6 @@ impl<'a> Parser<'a> {
self.bump();

let pat_str = self
.sess
.source_map()
// Remove the `(` from the span of the pattern:
.span_to_snippet(pat.span.trim_start(begin_par_sp).unwrap())
.unwrap_or_else(|_| pprust::pat_to_string(&pat));
Expand Down
17 changes: 7 additions & 10 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3071,10 +3071,7 @@ impl<'a> Parser<'a> {
id: ast::DUMMY_NODE_ID
}));

let expr_str = self
.sess
.source_map()
.span_to_snippet(expr.span)
let expr_str = self.span_to_snippet(expr.span)
.unwrap_or_else(|_| pprust::expr_to_string(&expr));

self.struct_span_err(self.token.span, &msg)
Expand Down Expand Up @@ -3796,7 +3793,7 @@ impl<'a> Parser<'a> {
let seq_span = pat.span.to(self.prev_span);
let mut err = self.struct_span_err(comma_span,
"unexpected `,` in pattern");
if let Ok(seq_snippet) = self.sess.source_map().span_to_snippet(seq_span) {
if let Ok(seq_snippet) = self.span_to_snippet(seq_span) {
err.span_suggestion(
seq_span,
"try adding parentheses to match on a tuple..",
Expand Down Expand Up @@ -4145,7 +4142,7 @@ impl<'a> Parser<'a> {
let parser_snapshot_after_type = self.clone();
mem::replace(self, parser_snapshot_before_type);

let snippet = self.sess.source_map().span_to_snippet(pat.span).unwrap();
let snippet = self.span_to_snippet(pat.span).unwrap();
err.span_label(pat.span, format!("while parsing the type for `{}`", snippet));
(Some((parser_snapshot_after_type, colon_sp, err)), None)
}
Expand Down Expand Up @@ -4565,7 +4562,7 @@ impl<'a> Parser<'a> {
if self.eat(&token::Semi) {
stmt_span = stmt_span.with_hi(self.prev_span.hi());
}
if let Ok(snippet) = self.sess.source_map().span_to_snippet(stmt_span) {
if let Ok(snippet) = self.span_to_snippet(stmt_span) {
e.span_suggestion(
stmt_span,
"try placing this code inside a block",
Expand Down Expand Up @@ -4738,7 +4735,7 @@ impl<'a> Parser<'a> {
lo.to(self.prev_span),
"parenthesized lifetime bounds are not supported"
);
if let Ok(snippet) = self.sess.source_map().span_to_snippet(inner_span) {
if let Ok(snippet) = self.span_to_snippet(inner_span) {
err.span_suggestion_short(
lo.to(self.prev_span),
"remove the parentheses",
Expand Down Expand Up @@ -4796,7 +4793,7 @@ impl<'a> Parser<'a> {
let mut new_bound_list = String::new();
if !bounds.is_empty() {
let mut snippets = bounds.iter().map(|bound| bound.span())
.map(|span| self.sess.source_map().span_to_snippet(span));
.map(|span| self.span_to_snippet(span));
while let Some(Ok(snippet)) = snippets.next() {
new_bound_list.push_str(" + ");
new_bound_list.push_str(&snippet);
Expand Down Expand Up @@ -7415,7 +7412,7 @@ impl<'a> Parser<'a> {
sp, &suggestion, format!(" {} ", kw), Applicability::MachineApplicable
);
} else {
if let Ok(snippet) = self.sess.source_map().span_to_snippet(ident_sp) {
if let Ok(snippet) = self.span_to_snippet(ident_sp) {
err.span_suggestion(
full_sp,
"if you meant to call a macro, try",
Expand Down