about summary refs log tree commit diff
path: root/src/test/compile-fail
AgeCommit message (Collapse)AuthorLines
2016-11-28Auto merge of #37791 - petrochenkov:where, r=nikomatsakisbors-0/+73
Support `?Sized` in where clauses Implemented as described in https://github.com/rust-lang/rust/issues/20503#issuecomment-258677026 - `?Trait` bounds are moved on type parameter definitions when possible, reported as errors otherwise. (It'd be nice to unify bounds and where clauses in HIR, but this is mostly blocked by rustdoc now - it needs to render bounds in pleasant way and the best way to do it so far is to mirror what was written in source code.) Fixes https://github.com/rust-lang/rust/issues/20503 r? @nikomatsakis
2016-11-28Remove BuiltinBound and BuiltinBounds.Mark-Simulacrum-12/+12
2016-11-28rustc_privacy: switch private-in-public checking to Ty.Eduard Burtescu-85/+106
2016-11-28rustc: rework stability to be on-demand for type-directed lookup.Eduard Burtescu-384/+1485
2016-11-28rustc: embed path resolutions into the HIR instead of keeping DefMap.Eduard-Mihai Burtescu-1/+1
2016-11-28rustc: desugar UFCS as much as possible during HIR lowering.Eduard Burtescu-7/+9
2016-11-26Overload get{,_mut}{,_unchecked}Steven Fackler-13/+14
2016-11-25Support `?Sized` in where clausesVadim Petrochenkov-0/+73
2016-11-23Rollup merge of #37442 - estebank:cast-deref-hint, r=jonathandturnerGuillaume Gomez-0/+5
Provide hint when cast needs a dereference For a given code: ``` rust vec![0.0].iter().map(|s| s as i16).collect::<Vec<i16>>(); ``` display: ``` nocode error: casting `&f64` as `i16` is invalid --> file3.rs:2:35 | 2 | vec![0.0].iter().map(|s| s as i16).collect::<Vec<i16>>(); | - ^^^ | | | did you mean `*s`? ``` instead of: ``` nocode error: casting `&f64` as `i16` is invalid --> <anon>:2:30 | 2 | vec![0.0].iter().map(|s| s as i16).collect(); | ^^^^^^^^ | = help: cast through a raw pointer first ``` Fixes #37338.
2016-11-22Auto merge of #37681 - nrc:crate-metadata, r=@alexcrichtonbors-0/+149
add --crate-type metadata r? @alexcrichton
2016-11-22Auto merge of #37487 - goffrie:break, r=nikomatsakisbors-0/+116
Implement the `loop_break_value` feature. This implements RFC 1624, tracking issue #37339. - `FnCtxt` (in typeck) gets a stack of `LoopCtxt`s, which store the currently deduced type of that loop, the desired type, and a list of break expressions currently seen. `loop` loops get a fresh type variable as their initial type (this logic is stolen from that for arrays). `while` loops get `()`. - `break {expr}` looks up the broken loop, and unifies the type of `expr` with the type of the loop. - `break` with no expr unifies the loop's type with `()`. - When building MIR, loops no longer construct a `()` value at termination of the loop; rather, the `break` expression assigns the result of the loop. - ~~I have also changed the loop scoping in MIR-building so that the test of a while loop is not considered to be part of that loop. This makes the rules consistent with #37360. The new loop scopes in typeck also follow this rule. That means that `loop { while (break) {} }` now terminates instead of looping forever. This is technically a breaking change.~~ - ~~On that note, expressions like `while break {}` and `if break {}` no longer parse because `{}` is interpreted as an expression argument to `break`. But no code except compiler test cases should do that anyway because it makes no sense.~~ - The RFC did not make it clear, but I chose to make `break ()` inside of a `while` loop illegal, just in case we wanted to do anything with that design space in the future. This is my first time dealing with this part of rustc so I'm sure there's plenty of problems to pick on here ^_^
2016-11-21Implement the `loop_break_value` feature.Geoffry Song-0/+116
This implements RFC 1624, tracking issue #37339. - `FnCtxt` (in typeck) gets a stack of `LoopCtxt`s, which store the currently deduced type of that loop, the desired type, and a list of break expressions currently seen. `loop` loops get a fresh type variable as their initial type (this logic is stolen from that for arrays). `while` loops get `()`. - `break {expr}` looks up the broken loop, and unifies the type of `expr` with the type of the loop. - `break` with no expr unifies the loop's type with `()`. - When building MIR, `loop` loops no longer construct a `()` value at termination of the loop; rather, the `break` expression assigns the result of the loop. `while` loops are unchanged. - `break` respects contexts in which expressions may not end with braced blocks. That is, `while break { break-value } { while-body }` is illegal; this preserves backwards compatibility. - The RFC did not make it clear, but I chose to make `break ()` inside of a `while` loop illegal, just in case we wanted to do anything with that design space in the future. This is my first time dealing with this part of rustc so I'm sure there's plenty of problems to pick on here ^_^
2016-11-22Start warning cycle.Jeffrey Seyfried-0/+34
2016-11-22Add a regression test and organize tests.Jeffrey Seyfried-3/+19
2016-11-21Auto merge of #37127 - jseyfried:stabilize_RFC_1560, r=nrcbors-526/+22
Stabilize RFC 1560 Fixes #13598, fixes #23157, fixes #32303. cc #35120 r? @nrc
2016-11-21Fix fallout in tests.Jeffrey Seyfried-526/+22
2016-11-21TestsNick Cameron-0/+149
2016-11-20Rollup merge of #37835 - ojsheikh:E0088, r=jonathandturnerGuillaume Gomez-0/+5
Update E0088 to new error format Fixes #35226 which is part of #35233. Is based on #36208 from @yossi-k. r? @jonathandturner
2016-11-19Provide hint when cast needs a dereferenceEsteban Küber-0/+5
For a given code: ```rust vec![0.0].iter().map(|s| s as i16).collect::<Vec<i16>>(); ``` display: ```nocode error: casting `&f64` as `i16` is invalid --> foo.rs:2:35 | 2 | vec![0.0].iter().map(|s| s as i16).collect::<Vec<i16>>(); | - ^^^ cannot cast `&f64` as `i16` | | | did you mean `*s`? ``` instead of: ```nocode error: casting `&f64` as `i16` is invalid --> <anon>:2:30 | 2 | vec![0.0].iter().map(|s| s as i16).collect(); | ^^^^^^^^ | = help: cast through a raw pointer first ```
2016-11-18Add test case for exported macros vs incremental compilation.Michael Woerister-0/+23
2016-11-17Auto merge of #37660 - nikomatsakis:incremental-36349, r=eddybbors-2/+2
Separate impl items from the parent impl This change separates impl item bodies out of the impl itself. This gives incremental more resolution. In so doing, it refactors how the visitors work, and cleans up a bit of the collect/check logic (mostly by moving things out of collect that didn't really belong there, because they were just checking conditions). However, this is not as effective as I expected, for a kind of frustrating reason. In particular, when invoking `foo.bar()` you still wind up with dependencies on private items. The problem is that the method resolution code scans that list for methods with the name `bar` -- and this winds up touching *all* the methods, even private ones. I can imagine two obvious ways to fix this: - separating fn bodies from fn sigs (#35078, currently being pursued by @flodiebold) - a more aggressive model of incremental that @michaelwoerister has been advocating, in which we hash the intermediate results (e.g., the outputs of collect) so that we can see that the intermediate result hasn't changed, even if a particular impl item has changed. So all in all I'm not quite sure whether to land this or not. =) It still seems like it has to be a win in some cases, but not with the test cases we have just now. I can try to gin up some test cases, but I'm not sure if they will be totally realistic. On the other hand, some of the early refactorings to the visitor trait seem worthwhile to me regardless. cc #36349 -- well, this is basically a fix for that issue, I guess r? @michaelwoerister NB: Based atop of @eddyb's PR https://github.com/rust-lang/rust/pull/37402; don't land until that lands.
2016-11-17Auto merge of #37424 - shiver:issue-37131, r=alexcrichtonbors-0/+18
Improved error reporting when target sysroot is missing. Attempts to resolve #37131. This is my first pull request on rust, so I would greatly appreciate any feedback you have on this. Thanks!
2016-11-17Auto merge of #37837 - GuillaumeGomez:rollup, r=GuillaumeGomezbors-8/+33
Rollup of 8 pull requests - Successful merges: #37752, #37757, #37759, #37766, #37772, #37799, #37806, #37821 - Failed merges: #37442
2016-11-17move impl wf check so they occur earlierNiko Matsakis-1/+0
Needed to keep coherence from freaking out.
2016-11-17Rollup merge of #37759 - robinst:trait-use-message-add-semicolon, r=eddybGuillaume Gomez-8/+8
Add semicolon to "perhaps add a `use` for one of them" help Similar to pull request #37430, this makes the message more copy-paste friendly and aligns it with other messages like: help: you can import it into scope: use foo::Bar; r? @eddyb
2016-11-17Rollup merge of #37752 - arielb1:incoherent-error, r=nikomatsakisGuillaume Gomez-0/+25
coherence: skip impls with an erroneous trait ref Impls with a erroneous trait ref are already ignored in the first part of coherence, so ignore them in the second part too. This avoids cascading coherence errors when 1 impl of a trait has an error. r? @nikomatsakis
2016-11-17Auto merge of #37732 - jseyfried:use_extern_macros, r=nrcbors-4/+74
Support `use`ing externally defined macros behind `#![feature(use_extern_macros)]` With `#![feature(use_extern_macros)]`, - A name collision between macros from different upstream crates is much less of an issue since we can `use` the macros in different submodules or rename with `as`. - We can reexport macros with `pub use`, so `#![feature(macro_reexport)]` is no longer needed. - These reexports are allowed in any module, so crates can expose a macro-modular interface. If a macro invocation can resolve to both a `use` import and a `macro_rules!` or `#[macro_use]`, it is an ambiguity error. r? @nrc
2016-11-17Add tests.Jeffrey Seyfried-0/+70
2016-11-17Add feature `use_extern_macros`.Jeffrey Seyfried-2/+2
2016-11-17Refactor out `PerNS`.Jeffrey Seyfried-2/+2
2016-11-17Improved error reporting when target sysroot is missing.Robert Vally-0/+18
2016-11-16Use span of first unexpected lifetime in E0088.Omer Sheikh-1/+1
2016-11-16Auto merge of #37375 - GuillaumeGomez:cast_message, r=arielb1bors-9/+3
Improve reference cast help message Fixes #37338.
2016-11-16Improve reference cast help messageGuillaume Gomez-9/+3
2016-11-16fix dep-graph checking to account for implitemsNiko Matsakis-1/+2
2016-11-16rustc: Implement #[link(cfg(..))] and crt-staticAlex Crichton-0/+29
This commit is an implementation of [RFC 1721] which adds a new target feature to the compiler, `crt-static`, which can be used to select how the C runtime for a target is linked. Most targets dynamically linke the C runtime by default with the notable exception of some of the musl targets. [RFC 1721]: https://github.com/rust-lang/rfcs/blob/master/text/1721-crt-static.md This commit first adds the new target-feature, `crt-static`. If enabled, then the `cfg(target_feature = "crt-static")` will be available. Targets like musl will have this enabled by default. This feature can be controlled through the standard target-feature interface, `-C target-feature=+crt-static` or `-C target-feature=-crt-static`. Next this adds an gated and unstable `#[link(cfg(..))]` feature to enable the `crt-static` semantics we want with libc. The exact behavior of this attribute is a little squishy, but it's intended to be a forever-unstable implementation detail of the liblibc crate. Specifically the `#[link(cfg(..))]` annotation means that the `#[link]` directive is only active in a compilation unit if that `cfg` value is satisfied. For example when compiling an rlib, these directives are just encoded and ignored for dylibs, and all staticlibs are continued to be put into the rlib as usual. When placing that rlib into a staticlib, executable, or dylib, however, the `cfg` is evaluated *as if it were defined in the final artifact* and the library is decided to be linked or not. Essentially, what'll happen is: * On MSVC with `-C target-feature=-crt-static`, the `msvcrt.lib` library will be linked to. * On MSVC with `-C target-feature=+crt-static`, the `libcmt.lib` library will be linked to. * On musl with `-C target-feature=-crt-static`, the object files in liblibc.rlib are removed and `-lc` is passed instead. * On musl with `-C target-feature=+crt-static`, the object files in liblibc.rlib are used and `-lc` is not passed. This commit does **not** include an update to the liblibc module to implement these changes. I plan to do that just after the 1.14.0 beta release is cut to ensure we get ample time to test this feature. cc #37406
2016-11-14Update E0088 to new format, remove E0090Yossi Konstantinovsky-0/+5
2016-11-14Add semicolon to "perhaps add a `use` for one of them" helpRobin Stocker-8/+8
Similar to pull request #37430, this makes the message more copy-paste friendly and aligns it with other messages like: help: you can import it into scope: use foo::Bar;
2016-11-13coherence: skip impls with an erroneous trait refAriel Ben-Yehuda-0/+25
Impls with a erroneous trait ref are already ignored in the first part of coherence, so ignore them in the second part too. This avoids cascading coherence errors when 1 impl of a trait has an error.
2016-11-12Auto merge of #37531 - estebank:fix-ref-mut-mut, r=jonathandturnerbors-30/+0
Fix invalid "ref mut mut" sugestion Change output from: ```nocode error: cannot borrow immutable local variable `x` as mutable --> <anon>:12:23 | 11 | TestEnum::Item(ref mut x) => { | --------- use `ref mut mut x` here to make mutable 12 | test(&mut x); | ^ cannot borrow mutably ``` to ```nocode error: cannot borrow immutable local variable `x` as mutable --> <anon>:12:23 | 12 | test(&mut x); | ^ | | | cannot reborrow mutably | try removing `&mut` here ``` Fixes #37139, #34337, #34126
2016-11-12Auto merge of #37554 - mikhail-m1:dnlle, r=jonathandturnerbors-62/+0
Improve "Doesn't live long enough" error case with temporary variable issue #36279 part of #35233 r? @jonathandturner
2016-11-12Rollup merge of #37613 - DanielKeep:eww-you-got-printf-in-your-format, ↵Eduard-Mihai Burtescu-0/+3
r=alexcrichton Add foreign formatting directive detection. This teaches `format_args!` how to interpret format printf- and shell-style format directives. This is used in cases where there are unused formatting arguments, and the reason for that *might* be because the programmer is trying to use the wrong kind of formatting string. This was prompted by an issue encountered by simulacrum on the #rust IRC channel. In short: although `println!` told them that they weren't using all of the conversion arguments, the problem was in using printf-syle directives rather than ones `println!` would undertand. Where possible, `format_args!` will tell the programmer what they should use instead. For example, it will suggest replacing `%05d` with `{:0>5}`, or `%2$.*3$s` with `{1:.3$}`. Even if it cannot suggest a replacement, it will explicitly note that Rust does not support that style of directive, and direct the user to the `std::fmt` documentation. ----- **Example**: given: ```rust fn main() { println!("%.*3$s %s!\n", "Hello,", "World", 4); println!("%1$*2$.*3$f", 123.456); } ``` The compiler outputs the following: ```text error: multiple unused formatting arguments --> local/fmt.rs:2:5 | 2 | println!("%.*3$s %s!\n", "Hello,", "World", 4); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: argument never used --> local/fmt.rs:2:30 | 2 | println!("%.*3$s %s!\n", "Hello,", "World", 4); | ^^^^^^^^ note: argument never used --> local/fmt.rs:2:40 | 2 | println!("%.*3$s %s!\n", "Hello,", "World", 4); | ^^^^^^^ note: argument never used --> local/fmt.rs:2:49 | 2 | println!("%.*3$s %s!\n", "Hello,", "World", 4); | ^ = help: `%.*3$s` should be written as `{:.2$}` = help: `%s` should be written as `{}` = note: printf formatting not supported; see the documentation for `std::fmt` = note: this error originates in a macro outside of the current crate error: argument never used --> local/fmt.rs:6:29 | 6 | println!("%1$*2$.*3$f", 123.456); | ^^^^^^^ | = help: `%1$*2$.*3$f` should be written as `{0:1$.2$}` = note: printf formatting not supported; see the documentation for `std::fmt` ```
2016-11-12Rollup merge of #37481 - estebank:lifetime-help-removal-for-impl, r=eddybEduard-Mihai Burtescu-2/+0
Don't provide hint to add lifetime on impl items ``` rust use std::str::FromStr; pub struct Foo<'a> { field: &'a str, } impl<'a> FromStr for Foo<'a> { type Err = (); fn from_str(path: &str) -> Result<Self, ()> { Ok(Foo { field: path }) } } ``` would give the following hint: ``` nocode help: consider using an explicit lifetime parameter as shown: fn from_str(path: &'a str) -> Result<Self, ()> --> <anon>:9:5 | 9 | fn from_str(path: &str) -> Result<Self, ()> { | ^ ``` which is never correct, since then there will be a lifetime mismatch between the `impl` and the trait. Remove this hint for all `impl` items. Re: #37363.
2016-11-11Auto merge of #37456 - estebank:unused-imports-verbosity, r=jonathandturnerbors-2/+3
Group unused import warnings per import list Given a file ``` rust use std::collections::{BinaryHeap, BTreeMap, BTreeSet}; fn main() {} ``` Show a single warning, instead of three for each unused import: ``` nocode warning: unused imports, #[warn(unused_imports)] on by default --> file2.rs:1:24 | 1 | use std::collections::{BinaryHeap, BTreeMap, BTreeSet}; | ^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^ ``` Include support for lints pointing at `MultilineSpan`s, instead of just `Span`s. Fixes #16132.
2016-11-11Auto merge of #37447 - estebank:non-duplicate-definition-error, r=nrcbors-12/+1
Show one error for duplicated type definitions For the following code: ``` rustc struct Bar; struct Bar; fn main () { } ``` show ``` nocode error[E0428]: a type named `Bar` has already been defined in this module --> src/test/compile-fail/E0428.rs:12:1 | 11 | struct Bar; | ----------- previous definition of `Bar` here 12 | struct Bar; | ^^^^^^^^^^^ error: aborting due to previous error ``` instead of ``` nocode error[E0428]: a type named `Bar` has already been defined in this module --> src/test/compile-fail/E0428.rs:12:1 | 11 | struct Bar; | ----------- previous definition of `Bar` here 12 | struct Bar; | ^^^^^^^^^^^ error[E0428]: a value named `Bar` has already been defined in this module --> src/test/compile-fail/E0428.rs:12:1 | 11 | struct Bar; | ----------- previous definition of `Bar` here 12 | struct Bar; | ^^^^^^^^^^^ error: aborting due to 2 previous errors ``` Fixes #35767.
2016-11-10Auto merge of #36615 - sinkuu:e0243_0244, r=nrcbors-25/+25
Make E0243/E0244 message consistent with E0107 E0243/E0233 prints `expected {}, found {}` on the span note, while E0107 prints it on the first line. This is confusing when both error occur simultaneously. This PR makes E0243/E0233 print `expected {}, found {}` on the first line. Code: ``` rust struct Foo<'a, 'b> { s: &'a str, t: &'b str, } type Bar<T, U> = Foo<T, U>; ``` rustc output (before): ``` error[E0107]: wrong number of lifetime parameters: expected 2, found 0 --> test.rs:6:18 | 6 | type Bar<T, U> = Foo<T, U>; | ^^^^^^^^^ expected 2 lifetime parameters error[E0244]: wrong number of type arguments --> test.rs:6:18 | 6 | type Bar<T, U> = Foo<T, U>; | ^^^^^^^^^ expected no type arguments, found 2 ``` rustc output (after): ``` error[E0107]: wrong number of lifetime parameters: expected 2, found 0 --> /tmp/test.rs:6:18 | 6 | type Bar<T, U> = Foo<T, U>; | ^^^^^^^^^ expected 2 lifetime parameters error[E0244]: wrong number of type arguments: expected 0, found 2 --> /tmp/test.rs:6:18 | 6 | type Bar<T, U> = Foo<T, U>; | ^^^^^^^^^ expected no type arguments ```
2016-11-11Add foreign formatting directive detection.Daniel Keep-0/+3
This teaches `format_args!` how to interpret format printf- and shell-style format directives. This is used in cases where there are unused formatting arguments, and the reason for that *might* be because the programmer is trying to use the wrong kind of formatting string. This was prompted by an issue encountered by simulacrum on the #rust IRC channel. In short: although `println!` told them that they weren't using all of the conversion arguments, the problem was in using printf-syle directives rather than ones `println!` would undertand. Where possible, `format_args!` will tell the programmer what they should use instead. For example, it will suggest replacing `%05d` with `{:0>5}`, or `%2$.*3$s` with `{1:.3$}`. Even if it cannot suggest a replacement, it will explicitly note that Rust does not support that style of directive, and direct the user to the `std::fmt` documentation.
2016-11-10Don't hint to add lifetime on trait implEsteban Küber-2/+0
Don't provide hint to add lifetime on impl items that implement a trait. ```rust use std::str::FromStr; pub struct Foo<'a> { field: &'a str, } impl<'a> FromStr for Foo<'a> { type Err = (); fn from_str(path: &str) -> Result<Self, ()> { Ok(Foo { field: path }) } } ``` would give the following hint: ```nocode help: consider using an explicit lifetime parameter as shown: fn from_str(path: &'a str) -> Result<Self, ()> --> <anon>:9:5 | 9 | fn from_str(path: &str) -> Result<Self, ()> { | ^ ``` which is never correct, since then there will be a lifetime mismatch between the impl and the trait. Remove this hint for impl items that implement a trait.
2016-11-10Support `#[macro_reexport]`ing custom derives.Jeffrey Seyfried-0/+1
2016-11-10Register and stability check `#[no_link]` crates.Jeffrey Seyfried-4/+4