Fix rebase
This commit is contained in:
parent
554b4282d8
commit
d7072b5bb4
12 changed files with 71 additions and 58 deletions
|
@ -676,7 +676,7 @@ impl<'a> LoweringContext<'a> {
|
||||||
// that collisions are ok here and this shouldn't
|
// that collisions are ok here and this shouldn't
|
||||||
// really show up for end-user.
|
// really show up for end-user.
|
||||||
let str_name = match hir_name {
|
let str_name = match hir_name {
|
||||||
ParamName::Plain(ident) => name.as_interned_str(),
|
ParamName::Plain(ident) => ident.as_interned_str(),
|
||||||
ParamName::Fresh(_) => keywords::UnderscoreLifetime.name().as_interned_str(),
|
ParamName::Fresh(_) => keywords::UnderscoreLifetime.name().as_interned_str(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -684,7 +684,7 @@ impl<'a> LoweringContext<'a> {
|
||||||
self.resolver.definitions().create_def_with_parent(
|
self.resolver.definitions().create_def_with_parent(
|
||||||
parent_id.index,
|
parent_id.index,
|
||||||
def_node_id,
|
def_node_id,
|
||||||
DefPathData::LifetimeDef(str_name),
|
DefPathData::LifetimeParam(str_name),
|
||||||
DefIndexAddressSpace::High,
|
DefIndexAddressSpace::High,
|
||||||
Mark::root(),
|
Mark::root(),
|
||||||
span,
|
span,
|
||||||
|
@ -719,10 +719,10 @@ impl<'a> LoweringContext<'a> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let hir_name = ParamName::Plain(name);
|
let hir_name = ParamName::Plain(ident);
|
||||||
|
|
||||||
if self.lifetimes_to_define.iter()
|
if self.lifetimes_to_define.iter()
|
||||||
.any(|(_, lt_name)| *lt_name.modern() == hir_name.modern()) {
|
.any(|(_, lt_name)| lt_name.modern() == hir_name.modern()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1185,10 +1185,11 @@ impl<'a> LoweringContext<'a> {
|
||||||
let ident = Ident::from_str(&pprust::ty_to_string(t)).with_span_pos(span);
|
let ident = Ident::from_str(&pprust::ty_to_string(t)).with_span_pos(span);
|
||||||
self.in_band_ty_params.push(hir::GenericParam {
|
self.in_band_ty_params.push(hir::GenericParam {
|
||||||
id: def_node_id,
|
id: def_node_id,
|
||||||
ident: ParamName::Plain(ident),
|
name: ParamName::Plain(ident),
|
||||||
pure_wrt_drop: false,
|
pure_wrt_drop: false,
|
||||||
attrs: hir_vec![],
|
attrs: hir_vec![],
|
||||||
bounds: hir_bounds,
|
bounds: hir_bounds,
|
||||||
|
span,
|
||||||
kind: hir::GenericParamKind::Type {
|
kind: hir::GenericParamKind::Type {
|
||||||
default: None,
|
default: None,
|
||||||
synthetic: Some(hir::SyntheticTyParamKind::ImplTrait),
|
synthetic: Some(hir::SyntheticTyParamKind::ImplTrait),
|
||||||
|
@ -1438,7 +1439,7 @@ impl<'a> LoweringContext<'a> {
|
||||||
|
|
||||||
let name = match name {
|
let name = match name {
|
||||||
hir::LifetimeName::Underscore => {
|
hir::LifetimeName::Underscore => {
|
||||||
hir::ParamName::Plain(keywords::UnderscoreLifetime.name())
|
hir::ParamName::Plain(keywords::UnderscoreLifetime.ident())
|
||||||
}
|
}
|
||||||
hir::LifetimeName::Param(param_name) => param_name,
|
hir::LifetimeName::Param(param_name) => param_name,
|
||||||
_ => bug!("expected LifetimeName::Param or ParamName::Plain"),
|
_ => bug!("expected LifetimeName::Param or ParamName::Plain"),
|
||||||
|
@ -2101,7 +2102,7 @@ impl<'a> LoweringContext<'a> {
|
||||||
let future_params = P(hir::GenericArgs {
|
let future_params = P(hir::GenericArgs {
|
||||||
args: hir_vec![],
|
args: hir_vec![],
|
||||||
bindings: hir_vec![hir::TypeBinding {
|
bindings: hir_vec![hir::TypeBinding {
|
||||||
name: Symbol::intern(FN_OUTPUT_NAME),
|
ident: Ident::from_str(FN_OUTPUT_NAME),
|
||||||
ty: output_ty,
|
ty: output_ty,
|
||||||
id: this.next_id().node_id,
|
id: this.next_id().node_id,
|
||||||
span,
|
span,
|
||||||
|
@ -2163,7 +2164,7 @@ impl<'a> LoweringContext<'a> {
|
||||||
|
|
||||||
fn lower_lifetime(&mut self, l: &Lifetime) -> hir::Lifetime {
|
fn lower_lifetime(&mut self, l: &Lifetime) -> hir::Lifetime {
|
||||||
let span = l.ident.span;
|
let span = l.ident.span;
|
||||||
match self.lower_ident(l.ident) {
|
match l.ident {
|
||||||
ident if ident.name == keywords::StaticLifetime.name() =>
|
ident if ident.name == keywords::StaticLifetime.name() =>
|
||||||
self.new_named_lifetime(l.id, span, hir::LifetimeName::Static),
|
self.new_named_lifetime(l.id, span, hir::LifetimeName::Static),
|
||||||
ident if ident.name == keywords::UnderscoreLifetime.name() =>
|
ident if ident.name == keywords::UnderscoreLifetime.name() =>
|
||||||
|
@ -2221,7 +2222,7 @@ impl<'a> LoweringContext<'a> {
|
||||||
let lt = self.lower_lifetime(&Lifetime { id: param.id, ident: param.ident });
|
let lt = self.lower_lifetime(&Lifetime { id: param.id, ident: param.ident });
|
||||||
let param_name = match lt.name {
|
let param_name = match lt.name {
|
||||||
hir::LifetimeName::Param(param_name) => param_name,
|
hir::LifetimeName::Param(param_name) => param_name,
|
||||||
_ => hir::ParamName::Plain(lt.name.name()),
|
_ => hir::ParamName::Plain(lt.name.ident()),
|
||||||
};
|
};
|
||||||
let param = hir::GenericParam {
|
let param = hir::GenericParam {
|
||||||
id: lt.id,
|
id: lt.id,
|
||||||
|
@ -2238,14 +2239,14 @@ impl<'a> LoweringContext<'a> {
|
||||||
param
|
param
|
||||||
}
|
}
|
||||||
GenericParamKind::Type { ref default, .. } => {
|
GenericParamKind::Type { ref default, .. } => {
|
||||||
let mut name = self.lower_ident(param.ident);
|
|
||||||
|
|
||||||
// Don't expose `Self` (recovered "keyword used as ident" parse error).
|
// Don't expose `Self` (recovered "keyword used as ident" parse error).
|
||||||
// `rustc::ty` expects `Self` to be only used for a trait's `Self`.
|
// `rustc::ty` expects `Self` to be only used for a trait's `Self`.
|
||||||
// Instead, use gensym("Self") to create a distinct name that looks the same.
|
// Instead, use gensym("Self") to create a distinct name that looks the same.
|
||||||
if name == keywords::SelfType.name() {
|
let ident = if param.ident.name == keywords::SelfType.name() {
|
||||||
name = Symbol::gensym("Self");
|
param.ident.gensym()
|
||||||
}
|
} else {
|
||||||
|
param.ident
|
||||||
|
};
|
||||||
|
|
||||||
let add_bounds = add_bounds.get(¶m.id).map_or(&[][..], |x| &x);
|
let add_bounds = add_bounds.get(¶m.id).map_or(&[][..], |x| &x);
|
||||||
if !add_bounds.is_empty() {
|
if !add_bounds.is_empty() {
|
||||||
|
@ -2256,11 +2257,11 @@ impl<'a> LoweringContext<'a> {
|
||||||
|
|
||||||
hir::GenericParam {
|
hir::GenericParam {
|
||||||
id: self.lower_node_id(param.id).node_id,
|
id: self.lower_node_id(param.id).node_id,
|
||||||
name: hir::ParamName::Plain(name),
|
name: hir::ParamName::Plain(ident),
|
||||||
span: param.ident.span,
|
|
||||||
pure_wrt_drop: attr::contains_name(¶m.attrs, "may_dangle"),
|
pure_wrt_drop: attr::contains_name(¶m.attrs, "may_dangle"),
|
||||||
attrs: self.lower_attrs(¶m.attrs),
|
attrs: self.lower_attrs(¶m.attrs),
|
||||||
bounds,
|
bounds,
|
||||||
|
span: ident.span,
|
||||||
kind: hir::GenericParamKind::Type {
|
kind: hir::GenericParamKind::Type {
|
||||||
default: default.as_ref().map(|x| {
|
default: default.as_ref().map(|x| {
|
||||||
self.lower_ty(x, ImplTraitContext::Disallowed)
|
self.lower_ty(x, ImplTraitContext::Disallowed)
|
||||||
|
@ -3656,7 +3657,7 @@ impl<'a> LoweringContext<'a> {
|
||||||
let e2 = self.lower_expr(e2);
|
let e2 = self.lower_expr(e2);
|
||||||
let ty_path = P(self.std_path(span, &["ops", "RangeInclusive"], None, false));
|
let ty_path = P(self.std_path(span, &["ops", "RangeInclusive"], None, false));
|
||||||
let ty = P(self.ty_path(id, span, hir::QPath::Resolved(None, ty_path)));
|
let ty = P(self.ty_path(id, span, hir::QPath::Resolved(None, ty_path)));
|
||||||
let new_seg = P(hir::PathSegment::from_name(Ident::from_str("new")));
|
let new_seg = P(hir::PathSegment::from_ident(Ident::from_str("new")));
|
||||||
let new_path = hir::QPath::TypeRelative(ty, new_seg);
|
let new_path = hir::QPath::TypeRelative(ty, new_seg);
|
||||||
let new = P(self.expr(span, hir::ExprPath(new_path), ThinVec::new()));
|
let new = P(self.expr(span, hir::ExprPath(new_path), ThinVec::new()));
|
||||||
hir::ExprCall(new, hir_vec![e1, e2])
|
hir::ExprCall(new, hir_vec![e1, e2])
|
||||||
|
|
|
@ -616,7 +616,7 @@ impl<'hir> Map<'hir> {
|
||||||
NodeItem(&Item { node: ItemTrait(..), .. }) => {
|
NodeItem(&Item { node: ItemTrait(..), .. }) => {
|
||||||
keywords::SelfType.name()
|
keywords::SelfType.name()
|
||||||
}
|
}
|
||||||
NodeGenericParam(param) => param.name.ident(),
|
NodeGenericParam(param) => param.name.ident().name,
|
||||||
_ => bug!("ty_param_name: {} not a type parameter", self.node_to_string(id)),
|
_ => bug!("ty_param_name: {} not a type parameter", self.node_to_string(id)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -955,7 +955,7 @@ impl<'hir> Map<'hir> {
|
||||||
NodeField(f) => f.ident.name,
|
NodeField(f) => f.ident.name,
|
||||||
NodeLifetime(lt) => lt.name.ident().name,
|
NodeLifetime(lt) => lt.name.ident().name,
|
||||||
NodeGenericParam(param) => param.name.ident().name,
|
NodeGenericParam(param) => param.name.ident().name,
|
||||||
NodeBinding(&Pat { node: PatKind::Binding(_,_,l,_), .. }) => l.node,
|
NodeBinding(&Pat { node: PatKind::Binding(_,_,l,_), .. }) => l.name,
|
||||||
NodeStructCtor(_) => self.name(self.get_parent(id)),
|
NodeStructCtor(_) => self.name(self.get_parent(id)),
|
||||||
_ => bug!("no name for {}", self.node_to_string(id))
|
_ => bug!("no name for {}", self.node_to_string(id))
|
||||||
}
|
}
|
||||||
|
@ -1021,7 +1021,7 @@ impl<'hir> Map<'hir> {
|
||||||
Some(EntryBlock(_, _, block)) => block.span,
|
Some(EntryBlock(_, _, block)) => block.span,
|
||||||
Some(EntryStructCtor(_, _, _)) => self.expect_item(self.get_parent(id)).span,
|
Some(EntryStructCtor(_, _, _)) => self.expect_item(self.get_parent(id)).span,
|
||||||
Some(EntryLifetime(_, _, lifetime)) => lifetime.span,
|
Some(EntryLifetime(_, _, lifetime)) => lifetime.span,
|
||||||
Some(EntryGenericParam(_, _, param)) => param.ident.span,
|
Some(EntryGenericParam(_, _, param)) => param.span,
|
||||||
Some(EntryVisibility(_, _, &Visibility::Restricted { ref path, .. })) => path.span,
|
Some(EntryVisibility(_, _, &Visibility::Restricted { ref path, .. })) => path.span,
|
||||||
Some(EntryVisibility(_, _, v)) => bug!("unexpected Visibility {:?}", v),
|
Some(EntryVisibility(_, _, v)) => bug!("unexpected Visibility {:?}", v),
|
||||||
Some(EntryLocal(_, _, local)) => local.span,
|
Some(EntryLocal(_, _, local)) => local.span,
|
||||||
|
|
|
@ -201,7 +201,7 @@ pub struct Lifetime {
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
|
#[derive(Debug, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
|
||||||
pub enum ParamName {
|
pub enum ParamName {
|
||||||
/// Some user-given name like `T` or `'x`.
|
/// Some user-given name like `T` or `'x`.
|
||||||
Plain(Name),
|
Plain(Ident),
|
||||||
|
|
||||||
/// Synthetic name generated when user elided a lifetime in an impl header,
|
/// Synthetic name generated when user elided a lifetime in an impl header,
|
||||||
/// e.g. the lifetimes in cases like these:
|
/// e.g. the lifetimes in cases like these:
|
||||||
|
@ -220,10 +220,17 @@ pub enum ParamName {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ParamName {
|
impl ParamName {
|
||||||
pub fn name(&self) -> Name {
|
pub fn ident(&self) -> Ident {
|
||||||
match *self {
|
match *self {
|
||||||
ParamName::Plain(name) => name,
|
ParamName::Plain(ident) => ident,
|
||||||
ParamName::Fresh(_) => keywords::UnderscoreLifetime.name(),
|
ParamName::Fresh(_) => keywords::UnderscoreLifetime.ident(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn modern(&self) -> ParamName {
|
||||||
|
match *self {
|
||||||
|
ParamName::Plain(ident) => ParamName::Plain(ident.modern()),
|
||||||
|
param_name => param_name,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -247,24 +254,22 @@ impl LifetimeName {
|
||||||
pub fn ident(&self) -> Ident {
|
pub fn ident(&self) -> Ident {
|
||||||
match *self {
|
match *self {
|
||||||
LifetimeName::Implicit => keywords::Invalid.ident(),
|
LifetimeName::Implicit => keywords::Invalid.ident(),
|
||||||
LifetimeName::Fresh(_) | LifetimeName::Underscore =>
|
LifetimeName::Underscore => keywords::UnderscoreLifetime.ident(),
|
||||||
keywords::UnderscoreLifetime.ident(),
|
|
||||||
LifetimeName::Static => keywords::StaticLifetime.ident(),
|
LifetimeName::Static => keywords::StaticLifetime.ident(),
|
||||||
LifetimeName::Ident(ident) => ident,
|
LifetimeName::Param(param_name) => param_name.ident(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_elided(&self) -> bool {
|
pub fn is_elided(&self) -> bool {
|
||||||
use self::LifetimeName::*;
|
|
||||||
match self {
|
match self {
|
||||||
Implicit | Underscore => true,
|
LifetimeName::Implicit | LifetimeName::Underscore => true,
|
||||||
|
|
||||||
// It might seem surprising that `Fresh(_)` counts as
|
// It might seem surprising that `Fresh(_)` counts as
|
||||||
// *not* elided -- but this is because, as far as the code
|
// *not* elided -- but this is because, as far as the code
|
||||||
// in the compiler is concerned -- `Fresh(_)` variants act
|
// in the compiler is concerned -- `Fresh(_)` variants act
|
||||||
// equivalently to "some fresh name". They correspond to
|
// equivalently to "some fresh name". They correspond to
|
||||||
// early-bound regions on an impl, in other words.
|
// early-bound regions on an impl, in other words.
|
||||||
Param(_) | Static => false,
|
LifetimeName::Param(_) | LifetimeName::Static => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,7 +279,7 @@ impl LifetimeName {
|
||||||
|
|
||||||
pub fn modern(&self) -> LifetimeName {
|
pub fn modern(&self) -> LifetimeName {
|
||||||
match *self {
|
match *self {
|
||||||
LifetimeName::Ident(ident) => LifetimeName::Ident(ident.modern()),
|
LifetimeName::Param(param_name) => LifetimeName::Param(param_name.modern()),
|
||||||
lifetime_name => lifetime_name,
|
lifetime_name => lifetime_name,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -492,6 +497,7 @@ pub struct GenericParam {
|
||||||
pub name: ParamName,
|
pub name: ParamName,
|
||||||
pub attrs: HirVec<Attribute>,
|
pub attrs: HirVec<Attribute>,
|
||||||
pub bounds: GenericBounds,
|
pub bounds: GenericBounds,
|
||||||
|
pub span: Span,
|
||||||
pub pure_wrt_drop: bool,
|
pub pure_wrt_drop: bool,
|
||||||
|
|
||||||
pub kind: GenericParamKind,
|
pub kind: GenericParamKind,
|
||||||
|
|
|
@ -2113,7 +2113,7 @@ impl<'a> State<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_generic_param(&mut self, param: &GenericParam) -> io::Result<()> {
|
pub fn print_generic_param(&mut self, param: &GenericParam) -> io::Result<()> {
|
||||||
self.print_name(param.name.name())?;
|
self.print_ident(param.name.ident())?;
|
||||||
match param.kind {
|
match param.kind {
|
||||||
GenericParamKind::Lifetime { .. } => {
|
GenericParamKind::Lifetime { .. } => {
|
||||||
let mut sep = ":";
|
let mut sep = ":";
|
||||||
|
@ -2144,7 +2144,7 @@ impl<'a> State<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_lifetime(&mut self, lifetime: &hir::Lifetime) -> io::Result<()> {
|
pub fn print_lifetime(&mut self, lifetime: &hir::Lifetime) -> io::Result<()> {
|
||||||
self.print_name(lifetime.name.name())
|
self.print_ident(lifetime.name.ident())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_where_clause(&mut self, where_clause: &hir::WhereClause) -> io::Result<()> {
|
pub fn print_where_clause(&mut self, where_clause: &hir::WhereClause) -> io::Result<()> {
|
||||||
|
|
|
@ -203,6 +203,7 @@ impl_stable_hash_for!(struct hir::GenericParam {
|
||||||
pure_wrt_drop,
|
pure_wrt_drop,
|
||||||
attrs,
|
attrs,
|
||||||
bounds,
|
bounds,
|
||||||
|
span,
|
||||||
kind
|
kind
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -689,7 +689,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
||||||
GenericParamKind::Lifetime { .. } => {
|
GenericParamKind::Lifetime { .. } => {
|
||||||
let (name, reg) = Region::early(&self.tcx.hir, &mut index, ¶m);
|
let (name, reg) = Region::early(&self.tcx.hir, &mut index, ¶m);
|
||||||
if let hir::ParamName::Plain(param_name) = name {
|
if let hir::ParamName::Plain(param_name) = name {
|
||||||
if param_name == keywords::UnderscoreLifetime.name() {
|
if param_name.name == keywords::UnderscoreLifetime.name() {
|
||||||
// Pick the elided lifetime "definition" if one exists
|
// Pick the elided lifetime "definition" if one exists
|
||||||
// and use it to make an elision scope.
|
// and use it to make an elision scope.
|
||||||
elision = Some(reg);
|
elision = Some(reg);
|
||||||
|
@ -1175,7 +1175,7 @@ fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body) {
|
||||||
ref lifetimes, s, ..
|
ref lifetimes, s, ..
|
||||||
} => {
|
} => {
|
||||||
// FIXME (#24278): non-hygienic comparison
|
// FIXME (#24278): non-hygienic comparison
|
||||||
if let Some(def) = lifetimes.get(&hir::LifetimeName::Ident(label.modern())) {
|
if let Some(def) = lifetimes.get(&hir::ParamName::Plain(label.modern())) {
|
||||||
let node_id = tcx.hir.as_local_node_id(def.id().unwrap()).unwrap();
|
let node_id = tcx.hir.as_local_node_id(def.id().unwrap()).unwrap();
|
||||||
|
|
||||||
signal_shadowing_problem(
|
signal_shadowing_problem(
|
||||||
|
@ -1397,10 +1397,10 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||||
debug!("node id first={:?}", node_id);
|
debug!("node id first={:?}", node_id);
|
||||||
if let Some((id, span, name)) = match self.tcx.hir.get(node_id) {
|
if let Some((id, span, name)) = match self.tcx.hir.get(node_id) {
|
||||||
hir::map::NodeLifetime(hir_lifetime) => {
|
hir::map::NodeLifetime(hir_lifetime) => {
|
||||||
Some((hir_lifetime.id, hir_lifetime.span, hir_lifetime.name.name()))
|
Some((hir_lifetime.id, hir_lifetime.span, hir_lifetime.name.ident()))
|
||||||
}
|
}
|
||||||
hir::map::NodeGenericParam(param) => {
|
hir::map::NodeGenericParam(param) => {
|
||||||
Some((param.id, param.span, param.name.name()))
|
Some((param.id, param.span, param.name.ident()))
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
} {
|
} {
|
||||||
|
@ -1423,10 +1423,10 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||||
let node_id = self.tcx.hir.as_local_node_id(def_id).unwrap();
|
let node_id = self.tcx.hir.as_local_node_id(def_id).unwrap();
|
||||||
if let Some((id, span, name)) = match self.tcx.hir.get(node_id) {
|
if let Some((id, span, name)) = match self.tcx.hir.get(node_id) {
|
||||||
hir::map::NodeLifetime(hir_lifetime) => {
|
hir::map::NodeLifetime(hir_lifetime) => {
|
||||||
Some((hir_lifetime.id, hir_lifetime.span, hir_lifetime.name.name()))
|
Some((hir_lifetime.id, hir_lifetime.span, hir_lifetime.name.ident()))
|
||||||
}
|
}
|
||||||
hir::map::NodeGenericParam(param) => {
|
hir::map::NodeGenericParam(param) => {
|
||||||
Some((param.id, param.span, param.name.name()))
|
Some((param.id, param.span, param.name.ident()))
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
} {
|
} {
|
||||||
|
@ -2243,7 +2243,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||||
}).collect();
|
}).collect();
|
||||||
for (i, (lifetime_i, lifetime_i_name)) in lifetimes.iter().enumerate() {
|
for (i, (lifetime_i, lifetime_i_name)) in lifetimes.iter().enumerate() {
|
||||||
if let hir::ParamName::Plain(_) = lifetime_i_name {
|
if let hir::ParamName::Plain(_) = lifetime_i_name {
|
||||||
let name = lifetime_i_name.name();
|
let name = lifetime_i_name.ident().name;
|
||||||
if name == keywords::UnderscoreLifetime.name() ||
|
if name == keywords::UnderscoreLifetime.name() ||
|
||||||
name == keywords::StaticLifetime.name() {
|
name == keywords::StaticLifetime.name() {
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_err!(
|
||||||
|
@ -2251,7 +2251,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||||
lifetime_i.span,
|
lifetime_i.span,
|
||||||
E0262,
|
E0262,
|
||||||
"invalid lifetime parameter name: `{}`",
|
"invalid lifetime parameter name: `{}`",
|
||||||
lifetime
|
lifetime_i.name.ident(),
|
||||||
);
|
);
|
||||||
err.span_label(
|
err.span_label(
|
||||||
lifetime_i.span,
|
lifetime_i.span,
|
||||||
|
@ -2269,7 +2269,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||||
lifetime_j.span,
|
lifetime_j.span,
|
||||||
E0263,
|
E0263,
|
||||||
"lifetime name `{}` declared twice in the same scope",
|
"lifetime name `{}` declared twice in the same scope",
|
||||||
lifetime_j.name.name()
|
lifetime_j.name.ident()
|
||||||
).span_label(lifetime_j.span, "declared twice")
|
).span_label(lifetime_j.span, "declared twice")
|
||||||
.span_label(lifetime_i.span, "previous declaration here")
|
.span_label(lifetime_i.span, "previous declaration here")
|
||||||
.emit();
|
.emit();
|
||||||
|
@ -2298,12 +2298,12 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||||
lifetime_i.span.to(lt.span),
|
lifetime_i.span.to(lt.span),
|
||||||
&format!(
|
&format!(
|
||||||
"unnecessary lifetime parameter `{}`",
|
"unnecessary lifetime parameter `{}`",
|
||||||
lifetime_i.name.name(),
|
lifetime_i.name.ident(),
|
||||||
),
|
),
|
||||||
).help(&format!(
|
).help(&format!(
|
||||||
"you can use the `'static` lifetime directly, in place \
|
"you can use the `'static` lifetime directly, in place \
|
||||||
of `{}`",
|
of `{}`",
|
||||||
lifetime_i.name.name(),
|
lifetime_i.name.ident(),
|
||||||
)).emit();
|
)).emit();
|
||||||
}
|
}
|
||||||
hir::LifetimeName::Param(_)
|
hir::LifetimeName::Param(_)
|
||||||
|
@ -2549,7 +2549,7 @@ fn insert_late_bound_lifetimes(
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!("insert_late_bound_lifetimes: lifetime {:?} with id {:?} is late-bound",
|
debug!("insert_late_bound_lifetimes: lifetime {:?} with id {:?} is late-bound",
|
||||||
param.name.name(),
|
param.name.ident(),
|
||||||
param.id);
|
param.id);
|
||||||
|
|
||||||
let inserted = map.late_bound.insert(param.id);
|
let inserted = map.late_bound.insert(param.id);
|
||||||
|
|
|
@ -331,7 +331,7 @@ fn check_for_bindings_named_the_same_as_variants(cx: &MatchVisitor, pat: &Pat) {
|
||||||
err.span_suggestion_with_applicability(
|
err.span_suggestion_with_applicability(
|
||||||
p.span,
|
p.span,
|
||||||
"to match on the variant, qualify the path",
|
"to match on the variant, qualify the path",
|
||||||
format!("{}::{}", ty_path, name.node),
|
format!("{}::{}", ty_path, ident),
|
||||||
Applicability::MachineApplicable
|
Applicability::MachineApplicable
|
||||||
);
|
);
|
||||||
err.emit();
|
err.emit();
|
||||||
|
|
|
@ -1497,17 +1497,17 @@ impl<'a> hir::lowering::Resolver for Resolver<'a> {
|
||||||
args: Option<P<hir::GenericArgs>>,
|
args: Option<P<hir::GenericArgs>>,
|
||||||
is_value: bool
|
is_value: bool
|
||||||
) -> hir::Path {
|
) -> hir::Path {
|
||||||
let mut segments = iter::once(keywords::CrateRoot.name())
|
let mut segments = iter::once(keywords::CrateRoot.ident())
|
||||||
.chain(
|
.chain(
|
||||||
crate_root.into_iter()
|
crate_root.into_iter()
|
||||||
.chain(components.iter().cloned())
|
.chain(components.iter().cloned())
|
||||||
.map(Symbol::intern)
|
.map(Ident::from_str)
|
||||||
).map(hir::PathSegment::from_name).collect::<Vec<_>>();
|
).map(hir::PathSegment::from_ident).collect::<Vec<_>>();
|
||||||
|
|
||||||
if let Some(args) = args {
|
if let Some(args) = args {
|
||||||
let name = segments.last().unwrap().name;
|
let ident = segments.last().unwrap().ident;
|
||||||
*segments.last_mut().unwrap() = hir::PathSegment {
|
*segments.last_mut().unwrap() = hir::PathSegment {
|
||||||
name,
|
ident,
|
||||||
args: Some(args),
|
args: Some(args),
|
||||||
infer_types: true,
|
infer_types: true,
|
||||||
};
|
};
|
||||||
|
|
|
@ -3836,7 +3836,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
// ... except when we try to 'break rust;'.
|
// ... except when we try to 'break rust;'.
|
||||||
// ICE this expression in particular (see #43162).
|
// ICE this expression in particular (see #43162).
|
||||||
if let hir::ExprPath(hir::QPath::Resolved(_, ref path)) = e.node {
|
if let hir::ExprPath(hir::QPath::Resolved(_, ref path)) = e.node {
|
||||||
if path.segments.len() == 1 && path.segments[0].name == "rust" {
|
if path.segments.len() == 1 && path.segments[0].ident.name == "rust" {
|
||||||
fatally_break_rust(self.tcx.sess);
|
fatally_break_rust(self.tcx.sess);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,7 +251,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
|
||||||
match param.kind {
|
match param.kind {
|
||||||
ty::GenericParamDefKind::Lifetime => {
|
ty::GenericParamDefKind::Lifetime => {
|
||||||
let name = if param.name == "" {
|
let name = if param.name == "" {
|
||||||
hir::ParamName::Plain(keywords::StaticLifetime.name())
|
hir::ParamName::Plain(keywords::StaticLifetime.ident())
|
||||||
} else {
|
} else {
|
||||||
hir::ParamName::Plain(ast::Ident::from_interned_str(param.name))
|
hir::ParamName::Plain(ast::Ident::from_interned_str(param.name))
|
||||||
};
|
};
|
||||||
|
|
|
@ -1896,19 +1896,19 @@ impl Clean<GenericParamDef> for hir::GenericParam {
|
||||||
hir::GenericBound::Outlives(lt) => lt,
|
hir::GenericBound::Outlives(lt) => lt,
|
||||||
_ => panic!(),
|
_ => panic!(),
|
||||||
});
|
});
|
||||||
let name = bounds.next().unwrap().name.name();
|
let name = bounds.next().unwrap().name.ident();
|
||||||
let mut s = format!("{}: {}", self.name.name(), name);
|
let mut s = format!("{}: {}", self.name.ident(), name);
|
||||||
for bound in bounds {
|
for bound in bounds {
|
||||||
s.push_str(&format!(" + {}", bound.name.name()));
|
s.push_str(&format!(" + {}", bound.name.ident()));
|
||||||
}
|
}
|
||||||
s
|
s
|
||||||
} else {
|
} else {
|
||||||
self.name.name().to_string()
|
self.name.ident().to_string()
|
||||||
};
|
};
|
||||||
(name, GenericParamDefKind::Lifetime)
|
(name, GenericParamDefKind::Lifetime)
|
||||||
}
|
}
|
||||||
hir::GenericParamKind::Type { ref default, synthetic, .. } => {
|
hir::GenericParamKind::Type { ref default, synthetic, .. } => {
|
||||||
(self.name.name().clean(cx), GenericParamDefKind::Type {
|
(self.name.ident().name.clean(cx), GenericParamDefKind::Type {
|
||||||
did: cx.tcx.hir.local_def_id(self.id),
|
did: cx.tcx.hir.local_def_id(self.id),
|
||||||
bounds: self.bounds.clean(cx),
|
bounds: self.bounds.clean(cx),
|
||||||
default: default.clean(cx),
|
default: default.clean(cx),
|
||||||
|
|
|
@ -59,6 +59,11 @@ impl Ident {
|
||||||
Ident::new(Symbol::intern(self.as_str().trim_left_matches('\'')), self.span)
|
Ident::new(Symbol::intern(self.as_str().trim_left_matches('\'')), self.span)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// "Normalize" ident for use in comparisons using "item hygiene".
|
||||||
|
/// Identifiers with same string value become same if they came from the same "modern" macro
|
||||||
|
/// (e.g. `macro` item, but not `macro_rules` item) and stay different if they came from
|
||||||
|
/// different "modern" macros.
|
||||||
|
/// Technically, this operation strips all non-opaque marks from ident's syntactic context.
|
||||||
pub fn modern(self) -> Ident {
|
pub fn modern(self) -> Ident {
|
||||||
Ident::new(self.name, self.span.modern())
|
Ident::new(self.name, self.span.modern())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue