Skip to content

Commit 261eb01

Browse files
committed
Restore the old behavior of the rustdoc keyword check + Fix rebase
1 parent 80f0149 commit 261eb01

File tree

8 files changed

+24
-20
lines changed

8 files changed

+24
-20
lines changed

src/librustc_plugin/load.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::mem;
1111
use std::path::PathBuf;
1212
use syntax::ast;
1313
use syntax::span_err;
14-
use syntax::symbol::{Symbol, keywords, sym};
14+
use syntax::symbol::{Symbol, kw, sym};
1515
use syntax_pos::{Span, DUMMY_SP};
1616

1717
/// Pointer to a registrar function.
@@ -58,7 +58,7 @@ pub fn load_plugins(sess: &Session,
5858
for plugin in plugins {
5959
// plugins must have a name and can't be key = value
6060
let name = plugin.name_or_empty();
61-
if name != keywords::Invalid.name() && !plugin.is_value_str() {
61+
if name != kw::Invalid && !plugin.is_value_str() {
6262
let args = plugin.meta_item_list().map(ToOwned::to_owned);
6363
loader.load_plugin(plugin.span(), name, args.unwrap_or_default());
6464
} else {

src/librustc_resolve/resolve_imports.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
707707
has_errors = true;
708708

709709
if let SingleImport { source, ref source_bindings, .. } = import.subclass {
710-
if source.name == keywords::SelfLower.name() {
710+
if source.name == kw::SelfLower {
711711
// Silence `unresolved import` error if E0429 is already emitted
712712
if let Err(Determined) = source_bindings.value_ns.get() {
713713
continue;

src/librustdoc/html/layout.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub fn render<T: fmt::Display, S: fmt::Display>(
4444
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\
4545
<meta name=\"generator\" content=\"rustdoc\">\
4646
<meta name=\"description\" content=\"{description}\">\
47-
<meta name=\"keywords\" content=\"{kw}\">\
47+
<meta name=\"keywords\" content=\"{keywords}\">\
4848
<title>{title}</title>\
4949
<link rel=\"stylesheet\" type=\"text/css\" href=\"{static_root_path}normalize{suffix}.css\">\
5050
<link rel=\"stylesheet\" type=\"text/css\" href=\"{static_root_path}rustdoc{suffix}.css\" \

src/libsyntax/attr/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use crate::parse::parser::Parser;
2222
use crate::parse::{self, ParseSess, PResult};
2323
use crate::parse::token::{self, Token};
2424
use crate::ptr::P;
25-
use crate::symbol::{kw, Symbol};
25+
use crate::symbol::Symbol;
2626
use crate::ThinVec;
2727
use crate::tokenstream::{TokenStream, TokenTree, DelimSpan};
2828
use crate::GLOBALS;
@@ -206,7 +206,7 @@ impl MetaItem {
206206
}
207207
}
208208
pub fn name_or_empty(&self) -> Symbol {
209-
self.ident().unwrap_or(Ident.invalid()).name
209+
self.ident().unwrap_or(Ident::invalid()).name
210210
}
211211

212212
// #[attribute(name = "value")]

src/libsyntax/ext/tt/macro_rules.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::parse::{Directory, ParseSess};
1313
use crate::parse::parser::Parser;
1414
use crate::parse::token::{self, NtTT};
1515
use crate::parse::token::Token::*;
16-
use crate::symbol::{Symbol, keywords, sym};
16+
use crate::symbol::{Symbol, kw, sym};
1717
use crate::tokenstream::{DelimSpan, TokenStream, TokenTree};
1818

1919
use errors::FatalError;
@@ -1046,8 +1046,8 @@ fn is_in_follow(tok: &quoted::TokenTree, frag: &str) -> IsInFollow {
10461046
match *tok {
10471047
TokenTree::Token(_, ref tok) => match *tok {
10481048
FatArrow | Comma | Eq | BinOp(token::Or) => IsInFollow::Yes,
1049-
Ident(i, false) if i.name == keywords::If.name() ||
1050-
i.name == keywords::In.name() => IsInFollow::Yes,
1049+
Ident(i, false) if i.name == kw::If ||
1050+
i.name == kw::In => IsInFollow::Yes,
10511051
_ => IsInFollow::No(tokens),
10521052
},
10531053
_ => IsInFollow::No(tokens),
@@ -1064,8 +1064,8 @@ fn is_in_follow(tok: &quoted::TokenTree, frag: &str) -> IsInFollow {
10641064
OpenDelim(token::DelimToken::Bracket) |
10651065
Comma | FatArrow | Colon | Eq | Gt | BinOp(token::Shr) | Semi |
10661066
BinOp(token::Or) => IsInFollow::Yes,
1067-
Ident(i, false) if i.name == keywords::As.name() ||
1068-
i.name == keywords::Where.name() => IsInFollow::Yes,
1067+
Ident(i, false) if i.name == kw::As ||
1068+
i.name == kw::Where => IsInFollow::Yes,
10691069
_ => IsInFollow::No(tokens),
10701070
},
10711071
TokenTree::MetaVarDecl(_, _, frag) if frag.name == sym::block =>
@@ -1092,7 +1092,7 @@ fn is_in_follow(tok: &quoted::TokenTree, frag: &str) -> IsInFollow {
10921092
match *tok {
10931093
TokenTree::Token(_, ref tok) => match *tok {
10941094
Comma => IsInFollow::Yes,
1095-
Ident(i, is_raw) if is_raw || i.name != keywords::Priv.name() =>
1095+
Ident(i, is_raw) if is_raw || i.name != kw::Priv =>
10961096
IsInFollow::Yes,
10971097
ref tok => if tok.can_begin_type() {
10981098
IsInFollow::Yes

src/libsyntax/feature_gate.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use crate::source_map::Spanned;
2222
use crate::edition::{ALL_EDITIONS, Edition};
2323
use crate::visit::{self, FnKind, Visitor};
2424
use crate::parse::{token, ParseSess};
25-
use crate::symbol::{Symbol, keywords, sym};
25+
use crate::symbol::{Symbol, kw, sym};
2626
use crate::tokenstream::TokenTree;
2727

2828
use errors::{DiagnosticBuilder, Handler};
@@ -1947,7 +1947,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
19471947
fn visit_item(&mut self, i: &'a ast::Item) {
19481948
match i.node {
19491949
ast::ItemKind::Const(_,_) => {
1950-
if i.ident.name == keywords::Underscore.name() {
1950+
if i.ident.name == kw::Underscore {
19511951
gate_feature_post!(&self, underscore_const_names, i.span,
19521952
"naming constants with `_` is unstable");
19531953
}

src/libsyntax/parse/literal.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ impl LitKind {
4343

4444
Some(match lit {
4545
token::Bool(i) => {
46-
assert!(i == keywords::True.name() || i == keywords::False.name());
47-
LitKind::Bool(i == keywords::True.name())
46+
assert!(i == kw::True || i == kw::False);
47+
LitKind::Bool(i == kw::True)
4848
}
4949
token::Byte(i) => {
5050
match unescape_byte(&i.as_str()) {
@@ -156,8 +156,8 @@ impl LitKind {
156156
}
157157
LitKind::FloatUnsuffixed(symbol) => (token::Lit::Float(symbol), None),
158158
LitKind::Bool(value) => {
159-
let kw = if value { keywords::True } else { keywords::False };
160-
(token::Lit::Bool(kw.name()), None)
159+
let kw = if value { kw::True } else { kw::False };
160+
(token::Lit::Bool(kw), None)
161161
}
162162
LitKind::Err(val) => (token::Lit::Err(val), None),
163163
}
@@ -175,8 +175,7 @@ impl Lit {
175175
diag: Option<(Span, &Handler)>,
176176
) -> Option<Lit> {
177177
let (token, suffix) = match *token {
178-
token::Ident(ident, false) if ident.name == keywords::True.name() ||
179-
ident.name == keywords::False.name() =>
178+
token::Ident(ident, false) if ident.name == kw::True || ident.name == kw::False =>
180179
(token::Bool(ident.name), None),
181180
token::Literal(token, suffix) =>
182181
(token, suffix),

src/libsyntax_pos/symbol.rs

+5
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,11 @@ impl Symbol {
933933
fn is_unused_keyword_2018(self) -> bool {
934934
self >= kw::Async && self <= kw::Try
935935
}
936+
937+
/// Used for sanity checking rustdoc keyword sections.
938+
pub fn is_doc_keyword(self) -> bool {
939+
self <= kw::Union
940+
}
936941
}
937942

938943
impl Ident {

0 commit comments

Comments
 (0)