Skip to content

Commit 58adb07

Browse files
authored
Auto merge of #34291 - Manishearth:rollup, r=Manishearth
Rollup of 4 pull requests - Successful merges: #34207, #34268, #34270, #34290 - Failed merges:
2 parents bb4a79b + e3d6bb1 commit 58adb07

File tree

21 files changed

+126
-182
lines changed

21 files changed

+126
-182
lines changed

src/librustc/hir/lowering.rs

+6-29
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,9 @@ use std::collections::BTreeMap;
5151
use std::iter;
5252
use syntax::ast::*;
5353
use syntax::attr::{ThinAttributes, ThinAttributesExt};
54-
use syntax::ext::mtwt;
5554
use syntax::ptr::P;
5655
use syntax::codemap::{respan, Spanned, Span};
57-
use syntax::parse::token::{self, keywords};
56+
use syntax::parse::token;
5857
use syntax::std_inject;
5958
use syntax::visit::{self, Visitor};
6059

@@ -184,16 +183,8 @@ impl<'a> LoweringContext<'a> {
184183
result
185184
}
186185

187-
fn lower_ident(&mut self, ident: Ident) -> Name {
188-
if ident.name != keywords::Invalid.name() {
189-
mtwt::resolve(ident)
190-
} else {
191-
ident.name
192-
}
193-
}
194-
195186
fn lower_opt_sp_ident(&mut self, o_id: Option<Spanned<Ident>>) -> Option<Spanned<Name>> {
196-
o_id.map(|sp_ident| respan(sp_ident.span, self.lower_ident(sp_ident.node)))
187+
o_id.map(|sp_ident| respan(sp_ident.span, sp_ident.node.name))
197188
}
198189

199190
fn lower_attrs(&mut self, attrs: &Vec<Attribute>) -> hir::HirVec<Attribute> {
@@ -338,18 +329,14 @@ impl<'a> LoweringContext<'a> {
338329
}
339330
}
340331

341-
fn lower_path_full(&mut self, p: &Path, rename: bool) -> hir::Path {
332+
fn lower_path(&mut self, p: &Path) -> hir::Path {
342333
hir::Path {
343334
global: p.global,
344335
segments: p.segments
345336
.iter()
346337
.map(|&PathSegment { identifier, ref parameters }| {
347338
hir::PathSegment {
348-
name: if rename {
349-
self.lower_ident(identifier)
350-
} else {
351-
identifier.name
352-
},
339+
name: identifier.name,
353340
parameters: self.lower_path_parameters(parameters),
354341
}
355342
})
@@ -358,10 +345,6 @@ impl<'a> LoweringContext<'a> {
358345
}
359346
}
360347

361-
fn lower_path(&mut self, p: &Path) -> hir::Path {
362-
self.lower_path_full(p, false)
363-
}
364-
365348
fn lower_path_parameters(&mut self, path_parameters: &PathParameters) -> hir::PathParameters {
366349
match *path_parameters {
367350
PathParameters::AngleBracketed(ref data) =>
@@ -870,8 +853,7 @@ impl<'a> LoweringContext<'a> {
870853
// `None` can occur in body-less function signatures
871854
None | Some(Def::Local(..)) => {
872855
hir::PatKind::Binding(this.lower_binding_mode(binding_mode),
873-
respan(pth1.span,
874-
this.lower_ident(pth1.node)),
856+
respan(pth1.span, pth1.node.name),
875857
sub.as_ref().map(|x| this.lower_pat(x)))
876858
}
877859
_ => hir::PatKind::Path(hir::Path::from_name(pth1.span, pth1.node.name))
@@ -1238,12 +1220,7 @@ impl<'a> LoweringContext<'a> {
12381220
position: position,
12391221
}
12401222
});
1241-
// Only local variables are renamed
1242-
let rename = match self.resolver.get_resolution(e.id).map(|d| d.base_def) {
1243-
Some(Def::Local(..)) | Some(Def::Upvar(..)) => true,
1244-
_ => false,
1245-
};
1246-
hir::ExprPath(hir_qself, self.lower_path_full(path, rename))
1223+
hir::ExprPath(hir_qself, self.lower_path(path))
12471224
}
12481225
ExprKind::Break(opt_ident) => hir::ExprBreak(self.lower_opt_sp_ident(opt_ident)),
12491226
ExprKind::Again(opt_ident) => hir::ExprAgain(self.lower_opt_sp_ident(opt_ident)),

src/librustc/hir/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,7 @@ pub type ExplicitSelf = Spanned<SelfKind>;
11381138
impl Arg {
11391139
pub fn to_self(&self) -> Option<ExplicitSelf> {
11401140
if let PatKind::Binding(BindByValue(mutbl), name, _) = self.pat.node {
1141-
if name.node.unhygienize() == keywords::SelfValue.name() {
1141+
if name.node == keywords::SelfValue.name() {
11421142
return match self.ty.node {
11431143
TyInfer => Some(respan(self.pat.span, SelfKind::Value(mutbl))),
11441144
TyRptr(lt, MutTy{ref ty, mutbl}) if ty.node == TyInfer => {
@@ -1154,7 +1154,7 @@ impl Arg {
11541154

11551155
pub fn is_self(&self) -> bool {
11561156
if let PatKind::Binding(_, name, _) = self.pat.node {
1157-
name.node.unhygienize() == keywords::SelfValue.name()
1157+
name.node == keywords::SelfValue.name()
11581158
} else {
11591159
false
11601160
}

src/librustc/hir/print.rs

+17-24
Original file line numberDiff line numberDiff line change
@@ -1728,12 +1728,9 @@ impl<'a> State<'a> {
17281728
}
17291729
}
17301730
self.print_name(path1.node)?;
1731-
match *sub {
1732-
Some(ref p) => {
1733-
word(&mut self.s, "@")?;
1734-
self.print_pat(&p)?;
1735-
}
1736-
None => (),
1731+
if let Some(ref p) = *sub {
1732+
word(&mut self.s, "@")?;
1733+
self.print_pat(&p)?;
17371734
}
17381735
}
17391736
PatKind::TupleStruct(ref path, ref elts, ddpos) => {
@@ -2246,25 +2243,21 @@ impl<'a> State<'a> {
22462243
Some(cm) => cm,
22472244
_ => return Ok(()),
22482245
};
2249-
match self.next_comment() {
2250-
Some(ref cmnt) => {
2251-
if (*cmnt).style != comments::Trailing {
2252-
return Ok(());
2253-
}
2254-
let span_line = cm.lookup_char_pos(span.hi);
2255-
let comment_line = cm.lookup_char_pos((*cmnt).pos);
2256-
let mut next = (*cmnt).pos + BytePos(1);
2257-
match next_pos {
2258-
None => (),
2259-
Some(p) => next = p,
2260-
}
2261-
if span.hi < (*cmnt).pos && (*cmnt).pos < next &&
2262-
span_line.line == comment_line.line {
2263-
self.print_comment(cmnt)?;
2264-
self.cur_cmnt_and_lit.cur_cmnt += 1;
2265-
}
2246+
if let Some(ref cmnt) = self.next_comment() {
2247+
if (*cmnt).style != comments::Trailing {
2248+
return Ok(());
2249+
}
2250+
let span_line = cm.lookup_char_pos(span.hi);
2251+
let comment_line = cm.lookup_char_pos((*cmnt).pos);
2252+
let mut next = (*cmnt).pos + BytePos(1);
2253+
if let Some(p) = next_pos {
2254+
next = p;
2255+
}
2256+
if span.hi < (*cmnt).pos && (*cmnt).pos < next &&
2257+
span_line.line == comment_line.line {
2258+
self.print_comment(cmnt)?;
2259+
self.cur_cmnt_and_lit.cur_cmnt += 1;
22662260
}
2267-
_ => (),
22682261
}
22692262
Ok(())
22702263
}

src/librustc/infer/error_reporting.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -1856,20 +1856,18 @@ fn lifetimes_in_scope<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
18561856
},
18571857
None => None
18581858
};
1859-
if method_id_opt.is_some() {
1860-
let method_id = method_id_opt.unwrap();
1859+
if let Some(method_id) = method_id_opt {
18611860
let parent = tcx.map.get_parent(method_id);
1862-
match tcx.map.find(parent) {
1863-
Some(node) => match node {
1861+
if let Some(node) = tcx.map.find(parent) {
1862+
match node {
18641863
ast_map::NodeItem(item) => match item.node {
18651864
hir::ItemImpl(_, _, ref gen, _, _, _) => {
18661865
taken.extend_from_slice(&gen.lifetimes);
18671866
}
18681867
_ => ()
18691868
},
18701869
_ => ()
1871-
},
1872-
None => ()
1870+
}
18731871
}
18741872
}
18751873
return taken;
@@ -1938,4 +1936,3 @@ fn name_to_dummy_lifetime(name: ast::Name) -> hir::Lifetime {
19381936
span: codemap::DUMMY_SP,
19391937
name: name }
19401938
}
1941-

src/librustc/middle/dead.rs

+13-19
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,9 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
160160
}
161161
scanned.insert(id);
162162

163-
match self.tcx.map.find(id) {
164-
Some(ref node) => {
165-
self.live_symbols.insert(id);
166-
self.visit_node(node);
167-
}
168-
None => (),
163+
if let Some(ref node) = self.tcx.map.find(id) {
164+
self.live_symbols.insert(id);
165+
self.visit_node(node);
169166
}
170167
}
171168
}
@@ -372,9 +369,8 @@ fn create_and_seed_worklist<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
372369
}
373370

374371
// Seed entry point
375-
match *tcx.sess.entry_fn.borrow() {
376-
Some((id, _)) => worklist.push(id),
377-
None => ()
372+
if let Some((id, _)) = *tcx.sess.entry_fn.borrow() {
373+
worklist.push(id);
378374
}
379375

380376
// Seed implemented trait items
@@ -464,16 +460,14 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
464460
// method of a private type is used, but the type itself is never
465461
// called directly.
466462
let impl_items = self.tcx.impl_items.borrow();
467-
match self.tcx.inherent_impls.borrow().get(&self.tcx.map.local_def_id(id)) {
468-
None => (),
469-
Some(impl_list) => {
470-
for impl_did in impl_list.iter() {
471-
for item_did in impl_items.get(impl_did).unwrap().iter() {
472-
if let Some(item_node_id) =
473-
self.tcx.map.as_local_node_id(item_did.def_id()) {
474-
if self.live_symbols.contains(&item_node_id) {
475-
return true;
476-
}
463+
if let Some(impl_list) =
464+
self.tcx.inherent_impls.borrow().get(&self.tcx.map.local_def_id(id)) {
465+
for impl_did in impl_list.iter() {
466+
for item_did in impl_items.get(impl_did).unwrap().iter() {
467+
if let Some(item_node_id) =
468+
self.tcx.map.as_local_node_id(item_did.def_id()) {
469+
if self.live_symbols.contains(&item_node_id) {
470+
return true;
477471
}
478472
}
479473
}

src/librustc/middle/resolve_lifetime.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,7 @@ fn extract_labels(ctxt: &mut LifetimeContext, b: &hir::Block) {
456456
fn expression_label(ex: &hir::Expr) -> Option<(ast::Name, Span)> {
457457
match ex.node {
458458
hir::ExprWhile(_, _, Some(label)) |
459-
hir::ExprLoop(_, Some(label)) => Some((label.node.unhygienize(),
460-
label.span)),
459+
hir::ExprLoop(_, Some(label)) => Some((label.node, label.span)),
461460
_ => None,
462461
}
463462
}

src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,12 @@ fn gather_move<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
122122

123123
let potentially_illegal_move =
124124
check_and_get_illegal_move_origin(bccx, &move_info.cmt);
125-
match potentially_illegal_move {
126-
Some(illegal_move_origin) => {
127-
debug!("illegal_move_origin={:?}", illegal_move_origin);
128-
let error = MoveError::with_move_info(illegal_move_origin,
129-
move_info.span_path_opt);
130-
move_error_collector.add_error(error);
131-
return
132-
}
133-
None => ()
125+
if let Some(illegal_move_origin) = potentially_illegal_move {
126+
debug!("illegal_move_origin={:?}", illegal_move_origin);
127+
let error = MoveError::with_move_info(illegal_move_origin,
128+
move_info.span_path_opt);
129+
move_error_collector.add_error(error);
130+
return;
134131
}
135132

136133
match opt_loan_path(&move_info.cmt) {

src/librustc_const_eval/check_match.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,7 @@ fn check_for_bindings_named_the_same_as_variants(cx: &MatchCheckCtxt, pat: &Pat)
247247
if let ty::TyEnum(edef, _) = pat_ty.sty {
248248
if let Def::Local(..) = cx.tcx.expect_def(p.id) {
249249
if edef.variants.iter().any(|variant|
250-
variant.name == name.node.unhygienize()
251-
&& variant.kind() == VariantKind::Unit
250+
variant.name == name.node && variant.kind() == VariantKind::Unit
252251
) {
253252
let ty_path = cx.tcx.item_path_str(edef.did);
254253
let mut err = struct_span_warn!(cx.tcx.sess, p.span, E0170,

src/librustc_lint/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ impl LateLintPass for NonShorthandFieldPatterns {
163163
continue;
164164
}
165165
if let PatKind::Binding(_, ident, None) = fieldpat.node.pat.node {
166-
if ident.node.unhygienize() == fieldpat.node.name {
166+
if ident.node == fieldpat.node.name {
167167
cx.span_lint(NON_SHORTHAND_FIELD_PATTERNS, fieldpat.span,
168168
&format!("the `{}:` in this pattern is redundant and can \
169169
be removed", ident.node))

src/librustc_metadata/creader.rs

+20-23
Original file line numberDiff line numberDiff line change
@@ -929,29 +929,26 @@ impl<'a> LocalCrateReader<'a> {
929929
return;
930930
}
931931

932-
match self.creader.extract_crate_info(i) {
933-
Some(info) => {
934-
let (cnum, _, _) = self.creader.resolve_crate(&None,
935-
&info.ident,
936-
&info.name,
937-
None,
938-
i.span,
939-
PathKind::Crate,
940-
true);
941-
942-
let def_id = self.definitions.opt_local_def_id(i.id).unwrap();
943-
let len = self.definitions.def_path(def_id.index).data.len();
944-
945-
self.creader.update_extern_crate(cnum,
946-
ExternCrate {
947-
def_id: def_id,
948-
span: i.span,
949-
direct: true,
950-
path_len: len,
951-
});
952-
self.cstore.add_extern_mod_stmt_cnum(info.id, cnum);
953-
}
954-
None => ()
932+
if let Some(info) = self.creader.extract_crate_info(i) {
933+
let (cnum, _, _) = self.creader.resolve_crate(&None,
934+
&info.ident,
935+
&info.name,
936+
None,
937+
i.span,
938+
PathKind::Crate,
939+
true);
940+
941+
let def_id = self.definitions.opt_local_def_id(i.id).unwrap();
942+
let len = self.definitions.def_path(def_id.index).data.len();
943+
944+
self.creader.update_extern_crate(cnum,
945+
ExternCrate {
946+
def_id: def_id,
947+
span: i.span,
948+
direct: true,
949+
path_len: len,
950+
});
951+
self.cstore.add_extern_mod_stmt_cnum(info.id, cnum);
955952
}
956953
}
957954
ast::ItemKind::ForeignMod(ref fm) => self.process_foreign_mod(i, fm),

src/librustc_trans/base.rs

+8-11
Original file line numberDiff line numberDiff line change
@@ -2252,17 +2252,14 @@ pub fn update_linkage(ccx: &CrateContext,
22522252
}
22532253

22542254
fn set_global_section(ccx: &CrateContext, llval: ValueRef, i: &hir::Item) {
2255-
match attr::first_attr_value_str_by_name(&i.attrs, "link_section") {
2256-
Some(sect) => {
2257-
if contains_null(&sect) {
2258-
ccx.sess().fatal(&format!("Illegal null byte in link_section value: `{}`", &sect));
2259-
}
2260-
unsafe {
2261-
let buf = CString::new(sect.as_bytes()).unwrap();
2262-
llvm::LLVMSetSection(llval, buf.as_ptr());
2263-
}
2264-
},
2265-
None => ()
2255+
if let Some(sect) = attr::first_attr_value_str_by_name(&i.attrs, "link_section") {
2256+
if contains_null(&sect) {
2257+
ccx.sess().fatal(&format!("Illegal null byte in link_section value: `{}`", &sect));
2258+
}
2259+
unsafe {
2260+
let buf = CString::new(sect.as_bytes()).unwrap();
2261+
llvm::LLVMSetSection(llval, buf.as_ptr());
2262+
}
22662263
}
22672264
}
22682265

src/librustc_trans/debuginfo/create_scope_map.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub fn create_scope_map(cx: &CrateContext,
5151
for arg in args {
5252
pat_util::pat_bindings(&arg.pat, |_, node_id, _, path1| {
5353
scope_stack.push(ScopeStackEntry { scope_metadata: fn_metadata,
54-
name: Some(path1.node.unhygienize()) });
54+
name: Some(path1.node) });
5555
scope_map.insert(node_id, fn_metadata);
5656
})
5757
}
@@ -260,7 +260,7 @@ fn walk_pattern(cx: &CrateContext,
260260
// N.B.: this comparison must be UNhygienic... because
261261
// gdb knows nothing about the context, so any two
262262
// variables with the same name will cause the problem.
263-
let name = path1.node.unhygienize();
263+
let name = path1.node;
264264
let need_new_scope = scope_stack
265265
.iter()
266266
.any(|entry| entry.name == Some(name));

src/librustc_trans/debuginfo/metadata.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -874,9 +874,8 @@ pub fn unknown_file_metadata(cx: &CrateContext) -> DIFile {
874874
}
875875

876876
fn file_metadata_(cx: &CrateContext, key: &str, file_name: &str, work_dir: &str) -> DIFile {
877-
match debug_context(cx).created_files.borrow().get(key) {
878-
Some(file_metadata) => return *file_metadata,
879-
None => ()
877+
if let Some(file_metadata) = debug_context(cx).created_files.borrow().get(key) {
878+
return *file_metadata;
880879
}
881880

882881
debug!("file_metadata: file_name: {}, work_dir: {}", file_name, work_dir);

0 commit comments

Comments
 (0)