Skip to content

Commit 0aa72ad

Browse files
authored
Rollup merge of rust-lang#56426 - petrochenkov:syntweak, r=nikomatsakis
libsyntax_pos: A few tweaks
2 parents e57ed0d + d08f7dc commit 0aa72ad

File tree

32 files changed

+119
-136
lines changed

32 files changed

+119
-136
lines changed

src/grammar/parser-lalr.y

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,14 +741,14 @@ fn_anon_params
741741
;
742742

743743
fn_params_with_self
744-
: '(' maybe_mut SELF maybe_ty_ascription maybe_comma_params ')' { $$ = mk_node("SelfValue", 3, $2, $4, $5); }
744+
: '(' maybe_mut SELF maybe_ty_ascription maybe_comma_params ')' { $$ = mk_node("SelfLower", 3, $2, $4, $5); }
745745
| '(' '&' maybe_mut SELF maybe_ty_ascription maybe_comma_params ')' { $$ = mk_node("SelfRegion", 3, $3, $5, $6); }
746746
| '(' '&' lifetime maybe_mut SELF maybe_ty_ascription maybe_comma_params ')' { $$ = mk_node("SelfRegion", 4, $3, $4, $6, $7); }
747747
| '(' maybe_params ')' { $$ = mk_node("SelfStatic", 1, $2); }
748748
;
749749

750750
fn_anon_params_with_self
751-
: '(' maybe_mut SELF maybe_ty_ascription maybe_comma_anon_params ')' { $$ = mk_node("SelfValue", 3, $2, $4, $5); }
751+
: '(' maybe_mut SELF maybe_ty_ascription maybe_comma_anon_params ')' { $$ = mk_node("SelfLower", 3, $2, $4, $5); }
752752
| '(' '&' maybe_mut SELF maybe_ty_ascription maybe_comma_anon_params ')' { $$ = mk_node("SelfRegion", 3, $3, $5, $6); }
753753
| '(' '&' lifetime maybe_mut SELF maybe_ty_ascription maybe_comma_anon_params ')' { $$ = mk_node("SelfRegion", 4, $3, $4, $6, $7); }
754754
| '(' maybe_anon_params ')' { $$ = mk_node("SelfStatic", 1, $2); }

src/librustc/hir/lowering.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,7 @@ impl<'a> LoweringContext<'a> {
12011201
None,
12021202
P(hir::Path {
12031203
def: self.expect_full_def(t.id),
1204-
segments: hir_vec![hir::PathSegment::from_ident(keywords::SelfType.ident())],
1204+
segments: hir_vec![hir::PathSegment::from_ident(keywords::SelfUpper.ident())],
12051205
span: t.span,
12061206
}),
12071207
)),
@@ -2425,7 +2425,7 @@ impl<'a> LoweringContext<'a> {
24252425
// Don't expose `Self` (recovered "keyword used as ident" parse error).
24262426
// `rustc::ty` expects `Self` to be only used for a trait's `Self`.
24272427
// Instead, use gensym("Self") to create a distinct name that looks the same.
2428-
let ident = if param.ident.name == keywords::SelfType.name() {
2428+
let ident = if param.ident.name == keywords::SelfUpper.name() {
24292429
param.ident.gensym()
24302430
} else {
24312431
param.ident
@@ -2981,7 +2981,7 @@ impl<'a> LoweringContext<'a> {
29812981

29822982
// Correctly resolve `self` imports
29832983
if path.segments.len() > 1
2984-
&& path.segments.last().unwrap().ident.name == keywords::SelfValue.name()
2984+
&& path.segments.last().unwrap().ident.name == keywords::SelfLower.name()
29852985
{
29862986
let _ = path.segments.pop();
29872987
if rename.is_none() {

src/librustc/hir/map/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ impl<'hir> Map<'hir> {
475475

476476
pub fn ty_param_name(&self, id: NodeId) -> Name {
477477
match self.get(id) {
478-
Node::Item(&Item { node: ItemKind::Trait(..), .. }) => keywords::SelfType.name(),
478+
Node::Item(&Item { node: ItemKind::Trait(..), .. }) => keywords::SelfUpper.name(),
479479
Node::GenericParam(param) => param.name.ident().name,
480480
_ => bug!("ty_param_name: {} not a type parameter", self.node_to_string(id)),
481481
}

src/librustc/hir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ pub struct Path {
311311

312312
impl Path {
313313
pub fn is_global(&self) -> bool {
314-
!self.segments.is_empty() && self.segments[0].ident.name == keywords::CrateRoot.name()
314+
!self.segments.is_empty() && self.segments[0].ident.name == keywords::PathRoot.name()
315315
}
316316
}
317317

src/librustc/hir/print.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,7 +1622,7 @@ impl<'a> State<'a> {
16221622
if i > 0 {
16231623
self.s.word("::")?
16241624
}
1625-
if segment.ident.name != keywords::CrateRoot.name() &&
1625+
if segment.ident.name != keywords::PathRoot.name() &&
16261626
segment.ident.name != keywords::DollarCrate.name() {
16271627
self.print_ident(segment.ident)?;
16281628
segment.with_generic_args(|generic_args| {
@@ -1636,7 +1636,7 @@ impl<'a> State<'a> {
16361636
}
16371637

16381638
pub fn print_path_segment(&mut self, segment: &hir::PathSegment) -> io::Result<()> {
1639-
if segment.ident.name != keywords::CrateRoot.name() &&
1639+
if segment.ident.name != keywords::PathRoot.name() &&
16401640
segment.ident.name != keywords::DollarCrate.name() {
16411641
self.print_ident(segment.ident)?;
16421642
segment.with_generic_args(|generic_args| {
@@ -1664,7 +1664,7 @@ impl<'a> State<'a> {
16641664
if i > 0 {
16651665
self.s.word("::")?
16661666
}
1667-
if segment.ident.name != keywords::CrateRoot.name() &&
1667+
if segment.ident.name != keywords::PathRoot.name() &&
16681668
segment.ident.name != keywords::DollarCrate.name() {
16691669
self.print_ident(segment.ident)?;
16701670
segment.with_generic_args(|generic_args| {

src/librustc/ich/impls_syntax.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,10 @@ impl_stable_hash_for!(struct ::syntax::attr::Stability {
134134
const_stability
135135
});
136136

137-
impl<'a> HashStable<StableHashingContext<'a>>
138-
for ::syntax::edition::Edition {
139-
fn hash_stable<W: StableHasherResult>(&self,
140-
hcx: &mut StableHashingContext<'a>,
141-
hasher: &mut StableHasher<W>) {
142-
mem::discriminant(self).hash_stable(hcx, hasher);
143-
}
144-
}
137+
impl_stable_hash_for!(enum ::syntax::edition::Edition {
138+
Edition2015,
139+
Edition2018,
140+
});
145141

146142
impl<'a> HashStable<StableHashingContext<'a>>
147143
for ::syntax::attr::StabilityLevel {

src/librustc/middle/liveness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1575,7 +1575,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
15751575
let sp = ident.span;
15761576
let var = self.variable(hir_id, sp);
15771577
// Ignore unused self.
1578-
if ident.name != keywords::SelfValue.name() {
1578+
if ident.name != keywords::SelfLower.name() {
15791579
if !self.warn_about_unused(sp, hir_id, entry_ln, var) {
15801580
if self.live_on_entry(entry_ln, var).is_none() {
15811581
self.report_dead_assign(hir_id, sp, var, true);

src/librustc/ty/context.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,12 +1493,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
14931493
BorrowckMode::Ast => match self.sess.edition() {
14941494
Edition::Edition2015 => BorrowckMode::Ast,
14951495
Edition::Edition2018 => BorrowckMode::Migrate,
1496-
1497-
// For now, future editions mean Migrate. (But it
1498-
// would make a lot of sense for it to be changed to
1499-
// `BorrowckMode::Mir`, depending on how we plan to
1500-
// time the forcing of full migration to NLL.)
1501-
_ => BorrowckMode::Migrate,
15021496
},
15031497
}
15041498
}
@@ -2710,7 +2704,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
27102704

27112705
#[inline]
27122706
pub fn mk_self_type(self) -> Ty<'tcx> {
2713-
self.mk_ty_param(0, keywords::SelfType.name().as_interned_str())
2707+
self.mk_ty_param(0, keywords::SelfUpper.name().as_interned_str())
27142708
}
27152709

27162710
pub fn mk_param_from_def(self, param: &ty::GenericParamDef) -> Kind<'tcx> {

src/librustc/ty/sty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ impl<'a, 'gcx, 'tcx> ParamTy {
10201020
}
10211021

10221022
pub fn for_self() -> ParamTy {
1023-
ParamTy::new(0, keywords::SelfType.name().as_interned_str())
1023+
ParamTy::new(0, keywords::SelfUpper.name().as_interned_str())
10241024
}
10251025

10261026
pub fn for_def(def: &ty::GenericParamDef) -> ParamTy {
@@ -1035,7 +1035,7 @@ impl<'a, 'gcx, 'tcx> ParamTy {
10351035
// FIXME(#50125): Ignoring `Self` with `idx != 0` might lead to weird behavior elsewhere,
10361036
// but this should only be possible when using `-Z continue-parse-after-error` like
10371037
// `compile-fail/issue-36638.rs`.
1038-
self.name == keywords::SelfType.name().as_str() && self.idx == 0
1038+
self.name == keywords::SelfUpper.name().as_str() && self.idx == 0
10391039
}
10401040
}
10411041

src/librustc_lint/unused.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ impl UnusedImportBraces {
473473
match items[0].0.kind {
474474
ast::UseTreeKind::Simple(rename, ..) => {
475475
let orig_ident = items[0].0.prefix.segments.last().unwrap().ident;
476-
if orig_ident.name == keywords::SelfValue.name() {
476+
if orig_ident.name == keywords::SelfLower.name() {
477477
return;
478478
}
479479
node_ident = rename.unwrap_or(orig_ident);

0 commit comments

Comments
 (0)