summary refs log tree commit diff
path: root/src/test/run-pass
AgeCommit message (Collapse)AuthorLines
2016-12-15Work around a borrow surviving too long (fixes #37686)Anthony Ramine-0/+16
2016-12-14don't double-apply variant padding to const enumsAriel Ben-Yehuda-0/+45
Fixes #38002.
2016-12-14evaluate obligations in LIFO order during closure projectionAriel Ben-Yehuda-0/+88
This is an annoying gotcha with the projection cache's handling of nested obligations. Nested projection obligations enter the issue in this case: ``` DEBUG:rustc::traits::project: AssociatedTypeNormalizer: depth=3 normalized <std::iter::Map<std::ops::Range<i32>, [closure@not-a-recursion-error.rs:5:30: 5:53]> as std::iter::IntoIterator>::Item to _#7t with 12 add'l obligations ``` Here the normalization result is the result of the nested impl `<[closure@not-a-recursion-error.rs:5:30: 5:53] as FnMut(i32)>::Output`, which is an additional obligation that is a part of "add'l obligations". By itself, this is proper behaviour - the additional obligation is returned, and the RFC 447 rules ensure that it is processed before the output `#_7t` is used in any way. However, the projection cache breaks this - it caches the `<std::iter::Map<std::ops::Range<i32>,[closure@not-a-recursion-error.rs:5:30: 5:53]> as std::iter::IntoIterator>::Item = #_7t` resolution. Now everybody else that attempts to look up the projection will just get `#_7t` *without* any additional obligations. This obviously causes all sorts of trouble (here a spurious `EvaluatedToAmbig` results in specializations not being discarded [here](https://github.com/rust-lang/rust/blob/9ca50bd4d50b55456e88a8c3ad8fcc9798f57522/src/librustc/traits/select.rs#L1705)). The compiler works even with this projection cache gotcha because in most cases during "one-pass evaluation". we tend to process obligations in LIFO order - after an obligation is added to the cache, we process its nested obligations before we do anything else (and if we have a cycle, we handle it specifically) - which makes sure the inference variables are resolved before they are used. That "LIFO" order That was not done when projecting out of a closure, so let's just fix that for the time being. Fixes #38033.
2016-11-08Auto merge of #36843 - petrochenkov:dotstab, r=nikomatsakisbors-12/+0
Stabilize `..` in tuple (struct) patterns I'd like to nominate `..` in tuple and tuple struct patterns for stabilization. This feature is a relatively small extension to existing stable functionality and doesn't have known blockers. The feature first appeared in Rust 1.10 6 months ago. An example of use: https://github.com/rust-lang/rust/pull/36203 Closes https://github.com/rust-lang/rust/issues/33627 r? @nikomatsakis
2016-11-07Auto merge of #36365 - matthew-piziak:silent-overflow, r=eddybbors-0/+50
fix silent overflows on `Step` impls Part of https://github.com/rust-lang/rust/issues/36110 r? @eddyb
2016-11-06Add test for issue 18060.Joe Neeman-0/+17
2016-11-05Merge branch 'selfgate' of https://github.com/petrochenkov/rust into rollupAlex Crichton-0/+4
2016-11-05Rollup merge of #37557 - TimNN:fix-36954, r=eddybAlex Crichton-0/+35
Use DefId's in const eval for cross-crate const fn's Fixes #36954. r? @eddyb cc @raphaelcohn
2016-11-04Auto merge of #37167 - nikomatsakis:jroesch-issue-18937, r=pnkfelixbors-0/+88
detect extra region requirements in impls The current "compare method" check fails to check for the "region obligations" that accrue in the fulfillment context. This branch switches that code to create a `FnCtxt` so that it can invoke the regionck code. Previous crater runs (I haven't done one with the latest tip) have found some small number of affected crates, so I went ahead and introduced a warning cycle. I will kick off a crater run with this branch shortly. This is a [breaking-change] because previously unsound code was accepted. The crater runs also revealed some cases where legitimate code was no longer type-checking, so the branch contains one additional (but orthogonal) change. It improves the elaborator so that we elaborate region requirements more thoroughly. In particular, if we know that `&'a T: 'b`, we now deduce that `T: 'b` and `'a: 'b`. I invested a certain amount of effort in getting a good error message. The error message looks like this: ``` error[E0276]: impl has stricter requirements than trait --> traits-elaborate-projection-region.rs:33:5 | 21 | fn foo() where T: 'a; | --------------------- definition of `foo` from trait ... 33 | fn foo() where U: 'a { } | ^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `U: 'a` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #18937 <https://github.com/rust-lang/rust/issues/18937> note: lint level defined here --> traits-elaborate-projection-region.rs:12:9 | 12 | #![deny(extra_requirement_in_impl)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ ``` Obviously the warning only prints if this is a _new_ error (that resulted from the bugfix). But all existing errors that fit this description are updated to follow the general template. In order to get the lint to preserve the span-labels and the error code, I separate out the core `Diagnostic` type (which encapsulates the error code, message, span, and children) from the `DiagnosticBuilder` (which layers on a `Handler` that can be used to report errors). I also extended `add_lint` with an alternative `add_lint_diagnostic` that takes in a full diagnostic (cc @jonathandturner for those changes). This doesn't feel ideal but feels like it's moving in the right direction =). r? @pnkfelix cc @arielb1 Fixes #18937
2016-11-03use DefId's in const eval for cross-crate const fn'sTim Neumann-0/+35
2016-11-03Add feature gate for Self and associated types in struct expressions and ↵Vadim Petrochenkov-0/+4
patterns
2016-11-03Stabilize `..` in tuple (struct) patternsVadim Petrochenkov-12/+0
2016-11-02add #32791 test caseNiko Matsakis-0/+81
2016-11-02add max value from iteratorMatthew Piziak-0/+4
2016-11-01elaborate `T: 'a` dependenciesNiko Matsakis-0/+88
2016-10-31Changed most vec! invocations to use square bracesiirelu-123/+123
Most of the Rust community agrees that the vec! macro is clearer when called using square brackets [] instead of regular brackets (). Most of these ocurrences are from before macros allowed using different types of brackets. There is one left unchanged in a pretty-print test, as the pretty printer still wants it to have regular brackets.
2016-10-30move overflow tests from rust-fail to run-passMatthew Piziak-0/+46
2016-10-29Auto merge of #37389 - cramertj:cramertj/fn-item-to-unsafe-ptr, r=eddybbors-0/+21
rustc_typeck: Allow reification from fn item to unsafe ptr See https://github.com/rust-lang/rfcs/issues/1762. I've never contributed to the compiler internals before-- apologies if I'm not going about this the right way.
2016-10-29Auto merge of #37378 - petrochenkov:nopat, r=eddybbors-2/+2
Prohibit patterns in trait methods without bodies They are not properly type checked ```rust trait Tr { fn f(&a: u8); // <- This compiles } ``` , mostly rejected by the parser already and generally don't make much sense. This PR is kind of a missing part of https://github.com/rust-lang/rust/pull/35015. Given the [statistics from crater](https://github.com/rust-lang/rust/pull/37378#issuecomment-256154994), the effect of this PR is mostly equivalent to improving `unused_mut` lint. cc https://github.com/rust-lang/rust/issues/35078#issuecomment-255707355 https://github.com/rust-lang/rust/pull/35015 https://github.com/rust-lang/rfcs/pull/1685 https://github.com/rust-lang/rust/issues/35203 r? @eddyb
2016-10-28Auto merge of #37367 - jseyfried:import_crate_root, r=nrcbors-3/+9
Support `use *;` and `use ::*;`. Fixes #31484. r? @nrc
2016-10-27Address comments + Fix rebaseVadim Petrochenkov-0/+3
2016-10-27Support `Self` in struct expressions and patternsVadim Petrochenkov-0/+54
2016-10-27Preparations and cleanupVadim Petrochenkov-0/+38
Diagnostics for struct path resolution errors in resolve and typeck are unified. Self type is treated as a type alias in few places (not reachable yet). Unsafe cell is seen in constants even through type aliases. All checks for struct paths in typeck work on type level.
2016-10-27Make sufficiently old or low-impact compatibility lints deny-by-defaultVadim Petrochenkov-1/+1
2016-10-26Auto merge of #11994 - eddyb:struct-literal-field-shorthand, r=nrcbors-0/+37
Implement field shorthands in struct literal expressions. Implements #37340 in a straight-forward way: `Foo { x, y: f() }` parses as `Foo { x: x, y: f() }`. Because of the added `is_shorthand` to `ast::Field`, this is `[syntax-breaking]` (cc @Manishearth). * [x] Mark the fields as being a shorthand (the exact same way we do it in patterns), for pretty-printing. * [x] Gate the shorthand syntax with `#![feature(field_init_shorthand)]`. * [x] Don't parse numeric field as identifiers. * [x] Arbitrary field order tests.
2016-10-27Implement field shorthands in struct literal expressions.Eduard Burtescu-0/+37
2016-10-26flatten nested slice patterns in HAIR constructionAriel Ben-Yehuda-0/+15
nested slice patterns have the same functionality as non-nested ones, so flatten them in HAIR construction. Fixes #26158.
2016-10-26handle mixed byte literal and byte array patternsAriel Ben-Yehuda-0/+54
Convert byte literal pattern to byte array patterns when they are both used together. so matching them is properly handled. I could've done the conversion eagerly, but that could have caused a bad worst-case for massive byte-array matches. Fixes #18027. Fixes #25051. Fixes #26510.
2016-10-26Prohibit patterns in trait methods without bodiesVadim Petrochenkov-2/+2
2016-10-25Auto merge of #36421 - TimNN:check-abis, r=alexcrichtonbors-0/+6
check target abi support This PR checks for each extern function / block whether the ABI / calling convention used is supported by the current target. This was achieved by adding an `abi_blacklist` field to the target specifications, listing the calling conventions unsupported for that target.
2016-10-25adapt testsTim Neumann-0/+6
2016-10-24rustc_typeck: Allow reification from fn item to unsafe ptrTaylor Cramer-0/+21
2016-10-24adapt existing testsTim Neumann-7/+1
2016-10-23Support `use *;` and `use ::*;`.Jeffrey Seyfried-3/+9
2016-10-22Auto merge of #37294 - nikomatsakis:issue-37154, r=nikomatsakisbors-0/+28
remove keys w/ skolemized regions from proj cache when popping skolemized regions This addresses #37154 (a regression). The projection cache was incorrectly caching the results for skolemized regions -- when we pop skolemized regions, we are supposed to drop cache keys for them (just as we remove those skolemized regions from the region inference graph). This is because those skolemized region numbers will be reused later with different meaning (and we have determined that the old ones don't leak out in any meaningful way). I did a *somewhat* aggressive fix here of only removing keys that mention the skolemized regions. One could imagine just removing all keys added since we started the skolemization (as indeed I did in my initial commit). This more aggressive fix required fixing a latent bug in `TypeFlags`, as an aside. I believe the more aggressive fix is correct; clearly there can be entries that are unrelated to the skoelemized region, and it's a shame to remove them. My one concern was that it *is* possible I believe to have some region variables that are created and related to skolemized regions, and maybe some of them could end up in the cache. However, that seems harmless enough to me-- those relations will be removed, and couldn't have impacted how trait resolution proceeded anyway (iow, the cache entry is not wrong, though it is kind of useless). r? @pnkfelix cc @arielb1
2016-10-22Auto merge of #37281 - TimNN:pad-align, r=eddybbors-0/+25
trans: pad const structs to aligned size Fixes #37222. I'm not sure if that is the *correct* way to fix this, but it *does* work.
2016-10-22Rollup merge of #37297 - thepowersgang:fix-bad-crate-attrs, r=eddybGuillaume Gomez-2/+2
test - Add missing ! to crate_type/crate_id attributes Fix some useless attributes in a test dependency.
2016-10-21add regression test for #37154Niko Matsakis-0/+28
Fixes #37154
2016-10-20trans: pad const structs to aligned sizeTim Neumann-0/+25
2016-10-20Tweak path parsing logicVadim Petrochenkov-0/+6
2016-10-20test - Add missing ! to crate_type/crate_id attributesJohn Hodge-2/+2
2016-10-19Rollup merge of #37230 - bluss:zip-specialization-for-map, r=alexcrichtonEduard-Mihai Burtescu-0/+112
Expand .zip() specialization to .map() and .cloned() Implement .zip() specialization for Map and Cloned. The crucial thing for transparent specialization is that we want to preserve the potential side effects. The simplest example is that in this code snippet: `(0..6).map(f).zip((0..4).map(g)).count()` `f` will be called five times, and `g` four times. The last time for `f` is when the other iterator is at its end, so this element is unused. This side effect can be preserved without disturbing code generation for simple uses of `.map()`. The `Zip::next_back()` case is even more complicated, unfortunately.
2016-10-19Rollup merge of #37224 - petrochenkov:nz, r=eddybEduard-Mihai Burtescu-0/+39
Mark enums with non-zero discriminant as non-zero cc https://github.com/rust-lang/rfcs/issues/1230 r? @eddyb
2016-10-19Rollup merge of #37208 - jseyfried:fix_partially_consumed_tokens_in_macros, ↵Eduard-Mihai Burtescu-0/+14
r=nrc macros: fix partially consumed tokens in macro matchers Fixes #37175. This PR also avoids re-transcribing the tokens consumed by a matcher (and cloning the `TtReader` once per matcher), which improves expansion performance of the test case from #34630 by ~8%. r? @nrc
2016-10-19Rollup merge of #37202 - petrochenkov:pretty, r=nrcEduard-Mihai Burtescu-113/+27
Fix some pretty printing tests Many pretty-printing tests are un-ignored. Some issues in classification of comments (trailing/isolated) and blank line counting are fixed. Some comments are printed more carefully. Some minor refactoring in pprust.rs `no-pretty-expanded` annotations are removed because this is the default now. `pretty-expanded` annotations are removed from compile-fail tests, they are not tested with pretty-printer. Closes https://github.com/rust-lang/rust/issues/23623 in favor of more specific https://github.com/rust-lang/rust/issues/37201 and https://github.com/rust-lang/rust/issues/37199 r? @nrc
2016-10-19Rollup merge of #37117 - pnkfelix:may-dangle-attr, r=nikomatsakisEduard-Mihai Burtescu-0/+310
`#[may_dangle]` attribute `#[may_dangle]` attribute Second step of #34761. Last big hurdle before we can work in earnest towards Allocator integration (#32838) Note: I am not clear if this is *also* a syntax-breaking change that needs to be part of a breaking-batch.
2016-10-18Fix some pretty printing testsVadim Petrochenkov-113/+27
2016-10-17Add regression test.Jeffrey Seyfried-0/+14
2016-10-17Auto merge of #37112 - pnkfelix:fix-issue-36744, r=arielb1bors-0/+54
Fix ICE: inject bitcast if types mismatch for invokes/calls/stores Fix ICE: inject bitcast if types mismatch for invokes/calls Fix #36744
2016-10-17Fix Subst construction: use subst from adt_def rather than Drop impl's subst.Felix S. Klock II-0/+89
This addresses issue pointed out by niko that prior code would break if the declaration order for generics does not match how they are fed into the instantiation of the type itself. (Added some tests exercising this scenario.)