Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5338f5f

Browse files
committedSep 13, 2022
Auto merge of #101757 - Dylan-DPC:rollup-wkt6oe9, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - #101602 (Streamline `AttrAnnotatedTokenStream`) - #101690 (Avoid `Iterator::last`) - #101700 (A `SubstitutionPart` is not considered a deletion if it replaces nothing with nothing) - #101745 (Fix typo in concat_bytes documentation) - #101748 (rustdoc: remove redundant CSS `#source-sidebar, #sidebar-toggle`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 7098c18 + 1c74d50 commit 5338f5f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+352
-437
lines changed
 

‎compiler/rustc_ast/src/ast.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub use UnsafeSource::*;
2424

2525
use crate::ptr::P;
2626
use crate::token::{self, CommentKind, Delimiter};
27-
use crate::tokenstream::{DelimSpan, LazyTokenStream, TokenStream};
27+
use crate::tokenstream::{DelimSpan, LazyAttrTokenStream, TokenStream};
2828
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
2929
use rustc_data_structures::stack::ensure_sufficient_stack;
3030
use rustc_data_structures::sync::Lrc;
@@ -91,7 +91,7 @@ pub struct Path {
9191
/// The segments in the path: the things separated by `::`.
9292
/// Global paths begin with `kw::PathRoot`.
9393
pub segments: Vec<PathSegment>,
94-
pub tokens: Option<LazyTokenStream>,
94+
pub tokens: Option<LazyAttrTokenStream>,
9595
}
9696

9797
impl PartialEq<Symbol> for Path {
@@ -534,7 +534,7 @@ pub struct Block {
534534
/// Distinguishes between `unsafe { ... }` and `{ ... }`.
535535
pub rules: BlockCheckMode,
536536
pub span: Span,
537-
pub tokens: Option<LazyTokenStream>,
537+
pub tokens: Option<LazyAttrTokenStream>,
538538
/// The following *isn't* a parse error, but will cause multiple errors in following stages.
539539
/// ```compile_fail
540540
/// let x = {
@@ -553,7 +553,7 @@ pub struct Pat {
553553
pub id: NodeId,
554554
pub kind: PatKind,
555555
pub span: Span,
556-
pub tokens: Option<LazyTokenStream>,
556+
pub tokens: Option<LazyAttrTokenStream>,
557557
}
558558

559559
impl Pat {
@@ -937,8 +937,8 @@ impl Stmt {
937937
/// a trailing semicolon.
938938
///
939939
/// This only modifies the parsed AST struct, not the attached
940-
/// `LazyTokenStream`. The parser is responsible for calling
941-
/// `CreateTokenStream::add_trailing_semi` when there is actually
940+
/// `LazyAttrTokenStream`. The parser is responsible for calling
941+
/// `ToAttrTokenStream::add_trailing_semi` when there is actually
942942
/// a semicolon in the tokenstream.
943943
pub fn add_trailing_semicolon(mut self) -> Self {
944944
self.kind = match self.kind {
@@ -984,7 +984,7 @@ pub struct MacCallStmt {
984984
pub mac: P<MacCall>,
985985
pub style: MacStmtStyle,
986986
pub attrs: AttrVec,
987-
pub tokens: Option<LazyTokenStream>,
987+
pub tokens: Option<LazyAttrTokenStream>,
988988
}
989989

990990
#[derive(Clone, Copy, PartialEq, Encodable, Decodable, Debug)]
@@ -1009,7 +1009,7 @@ pub struct Local {
10091009
pub kind: LocalKind,
10101010
pub span: Span,
10111011
pub attrs: AttrVec,
1012-
pub tokens: Option<LazyTokenStream>,
1012+
pub tokens: Option<LazyAttrTokenStream>,
10131013
}
10141014

10151015
#[derive(Clone, Encodable, Decodable, Debug)]
@@ -1108,7 +1108,7 @@ pub struct Expr {
11081108
pub kind: ExprKind,
11091109
pub span: Span,
11101110
pub attrs: AttrVec,
1111-
pub tokens: Option<LazyTokenStream>,
1111+
pub tokens: Option<LazyAttrTokenStream>,
11121112
}
11131113

11141114
impl Expr {
@@ -1967,7 +1967,7 @@ pub struct Ty {
19671967
pub id: NodeId,
19681968
pub kind: TyKind,
19691969
pub span: Span,
1970-
pub tokens: Option<LazyTokenStream>,
1970+
pub tokens: Option<LazyAttrTokenStream>,
19711971
}
19721972

19731973
impl Clone for Ty {
@@ -2532,7 +2532,7 @@ impl<D: Decoder> Decodable<D> for AttrId {
25322532
pub struct AttrItem {
25332533
pub path: Path,
25342534
pub args: MacArgs,
2535-
pub tokens: Option<LazyTokenStream>,
2535+
pub tokens: Option<LazyAttrTokenStream>,
25362536
}
25372537

25382538
/// A list of attributes.
@@ -2552,7 +2552,7 @@ pub struct Attribute {
25522552
#[derive(Clone, Encodable, Decodable, Debug)]
25532553
pub struct NormalAttr {
25542554
pub item: AttrItem,
2555-
pub tokens: Option<LazyTokenStream>,
2555+
pub tokens: Option<LazyAttrTokenStream>,
25562556
}
25572557

25582558
#[derive(Clone, Encodable, Decodable, Debug)]
@@ -2603,7 +2603,7 @@ impl PolyTraitRef {
26032603
pub struct Visibility {
26042604
pub kind: VisibilityKind,
26052605
pub span: Span,
2606-
pub tokens: Option<LazyTokenStream>,
2606+
pub tokens: Option<LazyAttrTokenStream>,
26072607
}
26082608

26092609
#[derive(Clone, Encodable, Decodable, Debug)]
@@ -2689,7 +2689,7 @@ pub struct Item<K = ItemKind> {
26892689
///
26902690
/// Note that the tokens here do not include the outer attributes, but will
26912691
/// include inner attributes.
2692-
pub tokens: Option<LazyTokenStream>,
2692+
pub tokens: Option<LazyAttrTokenStream>,
26932693
}
26942694

26952695
impl Item {

‎compiler/rustc_ast/src/ast_traits.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
use crate::ptr::P;
66
use crate::token::Nonterminal;
7-
use crate::tokenstream::LazyTokenStream;
7+
use crate::tokenstream::LazyAttrTokenStream;
88
use crate::{Arm, Crate, ExprField, FieldDef, GenericParam, Param, PatField, Variant};
99
use crate::{AssocItem, Expr, ForeignItem, Item, NodeId};
1010
use crate::{AttrItem, AttrKind, Block, Pat, Path, Ty, Visibility};
@@ -124,18 +124,18 @@ impl HasSpan for AttrItem {
124124

125125
/// A trait for AST nodes having (or not having) collected tokens.
126126
pub trait HasTokens {
127-
fn tokens(&self) -> Option<&LazyTokenStream>;
128-
fn tokens_mut(&mut self) -> Option<&mut Option<LazyTokenStream>>;
127+
fn tokens(&self) -> Option<&LazyAttrTokenStream>;
128+
fn tokens_mut(&mut self) -> Option<&mut Option<LazyAttrTokenStream>>;
129129
}
130130

131131
macro_rules! impl_has_tokens {
132132
($($T:ty),+ $(,)?) => {
133133
$(
134134
impl HasTokens for $T {
135-
fn tokens(&self) -> Option<&LazyTokenStream> {
135+
fn tokens(&self) -> Option<&LazyAttrTokenStream> {
136136
self.tokens.as_ref()
137137
}
138-
fn tokens_mut(&mut self) -> Option<&mut Option<LazyTokenStream>> {
138+
fn tokens_mut(&mut self) -> Option<&mut Option<LazyAttrTokenStream>> {
139139
Some(&mut self.tokens)
140140
}
141141
}
@@ -147,10 +147,10 @@ macro_rules! impl_has_tokens_none {
147147
($($T:ty),+ $(,)?) => {
148148
$(
149149
impl HasTokens for $T {
150-
fn tokens(&self) -> Option<&LazyTokenStream> {
150+
fn tokens(&self) -> Option<&LazyAttrTokenStream> {
151151
None
152152
}
153-
fn tokens_mut(&mut self) -> Option<&mut Option<LazyTokenStream>> {
153+
fn tokens_mut(&mut self) -> Option<&mut Option<LazyAttrTokenStream>> {
154154
None
155155
}
156156
}
@@ -162,25 +162,25 @@ impl_has_tokens!(AssocItem, AttrItem, Block, Expr, ForeignItem, Item, Pat, Path,
162162
impl_has_tokens_none!(Arm, ExprField, FieldDef, GenericParam, Param, PatField, Variant);
163163

164164
impl<T: AstDeref<Target: HasTokens>> HasTokens for T {
165-
fn tokens(&self) -> Option<&LazyTokenStream> {
165+
fn tokens(&self) -> Option<&LazyAttrTokenStream> {
166166
self.ast_deref().tokens()
167167
}
168-
fn tokens_mut(&mut self) -> Option<&mut Option<LazyTokenStream>> {
168+
fn tokens_mut(&mut self) -> Option<&mut Option<LazyAttrTokenStream>> {
169169
self.ast_deref_mut().tokens_mut()
170170
}
171171
}
172172

173173
impl<T: HasTokens> HasTokens for Option<T> {
174-
fn tokens(&self) -> Option<&LazyTokenStream> {
174+
fn tokens(&self) -> Option<&LazyAttrTokenStream> {
175175
self.as_ref().and_then(|inner| inner.tokens())
176176
}
177-
fn tokens_mut(&mut self) -> Option<&mut Option<LazyTokenStream>> {
177+
fn tokens_mut(&mut self) -> Option<&mut Option<LazyAttrTokenStream>> {
178178
self.as_mut().and_then(|inner| inner.tokens_mut())
179179
}
180180
}
181181

182182
impl HasTokens for StmtKind {
183-
fn tokens(&self) -> Option<&LazyTokenStream> {
183+
fn tokens(&self) -> Option<&LazyAttrTokenStream> {
184184
match self {
185185
StmtKind::Local(local) => local.tokens.as_ref(),
186186
StmtKind::Item(item) => item.tokens(),
@@ -189,7 +189,7 @@ impl HasTokens for StmtKind {
189189
StmtKind::MacCall(mac) => mac.tokens.as_ref(),
190190
}
191191
}
192-
fn tokens_mut(&mut self) -> Option<&mut Option<LazyTokenStream>> {
192+
fn tokens_mut(&mut self) -> Option<&mut Option<LazyAttrTokenStream>> {
193193
match self {
194194
StmtKind::Local(local) => Some(&mut local.tokens),
195195
StmtKind::Item(item) => item.tokens_mut(),
@@ -201,24 +201,24 @@ impl HasTokens for StmtKind {
201201
}
202202

203203
impl HasTokens for Stmt {
204-
fn tokens(&self) -> Option<&LazyTokenStream> {
204+
fn tokens(&self) -> Option<&LazyAttrTokenStream> {
205205
self.kind.tokens()
206206
}
207-
fn tokens_mut(&mut self) -> Option<&mut Option<LazyTokenStream>> {
207+
fn tokens_mut(&mut self) -> Option<&mut Option<LazyAttrTokenStream>> {
208208
self.kind.tokens_mut()
209209
}
210210
}
211211

212212
impl HasTokens for Attribute {
213-
fn tokens(&self) -> Option<&LazyTokenStream> {
213+
fn tokens(&self) -> Option<&LazyAttrTokenStream> {
214214
match &self.kind {
215215
AttrKind::Normal(normal) => normal.tokens.as_ref(),
216216
kind @ AttrKind::DocComment(..) => {
217217
panic!("Called tokens on doc comment attr {:?}", kind)
218218
}
219219
}
220220
}
221-
fn tokens_mut(&mut self) -> Option<&mut Option<LazyTokenStream>> {
221+
fn tokens_mut(&mut self) -> Option<&mut Option<LazyAttrTokenStream>> {
222222
Some(match &mut self.kind {
223223
AttrKind::Normal(normal) => &mut normal.tokens,
224224
kind @ AttrKind::DocComment(..) => {
@@ -229,7 +229,7 @@ impl HasTokens for Attribute {
229229
}
230230

231231
impl HasTokens for Nonterminal {
232-
fn tokens(&self) -> Option<&LazyTokenStream> {
232+
fn tokens(&self) -> Option<&LazyAttrTokenStream> {
233233
match self {
234234
Nonterminal::NtItem(item) => item.tokens(),
235235
Nonterminal::NtStmt(stmt) => stmt.tokens(),
@@ -243,7 +243,7 @@ impl HasTokens for Nonterminal {
243243
Nonterminal::NtIdent(..) | Nonterminal::NtLifetime(..) => None,
244244
}
245245
}
246-
fn tokens_mut(&mut self) -> Option<&mut Option<LazyTokenStream>> {
246+
fn tokens_mut(&mut self) -> Option<&mut Option<LazyAttrTokenStream>> {
247247
match self {
248248
Nonterminal::NtItem(item) => item.tokens_mut(),
249249
Nonterminal::NtStmt(stmt) => stmt.tokens_mut(),

0 commit comments

Comments
 (0)
Please sign in to comment.