about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2017-11-03Remove unused AsciiExt imports and fix tests related to ascii methodsLukas Kalbertodt-2/+2
Many AsciiExt imports have become useless thanks to the inherent ascii methods added in the last commits. These were removed. In some places, I fully specified the ascii method being called to enforce usage of the AsciiExt trait. Note that some imports are not removed but tagged with a `#[cfg(stage0)]` attribute. This is necessary, because certain ascii methods are not yet available in stage0. All those imports will be removed later. Additionally, failing tests were fixed. The test suite should exit successfully now.
2017-11-03Auto merge of #45484 - oli-obk:lint_names, r=nikomatsakisbors-1/+1
Report lint names in json diagnostics This allows tools like `rustfix` to have whitelists for what to automatically apply and what not.
2017-11-02Auto merge of #45409 - tamird:suggest-match-default-bindings, r=nikomatsakisbors-14/+52
typeck: suggest use of match_default_bindings feature Fixes #45383. Updates #42640. r? @nikomatsakis cc @tschottdorf This needs a UI test, but thought I'd get some early feedback.
2017-11-02Auto merge of #45647 - nrc:rls-bugs, r=eddybbors-0/+5
save-analysis: support unions r? @eddyb
2017-11-02Report lint names in json diagnosticsOliver Schneider-1/+1
2017-11-02Auto merge of #45630 - joshleeb:iss35241, r=estebankbors-0/+30
Improve display of error E0308 Ref. Forgetting to call a variant constructor causes a confusing error message #35241. This PR modifies [`note_type_err`](https://github.com/rust-lang/rust/blob/b7041bfab3a83702a8026fb7a18d8ea7d54cc648/src/librustc/infer/error_reporting/mod.rs#L669-L674) to display a `help` message when a `TyFnPtr` or `TyFnDef` are found and the return type, of the function or function pointer, is the same as the type that is expected. The output of compiling ```rust struct Foo(u32); fn test() -> Foo { Foo } fn main() {} ``` is now ```bash $ rustc src/test/ui/issue-35241.rs error[E0308]: mismatched types --> src/test/ui/issue-35241.rs:13:20 | 13 | fn test() -> Foo { Foo } | --- ^^^ expected struct `Foo`, found fn item | | | expected `Foo` because of return type | = help: did you mean `Foo { /* fields */ }`? = note: expected type `Foo` found type `fn(u32) -> Foo {Foo::{{constructor}}}` error: aborting due to previous error ```
2017-11-01Auto merge of #45538 - nikomatsakis:nll-liveness, r=pnkfelixbors-2/+629
enable non-lexical lifetimes in the MIR borrow checker This PR, joint work with @spastorino, fills out the NLL infrastructure and integrates it with the borrow checker. **Don't get too excited:** it includes still a number of hacks (the subtyping code is particularly hacky). However, it *does* kinda' work. =) The final commit demonstrates this by including a test that -- with both the AST borrowck and MIR borrowck -- reports an error by default. But if you pass `-Znll`, you only get an error from the AST borrowck, demonstrating that the integration succeeds: ``` struct MyStruct { field: String } fn main() { let mut my_struct = MyStruct { field: format!("Hello") }; let value = &my_struct.field; if value.is_empty() { my_struct.field.push_str("Hello, world!"); //~^ ERROR cannot borrow (Ast) } } ```
2017-11-01Auto merge of #45472 - michaelwoerister:incr-comp-caching-base, r=nikomatsakisbors-0/+19
incr.comp.: Implement compiler diagnostic persistence. This PR implements storing and loading diagnostics that the compiler generates and thus allows for emitting warnings during incremental compilation without actually re-evaluating the thing the warning originally came from. It also lays some groundwork for storing and loading type information and MIR in the incr. comp. cache. ~~It is still work in progress:~~ - ~~There's still some documentation to be added.~~ - ~~The way anonymous queries are handled might lead to duplicated emissions of warnings. Not sure if there is a better way or how frequent such duplication would be in practice.~~ Diagnostic message duplication is addressed separately in #45519. r? @nikomatsakis
2017-11-01Auto merge of #45435 - eddyb:binop-subtype-lhs, r=nikomatsakisbors-2/+59
rustc_typeck: use subtyping on the LHS of binops. Fixes #45425. r? @nikomatsakis
2017-11-01Rollup merge of #45660 - Cldfire:suggest-rename-import, r=estebankkennytm-0/+38
Suggest renaming import if names clash Closes https://github.com/rust-lang/rust/issues/32354. The output for the example in the issue looks like this: ``` ~/p/local-rust-dev-testing ❯❯❯ cargo +local-s1 build Compiling local-rust-dev-testing v0.1.0 (file:///home/cldfire/programming_projects/local-rust-dev-testing) error[E0252]: the name `ConstructorExtension` is defined multiple times --> src/main.rs:49:5 | 48 | use extension1::ConstructorExtension; | -------------------------------- previous import of the trait `ConstructorExtension` here 49 | use extension2::ConstructorExtension; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ConstructorExtension` reimported here | = note: `ConstructorExtension` must be defined only once in the type namespace of this module help: You can use `as` to change the binding name of the import | 49 | use extension2::ConstructorExtension as OtherConstructorExtension; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... ``` This is my first PR that touches the compiler in any way, so if there's something else I need to do here (e.g. add a test), please let me know :).
2017-11-01Rollup merge of #45650 - michaelwoerister:per-crate-type-symbol-threshold, ↵kennytm-2/+12
r=alexcrichton Take crate-type into account when generating symbol export lists (linker version scripts) r? @alexcrichton cc https://github.com/rust-lang/rust/issues/45613
2017-11-01Rollup merge of #45646 - sinkuu:dead-code-alias-in-pat, r=arielb1kennytm-0/+18
Count type aliases used in patterns as usage by dead_code lint Fixes #45614.
2017-11-01Rollup merge of #45644 - zackmdavis:edit_disallowed_inner_attr_note, r=estebankkennytm-2/+1
edit and fix bad spacing of inner-attribute-not-allowed note This multiline string literal was missing a backslash, leaving an awkward newline and 35 spaces in the middle of the message. But while we're here, the existing message seems kind of long in comparison to similar notes: to cut it down, we excise the mentions of doc comments, which seems sensible because we know that this erroneous attribute is not a doc comment (notice the `is_sugared_doc: false` at the end of the function; if it had been a doc comment, that error would get set in the `token::DocComment` match branch of `parse_outer_attributes`).
2017-10-31Add UI testCldfire-0/+38
2017-11-01Improve display of error E0308 for structsJosh Leeb-du Toit-0/+30
Improve the display of error E0308 for structs by adding a "did you mean" span label.
2017-10-31patch mir-opt reference filesNiko Matsakis-7/+13
2017-10-31WIP patch `compile-fail/nll/region-ends-after-if-condition.rs`Niko Matsakis-2/+16
2017-10-31change region display to `'_#Nr`, update the `newtype_index!` macroNiko Matsakis-14/+14
The macro now takes a format string. It no longer defaults to using the type name. Didn't seem worth going through contortions to maintain. I also changed most of the debug formats to be `foo[N]` instead of `fooN`.
2017-10-31connect MIR borrowck with NLLNiko Matsakis-0/+180
2017-10-31add basic region subtyping inferenceSantiago Pastorino-0/+49
2017-10-31add reborrow constraintsSantiago Pastorino-0/+39
2017-10-31update the format of liveness debug dumps to be more readableNiko Matsakis-46/+23
2017-10-31add subregion between borrow region and resulting referenceNiko Matsakis-0/+50
2017-10-31preliminary support for may-dangle attribute and drop constraintsNiko Matsakis-0/+50
2017-10-31extend liveness to distinguish "drop" and "non-drop" usesNiko Matsakis-25/+94
2017-10-31introduce liveness constraints into NLL codeNiko Matsakis-0/+55
And do a bunch of gratuitious refactoring that I did not bother to separate into nice commits.
2017-10-31extend liveness to compute intrablock liveness and add unit testsNiko Matsakis-5/+18
2017-10-31factor out `pre_defs` field by going backwardsNiko Matsakis-0/+36
2017-10-31add a test for the subtle case around callsNiko Matsakis-0/+42
2017-10-31execute liveness, write a simple testNiko Matsakis-0/+47
2017-10-31rustc_typeck: use subtyping on the LHS of binops.Eduard-Mihai Burtescu-2/+59
2017-10-31Add regression test for symbol visibility when compiling rlib+cdylib in one ↵Michael Woerister-2/+12
session.
2017-10-31save-analysis: support unionsNick Cameron-0/+5
2017-10-31Auto merge of #45551 - michaelwoerister:fix-hir-depnodes-and-ich, r=nikomatsakisbors-40/+82
incr.comp.: Fix two problems with HIR hashing. Fixes https://github.com/rust-lang/rust/issues/45469. This PR fixes two small problems: * Overflow checks are always enabled in a constant context, so we need to hash spans of potentially overflowing operations. (Eventually I'd like to handle spans differently so we don't have to make HIR hashing know so much about things like this.) * The HIR map collector had a bug where it would assign the `DepNode::Hir` instead of the corresponding `DepNode::HirBody` in some nested contexts. r? @nikomatsakis
2017-10-31Count type aliases in patternssinkuu-0/+18
2017-10-30edit and fix bad spacing of inner-attribute-not-allowed noteZack M. Davis-2/+1
This multiline string literal was missing a backslash, leaving an awkward newline and 35 spaces in the middle of the message. But while we're here, the existing message seems kind of long in comparison to similar notes: to cut it down, we excise the mentions of doc comments, which seems sensible because we know that this erroneous attribute is not a doc comment (notice the `is_sugared_doc: false` at the end of the function; if it had been a doc comment, that error would get set in the `token::DocComment` match branch of `parse_outer_attributes`).
2017-10-30typeck: suggest use of match_default_bindings featureTamir Duberstein-14/+52
Fixes #45383. Updates #42640.
2017-10-30Auto merge of #45603 - joshleeb:iss42106, r=estebankbors-0/+28
Fix duplicate display of error E0502 Ref. Repeated "mutable/immutable borrow" error messages #42106. This PR modifies the return type of [`report_error_if_loan_conflicts_with_restriction`](https://github.com/rust-lang/rust/blob/0f0f5db465de96b6c12e71f0c7d3e475f618b104/src/librustc_borrowck/borrowck/check_loans.rs#L398-L403) so the result can be checked in [`report_error_if_loans_conflict`](https://github.com/rust-lang/rust/blob/0f0f5db465de96b6c12e71f0c7d3e475f618b104/src/librustc_borrowck/borrowck/check_loans.rs#L377-L396). This is done to prevent displaying a duplicate of the error message E0502 which is referenced in #42106. The output of compiling: ```rust fn do_something<T>(collection: &mut Vec<T>) { let _a = &collection; collection.swap(1, 2); } fn main() {} ``` is now ```bash $ rustc src/test/compile-fail/issue-42106.rs error[E0502]: cannot borrow `*collection` as mutable because `collection` is also borrowed as immutable --> src/test/compile-fail/issue-42106.rs:13:5 | 12 | let _a = &collection; | ---------- immutable borrow occurs here 13 | collection.swap(1, 2); | ^^^^^^^^^^ mutable borrow occurs here 14 | } | - immutable borrow ends here error: aborting due to 2 previous errors ``` r? @estebank
2017-10-30Move issue-42106 test from compile-fail to uiJosh Leeb-du Toit-1/+13
2017-10-29Add several lints into `unused` lint groupVadim Petrochenkov-11/+29
Remove a couple of obsolete lints
2017-10-29Add test for fix duplicate display of E0502Josh Leeb-du Toit-0/+16
2017-10-28Auto merge of #45489 - oli-obk:json_diagnostics, r=petrochenkovbors-2/+25
Fix a quadradic duplication in json for multi-suggestions r? @petrochenkov
2017-10-28Auto merge of #44295 - plietar:extern-types, r=arielb1bors-0/+364
Implement RFC 1861: Extern types A few notes : - Type parameters are not supported. This was an unresolved question from the RFC. It is not clear how useful this feature is, and how variance should be treated. This can be added in a future PR. - `size_of_val` / `align_of_val` can be called with extern types, and respectively return 0 and 1. This differs from the RFC, which specified that they should panic, but after discussion with @eddyb on IRC this seems like a better solution. If/when a `DynSized` trait is added, this will be disallowed statically. - Auto traits are not implemented by default, since the contents of extern types is unknown. This means extern types are `!Sync`, `!Send` and `!Freeze`. This seems like the correct behaviour to me. Manual `unsafe impl Sync for Foo` is still possible. - This PR allows extern type to be used as the tail of a struct, as described by the RFC : ```rust extern { type OpaqueTail; } #[repr(C)] struct FfiStruct { data: u8, more_data: u32, tail: OpaqueTail, } ``` However this is undesirable, as the alignment of `tail` is unknown (the current PR assumes an alignment of 1). Unfortunately we can't prevent it in the general case as the tail could be a type parameter : ```rust #[repr(C)] struct FfiStruct<T: ?Sized> { data: u8, more_data: u32, tail: T, } ``` Adding a `DynSized` trait would solve this as well, by requiring tail fields to be bound by it. - Despite being unsized, pointers to extern types are thin and can be casted from/to integers. However it is not possible to write a `null<T>() -> *const T` function which works with extern types, as I've explained here : https://github.com/rust-lang/rust/issues/43467#issuecomment-321678621 - Trait objects cannot be built from extern types. I intend to support it eventually, although how this interacts with `DynSized`/`size_of_val` is still unclear. - The definition of `c_void` is unmodified
2017-10-28Auto merge of #45503 - thombles:tk/i44339-v5, r=petrochenkovbors-3/+28
Improve diagnostics when list of tokens has incorrect separators Make `parse_seq_to_before_tokens` more resilient to error conditions. Where possible it is better if it can consume up to the final bracket before returning. This change improves the diagnostics in a couple of situations: ``` struct S(pub () ()); // omitted separator use std::{foo. bar}; // used a similar but wrong separator ``` Fixes #44339 r? @petrochenkov
2017-10-27Implement RFC 1861: Extern typesPaul Lietar-0/+364
2017-10-26Auto merge of #45519 - michaelwoerister:dedup-errors, r=arielb1bors-143/+45
Don't emit the same compiler diagnostic twice. This PR makes the compiler filter out diagnostic messages that have already been emitted during the same compilation session.
2017-10-26incr.comp.: Update overflow-check logic in HIR hashing.Michael Woerister-40/+82
2017-10-26Auto merge of #45380 - dotdash:arg_copies, r=arielb1bors-113/+92
Avoid unnecessary copies of arguments that are simple bindings Initially MIR differentiated between arguments and locals, which introduced a need to add extra copies assigning the argument to a local, even for simple bindings. This differentiation no longer exists, but we're still creating those copies, bloating the MIR and LLVM IR we emit. Additionally, the current approach means that we create debug info for both the incoming argument (marking it as an argument), and then immediately shadow it a local that goes by the same name. This can be confusing when using e.g. "info args" in gdb, or when e.g. a debugger with a GUI displays the function arguments separately from the local variables, especially when the binding is mutable, because the argument doesn't change, while the local variable does.
2017-10-26Avoid unnecessary copies of arguments that are simple bindingsBjörn Steinbrink-113/+92
Initially MIR differentiated between arguments and locals, which introduced a need to add extra copies assigning the argument to a local, even for simple bindings. This differentiation no longer exists, but we're still creating those copies, bloating the MIR and LLVM IR we emit. Additionally, the current approach means that we create debug info for both the incoming argument (marking it as an argument), and then immediately shadow it a local that goes by the same name. This can be confusing when using e.g. "info args" in gdb, or when e.g. a debugger with a GUI displays the function arguments separately from the local variables, especially when the binding is mutable, because the argument doesn't change, while the local variable does.
2017-10-26Auto merge of #45488 - oli-obk:ctfe_resolve, r=eddybbors-0/+28
Resolve types properly in const eval r? @eddyb cc @arielb1