about summary refs log tree commit diff
path: root/src/test/ui
AgeCommit message (Collapse)AuthorLines
2018-08-02Auto merge of #52841 - petrochenkov:premacro, r=alexcrichtonbors-14/+395
resolve: Implement prelude search for macro paths, implement tool attributes When identifier is macro path is resolved in scopes (i.e. the first path segment - `foo` in `foo::mac!()` or `foo!()`), scopes are searched in the same order as for non-macro paths - items in modules, extern prelude, tool prelude (see later), standard library prelude, language prelude, but with some extra shadowing restrictions (names from globs and macro expansions cannot shadow names from outer scopes). See the comment in `fn resolve_lexical_macro_path_segment` for more details. "Tool prelude" currently contains two "tool modules" `rustfmt` and `clippy`, and is searched immediately after extern prelude. This makes the [possible long-term solution](https://github.com/rust-lang/rfcs/blob/master/text/2103-tool-attributes.md#long-term-solution) for tool attributes exactly equivalent to the existing extern prelude scheme, except that `--extern=my_crate` making crate names available in scope is replaced with something like `--tool=my_tool` making tool names available in scope. The `tool_attributes` feature is still unstable and `#![feature(tool_attributes)]` now implicitly enables `#![feature(use_extern_macros)]`. `use_extern_macros` is a prerequisite for `tool_attributes`, so their stabilization will happen in the same order. If `use_extern_macros` is not enabled, then tool attributes are treated as custom attributes (this is temporary, anyway). Fixes https://github.com/rust-lang/rust/issues/52576 Fixes https://github.com/rust-lang/rust/issues/52512 Fixes https://github.com/rust-lang/rust/issues/51277 cc https://github.com/rust-lang/rust/issues/52269
2018-08-02Auto merge of #52782 - pnkfelix:issue-45696-dangly-paths-for-box, r=eddybbors-4/+440
[NLL] Dangly paths for box Special-case `Box` in `rustc_mir::borrow_check`. Since we know dropping a box will not access any `&mut` or `&` references, it is safe to model its destructor as only touching the contents *owned* by the box. ---- There are three main things going on here: 1. The first main thing, this PR is fixing a bug in NLL where `rustc` previously would issue a diagnostic error in a case like this: ```rust fn foo(x: Box<&mut i32>) -> &mut i32 { &mut **x } ``` such code was accepted by the AST-borrowck in the past, but NLL was rejecting it with the following message ([playground](https://play.rust-lang.org/?gist=13c5560f73bfb16d6dab3ceaad44c0f8&version=nightly&mode=release&edition=2015)) ``` error[E0597]: `**x` does not live long enough --> src/main.rs:3:40 | 3 | fn foo(x: Box<&mut i32>) -> &mut i32 { &mut **x } | ^^^^^^^^ - `**x` dropped here while still borrowed | | | borrowed value does not live long enough | note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 3:1... --> src/main.rs:3:1 | 3 | fn foo(x: Box<&mut i32>) -> &mut i32 { &mut **x } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error ``` 2. The second main thing: The reason such code was previously rejected was because NLL (MIR-borrowck) incorporates a fix for issue #31567, where it models a destructor's execution as potentially accessing any borrows held by the thing being destructed. The tests with `Scribble` model this, showing that the compiler now catches such unsoundness. However, that fix for issue #31567 is too strong, in that NLL (MIR-borrowck) includes `Box` as one of the types with a destructor that potentially accesses any borrows held by the box. This thus was the cause of the main remaining discrepancy between AST-borrowck and MIR-borrowck, as documented in issue #45696, specifically in [the last example of this comment](https://github.com/rust-lang/rust/issues/45696#issuecomment-345367873), which I have adapted into the `fn foo` shown above. We did close issue #45696 back in December of 2017, but AFAICT that example was not fixed by PR #46268. (And we did not include a test, etc etc.) This PR fixes that case, by trying to model the so-called `DerefPure` semantics of `Box<T>` when we traverse the type of the input to `visit_terminator_drop`. 3. The third main thing is that during a review of the first draft of this PR, @matthewjasper pointed out that the new traversal of `Box<T>` could cause the compiler to infinite loop. I have adjusted the PR to avoid this (by tracking what types we have previously seen), and added a much needed test of this somewhat odd scenario. (Its an odd scenario because the particular case only arises for things like `struct A(Box<A>);`, something which cannot be constructed in practice.) Fix #45696.
2018-08-02Auto merge of #52949 - Mark-Simulacrum:snap, r=alexcrichtonbors-4/+1
Switch to bootstrapping from 1.29 beta r? @alexcrichton
2018-08-02When we turn on NLL migration in the 2018 edition, we need two-phase borrows ↵Felix S. Klock II-0/+32
too! Fix #52967.
2018-08-01Rollup merge of #52954 - cramertj:async-parse, r=petrochenkovPietro Albini-0/+23
async can begin expressions Fix https://github.com/rust-lang/rust/issues/52951 r? @petrochenkov
2018-08-01Rollup merge of #52926 - alexcrichton:trim-idioms-lints, r=oli-obkPietro Albini-7/+6
rustc: Trim down the `rust_2018_idioms` lint group These migration lints aren't all up to par in terms of a good migration experience. Some, like `unreachable_pub`, hit bugs like #52665 and unprepared macros to be handled enough of the time. Others like linting against `#[macro_use]` are swimming upstream in an ecosystem that's not quite ready (and slightly buggy pending a few current PRs). The general idea is that we will continue to recommend the `rust_2018_idioms` lint group as part of the transition guide (as an optional step) but we'll be much more selective about which lints make it into this group. Only those with a strong track record of not causing too much churn will make the cut. cc #52679
2018-08-01Rollup merge of #52899 - draganmladjenovic:ui_tests64, r=alexcrichtonPietro Albini-10/+14
tests/ui: Add missing mips{64} ignores
2018-08-01Rollup merge of #52834 - matthewjasper:allow-zst-conflicts, r=pnkfelixPietro Albini-0/+23
[NLL] Allow conflicting borrows of promoted length zero arrays This is currently overkill as there's no way to create two conflicting borrows of any promoted. It is possible that the following code might not fail due to const eval in the future (@oli-obk?). In which case either the array marked needs to not be promoted, or to be checked for conflicts ```rust static mut A: () = { let mut y = None; let z; let mut done_y = false; loop { let x = &mut [1]; // < this array if done_y { z = x; break; } y = Some(x); done_y = true; } some_const_fn(y, z); // some_const_fn expects that y to not alias z. }; ``` r? @pnkfelix @nikomatsakis closes #52671 cc #51823
2018-08-01Rollup merge of #52809 - davidtwco:issue-49579, r=pnkfelixPietro Albini-0/+27
Add test for unexpected region for local data ReStatic Fixes #49579. r? @pnkfelix @nikomatsakis
2018-08-01Rollup merge of #52793 - davidtwco:issue-49824, r=pnkfelixPietro Albini-0/+60
Add test for NLL: unexpected "free region `` does not outlive" error Fixes #49824. r? @pnkfelix @nikomatsakis
2018-08-01Switch to bootstrapping from 1.29 betaMark Rousskov-4/+1
2018-08-01async can begin expressionsTaylor Cramer-0/+23
2018-08-01Fix bug in test pointed out during review.Felix S. Klock II-2/+2
2018-08-01Expand long-live-borrows-in-boxes test to include simplier illustrative cases.Felix S. Klock II-5/+35
After talking about the PR with eddyb, I decided it was best to try to have some test cases that simplify the problem down to its core, so that people trying to understand what the issue is here will see those core examples first.
2018-08-01Test for (previously uncaught) infinite loop identified by matthewjasper.Felix S. Klock II-0/+66
2018-08-01Regression tests.Felix S. Klock II-0/+344
2018-08-01minor fallout from the change.Felix S. Klock II-4/+0
(Presumably the place that borrow_check ends up reporting for the error about is no longer the root `Local` itself, and thus the note diagnostic here stops firing.)
2018-08-01Added test for #49824.David Wood-0/+60
2018-08-01rustc: Trim down the `rust_2018_idioms` lint groupAlex Crichton-7/+6
These migration lints aren't all up to par in terms of a good migration experience. Some, like `unreachable_pub`, hit bugs like #52665 and unprepared macros to be handled enough of the time. Others like linting against `#[macro_use]` are swimming upstream in an ecosystem that's not quite ready (and slightly buggy pending a few current PRs). The general idea is that we will continue to recommend the `rust_2018_idioms` lint group as part of the transition guide (as an optional step) but we'll be much more selective about which lints make it into this group. Only those with a strong track record of not causing too much churn will make the cut. cc #52679
2018-08-01resolve: Implement prelude search for macro pathsVadim Petrochenkov-14/+395
resolve/expansion: Implement tool attributes
2018-08-01Rollup merge of #52907 - ↵Pietro Albini-38/+75
pnkfelix:issue-52877-original-source-should-precede-suggestions, r=petrochenkov NLL: On "cannot move out of type" error, print original before rewrite NLL: On "cannot move out of type" error, print original source before rewrite. * Arguably this change is sometimes injecting noise into the output (namely in the cases where the suggested rewrite is inline with the suggestion and we end up highlighting the original source code). I would not be opposed to something more aggressive/dynamic, like revising the suggestion code to automatically print the original source when necessary (e.g. when the error does not have a span that includes the span of the suggestion). * Also, as another note on this change: The doc comment for `Diagnostic::span_suggestion` says: ```rust /// The message /// /// * should not end in any punctuation (a `:` is added automatically) /// * should not be a question /// * should not contain any parts like "the following", "as shown" ``` * but the `:` is *not* added when the emitted line appears out-of-line relative to the suggestion. I find that to be an unfortunate UI experience. ---- As a drive-by fix, also changed code to combine multiple suggestions for a pattern into a single multipart suggestion (which vastly improves user experience IMO). ---- Includes the updates to expected NLL diagnostics. Fix #52877
2018-08-01Rollup merge of #52904 - pnkfelix:issue-51167-sort-by-span, r=petrochenkovPietro Albini-351/+351
NLL: sort diagnostics by span Sorting the output diagnostics by span is a long planned revision to the NLL diagnostics that we hope will yield a less surprising user experience in some case. Once we got them buffered, it was trivial to implement. (The hard part is skimming the resulting changes to the diagnostics to make sure nothing broke... Note that I largely rubber-stamped the `#[rustc_regions]` output change.) Fix #51167
2018-08-01Rollup merge of #52888 - estebank:shell-sugg, r=oli-obkPietro Albini-5/+24
Use suggestions for shell format arguments Follow up to #52649.
2018-08-01Rollup merge of #52883 - estebank:nll-diag-mut, r=oli-obkPietro Albini-10/+10
Include lifetime in mutability suggestion in NLL messages Fix #52880.
2018-08-01Rollup merge of #52878 - mikhail-m1:master, r=kennytmPietro Albini-1/+1
Fix wrong issue number in the test name I made a mistake in previous PR #52620, second issue number was wrong, changing from #52133 to #52113 r? @kennytm
2018-08-01Rollup merge of #52810 - matthewjasper:more-immutablity, r=pnkfelixPietro Albini-0/+9
[NLL] Don't make "fake" match variables mutable These variables can't be mutated by the user, but since they have names the unused-mut lint thinks that it should check them.
2018-07-31Use suggestions for shell format argumentsEsteban Küber-5/+24
2018-07-31Auto merge of #52234 - petrochenkov:macuse2, r=Mark-Simulacrumbors-8/+325
resolve: Modularize crate-local `#[macro_export] macro_rules` Based on https://github.com/rust-lang/rust/pull/50911, cc https://github.com/rust-lang/rust/pull/50911#issuecomment-401151270 `#[macro_export] macro_rules` items are collected from the whole crate and are planted into the root module as items, so the external view of the crate is symmetric with its internal view and something like `$crate::my_macro` where `my_macro` is `#[macro_export] macro_rules` works both locally and from other crates. Closes https://github.com/rust-lang/rust/issues/52726
2018-07-31Allow borrow conflicts for promoted length 0 arraysMatthew Jasper-0/+23
2018-07-31NLL: On "cannot move out of type" error, print original source before rewrite.Felix S. Klock II-38/+75
* Arguably this change is sometimes injecting noise into the output (namely in the cases where the suggested rewrite is inline with the suggestion and we end up highlighting the original source code). I would not be opposed to something more aggressive/dynamic, like revising the suggestion code to automatically print the original source when necessary (e.g. when the error does not have a span that includes the span of the suggestion). * Also, as another note on this change: The doc comment for `Diagnostic::span_suggestion` says: /// The message /// /// * should not end in any punctuation (a `:` is added automatically) /// * should not be a question /// * should not contain any parts like "the following", "as shown" but the `:` is *not* added when the emitted line appears out-of-line relative to the suggestion. I find that to be an unfortunate UI experience. ---- As a drive-by fix, also changed code to combine multiple suggestions for a pattern into a single multipart suggestion (which vastly improves user experience IMO). ---- Includes the updates to expected NLL diagnostics.
2018-07-31tests/ui: Add missing mips{64} ignoresdragan.mladjenovic-10/+14
2018-07-31Update the `.nll.stderr` files under new sorted-by-span scheme.Felix S. Klock II-72/+72
2018-07-31Update tests that use `-Z borrowck=compare` or `#[feature(nll)]` to ↵Felix S. Klock II-25/+25
accmmodate diagnostic change.
2018-07-31Blindly update the `#[rustc_region]` tests which got touched by the NLL ↵Felix S. Klock II-254/+254
diagnostic change.
2018-07-31add regression test for #52057Niko Matsakis-0/+35
Fixes #52057
2018-07-30Include lifetime in mutability suggestion in NLL messagesEsteban Küber-10/+10
2018-07-30Fix wrong issue number in the test nameMikhail Modin-1/+1
2018-07-30Auto merge of #52722 - alexcrichton:more-identifier-lints, r=oli-obkbors-0/+38
Tweak the raw_identifiers lints in 2018 * Enable the `raw_identifiers` feature automatically in the 2018 preview * Only emit lint warnings if the `raw_identifiers` feature is activated cc rust-lang/cargo#5783
2018-07-29Move a test that depends on the arch bitwidth to compile-failOliver Schneider-132/+0
2018-07-29Sanity-check all constantsOliver Schneider-13/+549
2018-07-29resolve: Modularize crate-local `#[macro_export] macro_rules`Vadim Petrochenkov-8/+325
2018-07-29Auto merge of #52620 - mikhail-m1:51351, r=nikomatsakisbors-46/+139
fix simple case of issue #51351 and #52133 r? @nikomatsakis
2018-07-29fix issues #51351 and #52133Mikhail Modin-46/+139
2018-07-28Don't make "fake" match variables mutableMatthew Jasper-0/+9
2018-07-28Added test for #49579.David Wood-0/+27
2018-07-28Auto merge of #52761 - toidiu:ak-static-infer-fg, r=nikomatsakisbors-0/+121
static infer feature gate https://github.com/rust-lang/rust/issues/44493 r? @nikomatsakis
2018-07-28Auto merge of #52802 - kennytm:rollup, r=kennytmbors-0/+46
Rollup of 11 pull requests Successful merges: - #52702 (Suggest fix when encountering different mutability from impl to trait) - #52703 (Improve a few vectors - calculate capacity or build from iterators) - #52740 (Suggest underscore when using dashes in crate namet push fork) - #52759 (Impl Send & Sync for JoinHandle) - #52760 (rustc_metadata: test loading atoi instead of cos) - #52763 (Omit the vendor component in Fuchsia triple) - #52765 (Remove unused "-Zenable_nonzeroing_move_hints" flag) - #52769 (Incorporate a stray test) - #52777 (Fix doc comment for 'ptr::copy_to' method) - #52779 (revert accidental atty downgrade) - #52781 (Use a slice where a vector is not necessary) Failed merges: r? @ghost
2018-07-28Rollup merge of #52740 - estebank:crate-name, r=petrochenkovkennytm-0/+34
Suggest underscore when using dashes in crate namet push fork Fix #48437.
2018-07-28Rollup merge of #52702 - csmoe:mut_diff, r=estebankkennytm-0/+12
Suggest fix when encountering different mutability from impl to trait Closes https://github.com/rust-lang/rust/issues/52412 r? @estebank
2018-07-28Auto merge of #52678 - matthewjasper:better-spans, r=nikomatsakisbors-134/+272
[NLL] Use better spans in some errors * Use the span of the discriminant and patterns for "fake" statements created to properly check matches. I plan to special case these soon, but this felt like a good first step * Use the span of the statement, rather than the initialization, when reporting move errors for `let x = ...`, which avoids giving an unhelpful suggestion to use `&{ }`. r? @nikomatsakis cc @pnkfelix