about summary refs log tree commit diff
path: root/src/test/run-pass
AgeCommit message (Collapse)AuthorLines
2017-11-15add some more positive testsNiko Matsakis-0/+99
It'd be good to have a positive test for each case where it is allowed, I should think.
2017-11-15rename `equality-universal` to a more extensible naming schemeNiko Matsakis-0/+0
2017-11-15Add/Modify tests for argument position impl TraitChristopher Vittal-13/+57
2017-11-14Auto merge of #45909 - sinkuu:issue-45885, r=arielb1bors-0/+38
Normalize inlined function in MIR inliner Fixes #45885 r? @arielb1
2017-11-12Auto merge of #45900 - rkruppe:u128-to-f32-saturation-by-default, r=alexcrichtonbors-21/+59
Make saturating u128 -> f32 casts the default behavior ... rather than being gated by `-Z saturating-float-casts`. There are several reasons for this: 1. Const eval already implements this behavior. 2. Unlike with float->int casts, this behavior is uncontroversially the right behavior and it is not as performance critical. Thus there is no particular need to make the bug fix for u128->f32 casts opt-in. 3. Having two orthogonal features under one flag is silly, and never should have happened in the first place. 4. Benchmarking float->int casts with the -Z flag should not pick up performance changes due to the u128->f32 casts (assuming there are any). Fixes #41799
2017-11-12Auto merge of #45870 - mikeyhew:arbitrary_self_types, r=arielb1bors-0/+115
Implement arbitrary_self_types r? @arielb1 cc @nikomatsakis Partial implementation of #44874. Supports trait and struct methods with arbitrary self types, as long as the type derefs (transitively) to `Self`. Doesn't support raw-pointer `self` yet. Methods with non-standard self types (i.e. anything other than `&self, &mut self, and Box<Self>`) are not object safe, because dynamic dispatch hasn't been implemented for them yet. I believe this is also a (partial) fix for #27941.
2017-11-12Auto merge of #45864 - nikomatsakis:issue-30046-infer-fn-once-in-closures, ↵bors-0/+35
r=eddyb adjust closure kind based on the guarantor's upvar note Fixes #30046. r? @eddyb
2017-11-11Auto merge of #45772 - leodasvacas:fix-auto-bounds-in-trait-objects, ↵bors-0/+3
r=nikomatsakis Fix checking of auto trait bounds in trait objects. Any auto trait is allowed in trait object bounds. Fix duplicate check of type and lifetime parameter count, which we were [emitting twice](https://play.rust-lang.org/?gist=37dbbdbbec62dec423bb8f6d92f137cc&version=stable). Note: This was the last use of `Send` in the compiler, meaning after a new `stage0` we could remove the `send` lang item.
2017-11-10Auto merge of #45804 - gnzlbg:div_intr, r=alexcrichtonbors-0/+14
[intrinsics] add missing div and rem vector intrinsics
2017-11-10Normalize inlined function in MIR inlinerShotaro Yamada-0/+38
2017-11-10Make saturating u128 -> f32 casts the default behaviorRobin Kruppe-21/+59
... rather than being gated by -Z saturating-float-casts. There are several reasons for this: 1. Const eval already implements this behavior. 2. Unlike with float->int casts, this behavior is uncontroversially the right behavior and it is not as performance critical. Thus there is no particular need to make the bug fix for u128->f32 casts opt-in. 3. Having two orthogonal features under one flag is silly, and never should have happened in the first place. 4. Benchmarking float->int casts with the -Z flag should not pick up performance changes due to the u128->f32 casts (assuming there are any). Fixes #41799
2017-11-10Rollup merge of #45901 - rkruppe:fix-typo, r=kennytmkennytm-2/+2
Fix typo in -Zsaturating-float-casts test
2017-11-10Rollup merge of #45887 - xfix:assert-eq-trailling-comma, r=dtolnaykennytm-0/+26
Allow a trailling comma in assert_eq/ne macro From Rust beginners IRC: &lt;???> It sure does annoy me that assert_eq!() does not accept a trailing comma after the last argument. &lt;???> ???: File an issue against https://github.com/rust-lang/rust and CC @rust-lang/libs Figured that might as well submit it. Will become insta-stable after merging (danger zone). cc @rust-lang/libs
2017-11-10Fix typo in -Zsaturating-float-casts testRobin Kruppe-2/+2
2017-11-09add run-pass testsMichael Hewson-0/+115
2017-11-09Allow a trailing comma in assert_eq/ne macroKonrad Borowski-0/+26
2017-11-08std: Remove `rand` crate and moduleAlex Crichton-377/+0
This commit removes the `rand` crate from the standard library facade as well as the `__rand` module in the standard library. Neither of these were used in any meaningful way in the standard library itself. The only need for randomness in libstd is to initialize the thread-local keys of a `HashMap`, and that unconditionally used `OsRng` defined in the standard library anyway. The cruft of the `rand` crate and the extra `rand` support in the standard library makes libstd slightly more difficult to port to new platforms, namely WebAssembly which doesn't have any randomness at all (without interfacing with JS). The purpose of this commit is to clarify and streamline randomness in libstd, focusing on how it's only required in one location, hashmap seeds. Note that the `rand` crate out of tree has almost always been a drop-in replacement for the `rand` crate in-tree, so any usage (accidental or purposeful) of the crate in-tree should switch to the `rand` crate on crates.io. This then also has the further benefit of avoiding duplication (mostly) between the two crates!
2017-11-09Auto merge of #45688 - Gankro:layout-tests, r=alexcrichtonbors-0/+173
Add reftest that checks the layout of repr(int) on non-c-like enums This verifies the first layout specified in https://github.com/rust-lang/rfcs/pull/2195 The second (`repr(C)`) layout isn't included here because it doesn't actually exist today. However if/when that's implemented a second test could be fairly easily derived from this one. CC @eddyb
2017-11-08Add reftest that checks the layout of repr(int) on non-c-like enumsAlexis Beingessner-0/+173
This verifies the layout specified in rfc #2195
2017-11-08Auto merge of #45205 - rkruppe:saturating-casts, r=eddybbors-0/+164
Saturating casts between integers and floats Introduces a new flag, `-Z saturating-float-casts`, which makes code generation for int->float and float->int casts safe (`undef`-free), implementing [the saturating semantics laid out by](https://github.com/rust-lang/rust/issues/10184#issuecomment-299229143) @jorendorff for float->int casts and overflowing to infinity for `u128::MAX` -> `f32`. Constant evaluation in trans was changed to behave like HIR const eval already did, i.e., saturate for u128->f32 and report an error for problematic float->int casts. Many thanks to @eddyb, whose APFloat port simplified many parts of this patch, and made HIR constant evaluation recognize dangerous float casts as mentioned above. Also thanks to @ActuallyaDeviloper whose branchless implementation served as inspiration for this implementation. cc #10184 #41799 fixes #45134
2017-11-08Disable u128 <-> float tests on emscriptenRobin Kruppe-29/+39
2017-11-08look for the note on the guarantor, not the root cmtNiko Matsakis-0/+35
This was causing upvar inference to fail for all cases where the move was from a projection, not the root variable.
2017-11-08Disable `mmap` in `libbacktrace` on Apple platformsJohn Colanduoni-0/+34
Fixes #45731 libbacktrace uses mmap if available to map ranges of the files containing debug information. On macOS `mmap` will succeed even if the mapped range does not exist, and a SIGBUS (with an unusual EXC_BAD_ACCESS code 10) will occur when the program attempts to page in the memory. To combat this we force `libbacktrace` to be built with the simple `read` based fallback on Apple platforms.
2017-11-07Make trans const eval error on overflow and NaN, matching HIR const eval.Robin Kruppe-39/+52
2017-11-07Saturating casts between integers and floats (both directions).Robin Kruppe-0/+141
This affects regular code generation as well as constant evaluation in trans, but not the HIR constant evaluator because that one returns an error for overflowing casts and NaN-to-int casts. That error is conservatively correct and we should be careful to not accept more code in constant expressions. The changes to code generation are guarded by a new -Z flag, to be able to evaluate the performance impact. The trans constant evaluation changes are unconditional because they have no run time impact and don't affect type checking either.
2017-11-06[intrinsics] add div and rem vector testsgnzlbg-0/+14
2017-11-05Auto merge of #45723 - sinkuu:ice_45493, r=arielb1bors-0/+26
Fix MIR inlining panic in generic function MIR inlining calls `Instance::resolve` with a substs containing param, and `trans_apply_param_substs` panics. ~~This PR fixes it by making `Instance::resolve` return `None` if `substs.has_param_types()`, though I'm not sure if this is a right fix.~~ Fixes #45493.
2017-11-05Auto merge of #45072 - nikomatsakis:issue-38714, r=arielb1bors-0/+115
new rules for merging expected and supplied types in closure signatures As uncovered in #38714, we currently have some pretty bogus code for combining the "expected signature" of a closure with the "supplied signature". To set the scene, consider a case like this: ```rust fn foo<F>(f: F) where F: for<'a> FnOnce(&'a u32) -> &'a u32 // ^ *expected* signature comes from this where-clause { ... } fn main() { foo(|x: &u32| -> &u32 { .. } // ^^^^^^^^^^^^^^^^^ supplied signature // comes from here } ``` In this case, the supplied signature (a) includes all the parts and (b) is the same as the expected signature, modulo the names used for the regions. But often people supply only *some* parts of the signature. For example, one might write `foo(|x| ..)`, leaving *everything* to be inferred, or perhaps `foo(|x: &u32| ...)`, which leaves the return type to be inferred. In the current code, we use the expected type to supply the types that are not given, but otherwise use the type the user gave, except for one case: if the user writes `fn foo(|x: _| ..)` (i.e., an underscore at the outermost level), then we will take the expected type (rather than instantiating a fresh type variable). This can result in nonsensical situations, particularly with bound regions that link the types of parameters to one another or to the return type. Consider `foo(|x: &u32| ...)` -- if we *literally* splice the expected return type of `&'a u32` together with what the user gave, we wind up with a signature like `for<'a> fn(&u32) -> &'a u32`. This is not even permitted as a type, because bound regions like `'a` must appear also in the arguments somewhere, which is why #38714 leads to an ICE. This PR institutes some new rules. These are not meant to be the *final* set of rules, but they are a kind of "lower bar" for what kind of code we accept (i.e., we can extend these rules in the future to be smarter in some cases, but -- as we will see -- these rules do accept some things that we then would not be able to back off from). These rules are derived from a few premises: - First and foremost, anonymous regions in closure annotation are mostly requests for the code to "figure out the right lifetime" and shouldn't be read too closely. So for example when people write a closure signature like `|x: &u32|`, they are really intended for us to "figure out" the right region for `x`. - In contrast, the current code treats this supplied type as being more definitive. In particular, writing `|x: &u32|` would always result in the region of `x` being bound in the closure type. In other words, the signature would be something like `for<'a> fn(&'a u32)` -- this is derived from the fact that `fn(&u32)` expands to a type where the region is bound in the fn type. - This PR takes a different approach. The "binding level" for reference types appearing in closure signatures can be informed in some cases by the expected signature. So, for example, if the expected signature is something like `(&'f u32)`, where the region of the first argument appears free, then for `|x: &u32|`, the new code would infer `x` to also have the free region `'f`. - This inference has some limits. We don't do this for bindings that appear within the selected types themselves. So e.g. `|x: fn(&u32)|`, when combined with an expected type of `fn(fn(&'f u32))`, would still result in a closure that expects `for<'a> fn(&'a u32)`. Such an annotation will ultimately result in an error, as it happens, since `foo` is supplying a `fn(&'f u32)` to the closure, but the closure signature demands a `for<'a> fn(&'a u32)`. But still we choose to trust it and have the user change it. - I wanted to preserve the rough intuition that one can copy-and-paste a type out of the fn signature and into the fn body without dramatically changing its meaning. Interestingly, if one has `|x: &u32|`, then regardless of whether the region of `x` is bound or free in the closure signature, it is also free in the region body, and that is also true when one writes `let x: &u32`, so that intuition holds here. But the same would not be true for `fn(&u32)`, hence the different behavior. - Second, we must take either **all** the references to bound regions from the expected type or **none**. The current code, as we saw, will happily take a bound region in the return type but drop the other place where it is used, in the parameters. Since bound regions are all about linking multiple things together, I think it's important not to do that. (That said, we could conceivably be a bit less strict here, since the subtyping rules will get our back, but we definitely don't want any bound regions that appear only in the return type.) - Finally, we cannot take the bound region names from the supplied types and "intermix" them with the names from the expected types. - We *could* potentially do some alpha renaming, but I didn't do that. - Ultimately, if the types the user supplied do not match expectations in some way that we cannot recover from, we fallback to deriving the closure signature solely from those expected types. - For example, if the expected type is `u32` but the user wrote `i32`. - Or, more subtle, if the user wrote e.g. `&'x u32` for some named lifetime `'x`, but the expected type includes a bound lifetime (`for<'a> (&'a u32)`). In that case, preferring the type that the user explicitly wrote would hide an appearance of a bound name from the expected type, and we try to never do that. The detailed rules that I came up with are found in the code, but for ease of reading I've also [excerpted them into a gist](https://gist.github.com/nikomatsakis/e69252a2b57e6d97d044c2f254c177f1). I am not convinced they are correct and would welcome feedback for alternative approaches. (As an aside, the way I think I would ultimately *prefer* to think about this is that the conversion from HIR types to internal types could be parameterized by an "expected type" that it uses to guide itself. However, since that would be a pain, I opted *in the code* to first instantiate the supplied types as `Ty<'tcx>` and then "merge" those types with the `Ty<'tcx>` from the expected signature.) I think we should probably FCP this before landing. cc @rust-lang/lang r? @arielb1
2017-11-05Fix MIR inlining panic in generic functionsinkuu-0/+26
2017-11-05Auto merge of #45754 - scottmcm:checked-npot, r=dtolnaybors-0/+60
Fix #18604: next_power_of_two should panic on overflow Fixes https://github.com/rust-lang/rust/issues/18604 Is it possible to write a test for this? My experiments showed `x.py test` running in release mode, so my attempt at a `#[should_panic]` didn't work.
2017-11-04Fix checking of auto trait bounds in trait objects.leonardo.yvens-0/+3
Any auto trait is allowed in trait object bounds. Fix duplicate check of type and lifetime parameter count.
2017-11-04Auto merge of #45394 - davidtwco:rfc-2008, r=petrochenkovbors-0/+253
RFC 2008: Future-proofing enums/structs with #[non_exhaustive] attribute This work-in-progress pull request contains my changes to implement [RFC 2008](https://github.com/rust-lang/rfcs/pull/2008). The related tracking issue is #44109. As of writing, enum-related functionality is not included and there are some issues related to tuple/unit structs. Enum related tests are currently ignored. WIP PR requested by @nikomatsakis [in Gitter](https://gitter.im/rust-impl-period/WG-compiler-middle?at=59e90e6297cedeb0482ade3e).
2017-11-04Ignoring pretty print for test due to #37199David Wood-0/+2
2017-11-03Add overflow tests for next_power_of_twoScott McMurray-0/+60
2017-11-03Added tests for RFC 2008.David Wood-0/+251
2017-11-03Parse auto traits the same as traits.leonardo.yvens-0/+24
This moves the well formedness checks to the AST validation pass. Tests were adjusted. The auto keyword should be back-compat now.
2017-11-03auto trait future compatibility lintleonardo.yvens-0/+2
2017-11-03Add tests for `auto trait`, fix parsing bugleonardo.yvens-0/+35
Now we can do the well formedness checks in the parser, yay!
2017-11-02new rules for merging expected/supplied types in closure signaturesNiko Matsakis-0/+115
Also, fix numbering in mir-opt tests. We are now anonymizing more consistently, I think, and hence some of the `TyAnon` indices shifted.
2017-11-01Auto merge of #45435 - eddyb:binop-subtype-lhs, r=nikomatsakisbors-0/+55
rustc_typeck: use subtyping on the LHS of binops. Fixes #45425. r? @nikomatsakis
2017-10-31rustc_typeck: use subtyping on the LHS of binops.Eduard-Mihai Burtescu-0/+55
2017-10-31Count type aliases in patternssinkuu-0/+18
2017-10-27Implement RFC 1861: Extern typesPaul Lietar-0/+207
2017-10-26Auto merge of #45519 - michaelwoerister:dedup-errors, r=arielb1bors-0/+0
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-26Auto merge of #45488 - oli-obk:ctfe_resolve, r=eddybbors-0/+28
Resolve types properly in const eval r? @eddyb cc @arielb1
2017-10-26Auto merge of #45464 - sinkuu:ice_44851, r=jseyfriedbors-0/+24
Visit attribute tokens in `DefCollector` and `BuildReducedGraphVisitor` Fixes #44851.
2017-10-25Rename some run-pass tests so they don't crash when executed from eCryptfs.Michael Woerister-0/+0
2017-10-25Add a regression test for the const eval type resolutionOliver Schneider-0/+28
2017-10-23Fix #44851 by visiting tokens in `DefCollector` and `BuildReducedGraphVisitor`sinkuu-0/+24
2017-10-22`crate` shorthand visibility modifierZack M. Davis-1/+13
With regrets, this breaks rustfmt and rls. This is in the matter of #45388.