Skip to content

Commit b132bf4

Browse files
committed
---
yaml --- r: 213984 b: refs/heads/master c: 4b42cbd h: refs/heads/master v: v3
1 parent c8b67da commit b132bf4

File tree

121 files changed

+3758
-4484
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+3758
-4484
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 29c86539b392b98ba84570143c625781ba248a9b
2+
refs/heads/master: 4b42cbd5eb3e947875aa427dbda52121ef186586
33
refs/heads/snap-stage3: ba0e1cd8147d452c356aacb29fb87568ca26f111
44
refs/heads/try: b53c0f93eedcdedd4fd89bccc5a3a09d1c5cd23e
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

trunk/src/librustc/diagnostics.rs

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,21 @@ See [RFC 911] for more details on the design of `const fn`s.
256256
[RFC 911]: https://github.com/rust-lang/rfcs/blob/master/text/0911-const-fn.md
257257
"##,
258258

259+
E0016: r##"
260+
Blocks in constants may only contain items (such as constant, function
261+
definition, etc...) and a tail expression. Example:
262+
263+
```
264+
const FOO: i32 = { let x = 0; x }; // 'x' isn't an item!
265+
```
266+
267+
To avoid it, you have to replace the non-item object:
268+
269+
```
270+
const FOO: i32 = { const X : i32 = 0; X };
271+
```
272+
"##,
273+
259274
E0018: r##"
260275
The value of static and const variables must be known at compile time. You
261276
can't cast a pointer as an integer because we can't know what value the
@@ -279,6 +294,42 @@ println!("{}", Y);
279294
```
280295
"##,
281296

297+
E0019: r##"
298+
A function call isn't allowed in the const's initialization expression
299+
because the expression's value must be known at compile-time. Example of
300+
erroneous code:
301+
302+
```
303+
enum Test {
304+
V1
305+
}
306+
307+
impl Test {
308+
fn test(&self) -> i32 {
309+
12
310+
}
311+
}
312+
313+
fn main() {
314+
const FOO: Test = Test::V1;
315+
316+
const A: i32 = FOO.test(); // You can't call Test::func() here !
317+
}
318+
```
319+
320+
Remember: you can't use a function call inside a const's initialization
321+
expression! However, you can totally use it elsewhere you want:
322+
323+
```
324+
fn main() {
325+
const FOO: Test = Test::V1;
326+
327+
FOO.func(); // here is good
328+
let x = FOO.func(); // or even here!
329+
}
330+
```
331+
"##,
332+
282333
E0020: r##"
283334
This error indicates that an attempt was made to divide by zero (or take the
284335
remainder of a zero divisor) in a static or constant expression.
@@ -950,9 +1001,7 @@ static mut BAR: Option<Vec<i32>> = None;
9501001

9511002

9521003
register_diagnostics! {
953-
E0016,
9541004
E0017,
955-
E0019,
9561005
E0022,
9571006
E0038,
9581007
E0109,

trunk/src/librustc/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#![feature(ref_slice)]
5252
#![feature(rustc_diagnostic_macros)]
5353
#![feature(rustc_private)]
54+
#![feature(scoped_tls)]
5455
#![feature(slice_bytes)]
5556
#![feature(slice_extras)]
5657
#![feature(slice_patterns)]

trunk/src/librustc/metadata/tydecode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ fn parse_builtin_bounds<F>(st: &mut PState, mut _conv: F) -> ty::BuiltinBounds w
898898
fn parse_builtin_bounds_<F>(st: &mut PState, _conv: &mut F) -> ty::BuiltinBounds where
899899
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
900900
{
901-
let mut builtin_bounds = ty::empty_builtin_bounds();
901+
let mut builtin_bounds = ty::BuiltinBounds::empty();
902902

903903
loop {
904904
match next(st) {

trunk/src/librustc/middle/astconv_util.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use middle::def;
1818
use middle::ty::{self, Ty};
1919
use syntax::ast;
20-
use util::ppaux::Repr;
2120

2221
pub const NO_REGIONS: usize = 1;
2322
pub const NO_TPS: usize = 2;
@@ -63,7 +62,7 @@ pub fn ast_ty_to_prim_ty<'tcx>(tcx: &ty::ctxt<'tcx>, ast_ty: &ast::Ty)
6362
let def = match tcx.def_map.borrow().get(&ast_ty.id) {
6463
None => {
6564
tcx.sess.span_bug(ast_ty.span,
66-
&format!("unbound path {}", path.repr(tcx)))
65+
&format!("unbound path {:?}", path))
6766
}
6867
Some(d) => d.full_def()
6968
};

trunk/src/librustc/middle/astencode.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ use middle::privacy::{AllPublic, LastMod};
3131
use middle::subst;
3232
use middle::subst::VecPerParamSpace;
3333
use middle::ty::{self, Ty, MethodCall, MethodCallee, MethodOrigin};
34-
use util::ppaux::ty_to_string;
3534

3635
use syntax::{ast, ast_util, codemap, fold};
3736
use syntax::codemap::Span;
@@ -1623,8 +1622,8 @@ fn decode_side_tables(dcx: &DecodeContext,
16231622
}
16241623
c::tag_table_node_type => {
16251624
let ty = val_dsr.read_ty(dcx);
1626-
debug!("inserting ty for node {}: {}",
1627-
id, ty_to_string(dcx.tcx, ty));
1625+
debug!("inserting ty for node {}: {:?}",
1626+
id, ty);
16281627
dcx.tcx.node_type_insert(id, ty);
16291628
}
16301629
c::tag_table_item_subst => {

trunk/src/librustc/middle/check_const.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ use middle::mem_categorization as mc;
3333
use middle::traits;
3434
use middle::ty::{self, Ty};
3535
use util::nodemap::NodeMap;
36-
use util::ppaux::Repr;
3736

3837
use syntax::ast;
3938
use syntax::codemap::Span;
@@ -300,7 +299,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
300299

301300
impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
302301
fn visit_item(&mut self, i: &ast::Item) {
303-
debug!("visit_item(item={})", i.repr(self.tcx));
302+
debug!("visit_item(item={})", self.tcx.map.node_to_string(i.id));
304303
match i.node {
305304
ast::ItemStatic(_, ast::MutImmutable, ref expr) => {
306305
self.check_static_type(&**expr);

trunk/src/librustc/middle/check_match.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ use syntax::print::pprust::pat_to_string;
3636
use syntax::parse::token;
3737
use syntax::ptr::P;
3838
use syntax::visit::{self, Visitor, FnKind};
39-
use util::ppaux::ty_to_string;
4039
use util::nodemap::FnvHashMap;
4140

4241
pub const DUMMY_WILD_PAT: &'static Pat = &Pat {
@@ -209,9 +208,8 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &ast::Expr) {
209208
if !type_is_empty(cx.tcx, pat_ty) {
210209
// We know the type is inhabited, so this must be wrong
211210
span_err!(cx.tcx.sess, ex.span, E0002,
212-
"non-exhaustive patterns: type {} is non-empty",
213-
ty_to_string(cx.tcx, pat_ty)
214-
);
211+
"non-exhaustive patterns: type {} is non-empty",
212+
pat_ty);
215213
}
216214
// If the type *is* empty, it's vacuously exhaustive
217215
return;
@@ -244,11 +242,11 @@ fn check_for_bindings_named_the_same_as_variants(cx: &MatchCheckCtxt, pat: &Pat)
244242
span_warn!(cx.tcx.sess, p.span, E0170,
245243
"pattern binding `{}` is named the same as one \
246244
of the variants of the type `{}`",
247-
&token::get_ident(ident.node), ty_to_string(cx.tcx, pat_ty));
245+
&token::get_ident(ident.node), pat_ty);
248246
fileline_help!(cx.tcx.sess, p.span,
249247
"if you meant to match on a variant, \
250248
consider making the path in the pattern qualified: `{}::{}`",
251-
ty_to_string(cx.tcx, pat_ty), &token::get_ident(ident.node));
249+
pat_ty, &token::get_ident(ident.node));
252250
}
253251
}
254252
}

trunk/src/librustc/middle/check_rvalues.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use middle::expr_use_visitor as euv;
1515
use middle::mem_categorization as mc;
1616
use middle::ty::ParameterEnvironment;
1717
use middle::ty;
18-
use util::ppaux::ty_to_string;
1918

2019
use syntax::ast;
2120
use syntax::codemap::Span;
@@ -59,11 +58,11 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for RvalueContextDelegate<'a, 'tcx> {
5958
span: Span,
6059
cmt: mc::cmt<'tcx>,
6160
_: euv::ConsumeMode) {
62-
debug!("consume; cmt: {:?}; type: {}", *cmt, ty_to_string(self.tcx, cmt.ty));
61+
debug!("consume; cmt: {:?}; type: {:?}", *cmt, cmt.ty);
6362
if !ty::type_is_sized(Some(self.param_env), self.tcx, span, cmt.ty) {
6463
span_err!(self.tcx.sess, span, E0161,
6564
"cannot move a value of type {0}: the size of {0} cannot be statically determined",
66-
ty_to_string(self.tcx, cmt.ty));
65+
cmt.ty);
6766
}
6867
}
6968

trunk/src/librustc/middle/const_eval.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ use middle::pat_util::def_to_path;
2323
use middle::ty::{self, Ty};
2424
use middle::astconv_util::ast_ty_to_prim_ty;
2525
use util::num::ToPrimitive;
26-
use util::ppaux::Repr;
2726

2827
use syntax::ast::{self, Expr};
2928
use syntax::ast_util;
@@ -1030,8 +1029,8 @@ fn resolve_trait_associated_const<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>,
10301029
rcvr_self,
10311030
Vec::new()));
10321031
let trait_substs = tcx.mk_substs(trait_substs);
1033-
debug!("resolve_trait_associated_const: trait_substs={}",
1034-
trait_substs.repr(tcx));
1032+
debug!("resolve_trait_associated_const: trait_substs={:?}",
1033+
trait_substs);
10351034
let trait_ref = ty::Binder(ty::TraitRef { def_id: trait_id,
10361035
substs: trait_substs });
10371036

@@ -1052,10 +1051,10 @@ fn resolve_trait_associated_const<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>,
10521051
}
10531052
Err(e) => {
10541053
tcx.sess.span_bug(ti.span,
1055-
&format!("Encountered error `{}` when trying \
1054+
&format!("Encountered error `{:?}` when trying \
10561055
to select an implementation for \
10571056
constant trait item reference.",
1058-
e.repr(tcx)))
1057+
e))
10591058
}
10601059
};
10611060

trunk/src/librustc/middle/effect.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use self::UnsafeContext::*;
1515
use middle::def;
1616
use middle::ty::{self, Ty};
1717
use middle::ty::MethodCall;
18-
use util::ppaux;
1918

2019
use syntax::ast;
2120
use syntax::codemap::Span;
@@ -66,8 +65,8 @@ impl<'a, 'tcx> EffectCheckVisitor<'a, 'tcx> {
6665
ast::ExprIndex(ref base, _) => ty::node_id_to_type(self.tcx, base.id),
6766
_ => return
6867
};
69-
debug!("effect: checking index with base type {}",
70-
ppaux::ty_to_string(self.tcx, base_type));
68+
debug!("effect: checking index with base type {:?}",
69+
base_type);
7170
match base_type.sty {
7271
ty::TyBox(ty) | ty::TyRef(_, ty::mt{ty, ..}) => if ty::TyStr == ty.sty {
7372
span_err!(self.tcx.sess, e.span, E0134,
@@ -142,25 +141,25 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> {
142141
ast::ExprMethodCall(_, _, _) => {
143142
let method_call = MethodCall::expr(expr.id);
144143
let base_type = self.tcx.method_map.borrow().get(&method_call).unwrap().ty;
145-
debug!("effect: method call case, base type is {}",
146-
ppaux::ty_to_string(self.tcx, base_type));
144+
debug!("effect: method call case, base type is {:?}",
145+
base_type);
147146
if type_is_unsafe_function(base_type) {
148147
self.require_unsafe(expr.span,
149148
"invocation of unsafe method")
150149
}
151150
}
152151
ast::ExprCall(ref base, _) => {
153152
let base_type = ty::node_id_to_type(self.tcx, base.id);
154-
debug!("effect: call case, base type is {}",
155-
ppaux::ty_to_string(self.tcx, base_type));
153+
debug!("effect: call case, base type is {:?}",
154+
base_type);
156155
if type_is_unsafe_function(base_type) {
157156
self.require_unsafe(expr.span, "call to unsafe function")
158157
}
159158
}
160159
ast::ExprUnary(ast::UnDeref, ref base) => {
161160
let base_type = ty::node_id_to_type(self.tcx, base.id);
162-
debug!("effect: unary case, base type is {}",
163-
ppaux::ty_to_string(self.tcx, base_type));
161+
debug!("effect: unary case, base type is {:?}",
162+
base_type);
164163
if let ty::TyRawPtr(_) = base_type.sty {
165164
self.require_unsafe(expr.span, "dereference of raw pointer")
166165
}

0 commit comments

Comments
 (0)