Skip to content
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

Rollup of 18 pull requests #35397

Closed
wants to merge 45 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
c622a42
Update the man page rustc.1
dns2utf8 Aug 4, 2016
91f9704
Update rustdoc version
dns2utf8 Aug 4, 2016
625fc29
Update error format for E0130
trixnz Aug 4, 2016
8787237
Add E0254 error explanation
GuillaumeGomez Aug 4, 2016
8641bc2
Updated E0081 to new format
Aug 5, 2016
c61cfb0
Update E0106 error message to new format.
Tiwalun Aug 5, 2016
764d5cf
Update E0379 to new format #35338
kc1212 Aug 5, 2016
4c672e0
Fixed no-pattern-in-args test for new E0130 format
trixnz Aug 5, 2016
7cd1779
Add new error code tests
GuillaumeGomez Aug 5, 2016
bc25879
Update E0207 to use struct_span_err, add span_label
shantanuraj Aug 5, 2016
eaa2697
Updated error message E0282
Aug 5, 2016
5eebb92
Update error message for E0166
Aug 5, 2016
b7468fa
Updated E0306 to new format.
razielgn Aug 5, 2016
40b7ace
Update E0229 to new format
Aug 5, 2016
2f5294e
Fixes #35304
mikhail-m1 Aug 5, 2016
e7e5cfe
Merge branch 'master' of https://github.com/rust-lang/rust
mikhail-m1 Aug 5, 2016
3575812
Update E0107 message to new format
ojsheikh Aug 5, 2016
00179a7
Updated style of unit test
Aug 5, 2016
7eca647
Update error format for E0373
trixnz Aug 5, 2016
2061d65
Add E0107 tests for multiple lifetime params
ojsheikh Aug 5, 2016
802b543
Update error format for E0326
trixnz Aug 5, 2016
51a270f
Fix E0229 unit tests
Aug 5, 2016
291b6f1
Comment on the casts in the `seek` implementations on files
tbu- Jul 18, 2016
58b618e
Update unit tests to accord for label in E0207
shantanuraj Aug 5, 2016
422e0d5
Update E0004 to use labels
TheZoq2 Aug 5, 2016
e0035c9
Update error message for E0323, E0324 and E0325
Aug 5, 2016
ff96b56
Updated E0282 to new requirements
Aug 5, 2016
e36be6e
Rollup merge of #34916 - tbu-:pr_comment_on_seek_cast, r=GuillaumeGomez
Aug 5, 2016
bf19adc
Rollup merge of #35287 - dns2utf8:man_page_rustc, r=nikomatsakis
Aug 5, 2016
6556ffd
Rollup merge of #35288 - Roybie:35271-E0166-update-error-format, r=Gu…
Aug 5, 2016
843a3e9
Rollup merge of #35331 - trixnz:update-error-130, r=jonathandturner
Aug 5, 2016
c3c287c
Rollup merge of #35353 - poveda-ruiz:master, r=jonathandturner
Aug 5, 2016
39a1a25
Rollup merge of #35356 - Tiwalun:fix-err-msg-e0106, r=jonathandturner
Aug 5, 2016
71b8958
Rollup merge of #35363 - GuillaumeGomez:err_codes, r=jonathandturner
Aug 5, 2016
431eeb0
Rollup merge of #35364 - kc1212:e0379, r=jonathandturner
Aug 5, 2016
2139a0a
Rollup merge of #35366 - medzin:E0282, r=jonathandturner
Aug 5, 2016
320e3dc
Rollup merge of #35368 - shantanuraj:master, r=jonathandturner
Aug 5, 2016
3dd50b5
Rollup merge of #35370 - razielgn:updated-e0306-to-new-format, r=jona…
Aug 5, 2016
8d881d6
Rollup merge of #35372 - Keats:err-323, r=jonathandturner
Aug 5, 2016
7f5d263
Rollup merge of #35373 - oijazsh:E0107, r=jonathandturner
Aug 5, 2016
dbe7af7
Rollup merge of #35374 - mrabault:e0229_format, r=jonathandturner
Aug 5, 2016
36af476
Rollup merge of #35375 - trixnz:update-error-326, r=jonathandturner
Aug 5, 2016
9834224
Rollup merge of #35376 - trixnz:update-error-373, r=jonathandturner
Aug 5, 2016
3e1fe82
Rollup merge of #35380 - TheZoq2:master, r=jonathandturner
Aug 5, 2016
9154cc9
Rollup merge of #35394 - mikhail-m1:master, r=jonathandturner
Aug 5, 2016
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
11 changes: 7 additions & 4 deletions src/librustc_const_eval/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1337,10 +1337,13 @@ pub fn eval_length<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
Ok(val as usize)
},
Ok(const_val) => {
span_err!(tcx.sess, count_expr.span, E0306,
"expected usize for {}, found {}",
reason,
const_val.description());
struct_span_err!(tcx.sess, count_expr.span, E0306,
"expected `usize` for {}, found {}",
reason,
const_val.description())
.span_label(count_expr.span, &format!("expected `usize`"))
.emit();

Err(ErrorReported)
}
Err(err) => {
Expand Down
14 changes: 11 additions & 3 deletions src/test/compile-fail/E0306.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

const A: [u32; "hello"] = []; //~ ERROR E0306
const B: [u32; true] = []; //~ ERROR E0306
const C: [u32; 0.0] = []; //~ ERROR E0306
const A: [u32; "hello"] = [];
//~^ ERROR expected `usize` for array length, found string literal [E0306]
//~| NOTE expected `usize`

const B: [u32; true] = [];
//~^ ERROR expected `usize` for array length, found boolean [E0306]
//~| NOTE expected `usize`

const C: [u32; 0.0] = [];
//~^ ERROR expected `usize` for array length, found float [E0306]
//~| NOTE expected `usize`

fn main() {
}
30 changes: 24 additions & 6 deletions src/test/compile-fail/const-integer-bool-ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,35 @@ const X3: usize = -42 && -39; //~ ERROR E0080
const ARR3: [i32; X3] = [99; 6]; //~ NOTE: for array length here

const Y: usize = 42.0 == 42.0;
const ARRR: [i32; Y] = [99; 1]; //~ ERROR: expected usize for array length
const ARRR: [i32; Y] = [99; 1];
//~^ ERROR: expected `usize` for array length, found boolean [E0306]
//~| NOTE expected `usize`

const Y1: usize = 42.0 >= 42.0;
const ARRR1: [i32; Y] = [99; 1]; //~ ERROR: expected usize for array length
const ARRR1: [i32; Y] = [99; 1];
//~^ ERROR: expected `usize` for array length, found boolean [E0306]
//~| NOTE expected `usize`

const Y2: usize = 42.0 <= 42.0;
const ARRR2: [i32; Y] = [99; 1]; //~ ERROR: expected usize for array length
const ARRR2: [i32; Y] = [99; 1];
//~^ ERROR: expected `usize` for array length, found boolean [E0306]
//~| NOTE expected `usize`

const Y3: usize = 42.0 > 42.0;
const ARRR3: [i32; Y] = [99; 0]; //~ ERROR: expected usize for array length
const ARRR3: [i32; Y] = [99; 0];
//~^ ERROR: expected `usize` for array length, found boolean [E0306]
//~| NOTE expected `usize`

const Y4: usize = 42.0 < 42.0;
const ARRR4: [i32; Y] = [99; 0]; //~ ERROR: expected usize for array length
const ARRR4: [i32; Y] = [99; 0];
//~^ ERROR: expected `usize` for array length, found boolean [E0306]
//~| NOTE expected `usize`

const Y5: usize = 42.0 != 42.0;
const ARRR5: [i32; Y] = [99; 0]; //~ ERROR: expected usize for array length
const ARRR5: [i32; Y] = [99; 0];
//~^ ERROR: expected `usize` for array length, found boolean [E0306]
//~| NOTE expected `usize`


fn main() {
let _ = ARR;
Expand Down
3 changes: 2 additions & 1 deletion src/test/compile-fail/issue-27008.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ fn main() {
//~| expected type `usize`
//~| found type `S`
//~| expected usize, found struct `S`
//~| ERROR expected usize for repeat count, found struct
//~| ERROR expected `usize` for repeat count, found struct [E0306]
//~| expected `usize`
}
15 changes: 10 additions & 5 deletions src/test/compile-fail/repeat_count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,27 @@ fn main() {
//~| expected type `usize`
//~| found type `()`
//~| expected usize, found ()
//~| ERROR expected usize for repeat count, found tuple [E0306]
//~| ERROR expected `usize` for repeat count, found tuple [E0306]
//~| expected `usize`
let c = [0; true];
//~^ ERROR mismatched types
//~| expected usize, found bool
//~| ERROR expected usize for repeat count, found boolean [E0306]
//~| ERROR expected `usize` for repeat count, found boolean [E0306]
//~| expected `usize`
let d = [0; 0.5];
//~^ ERROR mismatched types
//~| expected type `usize`
//~| found type `{float}`
//~| expected usize, found floating-point variable
//~| ERROR expected usize for repeat count, found float [E0306]
//~| ERROR expected `usize` for repeat count, found float [E0306]
//~| expected `usize`
let e = [0; "foo"];
//~^ ERROR mismatched types
//~| expected type `usize`
//~| found type `&'static str`
//~| expected usize, found &-ptr
//~| ERROR expected usize for repeat count, found string literal [E0306]
//~| ERROR expected `usize` for repeat count, found string literal [E0306]
//~| expected `usize`
let f = [0; -4_isize];
//~^ ERROR constant evaluation error
//~| expected usize, found isize
Expand All @@ -55,5 +59,6 @@ fn main() {
//~| expected type `usize`
//~| found type `main::G`
//~| expected usize, found struct `main::G`
//~| ERROR expected usize for repeat count, found struct [E0306]
//~| ERROR expected `usize` for repeat count, found struct [E0306]
//~| expected `usize`
}