Rename Lit.node
to Lit.kind
This commit is contained in:
parent
ce6aabbaa1
commit
17726f6b52
17 changed files with 25 additions and 25 deletions
|
@ -54,7 +54,7 @@ impl LoweringContext<'_> {
|
||||||
let ohs = P(self.lower_expr(ohs));
|
let ohs = P(self.lower_expr(ohs));
|
||||||
hir::ExprKind::Unary(op, ohs)
|
hir::ExprKind::Unary(op, ohs)
|
||||||
}
|
}
|
||||||
ExprKind::Lit(ref l) => hir::ExprKind::Lit(respan(l.span, l.node.clone())),
|
ExprKind::Lit(ref l) => hir::ExprKind::Lit(respan(l.span, l.kind.clone())),
|
||||||
ExprKind::Cast(ref expr, ref ty) => {
|
ExprKind::Cast(ref expr, ref ty) => {
|
||||||
let expr = P(self.lower_expr(expr));
|
let expr = P(self.lower_expr(expr));
|
||||||
hir::ExprKind::Cast(expr, self.lower_ty(ty, ImplTraitContext::disallowed()))
|
hir::ExprKind::Cast(expr, self.lower_ty(ty, ImplTraitContext::disallowed()))
|
||||||
|
|
|
@ -142,7 +142,7 @@ impl_stable_hash_for!(enum ::syntax::ast::LitIntType {
|
||||||
});
|
});
|
||||||
|
|
||||||
impl_stable_hash_for!(struct ::syntax::ast::Lit {
|
impl_stable_hash_for!(struct ::syntax::ast::Lit {
|
||||||
node,
|
kind,
|
||||||
token,
|
token,
|
||||||
span
|
span
|
||||||
});
|
});
|
||||||
|
|
|
@ -226,7 +226,7 @@ impl<'a> LintLevelsBuilder<'a> {
|
||||||
metas = &metas[0..metas.len()-1];
|
metas = &metas[0..metas.len()-1];
|
||||||
// FIXME (#55112): issue unused-attributes lint if we thereby
|
// FIXME (#55112): issue unused-attributes lint if we thereby
|
||||||
// don't have any lint names (`#[level(reason = "foo")]`)
|
// don't have any lint names (`#[level(reason = "foo")]`)
|
||||||
if let ast::LitKind::Str(rationale, _) = name_value.node {
|
if let ast::LitKind::Str(rationale, _) = name_value.kind {
|
||||||
if !self.sess.features_untracked().lint_reasons {
|
if !self.sess.features_untracked().lint_reasons {
|
||||||
feature_gate::emit_feature_err(
|
feature_gate::emit_feature_err(
|
||||||
&self.sess.parse_sess,
|
&self.sess.parse_sess,
|
||||||
|
|
|
@ -1883,7 +1883,7 @@ pub fn parse_cfgspecs(cfgspecs: Vec<String>) -> FxHashSet<(String, Option<String
|
||||||
MetaItemKind::List(..) => {
|
MetaItemKind::List(..) => {
|
||||||
error!(r#"expected `key` or `key="value"`"#);
|
error!(r#"expected `key` or `key="value"`"#);
|
||||||
}
|
}
|
||||||
MetaItemKind::NameValue(lit) if !lit.node.is_str() => {
|
MetaItemKind::NameValue(lit) if !lit.kind.is_str() => {
|
||||||
error!("argument value must be a string");
|
error!("argument value must be a string");
|
||||||
}
|
}
|
||||||
MetaItemKind::NameValue(..) | MetaItemKind::Word => {
|
MetaItemKind::NameValue(..) | MetaItemKind::Word => {
|
||||||
|
|
|
@ -1150,7 +1150,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
None => return Bound::Unbounded,
|
None => return Bound::Unbounded,
|
||||||
};
|
};
|
||||||
for meta in attr.meta_item_list().expect("rustc_layout_scalar_valid_range takes args") {
|
for meta in attr.meta_item_list().expect("rustc_layout_scalar_valid_range takes args") {
|
||||||
match meta.literal().expect("attribute takes lit").node {
|
match meta.literal().expect("attribute takes lit").kind {
|
||||||
ast::LitKind::Int(a, _) => return Bound::Included(a),
|
ast::LitKind::Int(a, _) => return Bound::Included(a),
|
||||||
_ => span_bug!(attr.span, "rustc_layout_scalar_valid_range expects int arg"),
|
_ => span_bug!(attr.span, "rustc_layout_scalar_valid_range expects int arg"),
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ impl EarlyLintPass for WhileTrue {
|
||||||
fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) {
|
fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) {
|
||||||
if let ast::ExprKind::While(cond, ..) = &e.kind {
|
if let ast::ExprKind::While(cond, ..) = &e.kind {
|
||||||
if let ast::ExprKind::Lit(ref lit) = pierce_parens(cond).kind {
|
if let ast::ExprKind::Lit(ref lit) = pierce_parens(cond).kind {
|
||||||
if let ast::LitKind::Bool(true) = lit.node {
|
if let ast::LitKind::Bool(true) = lit.kind {
|
||||||
if !lit.span.from_expansion() {
|
if !lit.span.from_expansion() {
|
||||||
let msg = "denote infinite loops with `loop { ... }`";
|
let msg = "denote infinite loops with `loop { ... }`";
|
||||||
let condition_span = cx.sess.source_map().def_span(e.span);
|
let condition_span = cx.sess.source_map().def_span(e.span);
|
||||||
|
|
|
@ -258,7 +258,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase {
|
||||||
.and_then(|attr| attr.meta())
|
.and_then(|attr| attr.meta())
|
||||||
.and_then(|meta| {
|
.and_then(|meta| {
|
||||||
meta.name_value_literal().and_then(|lit| {
|
meta.name_value_literal().and_then(|lit| {
|
||||||
if let ast::LitKind::Str(name, ..) = lit.node {
|
if let ast::LitKind::Str(name, ..) = lit.kind {
|
||||||
// Discard the double quotes surrounding the literal.
|
// Discard the double quotes surrounding the literal.
|
||||||
let sp = cx.sess().source_map().span_to_snippet(lit.span)
|
let sp = cx.sess().source_map().span_to_snippet(lit.span)
|
||||||
.ok()
|
.ok()
|
||||||
|
|
|
@ -1768,7 +1768,7 @@ fn args_required_const(tcx: TyCtxt<'_>, def_id: DefId) -> Option<FxHashSet<usize
|
||||||
let attr = attrs.iter().find(|a| a.check_name(sym::rustc_args_required_const))?;
|
let attr = attrs.iter().find(|a| a.check_name(sym::rustc_args_required_const))?;
|
||||||
let mut ret = FxHashSet::default();
|
let mut ret = FxHashSet::default();
|
||||||
for meta in attr.meta_item_list()? {
|
for meta in attr.meta_item_list()? {
|
||||||
match meta.literal()?.node {
|
match meta.literal()?.kind {
|
||||||
LitKind::Int(a, _) => { ret.insert(a as usize); }
|
LitKind::Int(a, _) => { ret.insert(a as usize); }
|
||||||
_ => return None,
|
_ => return None,
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ impl Cfg {
|
||||||
};
|
};
|
||||||
match cfg.node {
|
match cfg.node {
|
||||||
MetaItemKind::Word => Ok(Cfg::Cfg(name, None)),
|
MetaItemKind::Word => Ok(Cfg::Cfg(name, None)),
|
||||||
MetaItemKind::NameValue(ref lit) => match lit.node {
|
MetaItemKind::NameValue(ref lit) => match lit.kind {
|
||||||
LitKind::Str(value, _) => Ok(Cfg::Cfg(name, Some(value))),
|
LitKind::Str(value, _) => Ok(Cfg::Cfg(name, Some(value))),
|
||||||
_ => Err(InvalidCfgError {
|
_ => Err(InvalidCfgError {
|
||||||
// FIXME: if the main #[cfg] syntax decided to support non-string literals,
|
// FIXME: if the main #[cfg] syntax decided to support non-string literals,
|
||||||
|
|
|
@ -1361,7 +1361,7 @@ pub struct Lit {
|
||||||
/// The "semantic" representation of the literal lowered from the original tokens.
|
/// The "semantic" representation of the literal lowered from the original tokens.
|
||||||
/// Strings are unescaped, hexadecimal forms are eliminated, etc.
|
/// Strings are unescaped, hexadecimal forms are eliminated, etc.
|
||||||
/// FIXME: Remove this and only create the semantic representation during lowering to HIR.
|
/// FIXME: Remove this and only create the semantic representation during lowering to HIR.
|
||||||
pub node: LitKind,
|
pub kind: LitKind,
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ impl AttributeTemplate {
|
||||||
match meta_item_kind {
|
match meta_item_kind {
|
||||||
ast::MetaItemKind::Word => self.word,
|
ast::MetaItemKind::Word => self.word,
|
||||||
ast::MetaItemKind::List(..) => self.list.is_some(),
|
ast::MetaItemKind::List(..) => self.list.is_some(),
|
||||||
ast::MetaItemKind::NameValue(lit) if lit.node.is_str() => self.name_value_str.is_some(),
|
ast::MetaItemKind::NameValue(lit) if lit.kind.is_str() => self.name_value_str.is_some(),
|
||||||
ast::MetaItemKind::NameValue(..) => false,
|
ast::MetaItemKind::NameValue(..) => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -538,13 +538,13 @@ pub fn cfg_matches(cfg: &ast::MetaItem, sess: &ParseSess, features: Option<&Feat
|
||||||
MetaItemKind::List(..) => {
|
MetaItemKind::List(..) => {
|
||||||
error(cfg.span, "unexpected parentheses after `cfg` predicate key")
|
error(cfg.span, "unexpected parentheses after `cfg` predicate key")
|
||||||
}
|
}
|
||||||
MetaItemKind::NameValue(lit) if !lit.node.is_str() => {
|
MetaItemKind::NameValue(lit) if !lit.kind.is_str() => {
|
||||||
handle_errors(
|
handle_errors(
|
||||||
sess,
|
sess,
|
||||||
lit.span,
|
lit.span,
|
||||||
AttrError::UnsupportedLiteral(
|
AttrError::UnsupportedLiteral(
|
||||||
"literal in `cfg` predicate value must be a string",
|
"literal in `cfg` predicate value must be a string",
|
||||||
lit.node.is_bytestr()
|
lit.kind.is_bytestr()
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
true
|
true
|
||||||
|
@ -668,7 +668,7 @@ fn find_deprecation_generic<'a, I>(sess: &ParseSess,
|
||||||
AttrError::UnsupportedLiteral(
|
AttrError::UnsupportedLiteral(
|
||||||
"literal in `deprecated` \
|
"literal in `deprecated` \
|
||||||
value must be a string",
|
value must be a string",
|
||||||
lit.node.is_bytestr()
|
lit.kind.is_bytestr()
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -811,14 +811,14 @@ pub fn find_repr_attrs(sess: &ParseSess, attr: &Attribute) -> Vec<ReprAttr> {
|
||||||
let mut literal_error = None;
|
let mut literal_error = None;
|
||||||
if name == sym::align {
|
if name == sym::align {
|
||||||
recognised = true;
|
recognised = true;
|
||||||
match parse_alignment(&value.node) {
|
match parse_alignment(&value.kind) {
|
||||||
Ok(literal) => acc.push(ReprAlign(literal)),
|
Ok(literal) => acc.push(ReprAlign(literal)),
|
||||||
Err(message) => literal_error = Some(message)
|
Err(message) => literal_error = Some(message)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else if name == sym::packed {
|
else if name == sym::packed {
|
||||||
recognised = true;
|
recognised = true;
|
||||||
match parse_alignment(&value.node) {
|
match parse_alignment(&value.kind) {
|
||||||
Ok(literal) => acc.push(ReprPacked(literal)),
|
Ok(literal) => acc.push(ReprPacked(literal)),
|
||||||
Err(message) => literal_error = Some(message)
|
Err(message) => literal_error = Some(message)
|
||||||
};
|
};
|
||||||
|
@ -834,7 +834,7 @@ pub fn find_repr_attrs(sess: &ParseSess, attr: &Attribute) -> Vec<ReprAttr> {
|
||||||
recognised = true;
|
recognised = true;
|
||||||
let mut err = struct_span_err!(diagnostic, item.span(), E0693,
|
let mut err = struct_span_err!(diagnostic, item.span(), E0693,
|
||||||
"incorrect `repr(align)` attribute format");
|
"incorrect `repr(align)` attribute format");
|
||||||
match value.node {
|
match value.kind {
|
||||||
ast::LitKind::Int(int, ast::LitIntType::Unsuffixed) => {
|
ast::LitKind::Int(int, ast::LitIntType::Unsuffixed) => {
|
||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
item.span(),
|
item.span(),
|
||||||
|
|
|
@ -219,7 +219,7 @@ impl MetaItem {
|
||||||
pub fn value_str(&self) -> Option<Symbol> {
|
pub fn value_str(&self) -> Option<Symbol> {
|
||||||
match self.node {
|
match self.node {
|
||||||
MetaItemKind::NameValue(ref v) => {
|
MetaItemKind::NameValue(ref v) => {
|
||||||
match v.node {
|
match v.kind {
|
||||||
LitKind::Str(ref s, _) => Some(*s),
|
LitKind::Str(ref s, _) => Some(*s),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1099,7 +1099,7 @@ pub fn expr_to_spanned_string<'a>(
|
||||||
let expr = cx.expander().fully_expand_fragment(AstFragment::Expr(expr)).make_expr();
|
let expr = cx.expander().fully_expand_fragment(AstFragment::Expr(expr)).make_expr();
|
||||||
|
|
||||||
Err(match expr.kind {
|
Err(match expr.kind {
|
||||||
ast::ExprKind::Lit(ref l) => match l.node {
|
ast::ExprKind::Lit(ref l) => match l.kind {
|
||||||
ast::LitKind::Str(s, style) => return Ok((s, style, expr.span)),
|
ast::LitKind::Str(s, style) => return Ok((s, style, expr.span)),
|
||||||
ast::LitKind::Err(_) => None,
|
ast::LitKind::Err(_) => None,
|
||||||
_ => Some(cx.struct_span_err(l.span, err_msg))
|
_ => Some(cx.struct_span_err(l.span, err_msg))
|
||||||
|
|
|
@ -1504,7 +1504,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
|
||||||
// Check if the user erroneously used `doc(include(...))` syntax.
|
// Check if the user erroneously used `doc(include(...))` syntax.
|
||||||
let literal = it.meta_item_list().and_then(|list| {
|
let literal = it.meta_item_list().and_then(|list| {
|
||||||
if list.len() == 1 {
|
if list.len() == 1 {
|
||||||
list[0].literal().map(|literal| &literal.node)
|
list[0].literal().map(|literal| &literal.kind)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
@ -249,7 +249,7 @@ impl<'a> Parser<'a> {
|
||||||
let lit = self.parse_lit()?;
|
let lit = self.parse_lit()?;
|
||||||
debug!("checking if {:?} is unusuffixed", lit);
|
debug!("checking if {:?} is unusuffixed", lit);
|
||||||
|
|
||||||
if !lit.node.is_unsuffixed() {
|
if !lit.kind.is_unsuffixed() {
|
||||||
let msg = "suffixed literals are not allowed in attributes";
|
let msg = "suffixed literals are not allowed in attributes";
|
||||||
self.diagnostic().struct_span_err(lit.span, msg)
|
self.diagnostic().struct_span_err(lit.span, msg)
|
||||||
.help("instead of using a suffixed literal \
|
.help("instead of using a suffixed literal \
|
||||||
|
|
|
@ -255,7 +255,7 @@ impl LitKind {
|
||||||
impl Lit {
|
impl Lit {
|
||||||
/// Converts literal token into an AST literal.
|
/// Converts literal token into an AST literal.
|
||||||
fn from_lit_token(token: token::Lit, span: Span) -> Result<Lit, LitError> {
|
fn from_lit_token(token: token::Lit, span: Span) -> Result<Lit, LitError> {
|
||||||
Ok(Lit { token, node: LitKind::from_lit_token(token)?, span })
|
Ok(Lit { token, kind: LitKind::from_lit_token(token)?, span })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts arbitrary token into an AST literal.
|
/// Converts arbitrary token into an AST literal.
|
||||||
|
@ -282,8 +282,8 @@ impl Lit {
|
||||||
/// Attempts to recover an AST literal from semantic literal.
|
/// Attempts to recover an AST literal from semantic literal.
|
||||||
/// This function is used when the original token doesn't exist (e.g. the literal is created
|
/// This function is used when the original token doesn't exist (e.g. the literal is created
|
||||||
/// by an AST-based macro) or unavailable (e.g. from HIR pretty-printing).
|
/// by an AST-based macro) or unavailable (e.g. from HIR pretty-printing).
|
||||||
pub fn from_lit_kind(node: LitKind, span: Span) -> Lit {
|
pub fn from_lit_kind(kind: LitKind, span: Span) -> Lit {
|
||||||
Lit { token: node.to_lit_token(), node, span }
|
Lit { token: kind.to_lit_token(), kind, span }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Losslessly convert an AST literal into a token stream.
|
/// Losslessly convert an AST literal into a token stream.
|
||||||
|
|
|
@ -19,7 +19,7 @@ pub fn expand_concat(
|
||||||
let mut has_errors = false;
|
let mut has_errors = false;
|
||||||
for e in es {
|
for e in es {
|
||||||
match e.kind {
|
match e.kind {
|
||||||
ast::ExprKind::Lit(ref lit) => match lit.node {
|
ast::ExprKind::Lit(ref lit) => match lit.kind {
|
||||||
ast::LitKind::Str(ref s, _)
|
ast::LitKind::Str(ref s, _)
|
||||||
| ast::LitKind::Float(ref s, _)
|
| ast::LitKind::Float(ref s, _)
|
||||||
| ast::LitKind::FloatUnsuffixed(ref s) => {
|
| ast::LitKind::FloatUnsuffixed(ref s) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue