Skip to content

Commit cbc86da

Browse files
committed
---
yaml --- r: 232936 b: refs/heads/try c: 0c29243 h: refs/heads/master v: v3
1 parent 782f7a1 commit cbc86da

File tree

19 files changed

+724
-637
lines changed

19 files changed

+724
-637
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: edeb4f1c86cbf6af8ef9874d4b3af50f721ea1b8
33
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
4-
refs/heads/try: 865d6c3b5b8aa66109b08e1f73721e06116cc727
4+
refs/heads/try: 0c2924386d7a88c5986cdc7b2928a849881a7af0
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/src/doc/trpl/structs.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
% Structs
22

3-
Structs are a way of creating more complex data types. For example, if we were
3+
`struct`s are a way of creating more complex data types. For example, if we were
44
doing calculations involving coordinates in 2D space, we would need both an `x`
55
and a `y` value:
66

@@ -9,7 +9,7 @@ let origin_x = 0;
99
let origin_y = 0;
1010
```
1111

12-
A struct lets us combine these two into a single, unified datatype:
12+
A `struct` lets us combine these two into a single, unified datatype:
1313

1414
```rust
1515
struct Point {
@@ -28,14 +28,14 @@ There’s a lot going on here, so let’s break it down. We declare a `struct` w
2828
the `struct` keyword, and then with a name. By convention, `struct`s begin with
2929
a capital letter and are camel cased: `PointInSpace`, not `Point_In_Space`.
3030

31-
We can create an instance of our struct via `let`, as usual, but we use a `key:
31+
We can create an instance of our `struct` via `let`, as usual, but we use a `key:
3232
value` style syntax to set each field. The order doesn’t need to be the same as
3333
in the original declaration.
3434

3535
Finally, because fields have names, we can access the field through dot
3636
notation: `origin.x`.
3737

38-
The values in structs are immutable by default, like other bindings in Rust.
38+
The values in `struct`s are immutable by default, like other bindings in Rust.
3939
Use `mut` to make them mutable:
4040

4141
```rust
@@ -91,7 +91,7 @@ fn main() {
9191
# Update syntax
9292

9393
A `struct` can include `..` to indicate that you want to use a copy of some
94-
other struct for some of the values. For example:
94+
other `struct` for some of the values. For example:
9595

9696
```rust
9797
struct Point3d {
@@ -121,7 +121,7 @@ let point = Point3d { z: 1, x: 2, .. origin };
121121
# Tuple structs
122122

123123
Rust has another data type that’s like a hybrid between a [tuple][tuple] and a
124-
struct, called a ‘tuple struct’. Tuple structs have a name, but
124+
`struct`, called a ‘tuple struct’. Tuple structs have a name, but
125125
their fields don’t:
126126

127127
```rust
@@ -140,7 +140,7 @@ let black = Color(0, 0, 0);
140140
let origin = Point(0, 0, 0);
141141
```
142142

143-
It is almost always better to use a struct than a tuple struct. We would write
143+
It is almost always better to use a `struct` than a tuple struct. We would write
144144
`Color` and `Point` like this instead:
145145

146146
```rust
@@ -158,7 +158,7 @@ struct Point {
158158
```
159159

160160
Now, we have actual names, rather than positions. Good names are important,
161-
and with a struct, we have actual names.
161+
and with a `struct`, we have actual names.
162162

163163
There _is_ one case when a tuple struct is very useful, though, and that’s a
164164
tuple struct with only one element. We call this the ‘newtype’ pattern, because
@@ -180,13 +180,13 @@ destructuring `let`, just as with regular tuples. In this case, the
180180

181181
# Unit-like structs
182182

183-
You can define a struct with no members at all:
183+
You can define a `struct` with no members at all:
184184

185185
```rust
186186
struct Electron;
187187
```
188188

189-
Such a struct is called ‘unit-like’ because it resembles the empty
189+
Such a `struct` is called ‘unit-like’ because it resembles the empty
190190
tuple, `()`, sometimes called ‘unit’. Like a tuple struct, it defines a
191191
new type.
192192

@@ -195,6 +195,6 @@ marker type), but in combination with other features, it can become
195195
useful. For instance, a library may ask you to create a structure that
196196
implements a certain [trait][trait] to handle events. If you don’t have
197197
any data you need to store in the structure, you can just create a
198-
unit-like struct.
198+
unit-like `struct`.
199199

200200
[trait]: traits.html

branches/try/src/librustc/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
#![feature(rustc_diagnostic_macros)]
5252
#![feature(rustc_private)]
5353
#![feature(scoped_tls)]
54-
#![feature(slice_bytes)]
5554
#![feature(slice_splits)]
5655
#![feature(slice_patterns)]
5756
#![feature(staged_api)]

branches/try/src/librustc/lint/context.rs

Lines changed: 44 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@ use std::cell::RefCell;
3737
use std::cmp;
3838
use std::mem;
3939
use syntax::ast_util::IdVisitingOperation;
40-
use syntax::attr::AttrMetaMethods;
41-
use syntax::attr;
40+
use rustc_front::attr::{self, AttrMetaMethods};
41+
use rustc_front::util;
4242
use syntax::codemap::Span;
43-
use syntax::visit::{Visitor, FnKind};
4443
use syntax::parse::token::InternedString;
45-
use syntax::{ast, ast_util, visit};
44+
use syntax::ast;
45+
use rustc_front::hir;
46+
use rustc_front::visit::{self, Visitor, FnKind};
47+
use syntax::visit::Visitor as SyntaxVisitor;
4648
use syntax::diagnostic;
4749

4850
/// Information about the registered lints.
@@ -252,7 +254,7 @@ pub struct Context<'a, 'tcx: 'a> {
252254
pub tcx: &'a ty::ctxt<'tcx>,
253255

254256
/// The crate being checked.
255-
pub krate: &'a ast::Crate,
257+
pub krate: &'a hir::Crate,
256258

257259
/// Items exported from the crate being checked.
258260
pub exported_items: &'a ExportedItems,
@@ -284,7 +286,7 @@ macro_rules! run_lints { ($cx:expr, $f:ident, $($args:expr),*) => ({
284286
/// Parse the lint attributes into a vector, with `Err`s for malformed lint
285287
/// attributes. Writing this as an iterator is an enormous mess.
286288
// See also the hir version just below.
287-
pub fn gather_attrs(attrs: &[ast::Attribute])
289+
pub fn gather_attrs(attrs: &[hir::Attribute])
288290
-> Vec<Result<(InternedString, Level, Span), Span>> {
289291
let mut out = vec!();
290292
for attr in attrs {
@@ -297,7 +299,7 @@ pub fn gather_attrs(attrs: &[ast::Attribute])
297299

298300
let meta = &attr.node.value;
299301
let metas = match meta.node {
300-
ast::MetaList(_, ref metas) => metas,
302+
hir::MetaList(_, ref metas) => metas,
301303
_ => {
302304
out.push(Err(meta.span));
303305
continue;
@@ -306,7 +308,7 @@ pub fn gather_attrs(attrs: &[ast::Attribute])
306308

307309
for meta in metas {
308310
out.push(match meta.node {
309-
ast::MetaWord(ref lint_name) => Ok((lint_name.clone(), level, meta.span)),
311+
hir::MetaWord(ref lint_name) => Ok((lint_name.clone(), level, meta.span)),
310312
_ => Err(meta.span),
311313
});
312314
}
@@ -398,7 +400,7 @@ pub fn raw_emit_lint(sess: &Session, lint: &'static Lint,
398400

399401
impl<'a, 'tcx> Context<'a, 'tcx> {
400402
fn new(tcx: &'a ty::ctxt<'tcx>,
401-
krate: &'a ast::Crate,
403+
krate: &'a hir::Crate,
402404
exported_items: &'a ExportedItems) -> Context<'a, 'tcx> {
403405
// We want to own the lint store, so move it out of the session.
404406
let lint_store = mem::replace(&mut *tcx.sess.lint_store.borrow_mut(),
@@ -452,7 +454,7 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
452454
/// current lint context, call the provided function, then reset the
453455
/// lints in effect to their previous state.
454456
fn with_lint_attrs<F>(&mut self,
455-
attrs: &[ast::Attribute],
457+
attrs: &[hir::Attribute],
456458
f: F) where
457459
F: FnOnce(&mut Context),
458460
{
@@ -519,9 +521,9 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
519521
}
520522

521523
fn visit_ids<F>(&mut self, f: F) where
522-
F: FnOnce(&mut ast_util::IdVisitor<Context>)
524+
F: FnOnce(&mut util::IdVisitor<Context>)
523525
{
524-
let mut v = ast_util::IdVisitor {
526+
let mut v = util::IdVisitor {
525527
operation: self,
526528
pass_through_items: false,
527529
visited_outermost: false,
@@ -531,68 +533,68 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
531533
}
532534

533535
impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> {
534-
fn visit_item(&mut self, it: &ast::Item) {
536+
fn visit_item(&mut self, it: &hir::Item) {
535537
self.with_lint_attrs(&it.attrs, |cx| {
536538
run_lints!(cx, check_item, it);
537539
cx.visit_ids(|v| v.visit_item(it));
538540
visit::walk_item(cx, it);
539541
})
540542
}
541543

542-
fn visit_foreign_item(&mut self, it: &ast::ForeignItem) {
544+
fn visit_foreign_item(&mut self, it: &hir::ForeignItem) {
543545
self.with_lint_attrs(&it.attrs, |cx| {
544546
run_lints!(cx, check_foreign_item, it);
545547
visit::walk_foreign_item(cx, it);
546548
})
547549
}
548550

549-
fn visit_pat(&mut self, p: &ast::Pat) {
551+
fn visit_pat(&mut self, p: &hir::Pat) {
550552
run_lints!(self, check_pat, p);
551553
visit::walk_pat(self, p);
552554
}
553555

554-
fn visit_expr(&mut self, e: &ast::Expr) {
556+
fn visit_expr(&mut self, e: &hir::Expr) {
555557
run_lints!(self, check_expr, e);
556558
visit::walk_expr(self, e);
557559
}
558560

559-
fn visit_stmt(&mut self, s: &ast::Stmt) {
561+
fn visit_stmt(&mut self, s: &hir::Stmt) {
560562
run_lints!(self, check_stmt, s);
561563
visit::walk_stmt(self, s);
562564
}
563565

564-
fn visit_fn(&mut self, fk: FnKind<'v>, decl: &'v ast::FnDecl,
565-
body: &'v ast::Block, span: Span, id: ast::NodeId) {
566+
fn visit_fn(&mut self, fk: FnKind<'v>, decl: &'v hir::FnDecl,
567+
body: &'v hir::Block, span: Span, id: ast::NodeId) {
566568
run_lints!(self, check_fn, fk, decl, body, span, id);
567569
visit::walk_fn(self, fk, decl, body, span);
568570
}
569571

570572
fn visit_struct_def(&mut self,
571-
s: &ast::StructDef,
573+
s: &hir::StructDef,
572574
ident: ast::Ident,
573-
g: &ast::Generics,
575+
g: &hir::Generics,
574576
id: ast::NodeId) {
575577
run_lints!(self, check_struct_def, s, ident, g, id);
576578
visit::walk_struct_def(self, s);
577579
run_lints!(self, check_struct_def_post, s, ident, g, id);
578580
}
579581

580-
fn visit_struct_field(&mut self, s: &ast::StructField) {
582+
fn visit_struct_field(&mut self, s: &hir::StructField) {
581583
self.with_lint_attrs(&s.node.attrs, |cx| {
582584
run_lints!(cx, check_struct_field, s);
583585
visit::walk_struct_field(cx, s);
584586
})
585587
}
586588

587-
fn visit_variant(&mut self, v: &ast::Variant, g: &ast::Generics) {
589+
fn visit_variant(&mut self, v: &hir::Variant, g: &hir::Generics) {
588590
self.with_lint_attrs(&v.node.attrs, |cx| {
589591
run_lints!(cx, check_variant, v, g);
590592
visit::walk_variant(cx, v, g);
591593
run_lints!(cx, check_variant_post, v, g);
592594
})
593595
}
594596

595-
fn visit_ty(&mut self, t: &ast::Ty) {
597+
fn visit_ty(&mut self, t: &hir::Ty) {
596598
run_lints!(self, check_ty, t);
597599
visit::walk_ty(self, t);
598600
}
@@ -601,84 +603,79 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> {
601603
run_lints!(self, check_ident, sp, id);
602604
}
603605

604-
fn visit_mod(&mut self, m: &ast::Mod, s: Span, n: ast::NodeId) {
606+
fn visit_mod(&mut self, m: &hir::Mod, s: Span, n: ast::NodeId) {
605607
run_lints!(self, check_mod, m, s, n);
606608
visit::walk_mod(self, m);
607609
}
608610

609-
fn visit_local(&mut self, l: &ast::Local) {
611+
fn visit_local(&mut self, l: &hir::Local) {
610612
run_lints!(self, check_local, l);
611613
visit::walk_local(self, l);
612614
}
613615

614-
fn visit_block(&mut self, b: &ast::Block) {
616+
fn visit_block(&mut self, b: &hir::Block) {
615617
run_lints!(self, check_block, b);
616618
visit::walk_block(self, b);
617619
}
618620

619-
fn visit_arm(&mut self, a: &ast::Arm) {
621+
fn visit_arm(&mut self, a: &hir::Arm) {
620622
run_lints!(self, check_arm, a);
621623
visit::walk_arm(self, a);
622624
}
623625

624-
fn visit_decl(&mut self, d: &ast::Decl) {
626+
fn visit_decl(&mut self, d: &hir::Decl) {
625627
run_lints!(self, check_decl, d);
626628
visit::walk_decl(self, d);
627629
}
628630

629-
fn visit_expr_post(&mut self, e: &ast::Expr) {
631+
fn visit_expr_post(&mut self, e: &hir::Expr) {
630632
run_lints!(self, check_expr_post, e);
631633
}
632634

633-
fn visit_generics(&mut self, g: &ast::Generics) {
635+
fn visit_generics(&mut self, g: &hir::Generics) {
634636
run_lints!(self, check_generics, g);
635637
visit::walk_generics(self, g);
636638
}
637639

638-
fn visit_trait_item(&mut self, trait_item: &ast::TraitItem) {
640+
fn visit_trait_item(&mut self, trait_item: &hir::TraitItem) {
639641
self.with_lint_attrs(&trait_item.attrs, |cx| {
640642
run_lints!(cx, check_trait_item, trait_item);
641643
cx.visit_ids(|v| v.visit_trait_item(trait_item));
642644
visit::walk_trait_item(cx, trait_item);
643645
});
644646
}
645647

646-
fn visit_impl_item(&mut self, impl_item: &ast::ImplItem) {
648+
fn visit_impl_item(&mut self, impl_item: &hir::ImplItem) {
647649
self.with_lint_attrs(&impl_item.attrs, |cx| {
648650
run_lints!(cx, check_impl_item, impl_item);
649651
cx.visit_ids(|v| v.visit_impl_item(impl_item));
650652
visit::walk_impl_item(cx, impl_item);
651653
});
652654
}
653655

654-
fn visit_opt_lifetime_ref(&mut self, sp: Span, lt: &Option<ast::Lifetime>) {
656+
fn visit_opt_lifetime_ref(&mut self, sp: Span, lt: &Option<hir::Lifetime>) {
655657
run_lints!(self, check_opt_lifetime_ref, sp, lt);
656658
}
657659

658-
fn visit_lifetime_ref(&mut self, lt: &ast::Lifetime) {
660+
fn visit_lifetime_ref(&mut self, lt: &hir::Lifetime) {
659661
run_lints!(self, check_lifetime_ref, lt);
660662
}
661663

662-
fn visit_lifetime_def(&mut self, lt: &ast::LifetimeDef) {
664+
fn visit_lifetime_def(&mut self, lt: &hir::LifetimeDef) {
663665
run_lints!(self, check_lifetime_def, lt);
664666
}
665667

666-
fn visit_explicit_self(&mut self, es: &ast::ExplicitSelf) {
668+
fn visit_explicit_self(&mut self, es: &hir::ExplicitSelf) {
667669
run_lints!(self, check_explicit_self, es);
668670
visit::walk_explicit_self(self, es);
669671
}
670672

671-
fn visit_mac(&mut self, mac: &ast::Mac) {
672-
run_lints!(self, check_mac, mac);
673-
visit::walk_mac(self, mac);
674-
}
675-
676-
fn visit_path(&mut self, p: &ast::Path, id: ast::NodeId) {
673+
fn visit_path(&mut self, p: &hir::Path, id: ast::NodeId) {
677674
run_lints!(self, check_path, p, id);
678675
visit::walk_path(self, p);
679676
}
680677

681-
fn visit_attribute(&mut self, attr: &ast::Attribute) {
678+
fn visit_attribute(&mut self, attr: &hir::Attribute) {
682679
run_lints!(self, check_attribute, attr);
683680
}
684681
}
@@ -709,9 +706,9 @@ impl LintPass for GatherNodeLevels {
709706
lint_array!()
710707
}
711708

712-
fn check_item(&mut self, cx: &Context, it: &ast::Item) {
709+
fn check_item(&mut self, cx: &Context, it: &hir::Item) {
713710
match it.node {
714-
ast::ItemEnum(..) => {
711+
hir::ItemEnum(..) => {
715712
let lint_id = LintId::of(builtin::VARIANT_SIZE_DIFFERENCES);
716713
let lvlsrc = cx.lints.get_level_source(lint_id);
717714
match lvlsrc {
@@ -731,7 +728,7 @@ impl LintPass for GatherNodeLevels {
731728
///
732729
/// Consumes the `lint_store` field of the `Session`.
733730
pub fn check_crate(tcx: &ty::ctxt,
734-
krate: &ast::Crate,
731+
krate: &hir::Crate,
735732
exported_items: &ExportedItems) {
736733

737734
let mut cx = Context::new(tcx, krate, exported_items);

0 commit comments

Comments
 (0)