Skip to content

Commit 553a56d

Browse files
author
Alexander Regueiro
committed
Apply suggestions from code review
1 parent 49d2fd1 commit 553a56d

File tree

7 files changed

+17
-18
lines changed

7 files changed

+17
-18
lines changed

src/libsyntax/parse/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ impl<'a> Parser<'a> {
10861086
/// statement. This is something of a best-effort heuristic.
10871087
///
10881088
/// We terminate when we find an unmatched `}` (without consuming it).
1089-
pub fn recover_stmt(&mut self) {
1089+
crate fn recover_stmt(&mut self) {
10901090
self.recover_stmt_(SemiColonMode::Ignore, BlockMode::Ignore)
10911091
}
10921092

src/libsyntax/parse/lexer/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fn t1() {
3939
let mut string_reader = setup(
4040
&sm,
4141
&sh,
42-
"/* my source file */ fn main() { println!(\"zebra\"); }\n".to_owned(),
42+
"/* my source file */ fn main() { println!(\"zebra\"); }\n".to_string(),
4343
);
4444
assert_eq!(string_reader.next_token(), token::Comment);
4545
assert_eq!(string_reader.next_token(), token::Whitespace);

src/libsyntax/parse/parser/expr.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ impl<'a> Parser<'a> {
843843
return self.parse_block_expr(None, lo, BlockCheckMode::Default, attrs);
844844
}
845845
token::BinOp(token::Or) | token::OrOr => {
846-
return self.parse_closure(attrs);
846+
return self.parse_closure_expr(attrs);
847847
}
848848
token::OpenDelim(token::Bracket) => {
849849
self.bump();
@@ -919,7 +919,7 @@ impl<'a> Parser<'a> {
919919
return self.maybe_recover_from_bad_qpath(expr, true);
920920
}
921921
if self.check_keyword(kw::Move) || self.check_keyword(kw::Static) {
922-
return self.parse_closure(attrs);
922+
return self.parse_closure_expr(attrs);
923923
}
924924
if self.eat_keyword(kw::If) {
925925
return self.parse_if_expr(attrs);
@@ -996,7 +996,7 @@ impl<'a> Parser<'a> {
996996
return if self.is_async_block() { // Check for `async {` and `async move {`.
997997
self.parse_async_block(attrs)
998998
} else {
999-
self.parse_closure(attrs)
999+
self.parse_closure_expr(attrs)
10001000
};
10011001
}
10021002
if self.eat_keyword(kw::Return) {
@@ -1097,8 +1097,8 @@ impl<'a> Parser<'a> {
10971097
Ok(self.mk_expr(blk.span, ExprKind::Block(blk, opt_label), attrs))
10981098
}
10991099

1100-
/// Parses a closure (e.g., `move |args| expr`).
1101-
fn parse_closure(&mut self, attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> {
1100+
/// Parses a closure expression (e.g., `move |args| expr`).
1101+
fn parse_closure_expr(&mut self, attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> {
11021102
let lo = self.token.span;
11031103

11041104
let movability = if self.eat_keyword(kw::Static) {

src/libsyntax/parse/parser/stmt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ impl<'a> Parser<'a> {
422422
}
423423

424424
/// Parses a statement, including the trailing semicolon.
425-
pub fn parse_full_stmt(&mut self, macro_legacy_warnings: bool) -> PResult<'a, Option<Stmt>> {
425+
crate fn parse_full_stmt(&mut self, macro_legacy_warnings: bool) -> PResult<'a, Option<Stmt>> {
426426
// Skip looking for a trailing semicolon when we have an interpolated statement.
427427
maybe_whole!(self, NtStmt, |x| Some(x));
428428

src/libsyntax/source_map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,8 +479,8 @@ impl SourceMap {
479479
}
480480

481481
pub fn span_to_unmapped_path(&self, sp: Span) -> FileName {
482-
let source_file = self.lookup_char_pos(sp.lo()).file;
483-
source_file.unmapped_path.clone().unwrap_or(source_file.name.clone())
482+
self.lookup_char_pos(sp.lo()).file.unmapped_path.clone()
483+
.expect("`SourceMap::span_to_unmapped_path` called for imported `SourceFile`?")
484484
}
485485

486486
pub fn is_multiline(&self, sp: Span) -> bool {

src/libsyntax/source_map/tests.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ fn t6() {
9797
#[test]
9898
fn t7() {
9999
let sm = init_source_map();
100-
let span = Span::new(BytePos(12), BytePos(23), NO_EXPANSION);
100+
let span = Span::with_root_ctxt(BytePos(12), BytePos(23));
101101
let file_lines = sm.span_to_lines(span).unwrap();
102102

103103
assert_eq!(file_lines.file.name, PathBuf::from("blork.rs").into());
@@ -113,7 +113,7 @@ fn span_from_selection(input: &str, selection: &str) -> Span {
113113
assert_eq!(input.len(), selection.len());
114114
let left_index = selection.find('~').unwrap() as u32;
115115
let right_index = selection.rfind('~').map(|x|x as u32).unwrap_or(left_index);
116-
Span::new(BytePos(left_index), BytePos(right_index + 1), NO_EXPANSION)
116+
Span::with_root_ctxt(BytePos(left_index), BytePos(right_index + 1))
117117
}
118118

119119
/// Tests `span_to_snippet` and `span_to_lines` for a span converting 3
@@ -143,7 +143,7 @@ fn span_to_snippet_and_lines_spanning_multiple_lines() {
143143
#[test]
144144
fn t8() {
145145
let sm = init_source_map();
146-
let span = Span::new(BytePos(12), BytePos(23), NO_EXPANSION);
146+
let span = Span::with_root_ctxt(BytePos(12), BytePos(23));
147147
let snippet = sm.span_to_snippet(span);
148148

149149
assert_eq!(snippet, Ok("second line".to_string()));
@@ -153,7 +153,7 @@ fn t8() {
153153
#[test]
154154
fn t9() {
155155
let sm = init_source_map();
156-
let span = Span::new(BytePos(12), BytePos(23), NO_EXPANSION);
156+
let span = Span::with_root_ctxt(BytePos(12), BytePos(23));
157157
let sstr = sm.span_to_string(span);
158158

159159
assert_eq!(sstr, "blork.rs:2:1: 2:12");
@@ -176,7 +176,7 @@ fn span_merging_fail() {
176176
/// Returns the span corresponding to the `n`th occurrence of `substring` in `source_text`.
177177
trait SourceMapExtension {
178178
fn span_substr(
179-
self,
179+
&self,
180180
file: &Lrc<SourceFile>,
181181
source_text: &str,
182182
substring: &str,
@@ -208,10 +208,9 @@ impl SourceMapExtension for SourceMap {
208208
let lo = hi + offset;
209209
hi = lo + substring.len();
210210
if i == n {
211-
let span = Span::new(
211+
let span = Span::with_root_ctxt(
212212
BytePos(lo as u32 + file.start_pos.0),
213213
BytePos(hi as u32 + file.start_pos.0),
214-
NO_EXPANSION,
215214
);
216215
assert_eq!(&self.span_to_snippet(span).unwrap()[..], substring);
217216
return span;

src/libsyntax/visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,6 @@ pub fn walk_ty<'a, V: Visitor<'a>>(visitor: &mut V, typ: &'a Ty) {
344344
walk_list!(visitor, visit_lifetime, opt_lifetime);
345345
visitor.visit_ty(&mutable_type.ty)
346346
}
347-
TyKind::Never => {}
348347
TyKind::Tup(ref tuple_element_types) => {
349348
walk_list!(visitor, visit_ty, tuple_element_types);
350349
}
@@ -373,6 +372,7 @@ pub fn walk_ty<'a, V: Visitor<'a>>(visitor: &mut V, typ: &'a Ty) {
373372
TyKind::Mac(ref mac) => {
374373
visitor.visit_mac(mac)
375374
}
375+
TyKind::Never |
376376
TyKind::CVarArgs => {}
377377
}
378378
}

0 commit comments

Comments
 (0)