Skip to content

Commit c778d10

Browse files
committed
---
yaml --- r: 212277 b: refs/heads/master c: 1be9e6f h: refs/heads/master i: 212275: f8d85a3 v: v3
1 parent a8e9f83 commit c778d10

File tree

34 files changed

+128
-160
lines changed

34 files changed

+128
-160
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: 1ade076f62c9e8188c4fb5c888277a1673ac82cd
2+
refs/heads/master: 1be9e6f055fbcd6bfcf0a1f9e9ef0e86abe54f02
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ba0e1cd8147d452c356aacb29fb87568ca26f111
55
refs/heads/try: 1864973ae17213c5a58c4dd3f9af6d1b6c7d2e05

trunk/src/liballoc/boxed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ use core::raw::{TraitObject};
8181
#[lang = "exchange_heap"]
8282
#[unstable(feature = "alloc",
8383
reason = "may be renamed; uncertain about custom allocator design")]
84-
pub const HEAP: () = ();
84+
pub static HEAP: () = ();
8585

8686
/// A pointer type for heap allocation.
8787
///

trunk/src/libcollections/bit.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ fn match_words <'a,'b>(a: &'a BitVec, b: &'b BitVec) -> (MatchWords<'a>, MatchWo
125125
}
126126
}
127127

128-
const TRUE: &'static bool = &true;
129-
const FALSE: &'static bool = &false;
128+
static TRUE: bool = true;
129+
static FALSE: bool = false;
130130

131131
/// The bitvector type.
132132
///
@@ -172,9 +172,9 @@ impl Index<usize> for BitVec {
172172
#[inline]
173173
fn index(&self, i: usize) -> &bool {
174174
if self.get(i).expect("index out of bounds") {
175-
TRUE
175+
&TRUE
176176
} else {
177-
FALSE
177+
&FALSE
178178
}
179179
}
180180
}

trunk/src/libcollections/vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ use borrow::{Cow, IntoCow};
8383
use super::range::RangeArgument;
8484

8585
// FIXME- fix places which assume the max vector allowed has memory usize::MAX.
86-
const MAX_MEMORY_SIZE: usize = isize::MAX as usize;
86+
static MAX_MEMORY_SIZE: usize = isize::MAX as usize;
8787

8888
/// A growable list type, written `Vec<T>` but pronounced 'vector.'
8989
///

trunk/src/libcore/num/flt2dec/strategy/dragon.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use num::flt2dec::estimator::estimate_scaling_factor;
2424
use num::flt2dec::bignum::Digit32 as Digit;
2525
use num::flt2dec::bignum::Big32x36 as Big;
2626

27+
// FIXME(#22540) const ref to static array seems to ICE
2728
static POW10: [Digit; 10] = [1, 10, 100, 1000, 10000, 100000,
2829
1000000, 10000000, 100000000, 1000000000];
2930
static TWOPOW10: [Digit; 10] = [2, 20, 200, 2000, 20000, 200000,
@@ -327,3 +328,4 @@ pub fn format_exact(d: &Decoded, buf: &mut [u8], limit: i16) -> (/*#digits*/ usi
327328

328329
(len, k)
329330
}
331+

trunk/src/libcore/num/flt2dec/strategy/grisu.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ for i in xrange(-308, 333, 8):
8787
f = ((f << 64 >> (l-1)) + 1) >> 1; e += l - 64
8888
print ' (%#018x, %5d, %4d),' % (f, e, i)
8989
*/
90-
90+
// FIXME(#22540) const ref to static array seems to ICE
9191
#[doc(hidden)]
9292
pub static CACHED_POW10: [(u64, i16, i16); 81] = [ // (f, e, k)
9393
(0xe61acf033d1a45df, -1087, -308),
@@ -746,3 +746,4 @@ pub fn format_exact(d: &Decoded, buf: &mut [u8], limit: i16) -> (/*#digits*/ usi
746746
None => fallback(d, buf, limit),
747747
}
748748
}
749+

trunk/src/liblog/directive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub struct LogDirective {
1717
pub level: u32,
1818
}
1919

20-
pub const LOG_LEVEL_NAMES: [&'static str; 4] = ["ERROR", "WARN", "INFO",
20+
pub static LOG_LEVEL_NAMES: [&'static str; 4] = ["ERROR", "WARN", "INFO",
2121
"DEBUG"];
2222

2323
/// Parse an individual log level that is either a number or a symbolic log level

trunk/src/librand/distributions/ziggurat_tables.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// algorithm. Autogenerated by `ziggurat_tables.py`.
1313

1414
pub type ZigTable = &'static [f64; 257];
15-
pub const ZIG_NORM_R: f64 = 3.654152885361008796;
15+
pub static ZIG_NORM_R: f64 = 3.654152885361008796;
1616
pub static ZIG_NORM_X: [f64; 257] =
1717
[3.910757959537090045, 3.654152885361008796, 3.449278298560964462, 3.320244733839166074,
1818
3.224575052047029100, 3.147889289517149969, 3.083526132001233044, 3.027837791768635434,
@@ -145,7 +145,7 @@ pub static ZIG_NORM_F: [f64; 257] =
145145
0.887984660763399880, 0.898095921906304051, 0.908726440060562912, 0.919991505048360247,
146146
0.932060075968990209, 0.945198953453078028, 0.959879091812415930, 0.977101701282731328,
147147
1.000000000000000000];
148-
pub const ZIG_EXP_R: f64 = 7.697117470131050077;
148+
pub static ZIG_EXP_R: f64 = 7.697117470131050077;
149149
pub static ZIG_EXP_X: [f64; 257] =
150150
[8.697117470131052741, 7.697117470131050077, 6.941033629377212577, 6.478378493832569696,
151151
6.144164665772472667, 5.882144315795399869, 5.666410167454033697, 5.482890627526062488,

trunk/src/librustc/diagnostics.rs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -227,25 +227,6 @@ const Y: i32 = A;
227227
```
228228
"##,
229229

230-
E0014: r##"
231-
Constants can only be initialized by a constant value or, in a future
232-
version of Rust, a call to a const function. This error indicates the use
233-
of a path (like a::b, or x) denoting something other than one of these
234-
allowed items. Example:
235-
236-
```
237-
const FOO: i32 = { let x = 0; x }; // 'x' isn't a constant nor a function!
238-
```
239-
240-
To avoid it, you have to replace the non-constant value:
241-
242-
```
243-
const FOO: i32 = { const X : i32 = 0; X };
244-
// or even:
245-
const FOO: i32 = { 0 }; // but brackets are useless here
246-
```
247-
"##,
248-
249230
E0015: r##"
250231
The only functions that can be called in static or constant expressions are
251232
`const` functions. Rust currently does not support more general compile-time
@@ -950,6 +931,7 @@ static mut BAR: Option<Vec<i32>> = None;
950931

951932

952933
register_diagnostics! {
934+
E0014,
953935
E0016,
954936
E0017,
955937
E0019,

trunk/src/librustc/lint/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,9 @@ macro_rules! declare_lint {
101101
#[macro_export]
102102
macro_rules! lint_array { ($( $lint:expr ),*) => (
103103
{
104-
static ARRAY: LintArray = &[ $( &$lint ),* ];
105-
ARRAY
104+
#[allow(non_upper_case_globals)]
105+
static array: LintArray = &[ $( &$lint ),* ];
106+
array
106107
}
107108
) }
108109

trunk/src/librustc/metadata/tydecode.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ pub enum DefIdSource {
5050
// Identifies a type alias (`type X = ...`).
5151
TypeWithId,
5252

53+
// Identifies a type parameter (`fn foo<X>() { ... }`).
54+
TypeParameter,
55+
5356
// Identifies a region parameter (`fn foo<'X>() { ... }`).
5457
RegionParameter,
5558

@@ -190,7 +193,7 @@ pub fn parse_substs_data<'tcx, F>(data: &[u8], crate_num: ast::CrateNum, pos: us
190193
tcx: &ty::ctxt<'tcx>, conv: F) -> subst::Substs<'tcx> where
191194
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
192195
{
193-
debug!("parse_substs_data{}", data_log_string(data, pos));
196+
debug!("parse_substs_data {}", data_log_string(data, pos));
194197
let mut st = parse_state_from_data(data, crate_num, pos, tcx);
195198
parse_substs(&mut st, conv)
196199
}
@@ -539,14 +542,7 @@ fn parse_ty_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F) -> Ty<'tcx> w
539542
len: len };
540543

541544
match tcx.rcache.borrow().get(&key).cloned() {
542-
Some(tt) => {
543-
// If there is a closure buried in the type some where, then we
544-
// need to re-convert any def ids (see case 'k', below). That means
545-
// we can't reuse the cached version.
546-
if !ty::type_has_ty_closure(tt) {
547-
return tt;
548-
}
549-
}
545+
Some(tt) => return tt,
550546
None => {}
551547
}
552548
let mut ps = PState {

trunk/src/librustc/middle/astencode.rs

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use middle::def;
2020
use metadata::encoder as e;
2121
use middle::region;
2222
use metadata::tydecode;
23-
use metadata::tydecode::{DefIdSource, NominalType, TypeWithId};
23+
use metadata::tydecode::{DefIdSource, NominalType, TypeWithId, TypeParameter};
2424
use metadata::tydecode::{RegionParameter, ClosureSource};
2525
use metadata::tyencode;
2626
use middle::cast;
@@ -346,6 +346,13 @@ impl<D:serialize::Decoder> def_id_decoder_helpers for D
346346
// ______________________________________________________________________
347347
// Encoding and decoding the AST itself
348348
//
349+
// The hard work is done by an autogenerated module astencode_gen. To
350+
// regenerate astencode_gen, run src/etc/gen-astencode. It will
351+
// replace astencode_gen with a dummy file and regenerate its
352+
// contents. If you get compile errors, the dummy file
353+
// remains---resolve the errors and then rerun astencode_gen.
354+
// Annoying, I know, but hopefully only temporary.
355+
//
349356
// When decoding, we have to renumber the AST so that the node ids that
350357
// appear within are disjoint from the node ids in our existing ASTs.
351358
// We also have to adjust the spans: for now we just insert a dummy span,
@@ -649,6 +656,35 @@ impl<'a, 'tcx> read_method_callee_helper<'tcx> for reader::Decoder<'a> {
649656
}
650657
}
651658

659+
impl<'tcx> tr for MethodOrigin<'tcx> {
660+
fn tr(&self, dcx: &DecodeContext) -> MethodOrigin<'tcx> {
661+
match *self {
662+
ty::MethodStatic(did) => ty::MethodStatic(did.tr(dcx)),
663+
ty::MethodStaticClosure(did) => {
664+
ty::MethodStaticClosure(did.tr(dcx))
665+
}
666+
ty::MethodTypeParam(ref mp) => {
667+
ty::MethodTypeParam(
668+
ty::MethodParam {
669+
// def-id is already translated when we read it out
670+
trait_ref: mp.trait_ref.clone(),
671+
method_num: mp.method_num,
672+
impl_def_id: mp.impl_def_id.tr(dcx),
673+
}
674+
)
675+
}
676+
ty::MethodTraitObject(ref mo) => {
677+
ty::MethodTraitObject(
678+
ty::MethodObject {
679+
trait_ref: mo.trait_ref.clone(),
680+
.. *mo
681+
}
682+
)
683+
}
684+
}
685+
}
686+
}
687+
652688
pub fn encode_closure_kind(ebml_w: &mut Encoder, kind: ty::ClosureKind) {
653689
kind.encode(ebml_w).unwrap();
654690
}
@@ -1437,10 +1473,10 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
14371473
-> subst::Substs<'tcx> {
14381474
self.read_opaque(|this, doc| {
14391475
Ok(tydecode::parse_substs_data(doc.data,
1440-
dcx.cdata.cnum,
1441-
doc.start,
1442-
dcx.tcx,
1443-
|s, a| this.convert_def_id(dcx, s, a)))
1476+
dcx.cdata.cnum,
1477+
doc.start,
1478+
dcx.tcx,
1479+
|s, a| this.convert_def_id(dcx, s, a)))
14441480
}).unwrap()
14451481
}
14461482

@@ -1581,7 +1617,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
15811617
-> ast::DefId {
15821618
let r = match source {
15831619
NominalType | TypeWithId | RegionParameter => dcx.tr_def_id(did),
1584-
ClosureSource => dcx.tr_intern_def_id(did)
1620+
TypeParameter | ClosureSource => dcx.tr_intern_def_id(did)
15851621
};
15861622
debug!("convert_def_id(source={:?}, did={:?})={:?}", source, did, r);
15871623
return r;

trunk/src/librustc/middle/ty.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,6 @@ bitflags! {
814814
const HAS_REGIONS = 1 << 5,
815815
const HAS_TY_ERR = 1 << 6,
816816
const HAS_PROJECTION = 1 << 7,
817-
const HAS_TY_CLOSURE = 1 << 8,
818817
const NEEDS_SUBST = TypeFlags::HAS_PARAMS.bits |
819818
TypeFlags::HAS_SELF.bits |
820819
TypeFlags::HAS_REGIONS.bits,
@@ -986,9 +985,6 @@ pub fn type_needs_infer(ty: Ty) -> bool {
986985
pub fn type_has_projection(ty: Ty) -> bool {
987986
ty.flags.get().intersects(TypeFlags::HAS_PROJECTION)
988987
}
989-
pub fn type_has_ty_closure(ty: Ty) -> bool {
990-
ty.flags.get().intersects(TypeFlags::HAS_TY_CLOSURE)
991-
}
992988

993989
pub fn type_has_late_bound_regions(ty: Ty) -> bool {
994990
ty.flags.get().intersects(TypeFlags::HAS_RE_LATE_BOUND)
@@ -2964,7 +2960,6 @@ impl FlagComputation {
29642960
}
29652961

29662962
&ty_closure(_, substs) => {
2967-
self.add_flags(TypeFlags::HAS_TY_CLOSURE);
29682963
self.add_substs(substs);
29692964
}
29702965

trunk/src/librustc/util/ppaux.rs

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -304,18 +304,11 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
304304
s
305305
}
306306

307-
fn closure_to_string<'tcx>(cx: &ctxt<'tcx>,
308-
cty: &ty::ClosureTy<'tcx>,
309-
did: &ast::DefId)
310-
-> String {
307+
fn closure_to_string<'tcx>(cx: &ctxt<'tcx>, cty: &ty::ClosureTy<'tcx>) -> String {
311308
let mut s = String::new();
312309
s.push_str("[closure");
313310
push_sig_to_string(cx, &mut s, '(', ')', &cty.sig);
314-
if cx.sess.verbose() {
315-
s.push_str(&format!(" id={:?}]", did));
316-
} else {
317-
s.push(']');
318-
}
311+
s.push(']');
319312
s
320313
}
321314

@@ -414,20 +407,13 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
414407
ty_closure(ref did, substs) => {
415408
let closure_tys = cx.closure_tys.borrow();
416409
closure_tys.get(did).map(|closure_type| {
417-
closure_to_string(cx, &closure_type.subst(cx, substs), did)
410+
closure_to_string(cx, &closure_type.subst(cx, substs))
418411
}).unwrap_or_else(|| {
419-
let id_str = if cx.sess.verbose() {
420-
format!(" id={:?}", did)
421-
} else {
422-
"".to_owned()
423-
};
424-
425-
426412
if did.krate == ast::LOCAL_CRATE {
427413
let span = cx.map.span(did.node);
428-
format!("[closure {}{}]", span.repr(cx), id_str)
414+
format!("[closure {}]", span.repr(cx))
429415
} else {
430-
format!("[closure{}]", id_str)
416+
format!("[closure]")
431417
}
432418
})
433419
}

trunk/src/librustc_resolve/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3206,11 +3206,14 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
32063206
NoSuggestion
32073207
}
32083208

3209-
fn find_best_match_for_name(&mut self, name: &str) -> Option<String> {
3209+
fn find_best_match_for_name(&mut self, name: &str, max_distance: usize)
3210+
-> Option<String> {
3211+
let this = &mut *self;
3212+
32103213
let mut maybes: Vec<token::InternedString> = Vec::new();
32113214
let mut values: Vec<usize> = Vec::new();
32123215

3213-
for rib in self.value_ribs.iter().rev() {
3216+
for rib in this.value_ribs.iter().rev() {
32143217
for (&k, _) in &rib.bindings {
32153218
maybes.push(token::get_name(k));
32163219
values.push(usize::MAX);
@@ -3226,12 +3229,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
32263229
}
32273230
}
32283231

3229-
// As a loose rule to avoid obviously incorrect suggestions, clamp the
3230-
// maximum edit distance we will accept for a suggestion to one third of
3231-
// the typo'd name's length.
3232-
let max_distance = std::cmp::max(name.len(), 3) / 3;
3233-
32343232
if !values.is_empty() &&
3233+
values[smallest] != usize::MAX &&
3234+
values[smallest] < name.len() + 2 &&
32353235
values[smallest] <= max_distance &&
32363236
name != &maybes[smallest][..] {
32373237

@@ -3357,7 +3357,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
33573357
NoSuggestion => {
33583358
// limit search to 5 to reduce the number
33593359
// of stupid suggestions
3360-
self.find_best_match_for_name(&path_name)
3360+
self.find_best_match_for_name(&path_name, 5)
33613361
.map_or("".to_string(),
33623362
|x| format!("`{}`", x))
33633363
}

trunk/src/librustc_trans/trans/callee.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,9 @@ fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr)
117117
_ => {
118118
bcx.tcx().sess.span_bug(
119119
expr.span,
120-
&format!("type of callee is neither bare-fn nor closure: {}",
121-
bcx.ty_to_string(datum.ty)));
120+
&format!("type of callee is neither bare-fn nor closure: \
121+
{}",
122+
bcx.ty_to_string(datum.ty)));
122123
}
123124
}
124125
}
@@ -505,9 +506,6 @@ pub fn trans_fn_ref_with_substs<'a, 'tcx>(
505506
false
506507
};
507508

508-
debug!("trans_fn_ref_with_substs({}) must_monomorphise: {}",
509-
def_id.repr(tcx), must_monomorphise);
510-
511509
// Create a monomorphic version of generic functions
512510
if must_monomorphise {
513511
// Should be either intra-crate or inlined.

0 commit comments

Comments
 (0)