@@ -7,7 +7,7 @@ use rustc_ast::ast::{self, AttrStyle};
7
7
use rustc_ast:: token:: { self , CommentKind , Delimiter , Token , TokenKind } ;
8
8
use rustc_ast:: tokenstream:: TokenStream ;
9
9
use rustc_ast:: util:: unicode:: contains_text_flow_control_chars;
10
- use rustc_errors:: { error_code, Applicability , DiagCtxt , Diagnostic , StashKey } ;
10
+ use rustc_errors:: { error_code, Applicability , DiagCtxt , DiagnosticBuilder , StashKey } ;
11
11
use rustc_lexer:: unescape:: { self , EscapeError , Mode } ;
12
12
use rustc_lexer:: { Base , DocStyle , RawStrError } ;
13
13
use rustc_lexer:: { Cursor , LiteralKind } ;
@@ -42,12 +42,12 @@ pub struct UnmatchedDelim {
42
42
pub candidate_span : Option < Span > ,
43
43
}
44
44
45
- pub ( crate ) fn parse_token_trees < ' a > (
46
- sess : & ' a ParseSess ,
47
- mut src : & ' a str ,
45
+ pub ( crate ) fn parse_token_trees < ' sess , ' src > (
46
+ sess : & ' sess ParseSess ,
47
+ mut src : & ' src str ,
48
48
mut start_pos : BytePos ,
49
49
override_span : Option < Span > ,
50
- ) -> Result < TokenStream , Vec < Diagnostic > > {
50
+ ) -> Result < TokenStream , Vec < DiagnosticBuilder < ' sess > > > {
51
51
// Skip `#!`, if present.
52
52
if let Some ( shebang_len) = rustc_lexer:: strip_shebang ( src) {
53
53
src = & src[ shebang_len..] ;
@@ -76,39 +76,39 @@ pub(crate) fn parse_token_trees<'a>(
76
76
let mut buffer = Vec :: with_capacity ( 1 ) ;
77
77
for unmatched in unmatched_delims {
78
78
if let Some ( err) = make_unclosed_delims_error ( unmatched, sess) {
79
- err . buffer ( & mut buffer ) ;
79
+ buffer. push ( err ) ;
80
80
}
81
81
}
82
82
if let Err ( errs) = res {
83
83
// Add unclosing delimiter or diff marker errors
84
84
for err in errs {
85
- err . buffer ( & mut buffer ) ;
85
+ buffer. push ( err ) ;
86
86
}
87
87
}
88
88
Err ( buffer)
89
89
}
90
90
}
91
91
}
92
92
93
- struct StringReader < ' a > {
94
- sess : & ' a ParseSess ,
93
+ struct StringReader < ' sess , ' src > {
94
+ sess : & ' sess ParseSess ,
95
95
/// Initial position, read-only.
96
96
start_pos : BytePos ,
97
97
/// The absolute offset within the source_map of the current character.
98
98
pos : BytePos ,
99
99
/// Source text to tokenize.
100
- src : & ' a str ,
100
+ src : & ' src str ,
101
101
/// Cursor for getting lexer tokens.
102
- cursor : Cursor < ' a > ,
102
+ cursor : Cursor < ' src > ,
103
103
override_span : Option < Span > ,
104
104
/// When a "unknown start of token: \u{a0}" has already been emitted earlier
105
105
/// in this file, it's safe to treat further occurrences of the non-breaking
106
106
/// space character as whitespace.
107
107
nbsp_is_whitespace : bool ,
108
108
}
109
109
110
- impl < ' a > StringReader < ' a > {
111
- pub fn dcx ( & self ) -> & ' a DiagCtxt {
110
+ impl < ' sess , ' src > StringReader < ' sess , ' src > {
111
+ pub fn dcx ( & self ) -> & ' sess DiagCtxt {
112
112
& self . sess . dcx
113
113
}
114
114
@@ -526,7 +526,7 @@ impl<'a> StringReader<'a> {
526
526
527
527
/// Slice of the source text from `start` up to but excluding `self.pos`,
528
528
/// meaning the slice does not include the character `self.ch`.
529
- fn str_from ( & self , start : BytePos ) -> & ' a str {
529
+ fn str_from ( & self , start : BytePos ) -> & ' src str {
530
530
self . str_from_to ( start, self . pos )
531
531
}
532
532
@@ -537,12 +537,12 @@ impl<'a> StringReader<'a> {
537
537
}
538
538
539
539
/// Slice of the source text spanning from `start` up to but excluding `end`.
540
- fn str_from_to ( & self , start : BytePos , end : BytePos ) -> & ' a str {
540
+ fn str_from_to ( & self , start : BytePos , end : BytePos ) -> & ' src str {
541
541
& self . src [ self . src_index ( start) ..self . src_index ( end) ]
542
542
}
543
543
544
544
/// Slice of the source text spanning from `start` until the end
545
- fn str_from_to_end ( & self , start : BytePos ) -> & ' a str {
545
+ fn str_from_to_end ( & self , start : BytePos ) -> & ' src str {
546
546
& self . src [ self . src_index ( start) ..]
547
547
}
548
548
0 commit comments