Auto merge of #28642 - petrochenkov:name3, r=nrc
This PR removes random remaining `Ident`s outside of libsyntax and performs general cleanup In particular, interfaces of `Name` and `Ident` are tidied up, `Name`s and `Ident`s being small `Copy` aggregates are always passed to functions by value, and `Ident`s are never used as keys in maps, because `Ident` comparisons are tricky. Although this PR closes https://github.com/rust-lang/rust/issues/6993 there's still work related to it: - `Name` can be made `NonZero` to compress numerous `Option<Name>`s and `Option<Ident>`s but it requires const unsafe functions. - Implementation of `PartialEq` on `Ident` should be eliminated and replaced with explicit hygienic, non-hygienic or member-wise comparisons. - Finally, large parts of AST can potentially be converted to `Name`s in the same way as HIR to clearly separate identifiers used in hygienic and non-hygienic contexts. r? @nrc
This commit is contained in:
commit
2e88c36ebc
70 changed files with 337 additions and 401 deletions
|
@ -4658,7 +4658,7 @@ impl<'a> Parser<'a> {
|
|||
(fields, None)
|
||||
// Tuple-style struct definition with optional where-clause.
|
||||
} else if self.token == token::OpenDelim(token::Paren) {
|
||||
let fields = try!(self.parse_tuple_struct_body(&class_name, &mut generics));
|
||||
let fields = try!(self.parse_tuple_struct_body(class_name, &mut generics));
|
||||
(fields, Some(ast::DUMMY_NODE_ID))
|
||||
} else {
|
||||
let token_str = self.this_token_to_string();
|
||||
|
@ -4693,7 +4693,7 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
|
||||
pub fn parse_tuple_struct_body(&mut self,
|
||||
class_name: &ast::Ident,
|
||||
class_name: ast::Ident,
|
||||
generics: &mut ast::Generics)
|
||||
-> PResult<Vec<StructField>> {
|
||||
// This is the case where we find `struct Foo<T>(T) where T: Copy;`
|
||||
|
@ -5723,10 +5723,10 @@ impl<'a> Parser<'a> {
|
|||
Option<ast::Name>)>> {
|
||||
let ret = match self.token {
|
||||
token::Literal(token::Str_(s), suf) => {
|
||||
(self.id_to_interned_str(s.ident()), ast::CookedStr, suf)
|
||||
(self.id_to_interned_str(ast::Ident::with_empty_ctxt(s)), ast::CookedStr, suf)
|
||||
}
|
||||
token::Literal(token::StrRaw(s, n), suf) => {
|
||||
(self.id_to_interned_str(s.ident()), ast::RawStr(n), suf)
|
||||
(self.id_to_interned_str(ast::Ident::with_empty_ctxt(s)), ast::RawStr(n), suf)
|
||||
}
|
||||
_ => return Ok(None)
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue