about summary refs log tree commit diff
path: root/src/test/compile-fail
AgeCommit message (Collapse)AuthorLines
2017-03-26Auto merge of #40826 - frewsxcv:rollup, r=frewsxcvbors-0/+16
Rollup of 7 pull requests - Successful merges: #40642, #40734, #40740, #40771, #40807, #40820, #40821 - Failed merges:
2017-03-26Auto merge of #40501 - jseyfried:shadow_builtin_macros, r=nrcbors-0/+72
Allow `use` macro imports to shadow global macros Terminology: - global scope: builtin macros, macros from the prelude, `#[macro_use]`, or `#![plugin(..)]`. - legacy scope: crate-local `macro_rules!`. - modern scope: `use` macro imports, `macro` (once implemented). Today, the legacy scope can shadow the global scope (modulo RFC 1560 expanded shadowing restrictions). However, the modern scope cannot shadow or be shadowed by either the global or legacy scopes, leading to ambiguity errors. This PR allows the modern scope to shadow the global scope (subject to some restrictions). More specifically, a name in the global scope is as shadowable as a glob import in the module `self`. In other words, we imagine a special, implicit glob import in each module item: ```rust mod foo { #[lexical_only] // Not accessible via `foo::<name>`, like pre-RFC 1560 `use` imports. #[shadowable_by_legacy_scope] // for back-compat use <global_macros>::*; } ``` r? @nrc
2017-03-26store a copy of the Issue32230 info within TypeErrorAriel Ben-Yehuda-0/+21
The data can't be looked up from the region variable directly, because the region variable might have been destroyed at the end of a snapshot. Fixes #40000. Fixes #40743.
2017-03-25Improve wording and spans for unexpected tokenEsteban Küber-60/+0
* Point at where the token was expected instead of the last token successfuly parsed. * Only show `unexpected token` if the next char and the unexpected token don't have the same span. * Change some cfail and pfail tests to ui test. * Don't show all possible tokens in span label if they are more than 6.
2017-03-25Clarify suggetion for field used as methodEsteban Küber-20/+40
Instead of ``` error: no method named `src_addr` found for type `&wire::ipv4::Repr` in the current scope --> src/wire/ipv4.rs:409:34 | 409 | packet.set_src_addr(self.src_addr()); | ^^^^^^^^ | note: did you mean to write `self.src_addr`? --> src/wire/ipv4.rs:409:34 | 409 | packet.set_src_addr(self.src_addr()); | ^^^^^^^^ ``` present ``` error: no method named `src_addr` found for type `&wire::ipv4::Repr` in the current scope --> src/wire/ipv4.rs:409:34 | 409 | packet.set_src_addr(self.src_addr()); | ^^^^^^^^ `src_addr` is a field, not a method | = help: did you mean to write `self.src_addr` instead of `self.src_addr(...)`? ```
2017-03-25Rollup merge of #40734 - adamransom:fix/40661, r=jseyfriedCorey Farwell-0/+16
Add warning for use of lifetime parameter with 'static bound Previously a `'static` lifetime bound would result in an `undeclared lifetime` error when compiling, even though it could be considered valid. However, it is unnecessary to use it as a lifetime bound so we present the user with a warning instead and suggest using the `'static` lifetime directly, in place of the lifetime parameter. We can change this to an error (or warning with lint) if that's decided to be more appropriate. Example output: ``` warning: unnecessary lifetime parameter `'a` --> ../static-lifetime-bound.rs:3:10 | 3 | fn f<'a: 'static>(val: &'a i32) { | ^^^^^^^^^^^ | = help: you can use the `'static` lifetime directly, in place `'a` ``` Fixes #40661 r? @jseyfried
2017-03-24Point at last valid token on failed `expect_one_of`Esteban Küber-0/+4
```rust error: expected one of `.`, `;`, `?`, `}`, or an operator, found `)` --> $DIR/token-error-correct-3.rs:29:9 | 25 | foo() | - expected one of `.`, `;`, `?`, `}`, or an operator after this ... 29 | } else { | ^ unexpected token ```
2017-03-25Warn when using a `'static` lifetime boundAdam Ransom-0/+16
Previously a `'static` lifetime bound would result in an `undeclared lifetime` error when compiling, even though it could be considered valid. However, it is unnecessary to use it as a lifetime bound so we present the user with a warning instead and suggest using the `'static` lifetime directly, in place of the lifetime parameter.
2017-03-24Rollup merge of #40636 - nikomatsakis:revert-39485, r=eddybCorey Farwell-0/+36
Revert #39485, fixing type-inference regressions This reverts PR #39485, which should fix the immediate regressions. Eventually I'd like to land https://github.com/rust-lang/rust/pull/40224 -- or some variant of it -- which revisits the question fo dead-code and inference. r? @eddyb cc @canndrew
2017-03-24Allow declarative macros 2.0 and `use` macro imports to shadow builtin macros.Jeffrey Seyfried-0/+72
2017-03-23keep the AST node-id when lowering ExprKind::RangeAriel Ben-Yehuda-0/+16
When the Range expression is the root of a constant, its node-id is used for the def-id of the body, so it has to be preserved in the AST -> HIR lowering. Fixes #40749.
2017-03-23Rollup merge of #40753 - mandeep:change-ObjectSafetyViolation-message, r=brsonCorey Farwell-1/+1
Change object safety violation message Hello! This is my first pull request to rust so hopefully all goes well. This PR should fix issue #40670. I changed the error message in object_safety.rs and the corresponding compile-fail test in object-safety-supertrait-mentions-Self.rs. Once the changes were made, I ran ```python x.py test src/tools/tidy``` and ```python x.py test```. Tidy passed and the compile-fail tests passed, however the test suite failed on the tcp tests as my machine has IPv6 disabled. I'm not sure what to do in this case besides letting travis run the suite against my changes. Please let me know if there's anything I can do to help further. Thanks! Mandeep
2017-03-23Rollup merge of #40627 - estebank:pub-restricted, r=petrochenkovCorey Farwell-9/+12
Add diagnostic for incorrect `pub (restriction)` Given the following statement ```rust pub (a) fn afn() {} ``` Provide the following diagnostic: ```rust error: incorrect restriction in `pub` --> file.rs:15:1 | 15 | pub (a) fn afn() {} | ^^^ | = help: some valid visibility restrictions are: `pub(crate)`: visible only on the current crate `pub(super)`: visible only in the current module's parent `pub(in path::to::module)`: visible only on the specified path help: to make this visible only to module `a`, add `in` before the path: | pub (in a) fn afn() {} ``` Follow up to #40340, fix #40599, cc #32409.
2017-03-22Add diagnostic for incorrect `pub (restriction)`Esteban Küber-9/+12
Given the following statement ```rust pub (a) fn afn() {} ``` Provide the following diagnostic: ```rust error: incorrect restriction in `pub` --> file.rs:15:1 | 15 | pub (a) fn afn() {} | ^^^^^^^ | = help: some valid visibility restrictions are: `pub(crate)`: visible only on the current crate `pub(super)`: visible only in the current module's parent `pub(in path::to::module)`: visible only on the specified path help: to make this visible only to module `a`, add `in` before the path: | pub (in a) fn afn() {} ``` Remove cruft from old `pub(path)` syntax.
2017-03-22Changed E0038 error message in test to comply with new messagemandeep-1/+1
2017-03-22Rollup merge of #40518 - michaelwoerister:hir-id, r=eddybCorey Farwell-1/+1
Introduce HirId, a replacement for ast::NodeId after lowering to HIR This is the first step towards implementing #40303. This PR introduces the `HirId` type and generates a `HirId` for everything that would be assigned one (i.e. stuff in the HIR), but the HIR data types still use `NodeId` for now. Changing that is a big refactoring that I want to do in a separate PR. A `HirId` uniquely identifies a node in the HIR of the current crate. It is composed of the `owner`, which is the `DefIndex` of the directly enclosing `hir::Item`, `hir::TraitItem`, or `hir::ImplItem` (i.e. the closest "item-like"), and the `local_id` which is unique within the given owner. This PR is also running a number of consistency checks for the generated `HirId`s: - Does `NodeId` in the HIR have a corresponding `HirId`? - Is the `owner` part of each `HirId` consistent with its position in the HIR? - Do the numerical values of the `local_id` part all lie within a dense range of integers? cc @rust-lang/compiler r? @eddyb or @nikomatsakis
2017-03-22Rollup merge of #40509 - jseyfried:duplicate_check_macro_exports, r=nrcCorey Farwell-0/+19
Forbid conflicts between macros 1.0 exports and macros 2.0 exports This PR forbids for conflicts between `#[macro_export]`/`#[macro_reexport]` macro exports and `pub use` macro exports. For example, ```rust // crate A: pub use macros::foo; //^ This is allowed today, will be forbidden by this PR. // crate B: extern crate A; // This triggers a confusing error today. use A::foo; // This could refer to refer to either macro export in crate A. ``` r? @nrc
2017-03-22Fix the testsSimonas Kazlauskas-7/+7
2017-03-22Introduce HirId, a replacement for NodeId after lowering to HIR.Michael Woerister-1/+1
HirId has a more stable representation than NodeId, meaning that modifications to one item don't influence (part of) the IDs within other items. The other part is a DefIndex for which there already is a way of stable hashing and persistence. This commit introduces the HirId type and generates a HirId for every NodeId during HIR lowering, but the resulting values are not yet used anywhere, except in consistency checks.
2017-03-22Revert "Auto merge of #39485 - canndrew:inference-fix-39297, r=nikomatsakis"Niko Matsakis-0/+36
This reverts commit dc0bb3f2839c13ab42feacd423f728fbfd2f2f7a, reversing changes made to e879aa43ef63962f8e4d797292194a9f40a22a13. This is a temporary step intended to fix regressions. A more comprehensive fix for type inference and dead-code is in the works.
2017-03-21Check for conflicts between macros 1.0 exports (`#[macro_export]`, ↵Jeffrey Seyfried-0/+19
`#[macro_reexport]`) and macros 2.0 exports (`pub use` macro re-exports and `pub macro` (once implemented) at the crate root.
2017-03-21Refactor parsing of trait object typesVadim Petrochenkov-12/+27
2017-03-20Rollup merge of #40556 - cramertj:stabilize-pub-restricted, r=petrochenkovCorey Farwell-47/+1
Stabilize pub(restricted) Fix https://github.com/rust-lang/rust/issues/32409
2017-03-20Rollup merge of #40229 - cramertj:break-to-blocks, r=nikomatsakisCorey Farwell-0/+141
Implement `?` in catch expressions Builds on #39921. Final part of #39849. r? @nikomatsakis
2017-03-19Rollup merge of #40441 - tschottdorf:promotable-rfc, r=eddybCorey Farwell-0/+15
Add feature gate for rvalue-static-promotion Probably needs more tests (which ones?) and there may be other things that need to be done. Also not sure whether the version that introduces the flag is really `1.15.1`. See https://github.com/rust-lang/rfcs/pull/1414. Updates #38865.
2017-03-19Auto merge of #40346 - jseyfried:path_and_tokenstream_attr, r=nrcbors-2/+40
`TokenStream`-based attributes, paths in attribute and derive macro invocations This PR - refactors `Attribute` to use `Path` and `TokenStream` instead of `MetaItem`. - supports macro invocation paths for attribute procedural macros. - e.g. `#[::foo::attr_macro] struct S;`, `#[cfg_attr(all(), foo::attr_macro)] struct S;` - supports macro invocation paths for derive procedural macros. - e.g. `#[derive(foo::Bar, super::Baz)] struct S;` - supports arbitrary tokens as arguments to attribute procedural macros. - e.g. `#[foo::attr_macro arbitrary + tokens] struct S;` - supports using arbitrary tokens in "inert attributes" with derive procedural macros. - e.g. `#[derive(Foo)] struct S(#[inert arbitrary + tokens] i32);` where `#[proc_macro_derive(Foo, attributes(inert))]` r? @nrc
2017-03-17Add more catch-related CFG and lifetime tests and fix CFG bugTaylor Cramer-18/+81
2017-03-17Implement ? in catch expressions and add testsTaylor Cramer-0/+78
2017-03-17Make priv in pub hard error for crates using pub(restricted)Taylor Cramer-4/+0
2017-03-17Rollup merge of #40457 - frewsxcv:frewsxcv-macos, r=steveklabnikCorey Farwell-4/+4
Update usages of 'OSX' (and other old names) to 'macOS'. As of last year with version 'Sierra', the Mac operating system is now called 'macOS'.
2017-03-15Stabilize pub(restricted)Taylor Cramer-46/+4
2017-03-14Improve the documentation for `rvalue_static_promotion`Tobias Schottdorf-1/+1
2017-03-14Add feature toggle for rvalue-static-promotion RFCTobias Schottdorf-0/+15
See https://github.com/rust-lang/rfcs/pull/1414. Updates #38865.
2017-03-14Auto merge of #39921 - cramertj:add-catch-to-ast, r=nikomatsakisbors-0/+47
Add catch {} to AST Part of #39849. Builds on #39864.
2017-03-14Add tests.Jeffrey Seyfried-0/+1
2017-03-14Liberalize attributes.Jeffrey Seyfried-2/+39
2017-03-12Update usages of 'OSX' (and other old names) to 'macOS'.Corey Farwell-4/+4
As of last year with version 'Sierra', the Mac operating system is now called 'macOS'.
2017-03-12Auto merge of #40340 - petrochenkov:restricted, r=nikomatsakisbors-16/+11
Update syntax for `pub(restricted)` Update the syntax before stabilization. cc https://github.com/rust-lang/rust/issues/32409 r? @nikomatsakis
2017-03-11Add compile-fail tests for catch expr in match or conditionTaylor Cramer-0/+30
2017-03-11Temporarily prefix catch block with do keywordTaylor Cramer-63/+1
2017-03-11Add catch expr to AST and disallow catch as a struct nameTaylor Cramer-0/+79
2017-03-11Rollup merge of #40319 - eddyb:it's-"unsize"-not-"unsound", r=nikomatsakisAriel Ben-Yehuda-13/+84
Disallow subtyping between T and U in T: Unsize<U>. Because `&mut T` can be coerced to `&mut U`, `T` and `U` must be unified invariantly. Fixes #40288. E.g. coercing `&mut [&'a X; N]` to `&mut [&'b X]` must require `'a` be equal to `'b`, otherwise you can convert between `&'a X` and `&'b X` (in either direction), potentially unsoundly lengthening lifetimes. Subtyping here was introduced with `Unsize` in #24619 (landed in 1.1, original PR is #23785).
2017-03-10Update syntax for `pub(restricted)`Vadim Petrochenkov-16/+11
2017-03-10Point to enclosing block/fn on nested unsafeEsteban Küber-66/+0
When declaring nested unsafe blocks (`unsafe {unsafe {}}`) that trigger the "unnecessary `unsafe` block" error, point out the enclosing `unsafe block` or `unsafe fn` that makes it unnecessary.
2017-03-09Use subtyping on the target of unsizing coercions.Eduard-Mihai Burtescu-13/+13
2017-03-08Rollup merge of #40296 - topecongiro:add-missing-tests, r=alexcrichtonAriel Ben-Yehuda-0/+49
Add tests for issues with the 'E-needtest' label. This PR adds tests for the following issues:
2017-03-08Rollup merge of #40279 - gibfahn:test-unwind, r=est31Ariel Ben-Yehuda-0/+72
Add compile-fail tests for remaining items in whitelist and remove it Add compile-fail tests for `cfg_target_thread_local` and `unwind_attributes`, and remove the whitelist. Let me know if I should clean up the tests (or if I've done anything else wrong, this is my first contribution to rust). cc/ @est31
2017-03-08Disallow subtyping between T and U in T: Unsize<U>.Eduard-Mihai Burtescu-0/+71
2017-03-08Auto merge of #39713 - estebank:issue-39698, r=jonathandturnerbors-8/+12
Clean up "pattern doesn't bind x" messages Group "missing variable bind" spans in `or` matches and clarify wording for the two possible cases: when a variable from the first pattern is not in any of the subsequent patterns, and when a variable in any of the other patterns is not in the first one. Before: ```rust error[E0408]: variable `a` from pattern #1 is not bound in pattern #2 --> file.rs:10:23 | 10 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } | ^^^^^^^^^^^ pattern doesn't bind `a` error[E0408]: variable `b` from pattern #2 is not bound in pattern #1 --> file.rs:10:32 | 10 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } | ^ pattern doesn't bind `b` error[E0408]: variable `a` from pattern #1 is not bound in pattern #3 --> file.rs:10:37 | 10 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } | ^^^^^^^^ pattern doesn't bind `a` error[E0408]: variable `d` from pattern #1 is not bound in pattern #3 --> file.rs:10:37 | 10 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } | ^^^^^^^^ pattern doesn't bind `d` error[E0408]: variable `c` from pattern #3 is not bound in pattern #1 --> file.rs:10:43 | 10 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } | ^ pattern doesn't bind `c` error[E0408]: variable `d` from pattern #1 is not bound in pattern #4 --> file.rs:10:48 | 10 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } | ^^^^^^^^ pattern doesn't bind `d` error: aborting due to 6 previous errors ``` After: ```rust error[E0408]: variable `d` is not bound in all patterns --> $DIR/issue-39698.rs:20:37 | 20 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } | - - ^^^^^^^^ ^^^^^^^^ pattern doesn't bind `d` | | | | | | | pattern doesn't bind `d` | | variable not in all patterns | variable not in all patterns error[E0408]: variable `c` is not bound in all patterns --> $DIR/issue-39698.rs:20:48 | 20 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } | ^^^^^^^^^^^ ^^^^^^^^^^^ - ^^^^^^^^ pattern doesn't bind `c` | | | | | | | variable not in all patterns | | pattern doesn't bind `c` | pattern doesn't bind `c` error[E0408]: variable `a` is not bound in all patterns --> $DIR/issue-39698.rs:20:37 | 20 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } | - ^^^^^^^^^^^ ^^^^^^^^ - variable not in all patterns | | | | | | | pattern doesn't bind `a` | | pattern doesn't bind `a` | variable not in all patterns error[E0408]: variable `b` is not bound in all patterns --> $DIR/issue-39698.rs:20:37 | 20 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } | ^^^^^^^^^^^ - ^^^^^^^^ ^^^^^^^^ pattern doesn't bind `b` | | | | | | | pattern doesn't bind `b` | | variable not in all patterns | pattern doesn't bind `b` error: aborting due to 4 previous errors ``` Fixes #39698.
2017-03-07Add tests for issues with the 'E-needtest' label.topecongiro-0/+49