about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2020-06-01test miri-unleash TLS accessesRalf Jung-3/+55
2020-06-01Auto merge of #71192 - oli-obk:eager_alloc_id_canonicalization, r=wesleywiserbors-0/+53
Make TLS accesses explicit in MIR r? @rust-lang/wg-mir-opt cc @RalfJung @vakaras for miri thread locals cc @bjorn3 for cranelift fixes #70685
2020-06-01Rollup merge of #72823 - matthewjasper:describe-queries, r=eddybDylan DPC-56/+61
Add descriptions for all queries This also removes the default description for queries with DefId keys and makes the macro validate that a description is provided. cc #72730 r? @eddyb
2020-05-31Rollup merge of #72807 - xiaotianrandom:fix-assoc-type-diagnostics, r=estebankDylan DPC-0/+29
Avoid setting wrong obligation cause span of associated type mismatch Removes code that sets wrong obligation cause span of associated type mismatch. See the linked issue for details. Closes #72806.
2020-05-31Add descriptions for all queriesMatthew Jasper-56/+61
2020-05-31Rollup merge of #72715 - estebank:trailing-comma-where, r=petrochenkovRalf Jung-1/+1
Account for trailing comma when suggesting `where` clauses Fix #72693.
2020-05-31Add a test for wrong assoc type diagnosticsXIAO Tian-0/+29
2020-05-30Rollup merge of #72772 - RalfJung:valid-char, r=petrochenkovRalf Jung-1/+1
miri validation: clarify valid values of 'char' The old text said "expected a valid unicode codepoint", which is not actually correct -- it has to be a scalar value (which is a code point that is not part of a surrogate pair).
2020-05-30Rollup merge of #72757 - petrochenkov:shebang, r=varkorRalf Jung-0/+14
rustc_lexer: Optimize shebang detection slightly Sorry, I just couldn't resist. It shouldn't make any difference in practice. Also, documented a previously unnoticed case with doc comments treated as regular comments during shebang detection.
2020-05-30Rollup merge of #72668 - ↵Ralf Jung-0/+68
awoimbee:give-fn-parenthetical-notation-parentheses, r=estebank Fix missing parentheses Fn notation error Fixes #72611 Well, fixes the error output, I think E0658 is the right error to throw in this case so I didn't change that
2020-05-30Rollup merge of #72666 - ivanloz:profile_emit_flag, r=matthewjasperRalf Jung-0/+3
Add -Z profile-emit=<path> for Gcov gcda output. Adds a -Z flag to control the file path that the Gcov gcda output is written to during runtime. This flag expects a path and filename, e.g. -Z profile-emit=gcov/out/lib.gcda. This works similar to GCC/Clang's -fprofile-dir flag which allows control over the output path for gcda coverage files.
2020-05-30Rollup merge of #72657 - flip1995:impl_lint_pass-ty, r=matthewjasperRalf Jung-0/+26
Allow types (with lifetimes/generics) in impl_lint_pass cc https://github.com/rust-lang/rust-clippy/pull/5279#discussion_r430790267 This allows to implement `LintPass` for types with lifetimes and/or generics. The only thing, I'm not sure of is the `LintPass::name` function, which now includes the lifetime(s) (which will be `'_` most of the time) in the name returned for the lint pass, if it exists. But I don't think that this should be a problem, since the `LintPass::name` is never used for output for the user (?).
2020-05-30Rollup merge of #72637 - euclio:env-hygiene, r=davidtwcoRalf Jung-0/+8
expand `env!` with def-site context Similar to #66349. Fixes rust-lang/rust-clippy#5619.
2020-05-30Rollup merge of #72625 - Amanieu:asm-srcloc, r=petrochenkovRalf Jung-12/+133
Improve inline asm error diagnostics Previously we were just using the raw LLVM error output (with line, caret, etc) as the diagnostic message, which ends up looking rather out of place with our existing diagnostics. The new diagnostics properly format the diagnostics and also take advantage of LLVM's per-line `srcloc` attribute to map an error in inline assembly directly to the relevant line of source code. Incidentally also fixes #71639 by disabling `srcloc` metadata during LTO builds since we don't know what crate it might have come from. We can only resolve `srcloc`s from the currently crate since it indexes into the source map for the current crate. Fixes #72664 Fixes #71639 r? @petrochenkov ### Old style ```rust #![feature(llvm_asm)] fn main() { unsafe { let _x: i32; llvm_asm!( "mov $0, $1 invalid_instruction $0, $1 mov $0, $1" : "=&r" (_x) : "r" (0) :: "intel" ); } } ``` ``` error: <inline asm>:3:14: error: invalid instruction mnemonic 'invalid_instruction' invalid_instruction ecx, eax ^~~~~~~~~~~~~~~~~~~ --> src/main.rs:6:9 | 6 | / llvm_asm!( 7 | | "mov $0, $1 8 | | invalid_instruction $0, $1 9 | | mov $0, $1" ... | 12 | | :: "intel" 13 | | ); | |__________^ ``` ### New style ```rust #![feature(asm)] fn main() { unsafe { asm!( "mov {0}, {1} invalid_instruction {0}, {1} mov {0}, {1}", out(reg) _, in(reg) 0i64, ); } } ``` ``` error: invalid instruction mnemonic 'invalid_instruction' --> test.rs:7:14 | 7 | invalid_instruction {0}, {1} | ^ | note: instantiated into assembly here --> <inline asm>:3:14 | 3 | invalid_instruction rax, rcx | ^^^^^^^^^^^^^^^^^^^ ```
2020-05-30Tweak wording and spans of `'static` `dyn Trait`/`impl Trait` requirementsEsteban Küber-135/+65
2020-05-30Account for enclosing item when suggesting new lifetime nameEsteban Küber-10/+63
2020-05-30Tweak type parameter errors to reduce verbosityEsteban Küber-363/+55
2020-05-30Update nll testsEsteban Küber-8/+29
2020-05-30review comment: tweak wording and account for span overlapEsteban Küber-21/+20
2020-05-30Account for returned `dyn Trait` evaluating to `'static` lifetimeEsteban Küber-63/+114
Provide a suggestion for `dyn Trait + '_` when possible.
2020-05-30Fix NLL outputEsteban Küber-12/+98
2020-05-30Improve output of argument anonymous borrow missing annotation involving ↵Esteban Küber-68/+19
opaque return type Go from ``` error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements --> file8.rs:22:5 | 22 | / move || { 23 | | *dest = g.get(); 24 | | } | |_____^ | note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the function body at 18:1... --> file8.rs:18:1 | 18 | / fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a 19 | | where 20 | | G: Get<T> 21 | | { ... | 24 | | } 25 | | } | |_^ note: ...so that the types are compatible --> file8.rs:22:5 | 22 | / move || { //~ ERROR cannot infer an appropriate lifetime 23 | | *dest = g.get(); 24 | | } | |_____^ = note: expected `&mut T` found `&mut T` note: but, the lifetime must be valid for the lifetime `'a` as defined on the function body at 18:8... --> file8.rs:18:8 | 18 | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a | ^^ note: ...so that return value is valid for the call --> file8.rs:18:45 | 18 | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a | ^^^^^^^^^^^^^^^^^^^^^^^ ``` to ``` error[E0621]: explicit lifetime required in the type of `dest` --> file8.rs:18:45 | 18 | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a | ------ ^^^^^^^^^^^^^^^^^^^^^^^ lifetime `'a` required | | | help: add explicit lifetime `'a` to the type of `dest`: `&'a mut T` ```
2020-05-30Account for missing lifetime in opaque return typeEsteban Küber-0/+246
When encountering an opaque closure return type that needs to bound a lifetime to the function's arguments, including borrows and type params, provide appropriate suggestions that lead to working code. Get the user from ```rust fn foo<G, T>(g: G, dest: &mut T) -> impl FnOnce() where G: Get<T> { move || { *dest = g.get(); } } ``` to ```rust fn foo<'a, G: 'a, T>(g: G, dest: &'a mut T) -> impl FnOnce() +'a where G: Get<T> { move || { *dest = g.get(); } } ```
2020-05-30Test ui suggestion fn trait notationArthur Woimbée-0/+68
2020-05-30Rollup merge of #72607 - Amanieu:fix-72570, r=oli-obkRalf Jung-0/+18
Eagerly lower asm sub-expressions to HIR even if there is an error Fixes #72570 r? @oli-obk
2020-05-30Rollup merge of #72585 - Aaron1011:feature/opt-item-tokens, r=petrochenkovRalf Jung-2/+2
Only capture tokens for items with outer attributes Suggested by @petrochenkov in https://github.com/rust-lang/rust/issues/43081#issuecomment-633389225
2020-05-30Rollup merge of #72540 - davidtwco:issue-67552-mono-collector-comparison, ↵Ralf Jung-20/+69
r=varkor mir: adjust conditional in recursion limit check Fixes #67552. This PR adjusts the condition used in the recursion limit check of the monomorphization collector, from `>` to `>=`. In #67552, the test case had infinite indirect recursion, repeating a handful of functions (from the perspective of the monomorphization collector): `rec` -> `identity` -> `Iterator::count` -> `Iterator::fold` -> `Iterator::next` -> `rec`. During this process, `resolve_associated_item` was invoked for `Iterator::fold` (during the construction of an `Instance`), and ICE'd due to substitutions needing inference. However, previous iterations of this recursion would have called this function for `Iterator::fold` - and did! - and succeeded in doing so (trivially checkable from debug logging, `()` is present where `_` is in the substs of the failing execution). The expected outcome of this test case would be a recursion limit error (which is present when the `identity` fn indirection is removed), and the recursion depth of `rec` is increasing (other functions finish collecting their neighbours and thus have their recursion depths reset). When the ICE occurs, the recursion depth of `rec` is 256 (which matches the recursion limit), which suggests perhaps that a different part of the compiler is using a `>=` comparison and returning a different result on this recursion rather than what it returned in every previous recursion, thus stopping the monomorphization collector from reporting an error on the next recursion, where `recursion_depth_of_rec > 256` would have been true. With grep and some educated guesses, we can determine that the recursion limit check at line 818 in `src/librustc_trait_selection/traits/project.rs` is the other check that is using a different comparison. Modifying either comparison to be `>` or `>=` respectively will fix the error, but changing the monomorphization collector produces the nicer error.
2020-05-30Rollup merge of #72521 - Amanieu:fix-72484, r=petrochenkovRalf Jung-0/+38
Properly handle InlineAsmOperand::SymFn when collecting monomorphized items Fixes #72484
2020-05-30Rollup merge of #72441 - doctorn:late-bound-lifetime-ice, r=nikomatsakisRalf Jung-0/+34
Fix ICE with explicit late-bound lifetimes Rather than returning an explicit late-bound lifetime as a generic argument count mismatch (which is not necessarily true), this PR propagates the presence of explicit late-bound lifetimes. This avoids an ICE that can occur due to the presence of explicit late-bound lifetimes when building generic substitutions by explicitly ignoring them. r? @varkor cc @davidtwco (this removes a check you introduced in #60892) Resolves #72278
2020-05-30Make TLS accesses explicit in MIROliver Scherer-0/+53
2020-05-30miri validation: clarify valid values of 'char'Ralf Jung-1/+1
2020-05-30Rollup merge of #72741 - tmiasko:unused-mut, r=Mark-SimulacrumYuki Okushi-1/+1
Remove unused mut from long-linker-command-lines test
2020-05-30Rollup merge of #72724 - Aaron1011:revert-tokenstream-expand, r=petrochenkovYuki Okushi-30/+0
Revert recursive `TokenKind::Interpolated` expansion for now The crater run https://github.com/rust-lang/rust/issues/72622 revealed many root regressions, at least one of which is going to take some time to fix. For now, let's revert https://github.com/rust-lang/rust/pull/72388 to allow the 709 affected crates to continue building on the latest nightly.
2020-05-30Rollup merge of #72710 - jsgf:unused-deps-test, r=jsgfYuki Okushi-0/+15
Add test to make sure -Wunused-crate-dependencies works with tests Make sure code in `#[test]` blocks counts as a use of a crate.
2020-05-30Rollup merge of #72677 - chrissimpkins:fix-72574, r=estebankYuki Okushi-0/+46
Fix diagnostics for `@ ..` binding pattern in tuples and tuple structs Fixes #72574 Associated https://github.com/rust-lang/rust/pull/72534 https://github.com/rust-lang/rust/issues/72373 Includes a new suggestion with `Applicability::MaybeIncorrect` confidence level. ### Before #### tuple ``` error: `..` patterns are not allowed here --> src/main.rs:4:19 | 4 | (_a, _x @ ..) => {} | ^^ | = note: only allowed in tuple, tuple struct, and slice patterns error[E0308]: mismatched types --> src/main.rs:4:9 | 3 | match x { | - this expression has type `({integer}, {integer}, {integer})` 4 | (_a, _x @ ..) => {} | ^^^^^^^^^^^^^ expected a tuple with 3 elements, found one with 2 elements | = note: expected tuple `({integer}, {integer}, {integer})` found tuple `(_, _)` error: aborting due to 2 previous errors ``` #### tuple struct ``` error: `..` patterns are not allowed here --> src/main.rs:6:25 | 6 | Binder(_a, _x @ ..) => {} | ^^ | = note: only allowed in tuple, tuple struct, and slice patterns error[E0023]: this pattern has 2 fields, but the corresponding tuple struct has 3 fields --> src/main.rs:6:9 | 1 | struct Binder(i32, i32, i32); | ----------------------------- tuple struct defined here ... 6 | Binder(_a, _x @ ..) => {} | ^^^^^^^^^^^^^^^^^^^ expected 3 fields, found 2 error: aborting due to 2 previous errors ``` ### After *Note: final output edited during source review discussion, see thread for details* #### tuple ``` error: `_x @` is not allowed in a tuple --> src/main.rs:4:14 | 4 | (_a, _x @ ..) => {} | ^^^^^^^ is only allowed in a slice | help: replace with `..` or use a different valid pattern | 4 | (_a, ..) => {} | ^^ error[E0308]: mismatched types --> src/main.rs:4:9 | 3 | match x { | - this expression has type `({integer}, {integer}, {integer})` 4 | (_a, _x @ ..) => {} | ^^^^^^^^^^^^^ expected a tuple with 3 elements, found one with 1 element | = note: expected tuple `({integer}, {integer}, {integer})` found tuple `(_,)` error: aborting due to 2 previous errors ``` #### tuple struct ``` error: `_x @` is not allowed in a tuple struct --> src/main.rs:6:20 | 6 | Binder(_a, _x @ ..) => {} | ^^^^^^^ is only allowed in a slice | help: replace with `..` or use a different valid pattern | 6 | Binder(_a, ..) => {} | ^^ error[E0023]: this pattern has 1 field, but the corresponding tuple struct has 3 fields --> src/main.rs:6:9 | 1 | struct Binder(i32, i32, i32); | ----------------------------- tuple struct defined here ... 6 | Binder(_a, _x @ ..) => {} | ^^^^^^^^^^^^^^^^^^^ expected 3 fields, found 1 error: aborting due to 2 previous errors ``` r? @estebank
2020-05-30Rollup merge of #72621 - Aaron1011:fix/trait-select-error, r=nikomatsakisYuki Okushi-0/+50
Don't bail out of trait selection when predicate references an error Fixes #72590 With PR #70551, observing a `ty::Error` guarantees that compilation is going to fail. Therefore, there are no soundness impliciations to continuing on when we encounter a `ty::Error` - we can only affect whether or not additional error messags are emitted. By not bailing out, we avoid incorrectly determining that types are `!Sized` when a type error is present, which allows us to avoid emitting additional spurious error messages. The original comment mentioned this code being shared by coherence - howver, this change resulted in no diagnostic changes in any of the existing tests.
2020-05-29Auto merge of #72756 - RalfJung:rollup-tbjmtx2, r=RalfJungbors-123/+1027
Rollup of 9 pull requests Successful merges: - #67460 (Tweak impl signature mismatch errors involving `RegionKind::ReVar` lifetimes) - #71095 (impl From<[T; N]> for Box<[T]>) - #71500 (Make pointer offset methods/intrinsics const) - #71804 (linker: Support `-static-pie` and `-static -shared`) - #71862 (Implement RFC 2585: unsafe blocks in unsafe fn) - #72103 (borrowck `DefId` -> `LocalDefId`) - #72407 (Various minor improvements to Ipv6Addr::Display) - #72413 (impl Step for char (make Range*<char> iterable)) - #72439 (NVPTX support for new asm!) Failed merges: r? @ghost
2020-05-29fix diagnostics for `@ ..` binding pattern in tuples and tuple structsChris Simpkins-0/+46
fix comment add newline for tidy fmt error... edit suggestion message change the suggestion message to better handle cases with binding modes Apply suggestions from estebank code review Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com> edits to address source review Apply suggestions from estebank code review #2 Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com> update test files
2020-05-29Rollup merge of #72439 - westernmagic:master, r=AmanieuRalf Jung-0/+133
NVPTX support for new asm! This PR implements the new `asm!` syntax for the `nvptx64-nvidia-cuda` target. r? @Amanieu
2020-05-29Rollup merge of #71862 - LeSeulArtichaut:unsafe-block-in-unsafe-fn, ↵Ralf Jung-0/+343
r=nikomatsakis Implement RFC 2585: unsafe blocks in unsafe fn Tracking issue: #71668 r? @RalfJung cc @nikomatsakis
2020-05-29Rollup merge of #71500 - josephlr:offset, r=oli-obk,RalfJungRalf Jung-25/+315
Make pointer offset methods/intrinsics const Implements #71499 using [the implementations from miri](https://github.com/rust-lang/miri/blob/52f5d202bdcfe8986f0615845f8d1647ab8a2c6a/src/shims/intrinsics.rs#L96-L112). I added some tests what's allowed and what's UB. Let me know if any other cases should be added. CC: @RalfJung @oli-obk
2020-05-29Rollup merge of #71095 - pickfire:box-from-array, r=dtolnayRalf Jung-6/+25
impl From<[T; N]> for Box<[T]> Based on https://github.com/rust-lang/rust/pull/68692
2020-05-29Rollup merge of #67460 - estebank:named-lts, r=nikomatsakisRalf Jung-92/+211
Tweak impl signature mismatch errors involving `RegionKind::ReVar` lifetimes Fix #66406, fix #72106. ``` error: `impl` item signature doesn't match `trait` item signature --> $DIR/trait-param-without-lifetime-constraint.rs:14:5 | LL | fn get_relation(&self) -> To; | ----------------------------- expected `fn(&Article) -> &ProofReader` ... LL | fn get_relation(&self) -> &ProofReader { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&Article) -> &ProofReader` | = note: expected `fn(&Article) -> &ProofReader` found `fn(&Article) -> &ProofReader` help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait` --> $DIR/trait-param-without-lifetime-constraint.rs:10:31 | LL | fn get_relation(&self) -> To; | ^^ consider borrowing this type parameter in the trait ``` r? @nikomatsakis
2020-05-29rustc_lexer: Optimize shebang detection slightlyVadim Petrochenkov-0/+14
2020-05-29Rollup merge of #72572 - JohnTitor:add-tests, r=matthewjasperDylan DPC-0/+79
Add some regression tests Closes #68532 Closes #70121 Closes #71042 CC #56445 r? @matthewjasper since they (except for #71042) are related to #72362.
2020-05-29Rollup merge of #72465 - tmiasko:liveness-upvars, r=nikomatsakisDylan DPC-10/+335
Warn about unused captured variables Include captured variables in liveness analysis. Warn when captured variables are unused (but possibly read or written to). Warn about dead assignments to captured variables. Fixes #37707. Fixes #47128. Fixes #63220.
2020-05-29Rollup merge of #72383 - DarkEld3r:issue-72322, r=matthewjasperDylan DPC-4/+16
Suggest using std::mem::drop function instead of explicit destructor call I would prefer to give a better suggestion that includes code example, but I'm currently stuck on getting the correct span for that. Closes #72322.
2020-05-29Improve inline asm error diagnosticsAmanieu d'Antras-12/+133
2020-05-29liveness: Warn about unused captured variablesTomasz Miąsko-10/+335
2020-05-29Auto merge of #72727 - JohnTitor:rollup-nni16m2, r=JohnTitorbors-2/+51
Rollup of 11 pull requests Successful merges: - #71633 (Impl Error for Infallible) - #71843 (Tweak and stabilize AtomicN::fetch_update) - #72288 (Stabilization of weak-into-raw) - #72324 (Stabilize AtomicN::fetch_min and AtomicN::fetch_max) - #72452 (Clarified the documentation for Formatter::precision) - #72495 (Improve E0601 explanation) - #72534 (Improve missing `@` in slice binding pattern diagnostics) - #72547 (Added a codegen test for a recent optimization for overflow-checks=on) - #72711 (remove redundant `mk_const`) - #72713 (Whitelist #[allow_internal_unstable]) - #72720 (Clarify the documentation of `take`) Failed merges: r? @ghost