Skip to content

Rollup of 21 pull requests #27219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 110 commits into from
Jul 22, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
441b994
simplify processing of ConstVal objects when not all variants are legal
Jul 13, 2015
0c9e3dc
Fix negate_unsigned feature gate check
nagisa Jul 13, 2015
2250215
Implement lint deprecation/removal…
nagisa Jul 15, 2015
ccf9050
Don't recurse down closures for duplicate-label checking
Manishearth Jul 17, 2015
6bdfb05
Clarify the usage of "hints" in const_eval.
eefriedman Jun 30, 2015
4567704
Fix rustdoc formatting of impls
wthrowe Jul 18, 2015
a219917
Fix doc comment parsing in macros.
Jul 15, 2015
1373c4f
Properly create debug info for functions
dotdash Jul 13, 2015
47128b8
Create correct debuginfo for closure function signatures
dotdash Jul 14, 2015
9175a16
Generate proper debug info for function pointers
dotdash Jul 13, 2015
b684826
add test for #20162
apasel422 Jul 19, 2015
34309cd
implement 'a:'static region bounds
Jul 6, 2015
8edcff5
return erased regions from fulfill_obligation
Jul 6, 2015
28ce509
clean-up find_bound_for_assoc_item
arielb1 Jul 19, 2015
bbeace6
Add test of impl formatting
wthrowe Jul 20, 2015
761e11e
fixes #27124 for openbsd
semarie Jul 20, 2015
ac33f15
fix `configure`: allow both `--enable-debug` and `--disable-debuginfo`
pnkfelix Jul 20, 2015
871ccfb
Add a test for #26468
dotdash Jul 20, 2015
0ca8e49
Convert negate_unsigned feature gate to a warning
nagisa Jul 20, 2015
9bb6545
add test for #14229
apasel422 Jul 20, 2015
4c73dbd
add test for #19404
apasel422 Jul 20, 2015
3d65c7f
Create proper debuginfo for closure variables
dotdash Jul 14, 2015
39d4faf
Auto merge of #27025 - dotdash:issue-26484, r=pnkfelix
bors Jul 20, 2015
31a62d3
s/has gained/has not gained/g
pfalabella Jul 20, 2015
7e9e389
std: Add IntoRaw{Fd,Handle,Socket} traits
alexcrichton Jul 16, 2015
013d47b
syntax: Suppress panic message on `fatal`
alexcrichton Jul 20, 2015
1855750
Auto merge of #27026 - nagisa:overflowing-unsigned, r=pnkfelix
bors Jul 20, 2015
7cb157e
Register new snapshots
alexcrichton Jul 17, 2015
a7e5c63
add test for #10436
apasel422 Jul 20, 2015
225ad17
impl Debug for Atomic types
arthurprs Jul 19, 2015
3ae7b72
Fix wording nit for E0253
AlisdairO Jul 20, 2015
27fc0f2
Document iterators in std::io
steveklabnik Jul 20, 2015
1e79917
Improve Debug impl for File on Windows
retep998 Jul 20, 2015
9191a78
Revert "Fix `missing_docs` lint for const and static."
brson Jul 20, 2015
686d326
Add diagnostics for E0172, fix inline error message for E0139
AlisdairO Jul 19, 2015
47265bb
Auto merge of #27064 - alexcrichton:into-raw-os, r=brson
bors Jul 20, 2015
7e7ec6b
Document structures in std::io::utils
steveklabnik Jul 20, 2015
2fe870a
Auto merge of #26831 - arielb1:lifetime-fixes, r=nikomatsakis
bors Jul 20, 2015
44dd247
doc: Clean up primitive short descriptions
brson Jul 17, 2015
8497c42
std: Create separate docs for the primitives
brson Jul 20, 2015
9e18326
Update docs for take and broadcast
steveklabnik Jul 20, 2015
ed49bad
Auto merge of #27056 - Eljay:doc-comments, r=nikomatsakis
bors Jul 20, 2015
fa28192
Write better docs for std::io
steveklabnik Jul 20, 2015
24c5e49
std: Fix compiling the standard library on i686-MSVC
alexcrichton Jul 20, 2015
118a5c4
Auto merge of #27129 - arthurprs:debug_atomic, r=alexcrichton
bors Jul 21, 2015
a3e78f4
Add test of cross-crate impl formatting
wthrowe Jul 20, 2015
778c89c
Address feedback
brson Jul 21, 2015
a29c834
Add travis config to TRPL: release channels
steveklabnik Jul 21, 2015
238765e
Auto merge of #27103 - wthrowe:doc_format, r=alexcrichton
bors Jul 21, 2015
48a1f1b
Auto merge of #27139 - pnkfelix:allow-disable-debuginfo, r=dotdash
bors Jul 21, 2015
f9f0e44
Auto merge of #27144 - semarie:openbsd-archive_format, r=alexcrichton
bors Jul 21, 2015
691ce23
Auto merge of #27150 - retep998:where-are-my-files, r=alexcrichton
bors Jul 21, 2015
247a0d1
Auto merge of #27153 - alexcrichton:flaky-tests, r=brson
bors Jul 21, 2015
007246c
Allow for space between each filemap in the codemap
nrc Jul 2, 2015
0e907fa
Provide a filemap ctor with line info
nrc Jul 2, 2015
bf34187
Test
nrc Jul 3, 2015
f47d20a
Use a span from the correct file for the inner span of a module
nrc Jul 6, 2015
e33b128
Auto merge of #26816 - nrc:zero-codemap, r=@jroesch
bors Jul 21, 2015
9957228
Guidance on Windows install re "Add to PATH"
Dangthrimble Jul 20, 2015
2afe47d
Auto merge of #27160 - brson:revdoc, r=huonw
bors Jul 21, 2015
fec23d9
Auto merge of #27168 - brson:stdprim, r=steveklabnik
bors Jul 21, 2015
4128583
This test attempts to exercise cyclic structure much of `std::collect…
pnkfelix Jul 21, 2015
90a3692
Auto merge of #27171 - steveklabnik:doc_std_io, r=brson
bors Jul 21, 2015
5dbddfb
Auto merge of #26935 - oli-obk:const_val_description, r=eddyb
bors Jul 21, 2015
d68b152
std: Be resilient to failure in pthread_getattr_np
alexcrichton Jul 16, 2015
cbdc52e
Expand a bit on thread::park spurious wakeups
steveklabnik Jul 7, 2015
0eb7303
Add E0403 error explanation
GuillaumeGomez Jul 17, 2015
cd385cb
Add E0405 error explanation
GuillaumeGomez Jul 17, 2015
bc79f20
Add E0404 error explanation
GuillaumeGomez Jul 17, 2015
9581154
Add E0407 error explanation
GuillaumeGomez Jul 17, 2015
c13295b
Add E0428 error explanation
GuillaumeGomez Jul 17, 2015
d2aee95
Expand documentation for IntoInnerError
steveklabnik Jul 20, 2015
2e919b4
Add E0433 error explanation
GuillaumeGomez Jul 17, 2015
21dfd24
Auto merge of #26856 - steveklabnik:gh26475, r=alexcrichton
bors Jul 21, 2015
e6d8434
add test for #14382
apasel422 Jul 20, 2015
a5c7b96
Add info about usage of 'unsafe' keyword in bindings to foreign inter…
Jul 21, 2015
48870d4
rust -> Rust
Jul 21, 2015
cf1e078
Klabnik nit-picks ;)
ticki Jul 21, 2015
ee2d3bc
Auto merge of #27073 - alexcrichton:less-proc-fs, r=brson
bors Jul 21, 2015
18f115c
update compile-fail test for #21174 to account for #27127
apasel422 Jul 21, 2015
39a780d
Auto merge of #27093 - Manishearth:closure-label-shadow, r=pnkfelix
bors Jul 21, 2015
c35b2bd
trans: Move rust_try into the compiler
alexcrichton Jul 20, 2015
d33cab1
Auto merge of #27172 - alexcrichton:snapshots, r=brson
bors Jul 22, 2015
9090420
Auto merge of #27185 - pnkfelix:test-cyclic-collections, r=alexcrichton
bors Jul 22, 2015
e22c6f7
Improve documentation for std::io::BufWriter
steveklabnik Jul 20, 2015
f2c7345
Path changed to %PATH%
Dangthrimble Jul 22, 2015
25281b1
Auto merge of #27176 - alexcrichton:fix-stock-llvm, r=brson
bors Jul 22, 2015
d4d4206
Auto merge of #26683 - eefriedman:const-eval-hint, r=pnkfelix
bors Jul 22, 2015
e31ad95
Improve documentation for std::io::LineWriter
steveklabnik Jul 20, 2015
bc4daf7
Rollup merge of #27084 - GuillaumeGomez:patch-2, r=brson
steveklabnik Jul 22, 2015
5a44f70
Rollup merge of #27127 - AlisdairO:diagnostics172, r=Manishearth
steveklabnik Jul 22, 2015
db0e0ef
Rollup merge of #27131 - apasel422:issue-20162, r=arielb1
steveklabnik Jul 22, 2015
0ac7438
Rollup merge of #27140 - dotdash:test-26468, r=luqmana
steveklabnik Jul 22, 2015
70bbdd7
Rollup merge of #27146 - apasel422:issue-14229, r=alexcrichton
steveklabnik Jul 22, 2015
cb5d9a3
Rollup merge of #27147 - apasel422:issue-19404, r=alexcrichton
steveklabnik Jul 22, 2015
6b0833a
Rollup merge of #27151 - pfalabella:patch-2, r=steveklabnik
steveklabnik Jul 22, 2015
2375ef5
Rollup merge of #27154 - apasel422:issue-10436, r=Gankro
steveklabnik Jul 22, 2015
239657c
Rollup merge of #27155 - steveklabnik:doc_std_io_buf_writer, r=alexcr…
steveklabnik Jul 22, 2015
b73c6fe
Rollup merge of #27156 - AlisdairO:diagnostics253, r=Manishearth
steveklabnik Jul 22, 2015
558008b
Rollup merge of #27157 - steveklabnik:doc_std_io_iterators, r=alexcri…
steveklabnik Jul 22, 2015
5f0c998
Rollup merge of #27158 - apasel422:issue-14382, r=alexcrichton
steveklabnik Jul 22, 2015
cc60f3f
Rollup merge of #27163 - steveklabnik:doc_std_io_cursor, r=alexcrichton
steveklabnik Jul 22, 2015
47f1286
Rollup merge of #27164 - steveklabnik:doc_io_utils, r=alexcrichton
steveklabnik Jul 22, 2015
6397ecb
Rollup merge of #27166 - steveklabnik:doc_std_io_linewriter, r=alexcr…
steveklabnik Jul 22, 2015
932f0bb
Rollup merge of #27167 - steveklabnik:doc_std_io_take, r=alexcrichton
steveklabnik Jul 22, 2015
a39a36a
Rollup merge of #27170 - steveklabnik:doc_std_io_intoinnererror, r=al…
steveklabnik Jul 22, 2015
068e7d7
Rollup merge of #27175 - steveklabnik:channels_plus_travis, r=alexcri…
steveklabnik Jul 22, 2015
7cacf83
Rollup merge of #27183 - Dangthrimble:master, r=steveklabnik
steveklabnik Jul 22, 2015
5665efd
Rollup merge of #27201 - Ticki:master, r=steveklabnik
steveklabnik Jul 22, 2015
5f04b1b
Rollup merge of #27202 - apasel422:issue-21174, r=alexcrichton
steveklabnik Jul 22, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
simplify processing of ConstVal objects when not all variants are legal
  • Loading branch information
Oliver Schneider committed Jul 13, 2015
commit 441b9940ecc2056f04065f8d08ae7cde8bdae684
52 changes: 22 additions & 30 deletions src/librustc/middle/const_eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,22 @@ pub enum ConstVal {
Tuple(ast::NodeId),
}

impl ConstVal {
pub fn description(&self) -> &'static str {
match *self {
Float(_) => "float",
Int(i) if i < 0 => "negative integer",
Int(_) => "positive integer",
Uint(_) => "unsigned integer",
Str(_) => "string literal",
Binary(_) => "binary array",
Bool(_) => "boolean",
Struct(_) => "struct",
Tuple(_) => "tuple",
}
}
}

pub fn const_expr_to_pat(tcx: &ty::ctxt, expr: &Expr, span: Span) -> P<ast::Pat> {
let pat = match expr.node {
ast::ExprTup(ref exprs) =>
Expand Down Expand Up @@ -352,16 +368,8 @@ pub enum ErrKind {
InvalidOpForFloats(ast::BinOp_),
InvalidOpForIntUint(ast::BinOp_),
InvalidOpForUintInt(ast::BinOp_),
NegateOnString,
NegateOnBoolean,
NegateOnBinary,
NegateOnStruct,
NegateOnTuple,
NotOnFloat,
NotOnString,
NotOnBinary,
NotOnStruct,
NotOnTuple,
NegateOn(ConstVal),
NotOn(ConstVal),

NegateWithOverflow(i64),
AddiWithOverflow(i64, i64),
Expand Down Expand Up @@ -397,16 +405,8 @@ impl ConstEvalErr {
InvalidOpForFloats(_) => "can't do this op on floats".into_cow(),
InvalidOpForIntUint(..) => "can't do this op on an isize and usize".into_cow(),
InvalidOpForUintInt(..) => "can't do this op on a usize and isize".into_cow(),
NegateOnString => "negate on string".into_cow(),
NegateOnBoolean => "negate on boolean".into_cow(),
NegateOnBinary => "negate on binary literal".into_cow(),
NegateOnStruct => "negate on struct".into_cow(),
NegateOnTuple => "negate on tuple".into_cow(),
NotOnFloat => "not on float or string".into_cow(),
NotOnString => "not on float or string".into_cow(),
NotOnBinary => "not on binary literal".into_cow(),
NotOnStruct => "not on struct".into_cow(),
NotOnTuple => "not on tuple".into_cow(),
NegateOn(ref const_val) => format!("negate on {}", const_val.description()).into_cow(),
NotOn(ref const_val) => format!("not on {}", const_val.description()).into_cow(),

NegateWithOverflow(..) => "attempted to negate with overflow".into_cow(),
AddiWithOverflow(..) => "attempted to add with overflow".into_cow(),
Expand Down Expand Up @@ -754,23 +754,15 @@ pub fn eval_const_expr_with_substs<'tcx, S>(tcx: &ty::ctxt<'tcx>,
}
try!(const_uint_checked_neg(i, e, expr_uint_type))
}
Str(_) => signal!(e, NegateOnString),
Bool(_) => signal!(e, NegateOnBoolean),
Binary(_) => signal!(e, NegateOnBinary),
Tuple(_) => signal!(e, NegateOnTuple),
Struct(..) => signal!(e, NegateOnStruct),
const_val => signal!(e, NegateOn(const_val)),
}
}
ast::ExprUnary(ast::UnNot, ref inner) => {
match try!(eval_const_expr_partial(tcx, &**inner, ety)) {
Int(i) => Int(!i),
Uint(i) => const_uint_not(i, expr_uint_type),
Bool(b) => Bool(!b),
Str(_) => signal!(e, NotOnString),
Float(_) => signal!(e, NotOnFloat),
Binary(_) => signal!(e, NotOnBinary),
Tuple(_) => signal!(e, NotOnTuple),
Struct(..) => signal!(e, NotOnStruct),
const_val => signal!(e, NotOn(const_val)),
}
}
ast::ExprBinary(op, ref a, ref b) => {
Expand Down
8 changes: 1 addition & 7 deletions src/librustc/middle/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6100,13 +6100,7 @@ impl<'tcx> ctxt<'tcx> {
let found = match val {
ConstVal::Uint(count) => return count as usize,
ConstVal::Int(count) if count >= 0 => return count as usize,
ConstVal::Int(_) => "negative integer",
ConstVal::Float(_) => "float",
ConstVal::Str(_) => "string",
ConstVal::Bool(_) => "boolean",
ConstVal::Binary(_) => "binary array",
ConstVal::Struct(..) => "struct",
ConstVal::Tuple(_) => "tuple"
const_val => const_val.description(),
};
span_err!(self.sess, count_expr.span, E0306,
"expected positive integer for repeat count, found {}",
Expand Down
45 changes: 28 additions & 17 deletions src/test/compile-fail/repeat_count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,58 @@

fn main() {
let n = 1;
let a = [0; n]; //~ ERROR expected constant integer for repeat count, found variable
let a = [0; n];
//~^ ERROR expected constant integer for repeat count, found variable [E0307]
let b = [0; ()];
//~^ ERROR mismatched types
//~| expected `usize`
//~| found `()`
//~| expected usize
//~| found ()
//~| ERROR expected positive integer for repeat count, found tuple
//~^ ERROR mismatched types
//~| expected `usize`
//~| found `()`
//~| expected usize
//~| found ()) [E0308]
//~| ERROR expected positive integer for repeat count, found tuple [E0306]
let c = [0; true];
//~^ ERROR mismatched types
//~| expected `usize`
//~| found `bool`
//~| expected usize
//~| found bool
//~| ERROR expected positive integer for repeat count, found boolean
//~| found bool) [E0308]
//~| ERROR expected positive integer for repeat count, found boolean [E0306]
let d = [0; 0.5];
//~^ ERROR mismatched types
//~| expected `usize`
//~| found `_`
//~| expected usize
//~| found floating-point variable
//~| ERROR expected positive integer for repeat count, found float
//~| found floating-point variable) [E0308]
//~| ERROR expected positive integer for repeat count, found float [E0306]
let e = [0; "foo"];
//~^ ERROR mismatched types
//~| expected `usize`
//~| found `&'static str`
//~| expected usize
//~| found &-ptr
//~| ERROR expected positive integer for repeat count, found string
//~| found &-ptr) [E0308]
//~| ERROR expected positive integer for repeat count, found string literal [E0306]
let f = [0; -4_isize];
//~^ ERROR mismatched types
//~| expected `usize`
//~| found `isize`
//~| expected usize
//~| found isize
//~| ERROR expected positive integer for repeat count, found negative integer
//~| found isize) [E0308]
//~| ERROR expected positive integer for repeat count, found negative integer [E0306]
let f = [0_usize; -1_isize];
//~^ ERROR mismatched types
//~| expected `usize`
//~| found `isize`
//~| expected usize
//~| found isize
//~| ERROR expected positive integer for repeat count, found negative integer
//~| found isize) [E0308]
//~| ERROR expected positive integer for repeat count, found negative integer [E0306]
struct G {
g: (),
}
let g = [0; G { g: () }];
//~^ ERROR mismatched types
//~| expected `usize`
//~| found `main::G`
//~| expected usize
//~| found struct `main::G`) [E0308]
//~| ERROR expected positive integer for repeat count, found struct [E0306]
}