Skip to content

Commit

Permalink
Restore the old behavior of the rustdoc keyword check + Fix rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed May 13, 2019
1 parent 80f0149 commit 261eb01
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/librustc_plugin/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::mem;
use std::path::PathBuf;
use syntax::ast;
use syntax::span_err;
use syntax::symbol::{Symbol, keywords, sym};
use syntax::symbol::{Symbol, kw, sym};
use syntax_pos::{Span, DUMMY_SP};

/// Pointer to a registrar function.
Expand Down Expand Up @@ -58,7 +58,7 @@ pub fn load_plugins(sess: &Session,
for plugin in plugins {
// plugins must have a name and can't be key = value
let name = plugin.name_or_empty();
if name != keywords::Invalid.name() && !plugin.is_value_str() {
if name != kw::Invalid && !plugin.is_value_str() {
let args = plugin.meta_item_list().map(ToOwned::to_owned);
loader.load_plugin(plugin.span(), name, args.unwrap_or_default());
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_resolve/resolve_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
has_errors = true;

if let SingleImport { source, ref source_bindings, .. } = import.subclass {
if source.name == keywords::SelfLower.name() {
if source.name == kw::SelfLower {
// Silence `unresolved import` error if E0429 is already emitted
if let Err(Determined) = source_bindings.value_ns.get() {
continue;
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn render<T: fmt::Display, S: fmt::Display>(
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\
<meta name=\"generator\" content=\"rustdoc\">\
<meta name=\"description\" content=\"{description}\">\
<meta name=\"keywords\" content=\"{kw}\">\
<meta name=\"keywords\" content=\"{keywords}\">\
<title>{title}</title>\
<link rel=\"stylesheet\" type=\"text/css\" href=\"{static_root_path}normalize{suffix}.css\">\
<link rel=\"stylesheet\" type=\"text/css\" href=\"{static_root_path}rustdoc{suffix}.css\" \
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/attr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::parse::parser::Parser;
use crate::parse::{self, ParseSess, PResult};
use crate::parse::token::{self, Token};
use crate::ptr::P;
use crate::symbol::{kw, Symbol};
use crate::symbol::Symbol;
use crate::ThinVec;
use crate::tokenstream::{TokenStream, TokenTree, DelimSpan};
use crate::GLOBALS;
Expand Down Expand Up @@ -206,7 +206,7 @@ impl MetaItem {
}
}
pub fn name_or_empty(&self) -> Symbol {
self.ident().unwrap_or(Ident.invalid()).name
self.ident().unwrap_or(Ident::invalid()).name
}

// #[attribute(name = "value")]
Expand Down
12 changes: 6 additions & 6 deletions src/libsyntax/ext/tt/macro_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::parse::{Directory, ParseSess};
use crate::parse::parser::Parser;
use crate::parse::token::{self, NtTT};
use crate::parse::token::Token::*;
use crate::symbol::{Symbol, keywords, sym};
use crate::symbol::{Symbol, kw, sym};
use crate::tokenstream::{DelimSpan, TokenStream, TokenTree};

use errors::FatalError;
Expand Down Expand Up @@ -1046,8 +1046,8 @@ fn is_in_follow(tok: &quoted::TokenTree, frag: &str) -> IsInFollow {
match *tok {
TokenTree::Token(_, ref tok) => match *tok {
FatArrow | Comma | Eq | BinOp(token::Or) => IsInFollow::Yes,
Ident(i, false) if i.name == keywords::If.name() ||
i.name == keywords::In.name() => IsInFollow::Yes,
Ident(i, false) if i.name == kw::If ||
i.name == kw::In => IsInFollow::Yes,
_ => IsInFollow::No(tokens),
},
_ => IsInFollow::No(tokens),
Expand All @@ -1064,8 +1064,8 @@ fn is_in_follow(tok: &quoted::TokenTree, frag: &str) -> IsInFollow {
OpenDelim(token::DelimToken::Bracket) |
Comma | FatArrow | Colon | Eq | Gt | BinOp(token::Shr) | Semi |
BinOp(token::Or) => IsInFollow::Yes,
Ident(i, false) if i.name == keywords::As.name() ||
i.name == keywords::Where.name() => IsInFollow::Yes,
Ident(i, false) if i.name == kw::As ||
i.name == kw::Where => IsInFollow::Yes,
_ => IsInFollow::No(tokens),
},
TokenTree::MetaVarDecl(_, _, frag) if frag.name == sym::block =>
Expand All @@ -1092,7 +1092,7 @@ fn is_in_follow(tok: &quoted::TokenTree, frag: &str) -> IsInFollow {
match *tok {
TokenTree::Token(_, ref tok) => match *tok {
Comma => IsInFollow::Yes,
Ident(i, is_raw) if is_raw || i.name != keywords::Priv.name() =>
Ident(i, is_raw) if is_raw || i.name != kw::Priv =>
IsInFollow::Yes,
ref tok => if tok.can_begin_type() {
IsInFollow::Yes
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::source_map::Spanned;
use crate::edition::{ALL_EDITIONS, Edition};
use crate::visit::{self, FnKind, Visitor};
use crate::parse::{token, ParseSess};
use crate::symbol::{Symbol, keywords, sym};
use crate::symbol::{Symbol, kw, sym};
use crate::tokenstream::TokenTree;

use errors::{DiagnosticBuilder, Handler};
Expand Down Expand Up @@ -1947,7 +1947,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
fn visit_item(&mut self, i: &'a ast::Item) {
match i.node {
ast::ItemKind::Const(_,_) => {
if i.ident.name == keywords::Underscore.name() {
if i.ident.name == kw::Underscore {
gate_feature_post!(&self, underscore_const_names, i.span,
"naming constants with `_` is unstable");
}
Expand Down
11 changes: 5 additions & 6 deletions src/libsyntax/parse/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ impl LitKind {

Some(match lit {
token::Bool(i) => {
assert!(i == keywords::True.name() || i == keywords::False.name());
LitKind::Bool(i == keywords::True.name())
assert!(i == kw::True || i == kw::False);
LitKind::Bool(i == kw::True)
}
token::Byte(i) => {
match unescape_byte(&i.as_str()) {
Expand Down Expand Up @@ -156,8 +156,8 @@ impl LitKind {
}
LitKind::FloatUnsuffixed(symbol) => (token::Lit::Float(symbol), None),
LitKind::Bool(value) => {
let kw = if value { keywords::True } else { keywords::False };
(token::Lit::Bool(kw.name()), None)
let kw = if value { kw::True } else { kw::False };
(token::Lit::Bool(kw), None)
}
LitKind::Err(val) => (token::Lit::Err(val), None),
}
Expand All @@ -175,8 +175,7 @@ impl Lit {
diag: Option<(Span, &Handler)>,
) -> Option<Lit> {
let (token, suffix) = match *token {
token::Ident(ident, false) if ident.name == keywords::True.name() ||
ident.name == keywords::False.name() =>
token::Ident(ident, false) if ident.name == kw::True || ident.name == kw::False =>
(token::Bool(ident.name), None),
token::Literal(token, suffix) =>
(token, suffix),
Expand Down
5 changes: 5 additions & 0 deletions src/libsyntax_pos/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,11 @@ impl Symbol {
fn is_unused_keyword_2018(self) -> bool {
self >= kw::Async && self <= kw::Try
}

/// Used for sanity checking rustdoc keyword sections.
pub fn is_doc_keyword(self) -> bool {
self <= kw::Union
}
}

impl Ident {
Expand Down

0 comments on commit 261eb01

Please sign in to comment.