about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2020-02-21Improve testJonas Schievink-4/+45
2020-02-21Test interactions with specializationJonas Schievink-0/+73
2020-02-21Add tests for assoc. const defaultsJonas Schievink-0/+182
2020-02-21Add comments and assertions to testsJonas Schievink-8/+25
2020-02-21Add regression test for #54182Jonas Schievink-0/+94
2020-02-21Implement RFC 2532 – Associated Type DefaultsJonas Schievink-116/+218
2020-02-21print vis & defaultness for nested itemsMazdak Farrokhzad-26/+47
2020-02-21Auto merge of #69330 - Centril:literally-melting-ice, r=eddybbors-0/+26
`lit_to_const`: gracefully bubble up type errors. Fixes https://github.com/rust-lang/rust/issues/69310 which was injected by https://github.com/rust-lang/rust/pull/68118. r? @pnkfelix @varkor @eddyb cc @skinny121
2020-02-20Add test for #69312Wesley Wiser-0/+10
This bug was fixed by #67501. Closes #69312
2020-02-20Revert "Rollup merge of #69280 - ↵Dylan MacKenzie-32/+20
ecstatic-morse:promote-shuffle-no-special-case, r=petrochenkov" This reverts commit 61d3b6dedb1ec1f3e3cbd3d66b1a3453225bc37c, reversing changes made to c6ad1e2c2a0c7e48537617d36085f866fa6a65a3.
2020-02-20lit_to_const: gracefully bubble up type errors.Mazdak Farrokhzad-0/+26
2020-02-20Rollup merge of #69305 - estebank:consider-lt, r=Dylan-DPCMazdak Farrokhzad-51/+50
Tweak binding lifetime suggestion text We already have a structured suggestion, but the wording made it seem like that wasn't the case. Fix #65286. r? @varkor
2020-02-20Rollup merge of #69185 - RalfJung:const-prop-lints, r=oli-obkMazdak Farrokhzad-1015/+1516
Unify and improve const-prop lints Add a single helper method for all lints emitted by const-prop, and make that lint different from the CTFE `const_err` lint. Also consistently check overflow on *arithmetic*, not on the assertion, to make behavior the same for debug and release builds. See [this summary comment](https://github.com/rust-lang/rust/pull/69185#issuecomment-587924754) for details and the latest status. In terms of lint formatting, I went for what seems to be the better style: have a general message above the code, and then a specific message at the span: ``` error: this arithmetic operation will overflow --> $DIR/const-err2.rs:21:18 | LL | let a_i128 = -std::i128::MIN; | ^^^^^^^^^^^^^^^ attempt to negate with overflow ``` We could also just have the specific message above and no text at the span if that is preferred. I also converted some of the existing tests to use compiletest revisions, so that the same test can check a bunch of different compile flags. Fixes https://github.com/rust-lang/rust/issues/69020. Helps with https://github.com/rust-lang/rust/issues/69021: debug/release are now consistent, but the assoc-const test in that issue still fails (there is a FIXME in the PR for this). The reason seems to be that const-prop notices the assoc const in `T::N << 42` and does not even bother calling `const_prop` on that operation. Has no effect on https://github.com/rust-lang/rust/issues/61821; the duplication there has entirely different reasons.
2020-02-20Rollup merge of #68877 - estebank:point-at-params, r=petrochenkovMazdak Farrokhzad-98/+167
On mismatched argument count point at arguments
2020-02-20Backport only: avoid ICE on bad placeholder typeEsteban Küber-67/+328
#69148 has a proper fix, but it is too big to backport. This change avoids the ICE by actually emitting an appropriate error. The output will be duplicated in some cases, but that's better than the avoidable ICE.
2020-02-20Auto merge of #69145 - matthewjasper:mir-typeck-static-ty, r=nikomatsakisbors-0/+107
Fix MIR typeck soundness holes * Check types of static items * Always check lifetime bounds of `Copy` impls r? @nikomatsakis closes #69114
2020-02-20Auto merge of #69309 - Dylan-DPC:rollup-gjdqx7l, r=Dylan-DPCbors-0/+37
Rollup of 5 pull requests Successful merges: - #68705 (Add LinkedList::remove()) - #68945 (Stabilize Once::is_completed) - #68978 (Make integer exponentiation methods unstably const) - #69266 (Fix race condition when allocating source files in SourceMap) - #69287 (Clean up E0317 explanation) Failed merges: r? @ghost
2020-02-20Rollup merge of #68978 - ecstatic-morse:const-int-pow, r=oli-obkDylan DPC-0/+37
Make integer exponentiation methods unstably const cc #53718 This makes the following inherent methods on integer primitives into unstable `const fn`: - `pow` - `checked_pow` - `wrapping_pow` - `overflowing_pow` - `saturating_pow` - `next_power_of_two` - `checked_next_power_of_two` - `wrapping_next_power_of_two` Only two changes were made to the implementation of these methods. First, I had to switch from the `?` operator, which is not yet implemented in a const context, to a `try_opt` macro. Second, `next_power_of_two` was using `ops::Add::add` (see the first commit) to "get overflow checks", so I switched to `#[rustc_inherit_overflow_checks]`. I'm not quite sure why the attribute wasn't used in the first place.
2020-02-20Auto merge of #68847 - ecstatic-morse:const-impl, r=oli-obkbors-38/+313
Allow trait methods to be called on concrete types in a const context This partially implements [RFC 2632](https://github.com/rust-lang/rfcs/pull/2632) by const-checking methods inside an `impl const` block and allowing those methods to be called on concrete types. Calling trait methods on type parameters in a const context is not yet allowed. Implementing this will require much more work. Since we are only concerned with methods on concrete types, we are able to take advantage of the machinery in `Instance::resolve`, which is doing most of the work. This also propagates `#[rustc_const_unstable]` from parent items to child items, making that attribute behave like `#[stable]` and `#[unstable]` do. This allows trait methods to be marked as unstably const. cc #67792 #57563 cc @rust-lang/wg-const-eval r? @oli-obk
2020-02-20Add regression test for issue 68477.Ben Lewis-0/+23
2020-02-19Tweak binding lifetime suggestion textEsteban Küber-51/+50
We already have a structured suggestion, but the wording made it seem like that wasn't the case. Fix #65286. r? @varkor
2020-02-20Add regression testJonas Schievink-0/+30
2020-02-19fix 32bit-only testRalf Jung-1/+1
2020-02-19Update testsDylan MacKenzie-6/+28
2020-02-19Rollup merge of #69280 - ecstatic-morse:promote-shuffle-no-special-case, ↵Dylan DPC-20/+32
r=petrochenkov Remove special case for `simd_shuffle` arg promotion After rust-lang/stdarch#825, these intrinsics are now defined with `#[rustc_args_required_const(2)]`, so the special-case is no longer necessary.
2020-02-19avoid excessive number of revisionsRalf Jung-452/+6
2020-02-18Add `#[rustc_args_required_const]` to `simd_shuffle` testsDylan MacKenzie-20/+32
2020-02-18Add passing test for `Add` on generic structDylan MacKenzie-0/+32
2020-02-18Add ignored test for associated types in const implDylan MacKenzie-0/+28
2020-02-18Test `rustc_const_unstable` on trait fnsDylan MacKenzie-0/+45
2020-02-18Ensure const impl cannot coexist with non-const implDylan MacKenzie-0/+67
2020-02-18Split const trait method test and impl `ops::Add`Dylan MacKenzie-2/+43
2020-02-18Add tests for calling trait methods on concrete typesDylan MacKenzie-38/+78
2020-02-19Auto merge of #69113 - ecstatic-morse:unified-dataflow-borrowed, r=wesleywiserbors-2/+7
Combine `HaveBeenBorrowedLocals` and `IndirectlyMutableLocals` into one dataflow analysis This PR began as an attempt to port `HaveBeenBorrowedLocals` to the new dataflow framework (see #68241 for prior art). Along the way, I noticed that it could share most of its code with `IndirectlyMutableLocals` and then found a few bugs in the two analyses: - Neither one marked locals as borrowed after an `Rvalue::AddressOf`. - `IndirectlyMutableLocals` was missing a minor fix that `HaveBeenBorrowedLocals` got in #61069. This is not a problem today since it is only used during const-checking, where custom drop glue is forbidden. However, this may change some day. I decided to combine the two analyses so that they wouldn't diverge in the future while ensuring that they remain distinct types (called `MaybeBorrowedLocals` and `MaybeMutBorrowedLocals` to be consistent with the `Maybe{Un,}InitializedPlaces` naming scheme). I fixed the bugs and switched to exhaustive matching where possible to make them less likely in the future. Finally, I added comments explaining some of the finer points of the transfer function for these analyses (see #61069 and #65006).
2020-02-19Auto merge of #69241 - shahn:checked_add_revert, r=Mark-Simulacrum,lqdbors-0/+31
Revert "Remove `checked_add` in `Layout::repeat`" This fixes a a segfault in safe code, a stable regression. Reported in #69225. This reverts commit a983e0590a43ed8b0f60417828efd4e79b51f494.
2020-02-18Revert "Remove `checked_add` in `Layout::repeat`"Sebastian Hahn-0/+31
This fixes a a segfault in safe code, a stable regression. Reported in \#69225. This reverts commit a983e0590a43ed8b0f60417828efd4e79b51f494. Also adds a test for the expected behaviour.
2020-02-18better lint namesRalf Jung-91/+91
2020-02-18Rollup merge of #69236 - Centril:mut-parens-at-recovery, r=estebankMazdak Farrokhzad-11/+21
parse: recover `mut (x @ y)` as `(mut x @ mut y)`. Follow up to https://github.com/rust-lang/rust/pull/68992#discussion_r376829749 and https://github.com/rust-lang/rust/pull/63945. Specifically, when given `let mut (x @ y)` we recover with `let (mut x @ mut y)` as the suggestion: ```rust error: `mut` must be attached to each individual binding --> $DIR/mut-patterns.rs:12:9 | LL | let mut (x @ y) = 0; | ^^^^^^^^^^^ help: add `mut` to each binding: `(mut x @ mut y)` | = note: `mut` may be followed by `variable` and `variable @ pattern` ``` r? @matthewjasper @estebank
2020-02-18Rollup merge of #69217 - LeSeulArtichaut:remove-lint-impl-op, r=estebankMazdak Farrokhzad-61/+0
Do not emit note suggesting to implement operation trait to foreign type When a binary operation isn't valid, you will get a lint proposing to add a trait implementation to make the operation possible. However, this cannot be done for foreign types, such as types from `core` or `std`. For example: ``` = note: an implementation of `std::ops::Add` might be missing for `std::option::Option<i8>` ``` As mentioned in https://github.com/rust-lang/rust/issues/60497#issuecomment-562665539: > The note suggesting implementing Add<i8> should only be emitted if Option<i8> were local to the current crate, which it isn't, so in this case it shouldn't be emitted. (I will use the CI to check tests for me, or my computer will just burn... and running IDEs is not possible on a pile of ashes) r? @estebank
2020-02-18Rollup merge of #69211 - petrochenkov:prevtok, r=CentrilMazdak Farrokhzad-6/+41
parser: Simplify treatment of macro variables in `Parser::bump` Follow-up to https://github.com/rust-lang/rust/pull/69006. Token normalization for `$ident` and `$lifetime` is merged directly into `bump`. Special "unknown macro variable" diagnostic for unexpected `$`s is removed as preventing legal code from compiling (as a result `bump` also doesn't call itself recursively anymore and can't make `prev_token` inconsistent). r? @Centril
2020-02-18Rollup merge of #69194 - Centril:assoc-extern-fuse, r=petrochenkovMazdak Farrokhzad-122/+706
parse: fuse associated and extern items up to defaultness Language changes: - The grammar of extern `type` aliases is unified with associated ones, and becomes: ```rust TypeItem = "type" ident generics {":" bounds}? where_clause {"=" type}? ";" ; ``` Semantic restrictions (`ast_validation`) are added to forbid any parameters in `generics`, any bounds in `bounds`, and any predicates in `where_clause`, as well as the presence of a type expression (`= u8`). (Work still remains to fuse this with free `type` aliases, but this can be done later.) - The grammar of constants and static items (free, associated, and extern) now permits the absence of an expression, and becomes: ```rust GlobalItem = {"const" {ident | "_"} | "static" "mut"? ident} {"=" expr}? ";" ; ``` - A semantic restriction is added to enforce the presence of the expression (the body). - A semantic restriction is added to reject `const _` in associated contexts. Together, these changes allow us to fuse the grammar of associated items and extern items up to `default`ness which is the main goal of the PR. ----------------------- We are now very close to fully fusing the entirely of item parsing and their ASTs. To progress further, we must make a decision: should we parse e.g. `default use foo::bar;` and whatnot? Accepting that is likely easiest from a parsing perspective, as it does not require using look-ahead, but it is perhaps not too onerous to only accept it for `fn`s (and all their various qualifiers), `const`s, `static`s, and `type`s. r? @petrochenkov
2020-02-18Rollup merge of #69159 - estebank:use-appropriate-lt-name, r=ecstatic-morseMazdak Farrokhzad-7/+27
Select an appropriate unused lifetime name in suggestion Follow up to #69048.
2020-02-18Rollup merge of #69146 - matthewjasper:literal-qualif, r=eddybMazdak Farrokhzad-4/+6
Always const qualify literals by type r? @eddyb
2020-02-18Rollup merge of #69200 - jonas-schievink:yield-print, r=eddyb,ZoxcDylan DPC-1/+1
Fix printing of `Yield` terminator Addresses the bug found in https://github.com/rust-lang/rust/issues/69039#issuecomment-586633495
2020-02-18Rollup merge of #69192 - JohnTitor:add-tests, r=CentrilDylan DPC-0/+159
Add more regression tests Closes #39618 Closes #51798 Closes #62894 Closes #63952 Closes #68653 r? @Centril
2020-02-18Rollup merge of #69223 - spunit262:empty-string-gdb-version, r=Dylan-DPCYuki Okushi-0/+1
Ignore GDB versions with broken str printing. https://sourceware.org/bugzilla/show_bug.cgi?id=22236
2020-02-18Rollup merge of #69175 - estebank:shall-not-ice, r=petrochenkovYuki Okushi-0/+15
Do not ICE when encountering `yield` inside `async` block Fix #67158.
2020-02-18Rollup merge of #67272 - fisherdarling:master, r=varkor,hellow554Yuki Okushi-0/+71
recursion_limit parsing handles overflows This PR adds overflow handling to `#![recursion_limit]` attribute parsing. If parsing the given value results in an `IntErrorKind::Overflow`, then the recursion_limit is set to `usize::max_value()`. closes #67265
2020-02-18more English grammarRalf Jung-7/+7
2020-02-18miri value visitor: fix some wrong assumptions about layout; improve error ↵Ralf Jung-23/+23
messages