about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2017-08-13Rollup merge of #43782 - nrc:include, r=GuillaumeGomezGuillaume Gomez-0/+20
Fix include! in doc tests By making the path relative to the current file. Fixes #43153 [breaking-change] - if you use `include!` inside a doc test, you'll need to change the path to be relative to the current file rather than relative to the working directory.
2017-08-13Auto merge of #43348 - kennytm:fix-24658-doc-every-platform, r=alexcrichtonbors-0/+59
Expose all OS-specific modules in libstd doc. 1. Uses the special `--cfg dox` configuration passed by rustbuild when running `rustdoc`. Changes the `#[cfg(platform)]` into `#[cfg(any(dox, platform))]` so that platform-specific API are visible to rustdoc. 2. Since platform-specific implementations often won't compile correctly on other platforms, `rustdoc` is changed to apply `everybody_loops` to the functions during documentation and doc-test harness. 3. Since platform-specific code are documented on all platforms now, it could confuse users who found a useful API but is non-portable. Also, their examples will be doc-tested, so must be excluded when not testing on the native platform. An undocumented attribute `#[doc(cfg(...))]` is introduced to serve the above purposed. Fixes #24658 (Does _not_ fully implement #1998).
2017-08-12Auto merge of #43736 - ollie27:rustdoc_impls_js, r=QuietMisdreavusbors-0/+15
rustdoc: Don't add external impls to implementors js Otherwise impls from not documented crates appear. Fixes #43701
2017-08-12Check #[thread_local] statics correctly in the compiler.Eduard-Mihai Burtescu-10/+164
2017-08-12syntax: #[allow_internal_unsafe] bypasses the unsafe_code lint in macros.Eduard-Mihai Burtescu-1/+33
2017-08-12Auto merge of #43772 - arielb1:nonfree-block, r=nagisabors-15/+13
For box expressions, use NZ drop instead of a free block This falls naturally out of making drop elaboration work with `box` expressions, which is probably required for sane MIR borrow-checking. This is a pure refactoring with no intentional functional effects. r? @nagisa
2017-08-11Auto merge of #43800 - GuillaumeGomez:rollup, r=GuillaumeGomezbors-11/+129
Rollup of 18 pull requests - Successful merges: #43176, #43632, #43650, #43712, #43715, #43721, #43739, #43741, #43744, #43747, #43752, #43760, #43773, #43779, #43783, #43791, #43793, #43795 - Failed merges:
2017-08-11Rollup merge of #43752 - arshiamufti:union-test, r=estebankGuillaume Gomez-0/+5
Add IRC's `!union union` as a test, addresses #43553 This pull request adds a new test, `union` to `weird-exprs.rs`.
2017-08-11Rollup merge of #43744 - MaloJaffre:stage1-test, r=Mark-SimulacrumGuillaume Gomez-0/+53
Ignore tests that fail on stage1 That makes `./x.py test --stage 1` work on `x86_64-unknown-linux-gnu`.
2017-08-11Rollup merge of #43650 - RalfJung:mir-validate, r=arielb1Guillaume Gomez-11/+71
test MIR validation statements in closures r? @nikomatsakis
2017-08-11Auto merge of #43745 - kennytm:fix-43162, r=aturonbors-0/+23
Type-check `break value;` even outside of `loop {}`. Fix #43162, fix #43727.
2017-08-11Auto merge of #43743 - michaelwoerister:gcx-tcx-switcheroo, r=eddybbors-0/+5
Some assorted region hashing fixes. This PR contains three changes. 1. It changes what we implement `HashStable` for. Previously, the trait was implemented for things in the local `TyCtxt`. That was OK, since we only invoked hashing with a `TyCtxt<'_, 'tcx, 'tcx>` where there is no difference. With query result hashing this becomes a problem though. So we now implement `HashStable` for things in `'gcx`. 2. The PR makes the regular `HashStable` implementation *not* anonymize late-bound regions anymore. It's a waste of computing resources and it's not clear that it would always be correct to do so. 3. The PR adds an option for stable hashing to treat all regions as erased and uses this new option when computing the `TypeId`. This should help with https://github.com/rust-lang/rust/issues/41875. I did not add a test case for (3) since that's not possible yet. But it looks like @zackmdavis has something in the pipeline there `:)`. r? @eddyb
2017-08-10Auto merge of #43720 - pornel:staticconst, r=petrochenkovbors-0/+27
Hint correct extern constant syntax Error message for `extern "C" { const …}` is terse, and the right syntax is hard to guess given unfortunate difference between meaning of `static` in C and Rust. I've added a hint for the right syntax.
2017-08-10For box expressions, use NZ drop instead of a free blockAriel Ben-Yehuda-15/+13
This falls naturally out of making drop elaboration work with `box` expressions, which is probably required for sane MIR borrow-checking. This is a pure refactoring with no intentional functional effects.
2017-08-10Reword error hintKornel-1/+1
2017-08-10Auto merge of #43522 - alexcrichton:rewrite-lints, r=michaelwoeristerbors-217/+312
rustc: Rearchitect lints to be emitted more eagerly In preparation for incremental compilation this commit refactors the lint handling infrastructure in the compiler to be more "eager" and overall more incremental-friendly. Many passes of the compiler can emit lints at various points but before this commit all lints were buffered in a table to be emitted at the very end of compilation. This commit changes these lints to be emitted immediately during compilation using pre-calculated lint level-related data structures. Linting today is split into two phases, one set of "early" lints run on the `syntax::ast` and a "late" set of lints run on the HIR. This commit moves the "early" lints to running as late as possible in compilation, just before HIR lowering. This notably means that we're catching resolve-related lints just before HIR lowering. The early linting remains a pass very similar to how it was before, maintaining context of the current lint level as it walks the tree. Post-HIR, however, linting is structured as a method on the `TyCtxt` which transitively executes a query to calculate lint levels. Each request to lint on a `TyCtxt` will query the entire crate's 'lint level data structure' and then go from there about whether the lint should be emitted or not. The query depends on the entire HIR crate but should be very quick to calculate (just a quick walk of the HIR) and the red-green system should notice that the lint level data structure rarely changes, and should hopefully preserve incrementality. Overall this resulted in a pretty big change to the test suite now that lints are emitted much earlier in compilation (on-demand vs only at the end). This in turn necessitated the addition of many `#![allow(warnings)]` directives throughout the compile-fail test suite and a number of updates to the UI test suite. Closes https://github.com/rust-lang/rust/issues/42511
2017-08-10Auto merge of #43582 - ivanbakel:unused_mut_ref, r=arielb1bors-0/+20
Fixed mutable vars being marked used when they weren't #### NB : bootstrapping is slow on my machine, even with `keep-stage` - fixes for occurances in the current codebase are <s>in the pipeline</s> done. This PR is being put up for review of the fix of the issue. Fixes #43526, Fixes #30280, Fixes #25049 ### Issue Whenever the compiler detected a mutable deref being used mutably, it marked an associated value as being used mutably as well. In the case of derefencing local variables which were mutable references, this incorrectly marked the reference itself being used mutably, instead of its contents - with the consequence of making the following code emit no warnings ``` fn do_thing<T>(mut arg : &mut T) { ... // don't touch arg - just deref it to access the T } ``` ### Fix Make dereferences not be counted as a mutable use, but only when they're on borrows on local variables. #### Why not on things other than local variables? * Whenever you capture a variable in a closure, it gets turned into a hidden reference - when you use it in the closure, it gets dereferenced. If the closure uses the variable mutably, that is actually a mutable use of the thing being dereffed to, so it has to be counted. * If you deref a mutable `Box` to access the contents mutably, you are using the `Box` mutably - so it has to be counted.
2017-08-10Auto merge of #43737 - GuillaumeGomez:duplicate-method, r=eddybbors-0/+42
Improve error message when duplicate names for type and trait method Fixes #43626.
2017-08-10doc tests: use the filename from the source file for doc test programs, ↵Nick Cameron-0/+20
rather than a dummy name
2017-08-10Implemented #[doc(cfg(...))].kennytm-0/+59
This attribute has two effects: 1. Items with this attribute and their children will have the "This is supported on **** only" message attached in the documentation. 2. The items' doc tests will be skipped if the configuration does not match.
2017-08-10Auto merge of #43735 - est31:master, r=alexcrichtonbors-0/+37
Avoid calling the column!() macro in panic Closes #43057 This "fix" adds a new macro called `__rust_unstable_column` and to use it instead of the `column` macro inside panic. The new macro can be shadowed as well as `column` can, but its very likely that there is no code that does this in practice. There is no real way to make "unstable" macros that are usable by stable macros, so we do the next best thing and prefix the macro with `__rust_unstable` to make sure people recognize it is unstable. r? @alexcrichton
2017-08-10Add a feature gateest31-0/+14
@alexcrichton figured out a way how to do it :)
2017-08-10Better diagnostics and recovery for `const` in extern blocksVadim Petrochenkov-0/+27
2017-08-09Auto merge of #43484 - estebank:point-to-return, r=arielb1bors-7/+28
Point at return type always when type mismatch against it Before this, the diagnostic errors would only point at the return type when changing it would be a possible solution to a type error. Add a label to the return type without a suggestion to change in order to make the source of the expected type obvious. Follow up to #42850, fixes #25133, fixes #41897.
2017-08-09Readd backticks around ()Esteban Küber-4/+4
2017-08-09rustc: Rearchitect lints to be emitted more eagerlyAlex Crichton-217/+312
In preparation for incremental compilation this commit refactors the lint handling infrastructure in the compiler to be more "eager" and overall more incremental-friendly. Many passes of the compiler can emit lints at various points but before this commit all lints were buffered in a table to be emitted at the very end of compilation. This commit changes these lints to be emitted immediately during compilation using pre-calculated lint level-related data structures. Linting today is split into two phases, one set of "early" lints run on the `syntax::ast` and a "late" set of lints run on the HIR. This commit moves the "early" lints to running as late as possible in compilation, just before HIR lowering. This notably means that we're catching resolve-related lints just before HIR lowering. The early linting remains a pass very similar to how it was before, maintaining context of the current lint level as it walks the tree. Post-HIR, however, linting is structured as a method on the `TyCtxt` which transitively executes a query to calculate lint levels. Each request to lint on a `TyCtxt` will query the entire crate's 'lint level data structure' and then go from there about whether the lint should be emitted or not. The query depends on the entire HIR crate but should be very quick to calculate (just a quick walk of the HIR) and the red-green system should notice that the lint level data structure rarely changes, and should hopefully preserve incrementality. Overall this resulted in a pretty big change to the test suite now that lints are emitted much earlier in compilation (on-demand vs only at the end). This in turn necessitated the addition of many `#![allow(warnings)]` directives throughout the compile-fail test suite and a number of updates to the UI test suite.
2017-08-09Erase/anonymize regions while computing TypeId hash.Michael Woerister-0/+5
2017-08-08Only refer to return type when it matchesEsteban Küber-7/+4
2017-08-09Auto merge of #43728 - zackmdavis:fnused, r=eddybbors-0/+47
#[must_use] for functions This implements [RFC 1940](https://github.com/rust-lang/rfcs/pull/1940). The RFC and discussion thereof seem to suggest that tagging `PartialEq::eq` and friends as `#[must_use]` would automatically lint for unused comparisons, but it doesn't work out that way (at least the way I've implemented it): unused `.eq` method calls get linted, but not `==` expressions. (The lint operates on the HIR, which sees binary operations as their own thing, even if they ultimately just call `.eq` _&c._.) What do _you_ think?? Resolves #43302.
2017-08-08Auto merge of #43691 - GuillaumeGomez:fix-rustdoc, r=QuietMisdreavusbors-0/+18
Fix rustdoc Fixes #43625. r? @rust-lang/dev-tools cc @rust-lang/docs
2017-08-08explain that the example is indeed UB, but that's okayRalf Jung-0/+3
2017-08-08Improve error message when duplicate names for type and trait methodGuillaume Gomez-0/+42
2017-08-08#[must_use] for functions (RFC 1940)Zack M. Davis-0/+47
The return value of a function annotated with `must_use`, must be used. This is in the matter of #43302.
2017-08-08Ignore tests that fail on stage1Malo Jaffré-0/+53
That makes ./x.py test --stage 1 work on x86_64-unknown-linux-gnu.
2017-08-09Type-check `break value;` even outside of `loop {}`.kennytm-0/+23
Fix #43162, fix #43727.
2017-08-08rustdoc: Don't add external impls to implementors jsOliver Middleton-0/+15
Otherwise impls from not documented crates appear.
2017-08-08Avoid calling the column!() macro in panicest31-0/+23
2017-08-07Remove \0 printingGuillaume Gomez-1/+1
2017-08-07Auto merge of #43699 - GuillaumeGomez:e0623, r=eddybbors-0/+22
Add missing error code for private method
2017-08-06Add missing error code for private methodGuillaume Gomez-0/+22
2017-08-06Fix hoedown error in rustdocGuillaume Gomez-0/+18
2017-08-06Auto merge of #43397 - GuillaumeGomez:unused-union-field, r=petrochenkovbors-0/+74
Don't warn on unused field on union Fixes #43393.
2017-08-06Handle type aliases as wellGuillaume Gomez-1/+16
2017-08-06Added closure test case.Isaac van Bakel-0/+6
2017-08-06Fix union unused fields checkGuillaume Gomez-5/+17
2017-08-06Improve union unused field detectionGuillaume Gomez-12/+16
2017-08-06Auto merge of #43488 - Florob:repeat-opt, r=arielb1bors-0/+74
Optimize initialization of arrays using repeat expressions This PR was inspired by [this thread](https://www.reddit.com/r/rust/comments/6o8ok9/understanding_rust_performances_a_newbie_question/) on Reddit. It tries to bring array initialization in the same ballpark as `Vec::from_elem()` for unoptimized builds. For optimized builds this should relieve LLVM of having to figure out the construct we generate is in fact a `memset()`. To that end this emits `llvm.memset()` when: * the array is of integer type and all elements are zero (`Vec::from_elem()` also explicitly optimizes for this case) * the array elements are byte sized If the array is zero-sized initialization is omitted entirely.
2017-08-05Don't warn on unused field on unionGuillaume Gomez-0/+43
2017-08-05Auto merge of #43554 - eddyb:apfloat, r=nikomatsakisbors-2/+2
APFloat: Rewrite It In Rust and use it for deterministic floating-point CTFE. As part of the CTFE initiative, we're forced to find a solution for floating-point operations. By design, IEEE-754 does not explicitly define everything in a deterministic manner, and there is some variability between platforms, at the very least (e.g. NaN payloads). If types are to evaluate constant expressions involving type (or in the future, const) generics, that evaluation needs to be *fully deterministic*, even across `rustc` host platforms. That is, if `[T; T::X]` was used in a cross-compiled library, and the evaluation of `T::X` executed a floating-point operation, that operation has to be reproducible on *any other host*, only knowing `T` and the definition of the `X` associated const (as either AST or HIR). Failure to uphold those rules allows an associated type (e.g. `<Foo as Iterator>::Item`) to be seen as two (or more) different types, depending on the current host, and such type safety violations typically allow writing of a `transmute` in safe code, given enough generics. The options considered by @rust-lang/compiler were: 1. Ban floating-point operations in generic const-evaluation contexts 2. Emulate floating-point operations in an uniformly deterministic fashion The former option may seem appealing at first, but floating-point operations *are allowed today*, so they can't be banned wholesale, a distinction has to be made between the code that already works, and future generic contexts. *Moreover*, every computation that succeeded *has to be cached*, otherwise the generic case can be reproduced without any generics. IMO there are too many ways it can go wrong, and a single violation can be enough for an unsoundness hole. Not to mention we may end up really wanting floating-point operations *anyway*, in CTFE. I went with the latter option, and seeing how LLVM *already* has a library for this exact purpose (as it needs to perform optimizations independently of host floating-point capabilities), i.e. `APFloat`, that was what I ended up basing this PR on. But having been burned by the low reusability of bindings that link to LLVM, and because I would *rather* the floating-point operations to be wrong than not deterministic or not memory-safe (`APFloat` does far more pointer juggling than I'm comfortable with), I decided to RIIR. This way, we have a guarantee of *no* `unsafe` code, a bit more control over the where native floating-point might accidentally be involved, and non-LLVM backends can share it. I've also ported all the testcases over, *before* any functionality, to catch any mistakes. Currently the PR replaces all CTFE operations to go through `apfloat::ieee::{Single,Double}`, keeping only the bits of the `f32` / `f64` memory representation in between operations. Converting from a string also double-checks that `core::num` and `apfloat` agree on the interpretation of a floating-point number literal, in case either of them has any bugs left around. r? @nikomatsakis f? @nagisa @est31 <hr/> Huge thanks to @edef1c for first demoing usable `APFloat` bindings and to @chandlerc for fielding my questions on IRC about `APFloat` peculiarities (also upstreaming some bugfixes).
2017-08-05Auto merge of #43642 - mmatyas:unskip_aarch64_tests, r=sanxiynbors-6/+0
Unskip some tests on AArch64 I've been running the test suite remotely on an Acer Chromebook R13 and natively on an ARM Juno developer board, both AArch64 devices. Most of the tests that are skipped on AArch64 are due to testing stdcall/fastcall/x86-specific code or the debugger, but I've found a few tests that could be enabled there. These have been skipped previously due to failing on the `aarch64-linux-android` and `mac-android` buildbots, more than 2 years ago (#23471, #23695). It seems we don't test those platforms any more, but as they do work on AArch64 Linux, I'd like to propose re-enabling them. All of them pass on my devices.