Skip to content

Commit add04de

Browse files
authored
Rollup merge of rust-lang#64226 - alexreg:rush-pr-3, r=centril
Aggregation of cosmetic changes made during work on REPL PRs: libsyntax Factored out from hacking on rustc for work on the REPL. r? @Centril
2 parents 9aaeef0 + 553a56d commit add04de

26 files changed

+528
-515
lines changed

src/libsyntax/ast.rs

+26-26
Original file line numberDiff line numberDiff line change
@@ -413,11 +413,11 @@ impl WherePredicate {
413413
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
414414
pub struct WhereBoundPredicate {
415415
pub span: Span,
416-
/// Any generics from a `for` binding
416+
/// Any generics from a `for` binding.
417417
pub bound_generic_params: Vec<GenericParam>,
418-
/// The type being bounded
418+
/// The type being bounded.
419419
pub bounded_ty: P<Ty>,
420-
/// Trait and lifetime bounds (`Clone+Send+'static`)
420+
/// Trait and lifetime bounds (`Clone + Send + 'static`).
421421
pub bounds: GenericBounds,
422422
}
423423

@@ -495,15 +495,15 @@ pub enum MetaItemKind {
495495
NameValue(Lit),
496496
}
497497

498-
/// A Block (`{ .. }`).
498+
/// A block (`{ .. }`).
499499
///
500500
/// E.g., `{ .. }` as in `fn foo() { .. }`.
501501
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
502502
pub struct Block {
503-
/// Statements in a block
503+
/// The statements in the block.
504504
pub stmts: Vec<Stmt>,
505505
pub id: NodeId,
506-
/// Distinguishes between `unsafe { ... }` and `{ ... }`
506+
/// Distinguishes between `unsafe { ... }` and `{ ... }`.
507507
pub rules: BlockCheckMode,
508508
pub span: Span,
509509
}
@@ -908,11 +908,11 @@ pub enum MacStmtStyle {
908908
/// Local represents a `let` statement, e.g., `let <pat>:<ty> = <expr>;`.
909909
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
910910
pub struct Local {
911+
pub id: NodeId,
911912
pub pat: P<Pat>,
912913
pub ty: Option<P<Ty>>,
913914
/// Initializer expression to set the value, if any.
914915
pub init: Option<P<Expr>>,
915-
pub id: NodeId,
916916
pub span: Span,
917917
pub attrs: ThinVec<Attribute>,
918918
}
@@ -970,7 +970,7 @@ pub struct AnonConst {
970970
pub value: P<Expr>,
971971
}
972972

973-
/// An expression
973+
/// An expression.
974974
#[derive(Clone, RustcEncodable, RustcDecodable)]
975975
pub struct Expr {
976976
pub id: NodeId,
@@ -984,26 +984,26 @@ pub struct Expr {
984984
static_assert_size!(Expr, 96);
985985

986986
impl Expr {
987-
/// Whether this expression would be valid somewhere that expects a value; for example, an `if`
988-
/// condition.
987+
/// Returns `true` if this expression would be valid somewhere that expects a value;
988+
/// for example, an `if` condition.
989989
pub fn returns(&self) -> bool {
990990
if let ExprKind::Block(ref block, _) = self.node {
991991
match block.stmts.last().map(|last_stmt| &last_stmt.node) {
992-
// implicit return
992+
// Implicit return
993993
Some(&StmtKind::Expr(_)) => true,
994994
Some(&StmtKind::Semi(ref expr)) => {
995995
if let ExprKind::Ret(_) = expr.node {
996-
// last statement is explicit return
996+
// Last statement is explicit return.
997997
true
998998
} else {
999999
false
10001000
}
10011001
}
1002-
// This is a block that doesn't end in either an implicit or explicit return
1002+
// This is a block that doesn't end in either an implicit or explicit return.
10031003
_ => false,
10041004
}
10051005
} else {
1006-
// This is not a block, it is a value
1006+
// This is not a block, it is a value.
10071007
true
10081008
}
10091009
}
@@ -2307,57 +2307,57 @@ impl Default for FnHeader {
23072307

23082308
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
23092309
pub enum ItemKind {
2310-
/// An `extern crate` item, with optional *original* crate name if the crate was renamed.
2310+
/// An `extern crate` item, with the optional *original* crate name if the crate was renamed.
23112311
///
23122312
/// E.g., `extern crate foo` or `extern crate foo_bar as foo`.
23132313
ExternCrate(Option<Name>),
2314-
/// A use declaration (`use` or `pub use`) item.
2314+
/// A use declaration item (`use`).
23152315
///
23162316
/// E.g., `use foo;`, `use foo::bar;` or `use foo::bar as FooBar;`.
23172317
Use(P<UseTree>),
2318-
/// A static item (`static` or `pub static`).
2318+
/// A static item (`static`).
23192319
///
23202320
/// E.g., `static FOO: i32 = 42;` or `static FOO: &'static str = "bar";`.
23212321
Static(P<Ty>, Mutability, P<Expr>),
2322-
/// A constant item (`const` or `pub const`).
2322+
/// A constant item (`const`).
23232323
///
23242324
/// E.g., `const FOO: i32 = 42;`.
23252325
Const(P<Ty>, P<Expr>),
2326-
/// A function declaration (`fn` or `pub fn`).
2326+
/// A function declaration (`fn`).
23272327
///
23282328
/// E.g., `fn foo(bar: usize) -> usize { .. }`.
23292329
Fn(P<FnDecl>, FnHeader, Generics, P<Block>),
2330-
/// A module declaration (`mod` or `pub mod`).
2330+
/// A module declaration (`mod`).
23312331
///
23322332
/// E.g., `mod foo;` or `mod foo { .. }`.
23332333
Mod(Mod),
2334-
/// An external module (`extern` or `pub extern`).
2334+
/// An external module (`extern`).
23352335
///
23362336
/// E.g., `extern {}` or `extern "C" {}`.
23372337
ForeignMod(ForeignMod),
23382338
/// Module-level inline assembly (from `global_asm!()`).
23392339
GlobalAsm(P<GlobalAsm>),
2340-
/// A type alias (`type` or `pub type`).
2340+
/// A type alias (`type`).
23412341
///
23422342
/// E.g., `type Foo = Bar<u8>;`.
23432343
TyAlias(P<Ty>, Generics),
23442344
/// An opaque `impl Trait` type alias.
23452345
///
23462346
/// E.g., `type Foo = impl Bar + Boo;`.
23472347
OpaqueTy(GenericBounds, Generics),
2348-
/// An enum definition (`enum` or `pub enum`).
2348+
/// An enum definition (`enum`).
23492349
///
23502350
/// E.g., `enum Foo<A, B> { C<A>, D<B> }`.
23512351
Enum(EnumDef, Generics),
2352-
/// A struct definition (`struct` or `pub struct`).
2352+
/// A struct definition (`struct`).
23532353
///
23542354
/// E.g., `struct Foo<A> { x: A }`.
23552355
Struct(VariantData, Generics),
2356-
/// A union definition (`union` or `pub union`).
2356+
/// A union definition (`union`).
23572357
///
23582358
/// E.g., `union Foo<A, B> { x: A, y: B }`.
23592359
Union(VariantData, Generics),
2360-
/// A Trait declaration (`trait` or `pub trait`).
2360+
/// A trait declaration (`trait`).
23612361
///
23622362
/// E.g., `trait Foo { .. }`, `trait Foo<T> { .. }` or `auto trait Foo {}`.
23632363
Trait(IsAuto, Unsafety, Generics, GenericBounds, Vec<TraitItem>),

src/libsyntax/attr/mod.rs

+22-21
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Functions dealing with attributes and meta items
1+
//! Functions dealing with attributes and meta items.
22
33
mod builtin;
44

@@ -61,15 +61,15 @@ pub fn is_known_lint_tool(m_item: Ident) -> bool {
6161
}
6262

6363
impl NestedMetaItem {
64-
/// Returns the MetaItem if self is a NestedMetaItem::MetaItem.
64+
/// Returns the `MetaItem` if `self` is a `NestedMetaItem::MetaItem`.
6565
pub fn meta_item(&self) -> Option<&MetaItem> {
6666
match *self {
6767
NestedMetaItem::MetaItem(ref item) => Some(item),
6868
_ => None
6969
}
7070
}
7171

72-
/// Returns the Lit if self is a NestedMetaItem::Literal.
72+
/// Returns the `Lit` if `self` is a `NestedMetaItem::Literal`s.
7373
pub fn literal(&self) -> Option<&Lit> {
7474
match *self {
7575
NestedMetaItem::Literal(ref lit) => Some(lit),
@@ -82,21 +82,21 @@ impl NestedMetaItem {
8282
self.meta_item().map_or(false, |meta_item| meta_item.check_name(name))
8383
}
8484

85-
/// For a single-segment meta-item returns its name, otherwise returns `None`.
85+
/// For a single-segment meta item, returns its name; otherwise, returns `None`.
8686
pub fn ident(&self) -> Option<Ident> {
8787
self.meta_item().and_then(|meta_item| meta_item.ident())
8888
}
8989
pub fn name_or_empty(&self) -> Symbol {
9090
self.ident().unwrap_or(Ident::invalid()).name
9191
}
9292

93-
/// Gets the string value if self is a MetaItem and the MetaItem is a
94-
/// MetaItemKind::NameValue variant containing a string, otherwise None.
93+
/// Gets the string value if `self` is a `MetaItem` and the `MetaItem` is a
94+
/// `MetaItemKind::NameValue` variant containing a string, otherwise `None`.
9595
pub fn value_str(&self) -> Option<Symbol> {
9696
self.meta_item().and_then(|meta_item| meta_item.value_str())
9797
}
9898

99-
/// Returns a name and single literal value tuple of the MetaItem.
99+
/// Returns a name and single literal value tuple of the `MetaItem`.
100100
pub fn name_value_literal(&self) -> Option<(Name, &Lit)> {
101101
self.meta_item().and_then(
102102
|meta_item| meta_item.meta_item_list().and_then(
@@ -112,32 +112,32 @@ impl NestedMetaItem {
112112
}))
113113
}
114114

115-
/// Gets a list of inner meta items from a list MetaItem type.
115+
/// Gets a list of inner meta items from a list `MetaItem` type.
116116
pub fn meta_item_list(&self) -> Option<&[NestedMetaItem]> {
117117
self.meta_item().and_then(|meta_item| meta_item.meta_item_list())
118118
}
119119

120-
/// Returns `true` if the variant is MetaItem.
120+
/// Returns `true` if the variant is `MetaItem`.
121121
pub fn is_meta_item(&self) -> bool {
122122
self.meta_item().is_some()
123123
}
124124

125-
/// Returns `true` if the variant is Literal.
125+
/// Returns `true` if the variant is `Literal`.
126126
pub fn is_literal(&self) -> bool {
127127
self.literal().is_some()
128128
}
129129

130-
/// Returns `true` if self is a MetaItem and the meta item is a word.
130+
/// Returns `true` if `self` is a `MetaItem` and the meta item is a word.
131131
pub fn is_word(&self) -> bool {
132132
self.meta_item().map_or(false, |meta_item| meta_item.is_word())
133133
}
134134

135-
/// Returns `true` if self is a MetaItem and the meta item is a ValueString.
135+
/// Returns `true` if `self` is a `MetaItem` and the meta item is a `ValueString`.
136136
pub fn is_value_str(&self) -> bool {
137137
self.value_str().is_some()
138138
}
139139

140-
/// Returns `true` if self is a MetaItem and the meta item is a list.
140+
/// Returns `true` if `self` is a `MetaItem` and the meta item is a list.
141141
pub fn is_meta_item_list(&self) -> bool {
142142
self.meta_item_list().is_some()
143143
}
@@ -156,7 +156,7 @@ impl Attribute {
156156
matches
157157
}
158158

159-
/// For a single-segment attribute returns its name, otherwise returns `None`.
159+
/// For a single-segment attribute, returns its name; otherwise, returns `None`.
160160
pub fn ident(&self) -> Option<Ident> {
161161
if self.path.segments.len() == 1 {
162162
Some(self.path.segments[0].ident)
@@ -187,14 +187,14 @@ impl Attribute {
187187
self.meta_item_list().is_some()
188188
}
189189

190-
/// Indicates if the attribute is a Value String.
190+
/// Indicates if the attribute is a `ValueString`.
191191
pub fn is_value_str(&self) -> bool {
192192
self.value_str().is_some()
193193
}
194194
}
195195

196196
impl MetaItem {
197-
/// For a single-segment meta-item returns its name, otherwise returns `None`.
197+
/// For a single-segment meta item, returns its name; otherwise, returns `None`.
198198
pub fn ident(&self) -> Option<Ident> {
199199
if self.path.segments.len() == 1 {
200200
Some(self.path.segments[0].ident)
@@ -206,8 +206,9 @@ impl MetaItem {
206206
self.ident().unwrap_or(Ident::invalid()).name
207207
}
208208

209-
// #[attribute(name = "value")]
210-
// ^^^^^^^^^^^^^^
209+
// Example:
210+
// #[attribute(name = "value")]
211+
// ^^^^^^^^^^^^^^
211212
pub fn name_value_literal(&self) -> Option<&Lit> {
212213
match &self.node {
213214
MetaItemKind::NameValue(v) => Some(v),
@@ -255,7 +256,7 @@ impl MetaItem {
255256
}
256257

257258
impl Attribute {
258-
/// Extracts the MetaItem from inside this Attribute.
259+
/// Extracts the `MetaItem` from inside this `Attribute`.
259260
pub fn meta(&self) -> Option<MetaItem> {
260261
let mut tokens = self.tokens.trees().peekable();
261262
Some(MetaItem {
@@ -318,8 +319,8 @@ impl Attribute {
318319
})
319320
}
320321

321-
/// Converts self to a normal #[doc="foo"] comment, if it is a
322-
/// comment like `///` or `/** */`. (Returns self unchanged for
322+
/// Converts `self` to a normal `#[doc="foo"]` comment, if it is a
323+
/// comment like `///` or `/** */`. (Returns `self` unchanged for
323324
/// non-sugared doc attributes.)
324325
pub fn with_desugared_doc<T, F>(&self, f: F) -> T where
325326
F: FnOnce(&Attribute) -> T,

src/libsyntax/ext/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ impl<'a> ExtCtxt<'a> {
958958
self.resolver.check_unused_macros();
959959
}
960960

961-
/// Resolve a path mentioned inside Rust code.
961+
/// Resolves a path mentioned inside Rust code.
962962
///
963963
/// This unifies the logic used for resolving `include_X!`, and `#[doc(include)]` file paths.
964964
///

src/libsyntax/feature_gate/active.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
//! List of the active feature gates.
22
3+
use super::{State, Feature};
4+
35
use crate::edition::Edition;
46
use crate::symbol::{Symbol, sym};
7+
58
use syntax_pos::Span;
6-
use super::{State, Feature};
79

810
macro_rules! set {
911
($field: ident) => {{
@@ -37,9 +39,9 @@ macro_rules! declare_features {
3739
/// A set of features to be used by later passes.
3840
#[derive(Clone)]
3941
pub struct Features {
40-
/// `#![feature]` attrs for language features, for error reporting
42+
/// `#![feature]` attrs for language features, for error reporting.
4143
pub declared_lang_features: Vec<(Symbol, Span, Option<Symbol>)>,
42-
/// `#![feature]` attrs for non-language (library) features
44+
/// `#![feature]` attrs for non-language (library) features.
4345
pub declared_lib_features: Vec<(Symbol, Span)>,
4446
$(
4547
$(#[doc = $doc])*
@@ -66,11 +68,11 @@ macro_rules! declare_features {
6668
}
6769

6870
impl Feature {
69-
/// Set this feature in `Features`. Panics if called on a non-active feature.
71+
/// Sets this feature in `Features`. Panics if called on a non-active feature.
7072
pub fn set(&self, features: &mut Features, span: Span) {
7173
match self.state {
7274
State::Active { set } => set(features, span),
73-
_ => panic!("Called `set` on feature `{}` which is not `active`", self.name)
75+
_ => panic!("called `set` on feature `{}` which is not `active`", self.name)
7476
}
7577
}
7678
}
@@ -478,7 +480,7 @@ declare_features! (
478480
(active, precise_pointer_size_matching, "1.32.0", Some(56354), None),
479481

480482
/// Allows relaxing the coherence rules such that
481-
/// `impl<T> ForeignTrait<LocalType> for ForeignType<T> is permitted.
483+
/// `impl<T> ForeignTrait<LocalType> for ForeignType<T>` is permitted.
482484
(active, re_rebalance_coherence, "1.32.0", Some(55437), None),
483485

484486
/// Allows using `#[ffi_returns_twice]` on foreign functions.
@@ -520,7 +522,7 @@ declare_features! (
520522
/// Allows `async || body` closures.
521523
(active, async_closure, "1.37.0", Some(62290), None),
522524

523-
/// Allows the use of `#[cfg(doctest)]`, set when rustdoc is collecting doctests
525+
/// Allows the use of `#[cfg(doctest)]`; set when rustdoc is collecting doctests.
524526
(active, cfg_doctest, "1.37.0", Some(62210), None),
525527

526528
/// Allows `[x; N]` where `x` is a constant (RFC 2203).
@@ -529,7 +531,7 @@ declare_features! (
529531
/// Allows `impl Trait` to be used inside type aliases (RFC 2515).
530532
(active, type_alias_impl_trait, "1.38.0", Some(63063), None),
531533

532-
/// Allows the use of or-patterns, e.g. `0 | 1`.
534+
/// Allows the use of or-patterns (e.g., `0 | 1`).
533535
(active, or_patterns, "1.38.0", Some(54883), None),
534536

535537
// -------------------------------------------------------------------------

src/libsyntax/feature_gate/builtin_attrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ const INTERAL_UNSTABLE: &str = "this is an internal attribute that will never be
169169

170170
pub type BuiltinAttribute = (Symbol, AttributeType, AttributeTemplate, AttributeGate);
171171

172-
/// Attributes that have a special meaning to rustc or rustdoc
172+
/// Attributes that have a special meaning to rustc or rustdoc.
173173
pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
174174
// ==========================================================================
175175
// Stable attributes:

0 commit comments

Comments
 (0)