Skip to content

Commit 1faa096

Browse files
author
Jakub Bukaj
committed
rollup merge of #19073: jakub-/issue-19069
Fixes #19069. These were never intended not to be feature-gated but this PR is nonetheless a... [breaking-change]
2 parents 8997b09 + bde225e commit 1faa096

File tree

10 files changed

+55
-19
lines changed

10 files changed

+55
-19
lines changed

src/librustc/lint/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ impl LintPass for NonSnakeCase {
994994
self.check_snake_case(cx, "trait method", t.ident, t.span);
995995
}
996996

997-
fn check_lifetime_decl(&mut self, cx: &Context, t: &ast::LifetimeDef) {
997+
fn check_lifetime_def(&mut self, cx: &Context, t: &ast::LifetimeDef) {
998998
self.check_snake_case(cx, "lifetime", t.lifetime.name.ident(), t.lifetime.span);
999999
}
10001000

src/librustc/lint/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,8 +725,8 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> {
725725
run_lints!(self, check_lifetime_ref, lt);
726726
}
727727

728-
fn visit_lifetime_decl(&mut self, lt: &ast::LifetimeDef) {
729-
run_lints!(self, check_lifetime_decl, lt);
728+
fn visit_lifetime_def(&mut self, lt: &ast::LifetimeDef) {
729+
run_lints!(self, check_lifetime_def, lt);
730730
}
731731

732732
fn visit_explicit_self(&mut self, es: &ast::ExplicitSelf) {

src/librustc/lint/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ pub trait LintPass {
155155
fn check_variant_post(&mut self, _: &Context, _: &ast::Variant, _: &ast::Generics) { }
156156
fn check_opt_lifetime_ref(&mut self, _: &Context, _: Span, _: &Option<ast::Lifetime>) { }
157157
fn check_lifetime_ref(&mut self, _: &Context, _: &ast::Lifetime) { }
158-
fn check_lifetime_decl(&mut self, _: &Context, _: &ast::LifetimeDef) { }
158+
fn check_lifetime_def(&mut self, _: &Context, _: &ast::LifetimeDef) { }
159159
fn check_explicit_self(&mut self, _: &Context, _: &ast::ExplicitSelf) { }
160160
fn check_mac(&mut self, _: &Context, _: &ast::Mac) { }
161161
fn check_path(&mut self, _: &Context, _: &ast::Path, _: ast::NodeId) { }

src/librustc/middle/resolve_lifetime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
226226
self.with(LateScope(&trait_ref.bound_lifetimes, self.scope), |this| {
227227
this.check_lifetime_defs(&trait_ref.bound_lifetimes);
228228
for lifetime in trait_ref.bound_lifetimes.iter() {
229-
this.visit_lifetime_decl(lifetime);
229+
this.visit_lifetime_def(lifetime);
230230
}
231231
this.visit_trait_ref(&trait_ref.trait_ref)
232232
})

src/librustc_back/svh.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ mod svh_visitor {
181181
SawStructDef(token::InternedString),
182182

183183
SawLifetimeRef(token::InternedString),
184-
SawLifetimeDecl(token::InternedString),
184+
SawLifetimeDef(token::InternedString),
185185

186186
SawMod,
187187
SawViewItem,
@@ -414,8 +414,8 @@ mod svh_visitor {
414414
SawLifetimeRef(content(l.name)).hash(self.st);
415415
}
416416

417-
fn visit_lifetime_decl(&mut self, l: &LifetimeDef) {
418-
SawLifetimeDecl(content(l.lifetime.name)).hash(self.st);
417+
fn visit_lifetime_def(&mut self, l: &LifetimeDef) {
418+
SawLifetimeDef(content(l.lifetime.name)).hash(self.st);
419419
}
420420

421421
// We do recursively walk the bodies of functions/methods

src/libsyntax/ast_map/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
866866
self.insert(lifetime.id, NodeLifetime(lifetime));
867867
}
868868

869-
fn visit_lifetime_decl(&mut self, def: &'ast LifetimeDef) {
869+
fn visit_lifetime_def(&mut self, def: &'ast LifetimeDef) {
870870
self.visit_lifetime_ref(&def.lifetime);
871871
}
872872
}

src/libsyntax/ast_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ impl<'a, 'v, O: IdVisitingOperation> Visitor<'v> for IdVisitor<'a, O> {
535535
self.operation.visit_id(lifetime.id);
536536
}
537537

538-
fn visit_lifetime_decl(&mut self, def: &'v LifetimeDef) {
538+
fn visit_lifetime_def(&mut self, def: &'v LifetimeDef) {
539539
self.visit_lifetime_ref(&def.lifetime);
540540
}
541541
}

src/libsyntax/feature_gate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ impl<'a> Context<'a> {
141141
}
142142

143143
impl<'a, 'v> Visitor<'v> for Context<'a> {
144-
fn visit_ident(&mut self, sp: Span, id: ast::Ident) {
145-
if !token::get_ident(id).get().is_ascii() {
144+
fn visit_name(&mut self, sp: Span, name: ast::Name) {
145+
if !token::get_name(name).get().is_ascii() {
146146
self.gate_feature("non_ascii_idents", sp,
147147
"non-ascii idents are not fully supported.");
148148
}

src/libsyntax/visit.rs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,11 @@ pub enum FnKind<'a> {
5555
/// new default implementation gets introduced.)
5656
pub trait Visitor<'v> {
5757

58-
fn visit_ident(&mut self, _sp: Span, _ident: Ident) {
59-
/*! Visit the idents */
58+
fn visit_name(&mut self, _span: Span, _name: Name) {
59+
// Nothing to do.
60+
}
61+
fn visit_ident(&mut self, span: Span, ident: Ident) {
62+
self.visit_name(span, ident.name);
6063
}
6164
fn visit_mod(&mut self, m: &'v Mod, _s: Span, _n: NodeId) { walk_mod(self, m) }
6265
fn visit_view_item(&mut self, i: &'v ViewItem) { walk_view_item(self, i) }
@@ -102,11 +105,11 @@ pub trait Visitor<'v> {
102105
None => ()
103106
}
104107
}
105-
fn visit_lifetime_ref(&mut self, _lifetime: &'v Lifetime) {
106-
/*! Visits a reference to a lifetime */
108+
fn visit_lifetime_ref(&mut self, lifetime: &'v Lifetime) {
109+
self.visit_name(lifetime.span, lifetime.name)
107110
}
108-
fn visit_lifetime_decl(&mut self, _lifetime: &'v LifetimeDef) {
109-
/*! Visits a declaration of a lifetime */
111+
fn visit_lifetime_def(&mut self, lifetime: &'v LifetimeDef) {
112+
walk_lifetime_def(self, lifetime)
110113
}
111114
fn visit_explicit_self(&mut self, es: &'v ExplicitSelf) {
112115
walk_explicit_self(self, es)
@@ -207,6 +210,14 @@ pub fn walk_local<'v, V: Visitor<'v>>(visitor: &mut V, local: &'v Local) {
207210
walk_expr_opt(visitor, &local.init);
208211
}
209212

213+
pub fn walk_lifetime_def<'v, V: Visitor<'v>>(visitor: &mut V,
214+
lifetime_def: &'v LifetimeDef) {
215+
visitor.visit_lifetime_ref(&lifetime_def.lifetime);
216+
for bound in lifetime_def.bounds.iter() {
217+
visitor.visit_lifetime_ref(bound);
218+
}
219+
}
220+
210221
pub fn walk_explicit_self<'v, V: Visitor<'v>>(visitor: &mut V,
211222
explicit_self: &'v ExplicitSelf) {
212223
match explicit_self.node {
@@ -424,7 +435,7 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
424435
pub fn walk_lifetime_decls_helper<'v, V: Visitor<'v>>(visitor: &mut V,
425436
lifetimes: &'v Vec<LifetimeDef>) {
426437
for l in lifetimes.iter() {
427-
visitor.visit_lifetime_decl(l);
438+
visitor.visit_lifetime_def(l);
428439
}
429440
}
430441

@@ -555,6 +566,7 @@ pub fn walk_ty_param_bound<'v, V: Visitor<'v>>(visitor: &mut V,
555566

556567
pub fn walk_generics<'v, V: Visitor<'v>>(visitor: &mut V, generics: &'v Generics) {
557568
for type_parameter in generics.ty_params.iter() {
569+
visitor.visit_ident(type_parameter.span, type_parameter.ident);
558570
walk_ty_param_bounds_helper(visitor, &type_parameter.bounds);
559571
match type_parameter.default {
560572
Some(ref ty) => visitor.visit_ty(&**ty),

src/test/compile-fail/utf8_idents.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
//
11+
// ignore-lexer-test FIXME #15679
12+
13+
fn foo<
14+
'β, //~ ERROR non-ascii idents are not fully supported.
15+
γ //~ ERROR non-ascii idents are not fully supported.
16+
>() {}
17+
18+
struct X {
19+
δ: uint //~ ERROR non-ascii idents are not fully supported.
20+
}
21+
22+
pub fn main() {
23+
let α = 0.00001f64; //~ ERROR non-ascii idents are not fully supported.
24+
}

0 commit comments

Comments
 (0)