Skip to content

Commit 6b152f8

Browse files
committed
Don't gensym Self parameters
1 parent 2f6babb commit 6b152f8

File tree

2 files changed

+2
-25
lines changed

2 files changed

+2
-25
lines changed

src/librustc/hir/lowering.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -2886,15 +2886,6 @@ impl<'a> LoweringContext<'a> {
28862886
(param_name, kind)
28872887
}
28882888
GenericParamKind::Type { ref default, .. } => {
2889-
// Don't expose `Self` (recovered "keyword used as ident" parse error).
2890-
// `rustc::ty` expects `Self` to be only used for a trait's `Self`.
2891-
// Instead, use `gensym("Self")` to create a distinct name that looks the same.
2892-
let ident = if param.ident.name == kw::SelfUpper {
2893-
param.ident.gensym()
2894-
} else {
2895-
param.ident
2896-
};
2897-
28982889
let add_bounds = add_bounds.get(&param.id).map_or(&[][..], |x| &x);
28992890
if !add_bounds.is_empty() {
29002891
let params = self.lower_param_bounds(add_bounds, itctx.reborrow()).into_iter();
@@ -2913,7 +2904,7 @@ impl<'a> LoweringContext<'a> {
29132904
.next(),
29142905
};
29152906

2916-
(hir::ParamName::Plain(ident), kind)
2907+
(hir::ParamName::Plain(param.ident), kind)
29172908
}
29182909
GenericParamKind::Const { ref ty } => {
29192910
(hir::ParamName::Plain(param.ident), hir::GenericParamKind::Const {

src/librustc_typeck/collect.rs

+1-15
Original file line numberDiff line numberDiff line change
@@ -1011,13 +1011,6 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::Generics {
10111011
synthetic,
10121012
..
10131013
} => {
1014-
if param.name.ident().name == kw::SelfUpper {
1015-
span_bug!(
1016-
param.span,
1017-
"`Self` should not be the name of a regular parameter"
1018-
);
1019-
}
1020-
10211014
if !allow_defaults && default.is_some() {
10221015
if !tcx.features().default_type_parameter_fallback {
10231016
tcx.lint_hir(
@@ -1041,13 +1034,6 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::Generics {
10411034
}
10421035
}
10431036
GenericParamKind::Const { .. } => {
1044-
if param.name.ident().name == kw::SelfUpper {
1045-
span_bug!(
1046-
param.span,
1047-
"`Self` should not be the name of a regular parameter",
1048-
);
1049-
}
1050-
10511037
ty::GenericParamDefKind::Const
10521038
}
10531039
_ => return None,
@@ -1569,7 +1555,7 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
15691555
&format!(
15701556
"defining opaque type use restricts opaque \
15711557
type by using the generic parameter `{}` twice",
1572-
p.name
1558+
p,
15731559
),
15741560
);
15751561
return;

0 commit comments

Comments
 (0)