about summary refs log tree commit diff
path: root/src/test/compile-fail
AgeCommit message (Collapse)AuthorLines
2017-11-21Report special messages for path segment keywords in wrong positionsVadim Petrochenkov-10/+9
2017-11-21Support `::crate` in pathsVadim Petrochenkov-2/+76
2017-11-20Auto merge of #45905 - alexcrichton:add-wasm-target, r=aturonbors-0/+14
std: Add a new wasm32-unknown-unknown target This commit adds a new target to the compiler: wasm32-unknown-unknown. This target is a reimagining of what it looks like to generate WebAssembly code from Rust. Instead of using Emscripten which can bring with it a weighty runtime this instead is a target which uses only the LLVM backend for WebAssembly and a "custom linker" for now which will hopefully one day be direct calls to lld. Notable features of this target include: * There is zero runtime footprint. The target assumes nothing exists other than the wasm32 instruction set. * There is zero toolchain footprint beyond adding the target. No custom linker is needed, rustc contains everything. * Very small wasm modules can be generated directly from Rust code using this target. * Most of the standard library is stubbed out to return an error, but anything related to allocation works (aka `HashMap`, `Vec`, etc). * Naturally, any `#[no_std]` crate should be 100% compatible with this new target. This target is currently somewhat janky due to how linking works. The "linking" is currently unconditional whole program LTO (aka LLVM is being used as a linker). Naturally that means compiling programs is pretty slow! Eventually though this target should have a linker. This target is also intended to be quite experimental. I'm hoping that this can act as a catalyst for further experimentation in Rust with WebAssembly. Breaking changes are very likely to land to this target, so it's not recommended to rely on it in any critical capacity yet. We'll let you know when it's "production ready". ### Building yourself First you'll need to configure the build of LLVM and enable this target ``` $ ./configure --target=wasm32-unknown-unknown --set llvm.experimental-targets=WebAssembly ``` Next you'll want to remove any previously compiled LLVM as it needs to be rebuilt with WebAssembly support. You can do that with: ``` $ rm -rf build ``` And then you're good to go! A `./x.py build` should give you a rustc with the appropriate libstd target. ### Test support Currently testing-wise this target is looking pretty good but isn't complete. I've got almost the entire `run-pass` test suite working with this target (lots of tests ignored, but many passing as well). The `core` test suite is [still getting LLVM bugs fixed](https://reviews.llvm.org/D39866) to get that working and will take some time. Relatively simple programs all seem to work though! In general I've only tested this with a local fork that makes use of LLVM 5 rather than our current LLVM 4 on master. The LLVM 4 WebAssembly backend AFAIK isn't broken per se but is likely missing bug fixes available on LLVM 5. I'm hoping though that we can decouple the LLVM 5 upgrade and adding this wasm target! ### But the modules generated are huge! It's worth nothing that you may not immediately see the "smallest possible wasm module" for the input you feed to rustc. For various reasons it's very difficult to get rid of the final "bloat" in vanilla rustc (again, a real linker should fix all this). For now what you'll have to do is: cargo install --git https://github.com/alexcrichton/wasm-gc wasm-gc foo.wasm bar.wasm And then `bar.wasm` should be the smallest we can get it! --- In any case for now I'd love feedback on this, particularly on the various integration points if you've got better ideas of how to approach them!
2017-11-19std: Add a new wasm32-unknown-unknown targetAlex Crichton-0/+14
This commit adds a new target to the compiler: wasm32-unknown-unknown. This target is a reimagining of what it looks like to generate WebAssembly code from Rust. Instead of using Emscripten which can bring with it a weighty runtime this instead is a target which uses only the LLVM backend for WebAssembly and a "custom linker" for now which will hopefully one day be direct calls to lld. Notable features of this target include: * There is zero runtime footprint. The target assumes nothing exists other than the wasm32 instruction set. * There is zero toolchain footprint beyond adding the target. No custom linker is needed, rustc contains everything. * Very small wasm modules can be generated directly from Rust code using this target. * Most of the standard library is stubbed out to return an error, but anything related to allocation works (aka `HashMap`, `Vec`, etc). * Naturally, any `#[no_std]` crate should be 100% compatible with this new target. This target is currently somewhat janky due to how linking works. The "linking" is currently unconditional whole program LTO (aka LLVM is being used as a linker). Naturally that means compiling programs is pretty slow! Eventually though this target should have a linker. This target is also intended to be quite experimental. I'm hoping that this can act as a catalyst for further experimentation in Rust with WebAssembly. Breaking changes are very likely to land to this target, so it's not recommended to rely on it in any critical capacity yet. We'll let you know when it's "production ready". --- Currently testing-wise this target is looking pretty good but isn't complete. I've got almost the entire `run-pass` test suite working with this target (lots of tests ignored, but many passing as well). The `core` test suite is still getting LLVM bugs fixed to get that working and will take some time. Relatively simple programs all seem to work though! --- It's worth nothing that you may not immediately see the "smallest possible wasm module" for the input you feed to rustc. For various reasons it's very difficult to get rid of the final "bloat" in vanilla rustc (again, a real linker should fix all this). For now what you'll have to do is: cargo install --git https://github.com/alexcrichton/wasm-gc wasm-gc foo.wasm bar.wasm And then `bar.wasm` should be the smallest we can get it! --- In any case for now I'd love feedback on this, particularly on the various integration points if you've got better ideas of how to approach them!
2017-11-19Auto merge of #45225 - eddyb:trans-abi, r=arielb1bors-0/+23
Refactor type memory layouts and ABIs, to be more general and easier to optimize. To combat combinatorial explosion, type layouts are now described through 3 orthogonal properties: * `Variants` describes the plurality of sum types (where applicable) * `Single` is for one inhabited/active variant, including all C `struct`s and `union`s * `Tagged` has its variants discriminated by an integer tag, including C `enum`s * `NicheFilling` uses otherwise-invalid values ("niches") for all but one of its inhabited variants * `FieldPlacement` describes the number and memory offsets of fields (if any) * `Union` has all its fields at offset `0` * `Array` has offsets that are a multiple of its `stride`; guarantees all fields have one type * `Arbitrary` records all the field offsets, which can be out-of-order * `Abi` describes how values of the type should be passed around, including for FFI * `Uninhabited` corresponds to no values, associated with unreachable control-flow * `Scalar` is ABI-identical to its only integer/floating-point/pointer "scalar component" * `ScalarPair` has two "scalar components", but only applies to the Rust ABI * `Vector` is for SIMD vectors, typically `#[repr(simd)]` `struct`s in Rust * `Aggregate` has arbitrary contents, including all non-transparent C `struct`s and `union`s Size optimizations implemented so far: * ignoring uninhabited variants (i.e. containing uninhabited fields), e.g.: * `Option<!>` is 0 bytes * `Result<T, !>` has the same size as `T` * using arbitrary niches, not just `0`, to represent a data-less variant, e.g.: * `Option<bool>`, `Option<Option<bool>>`, `Option<Ordering>` are all 1 byte * `Option<char>` is 4 bytes * using a range of niches to represent *multiple* data-less variants, e.g.: * `enum E { A(bool), B, C, D }` is 1 byte Code generation now takes advantage of `Scalar` and `ScalarPair` to, in more cases, pass around scalar components as immediates instead of indirectly, through pointers into temporary memory, while avoiding LLVM's "first-class aggregates", and there's more untapped potential here. Closes #44426, fixes #5977, fixes #14540, fixes #43278.
2017-11-19mir-borrowck: Remove parens in the lvalue description of a derefBasile Desloges-12/+12
2017-11-19dead code lint to say "never constructed" for variantsZack M. Davis-9/+9
As reported in #19140, #44083, and #44565, some users were confused when the dead-code lint reported an enum variant to be "unused" when it was matched on (but not constructed). This wording change makes it clearer that the lint is in fact checking for construction. We continue to say "used" for all other items (it's tempting to say "called" for functions and methods, but this turns out not to be correct: functions can be passed as arguments and the dead-code lint isn't special-casing that or anything). Resolves #19140.
2017-11-19rustc: remove Ty::layout and move everything to layout_of.Eduard-Mihai Burtescu-0/+23
2017-11-18fix compile-fail testsNiko Matsakis-5/+1
2017-11-18Auto merge of #46032 - KiChjang:ignore-borrowck-statics, r=nikomatsakisbors-34/+0
Ignore borrowck for static lvalues and allow assignment to static muts Fixes #45129. Fixes #45641.
2017-11-18rename `issue-21410.rs` to `ui/unboxed-closure-no-cyclic-sig.rs`Niko Matsakis-15/+0
2017-11-18add a compile-fail test for cyclic generators being forbiddenNiko Matsakis-0/+45
2017-11-18move the signature into the closure typeNiko Matsakis-2/+35
2017-11-18stop using the `closure_kinds` query / table for anythingNiko Matsakis-1/+1
Closure Kind is now extracted from the closure substs exclusively.
2017-11-17Do not registor borrows for unsafe lvaluesKeith Yeung-34/+0
2017-11-17add doc_highlight feature flag and testsQuietMisdreavus-0/+14
2017-11-17Fix impl Trait Lifetime HandlingTaylor Cramer-43/+122
After this change, impl Trait existentials are desugared to a new `abstract type` definition paired with a set of lifetimes to apply. In-scope generics are included as parents of the `abstract type` generics. Parent regions are replaced with static, and parent regions referenced in the `impl Trait` type are duplicated at the end of the `abstract type`'s generics.
2017-11-16Use local spans onlyEsteban Küber-2/+9
2017-11-17Updated test to reflect expected Mir output.David Wood-5/+18
2017-11-16Auto merge of #45825 - nikomatsakis:nll-factor-region-inference, r=arielb1bors-1/+0
integrate MIR type-checker with NLL inference This branch refactors NLL type inference so that it uses the MIR type-checker to gather constraints. Along the way, it also refactors how region constraints are gathered in the normal inference context mildly. The new setup is like this: - What used to be `region_inference` is split into two parts: - `region_constraints`, which just collects up sets of constraints - `lexical_region_resolve`, which does the iterative, lexical region resolution - When `resolve_regions_and_report_errors` is invoked, the inference engine converts the constraints into final values. - In the MIR type checker, however, we do not invoke this method, but instead periodically take the region constraints and package them up for the NLL solver to use later. - This allows us to track when and where those constraints were incurred. - We also remove the central fulfillment context from the MIR type checker, instead instantiating new fulfillment contexts at each point. This allows us to capture the set of obligations that occurred at a particular point, and also to ensure that if the same obligation arises at two points, we will enforce the region constraints at both locations. - The MIR type checker is also enhanced to instantiate late-bound-regions with fresh variables and handle a few other corner cases that arose. - I also extracted some of the 'outlives' logic from the regionck, which will be needed later (see future work) to handle the type-outlives relationships. One concern I have with this branch: since the MIR type checker is used even without the `-Znll` switch, I'm not sure if it will impact performance. One simple fix here would be to only enable the MIR type-checker if debug-assertions are enabled, since it just serves to validate the MIR. Longer term I hope to address this by improving the interface to the trait solver to be more query-based (ongoing work). There is plenty of future work left. Here are two things that leap to mind: - **Type-region outlives.** Currently, the NLL solver will ICE if it is required to handle a constraint like `T: 'a`. Fixing this will require a small amount of refactoring to extract the implied bounds code. I plan to follow a file-up bug on this (hopefully with mentoring instructions). - **Testing.** It's a good idea to enumerate some of the tricky scenarios that need testing, but I think it'd be nice to try and parallelize some of the actual test writing (and resulting bug fixing): - Same obligation occurring at two points. - Well-formedness and trait obligations of various kinds (which are not all processed by the current MIR type-checker). - More tests for how subtyping and region inferencing interact. - More suggestions welcome! r? @arielb1
2017-11-16Rollup merge of #45984 - ExpHP:attr-error-context, r=estebankGuillaume Gomez-22/+14
Add context to E0084, E0517, E0518 A small diagnostic enhancement to get my feet wet. Please scrutinize! This modifies errors E0084, E0517, and E0518 to include both the annotation and the annotated item. All of these errors already had labels; I moved the label to the other span, and rephrased it as necessary. Fixes #45886
2017-11-15Point to ADT definition when not finding variant, method, assoc typeEsteban Küber-3/+5
2017-11-15Use the proper term when using non-existing variantEsteban Küber-7/+8
When using a non-existing variant, function or associated item, refer to the proper term, instead of defaulting to "associated item" in diagnostics.
2017-11-15Auto merge of #45918 - chrisvittal:impl-trait-pr, r=nikomatsakisbors-69/+295
Implement `impl Trait` in argument position (RFC1951, Universal quantification) Implements the remainder of #44721, part of #34511. **Note**: This PR currently allows argument position `impl Trait` in trait functions. The machinery is there to prevent this if we want to, but it currently does not. Rename `hir::TyImplTrait` to `hir::TyImplTraitExistential` and add `hir::TyImplTraitUniversal(DefId, TyParamBounds)`. The `DefId` is needed to extract the index of the parameter in `ast_ty_to_ty`. Introduce an `ImplTraitContext` enum to lowering to keep track of the kind and allowedness of `impl Trait` in that position. This new argument is passed through many places, all ending up in `lower_ty`. Modify `generics_of` and `explicit_predicates_of` to collect the `impl Trait` args into anonymous synthetic generic parameters and to extend the predicates with the appropriate bounds. Add a comparison of the 'syntheticness' of type parameters, that is, prevent the following. ```rust trait Foo { fn foo(&self, &impl Debug); } impl Foo for Bar { fn foo<U: Debug>(&self, x: &U) { ... } } ``` And vice versa. Incedentally, supress `unused type parameter` errors if the type being compared is already a `TyError`. **TODO**: I have tried to annotate open questions with **FIXME**s. The most notable ones that haven't been resolved are the names of the `impl Trait` types and the questions surrounding the new `compare_synthetic_generics` method. 1. For now, the names used for `impl Trait` parameters are `keywords::Invalid.name()`. I would like them to be `impl ...` if possible, but I haven't figured out a way to do that yet. 2. For `compare_synthetic_generics` I have tried to outline the open questions in the [function itself](https://github.com/chrisvittal/rust/blob/3fc9e3705f7bd01f3cb0ea470cf2892f17a92350/src/librustc_typeck/check/compare_method.rs#L714-L725) r? @nikomatsakis
2017-11-15convert EXTRA_REQUIREMENT_IN_IMPL into a hard errorNiko Matsakis-1/+0
cc #37166
2017-11-15Add cases to where-allowed.rsChristopher Vittal-4/+9
2017-11-15Incorporate review feedbackChristopher Vittal-2/+0
Add requested comments, restructure some small bits of code. Fix extern declarations allowing impl Trait.
2017-11-15extend `where-allowed.rs` with many more casesNiko Matsakis-93/+179
also merge disallowed and disallowed-2 into that set
2017-11-15rename many-cases to where-allowedNiko Matsakis-0/+0
2017-11-15test we reject equivalent signatures with more than one argumentNiko Matsakis-0/+23
2017-11-15Remove unamed parametersChristopher Vittal-2/+2
2017-11-15Add/Modify tests for argument position impl TraitChristopher Vittal-5/+103
2017-11-15Add universal_impl_trait feature gateChristopher Vittal-1/+17
Move feature gate check to inside HIR lowering. Change error messages and update tests.
2017-11-15Auto merge of #45938 - vramana:fix-ice-45698, r=arielb1bors-0/+24
Fix End-user description not implemented for field access on `TyClosure - [x] Add Tests
2017-11-15fix testMikhail Modin-2/+1
2017-11-15add `StorageDead` handlingMikhail Modin-0/+30
2017-11-15Auto merge of #45922 - vramana:fix-45702, r=nikomatsakisbors-9/+33
Fix MIR borrowck EndRegion not found Fixes #45702 - [x] Add Tests
2017-11-14add NOTE: to test notesMichael Lamparski-14/+14
2017-11-15Fix printing of upvar in closuresRamana Venkata-0/+24
2017-11-14Rollup merge of #45967 - matthewjasper:array-move-types, r=arielb1Guillaume Gomez-1/+6
MIR-borrowck: don't ICE for cannot move from array error Closes #45694 compile-fail test E0508 now gives ```text error[E0508]: cannot move out of type `[NonCopy; 1]`, a non-copy array (Ast) --> .\src\test\compile-fail\E0508.rs:18:18 | 18 | let _value = array[0]; //[ast]~ ERROR E0508 | ^^^^^^^^ | | | cannot move out of here | help: consider using a reference instead: `&array[0]` error[E0508]: cannot move out of type `[NonCopy; 1]`, a non-copy array (Mir) --> .\src\test\compile-fail\E0508.rs:18:18 | 18 | let _value = array[0]; //[ast]~ ERROR E0508 | ^^^^^^^^ cannot move out of here error: aborting due to 2 previous errors ```
2017-11-14un-add some notes from testsMichael Lamparski-23/+12
2017-11-14Add context to E0084, E00517, E0518Michael Lamparski-28/+31
Show both the attribute and the item
2017-11-13Use the correct type for cannot move errormatthewjasper-1/+6
2017-11-13mir-borrowck: Test for `check_access_permissions()`Basile Desloges-1/+82
2017-11-13Auto merge of #45890 - arielb1:self-first, r=eddybbors-0/+35
check::method - unify receivers before normalizing method signatures Normalizing method signatures can unify inference variables, which can cause receiver unification to fail. Unify the receivers first to avoid that. Fixes #36701. Fixes #45801. Fixes #45855. r? @eddyb beta-nominating because #43880 made this ICE happen in more cases (the code in that issue ICEs post-#43880 only, but the unit test here ICEs on all versions).
2017-11-12update project-fn-test-invariant testCengiz Can-2/+2
2017-11-12update failing E0621 testsCengiz Can-6/+6
2017-11-12use BTreeMap for region constraintsCengiz Can-2/+2
2017-11-12Update fn-ret-invariant test assertionCengiz Can-2/+1
2017-11-12Improve SubSupConflict case with one named, one anonymous lifetime parameter ↵Cengiz Can-24/+26
#42701