Don't gensym Self
parameters
This commit is contained in:
parent
2f6babbc6d
commit
6b152f83c7
2 changed files with 2 additions and 25 deletions
|
@ -2886,15 +2886,6 @@ impl<'a> LoweringContext<'a> {
|
||||||
(param_name, kind)
|
(param_name, kind)
|
||||||
}
|
}
|
||||||
GenericParamKind::Type { ref default, .. } => {
|
GenericParamKind::Type { ref default, .. } => {
|
||||||
// Don't expose `Self` (recovered "keyword used as ident" parse error).
|
|
||||||
// `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.
|
|
||||||
let ident = if param.ident.name == kw::SelfUpper {
|
|
||||||
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() {
|
||||||
let params = self.lower_param_bounds(add_bounds, itctx.reborrow()).into_iter();
|
let params = self.lower_param_bounds(add_bounds, itctx.reborrow()).into_iter();
|
||||||
|
@ -2913,7 +2904,7 @@ impl<'a> LoweringContext<'a> {
|
||||||
.next(),
|
.next(),
|
||||||
};
|
};
|
||||||
|
|
||||||
(hir::ParamName::Plain(ident), kind)
|
(hir::ParamName::Plain(param.ident), kind)
|
||||||
}
|
}
|
||||||
GenericParamKind::Const { ref ty } => {
|
GenericParamKind::Const { ref ty } => {
|
||||||
(hir::ParamName::Plain(param.ident), hir::GenericParamKind::Const {
|
(hir::ParamName::Plain(param.ident), hir::GenericParamKind::Const {
|
||||||
|
|
|
@ -1011,13 +1011,6 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::Generics {
|
||||||
synthetic,
|
synthetic,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
if param.name.ident().name == kw::SelfUpper {
|
|
||||||
span_bug!(
|
|
||||||
param.span,
|
|
||||||
"`Self` should not be the name of a regular parameter"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if !allow_defaults && default.is_some() {
|
if !allow_defaults && default.is_some() {
|
||||||
if !tcx.features().default_type_parameter_fallback {
|
if !tcx.features().default_type_parameter_fallback {
|
||||||
tcx.lint_hir(
|
tcx.lint_hir(
|
||||||
|
@ -1041,13 +1034,6 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::Generics {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GenericParamKind::Const { .. } => {
|
GenericParamKind::Const { .. } => {
|
||||||
if param.name.ident().name == kw::SelfUpper {
|
|
||||||
span_bug!(
|
|
||||||
param.span,
|
|
||||||
"`Self` should not be the name of a regular parameter",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
ty::GenericParamDefKind::Const
|
ty::GenericParamDefKind::Const
|
||||||
}
|
}
|
||||||
_ => return None,
|
_ => return None,
|
||||||
|
@ -1569,7 +1555,7 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
|
||||||
&format!(
|
&format!(
|
||||||
"defining opaque type use restricts opaque \
|
"defining opaque type use restricts opaque \
|
||||||
type by using the generic parameter `{}` twice",
|
type by using the generic parameter `{}` twice",
|
||||||
p.name
|
p,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue