about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2018-01-25Rollup merge of #47726 - pietroalbini:fix-nested-empty-groups-span, ↵Guillaume Gomez-17/+42
r=petrochenkov Fix spans in unused import lint for nested groups This fixes an inconsistency for empty nested groups, and adds a test for all the possible cases of the lint. ``` warning: unused imports: `*`, `Foo`, `baz::{}`, `foobar::*` --> test.rs:16:11 | 16 | use foo::{Foo, bar::{baz::{}, foobar::*}, *}; | ^^^ ^^^^^^^ ^^^^^^^^^ ^ | = note: #[warn(unused_imports)] on by default warning: unused import: `*` --> test.rs:17:24 | 17 | use foo::bar::baz::{*, *}; | ^ warning: unused import: `use foo::{};` --> test.rs:18:1 | 18 | use foo::{}; | ^^^^^^^^^^^^ ``` cc #44494
2018-01-25Rollup merge of #47702 - etaoins:fix-into-cast-paren-precedence, r=petrochenkovGuillaume Gomez-1/+26
Fix into() cast paren check precedence As discussed in #47699 the logic for determining if an expression needs parenthesis when suggesting an `.into()` cast is incorrect. Two broken examples from nightly are: ``` error[E0308]: mismatched types --> main.rs:4:10 | 4 | test(foo as i8); | ^^^^^^^^^ expected i32, found i8 help: you can cast an `i8` to `i32`, which will sign-extend the source value | 4 | test(foo as i8.into()); | ``` ``` error[E0308]: mismatched types --> main.rs:4:10 | 4 | test(*foo); | ^^^^ expected i32, found i8 help: you can cast an `i8` to `i32`, which will sign-extend the source value | 4 | test(*foo.into()); | ``` As suggested by @petrochenkov switch the precedence check to `PREC_POSTFIX`. This catches both `as` and unary operators. Fixes #47699. r? @petrochenkov
2018-01-25Rollup merge of #47691 - estebank:unknown-lang-item-sp, r=rkruppeGuillaume Gomez-1/+30
Point at unknown lang item attribute
2018-01-25Rollup merge of #47609 - ritiek:test-mutating-references, r=nikomatsakisGuillaume Gomez-6/+6
NLL test for mutating &mut references As mentioned in #46361. cc @nikomatsakis?
2018-01-25Rollup merge of #47534 - estebank:suggest-public-traits, r=petrochenkovGuillaume Gomez-12/+33
On missing method do not suggest private traits When encountering a method call for an ADT that doesn't have any implementation of it, we search for traits that could be implemented that do have that method. Filter out private non-local traits that would not be able to be implemented. This doesn't account for public traits that are in a private scope, but works as a first approximation and is a more correct behavior than the current one. Fix #45781.
2018-01-25Auto merge of #47374 - topecongiro:issue-47096, r=nikomatsakisbors-0/+24
Simplify irrefutable slice patterns Closes #47096.
2018-01-25Auto merge of #47006 - bitshifter:stabilize-repr-align, r=eddybbors-50/+2
Stabilized `#[repr(align(x))]` attribute (RFC 1358) Stabilzed `#[repr(align(x))]` with attr_literal syntax as proposed by @eddyb https://github.com/rust-lang/rust/issues/33626#issuecomment-348467804
2018-01-24Fix wrong span for nested empty groupsPietro Albini-17/+42
2018-01-24Fix into() cast paren check precedenceRyan Cumming-1/+26
As discussed in #47699 the logic for determining if an expression needs parenthesis when suggesting an `.into()` cast is incorrect. Two broken examples from nightly are: ``` error[E0308]: mismatched types --> main.rs:4:10 | 4 | test(foo as i8); | ^^^^^^^^^ expected i32, found i8 help: you can cast an `i8` to `i32`, which will sign-extend the source value | 4 | test(foo as i8.into()); | ``` ``` error[E0308]: mismatched types --> main.rs:4:10 | 4 | test(*foo); | ^^^^ expected i32, found i8 help: you can cast an `i8` to `i32`, which will sign-extend the source value | 4 | test(*foo.into()); | ``` As suggested by @petrochenkov switch the precedence check to PREC_POSTFIX. This catches both `as` and unary operators. Fixes #47699.
2018-01-23Point at unknown lang item attributeEsteban Küber-1/+30
2018-01-23Auto merge of #45337 - Zoxc:gen-static, r=nikomatsakisbors-13/+424
Immovable generators This adds support for immovable generators which allow you to borrow local values inside generator across suspension points. These are declared using a `static` keyword: ```rust let mut generator = static || { let local = &Vec::new(); yield; local.push(0i8); }; generator.resume(); // ERROR moving the generator after it has resumed would invalidate the interior reference // drop(generator); ``` Region inference is no longer affected by the types stored in generators so the regions inside should be similar to other code (and unaffected by the presence of `yield` expressions). The borrow checker is extended to pick up the slack so interior references still result in errors for movable generators. This fixes #44197, #45259 and #45093. This PR depends on [PR #44917 (immovable types)](https://github.com/rust-lang/rust/pull/44917), I suggest potential reviewers ignore the first commit as it adds immovable types.
2018-01-23Remove similar test that does not run the resultritiek-35/+1
2018-01-23Auto merge of #47678 - kennytm:rollup, r=kennytmbors-7/+159
Rollup of 14 pull requests - Successful merges: #47423, #47425, #47440, #47541, #47549, #47554, #47558, #47610, #47635, #47655, #47661, #47662, #47667, #47672 - Failed merges:
2018-01-23Rollup merge of #47672 - ollie27:rustdoc_auto_traits, r=GuillaumeGomezkennytm-0/+36
rustdoc: Show when traits are auto traits
2018-01-23Rollup merge of #47667 - GuillaumeGomez:fix-quoted-search, r=QuietMisdreavuskennytm-0/+23
Fix quoted search r? @QuietMisdreavus
2018-01-23Rollup merge of #47662 - spastorino:add_test_to_nll, r=nikomatsakiskennytm-0/+3
Add dynamic-drop test to nll tests also r? @nikomatsakis Fixes #47585
2018-01-23Rollup merge of #47655 - ↵kennytm-0/+31
etaoins:fix-spurious-warning-on-empty-proc-macro-crate, r=alexcrichton Fix spurious warning on empty proc macro crates While attempting to reproduce rust-lang/rust#47086 I noticed the following warning: ```shell > rustc /dev/null --crate-type proc-macro warning: unused variable: `registrar` --> /dev/null:0:1 ``` As there are no macros to register the automatically generated registrar function for the crate has no body. As a result its `registrar` argument is unused triggering the above warning. The warning is confusing and not easily actionable by the developer. It could also be triggered legitimately by e.g. having all of the macros in a crate #[cfg]'ed out. Fix by naming the generated argument `_registrar` inside `mk_registrar()`. This suppresses the unused variable warning.
2018-01-23Rollup merge of #47549 - Manishearth:29723-regression, r=nikomatsakiskennytm-0/+39
Add regression test for #29723 cc #29723 r? @nikomatsakis
2018-01-23Rollup merge of #47440 - mark-i-m:zunpretty, r=nikomatsakiskennytm-7/+6
Change the --unpretty flag to -Z unpretty First PR :smile: ! -Z unpretty no longer requires -Z unstable-options. Also, I mildly changed the syntax of the flag to match the other -Z flags. All uses of the flag take the form `unpretty=something` where something can either `string` or `string=string` (see the help messages of the CLI). Fix #47395 r? @nikomatsakis EDIT: apparently rust-highfive doesn't see edits...
2018-01-23Rollup merge of #47425 - EdSchouten:immutable-tls, r=nikomatsakiskennytm-0/+21
Properly pass down immutability info for thread-locals. For thread-locals we call into cat_rvalue_node() to create a CMT (Category, Mutability, Type) that always has McDeclared. This is incorrect for thread-locals that don't have the 'mut' keyword; we should use McImmutable there. Extend cat_rvalue_node() to have an additional mutability parameter. Fix up all the callers to make use of that function. Also extend one of the existing unit tests to cover this. Fixes: #47053
2018-01-23Auto merge of #47046 - Manishearth:intra-doc-links, ↵bors-0/+60
r=eddyb,GuillaumeGomez,QuietMisdreavus,Manishearth Implement RFC 1946 - intra-rustdoc links https://github.com/rust-lang/rfcs/pull/1946 https://github.com/rust-lang/rust/issues/43466 Note for reviewers: The plain line counts are a little inflated because of how the markdown link parsing was done. [Read the file diff with "whitespace only" changes removed](https://github.com/rust-lang/rust/pull/47046/files?w=1) to get a better view of what actually changed there. This pulls the name/path resolution mechanisms out of the compiler and runs it on the markdown in a crate's docs, so that links can be made to `SomeStruct` directly rather than finding the folder path to `struct.SomeStruct.html`. Check the `src/test/rustdoc/intra-paths.rs` test in this PR for a demo. The change was... a little invasive, but unlocks a really powerful mechanism for writing documentation that doesn't care about where an item was written to on the hard disk. Items included: - [x] Make work with the hoedown renderer - [x] Handle relative paths - [x] Parse out the "path ambiguities" qualifiers (`[crate foo]`, `[struct Foo]`, `[foo()]`, `[static FOO]`, `[foo!]`, etc) - [x] Resolve foreign macros - [x] Resolve local macros - [x] Handle the use of inner/outer attributes giving different resolution scopes (handling for non-modules pushed to different PR) Items not included: - [ ] Make sure cross-crate inlining works (blocked on refactor described in https://github.com/rust-lang/rust/pull/47046#issuecomment-354824520) - [ ] Implied Shortcut Reference Links (where just doing `[::std::iter::Iterator][]` without a reference anchor will resolve using the reference name rather than the link target) (requires modifying the markdown parser - blocked on Hoedown/Pulldown switch and https://github.com/google/pulldown-cmark/issues/121) - [ ] Handle enum variants and UFCS methods (Enum variants link to the enum page, associated methods don't link at all) - [ ] Emit more warnings/errors when things fail to resolve (linking to a value-namespaced item without a qualifier will emit an error, otherwise the link is just treated as a url, not a rust path) - [ ] Give better spans for resolution errors (currently the span for the first doc comment is used) - [ ] Check for inner doc comments on things that aren't modules I'm making the PR, but it should be noted that most of the work was done by Misdreavus :smile: (Editor's note: This has become a lie, check that commit log, Manish did a ton of work after this PR was opened `>_>`)
2018-01-23Port borrows across yield check to MIR borrowckJohn Kåre Alsaker-0/+54
2018-01-23Add dropck testJohn Kåre Alsaker-0/+44
2018-01-23Fix yield-while-local-borrowed.rs testJohn Kåre Alsaker-8/+42
2018-01-23Make immovable generators unsafeJohn Kåre Alsaker-6/+35
2018-01-23Adds support for immovable generators. Move checking of invalid borrows ↵John Kåre Alsaker-5/+255
across suspension points to borrowck. Fixes #44197, #45259 and #45093.
2018-01-23rustdoc: Show when traits are auto traitsOliver Middleton-0/+36
2018-01-22Fix quoted searchGuillaume Gomez-0/+23
2018-01-23Stabilized `#[repr(align(x))]` attribute (RFC 1358)Cameron Hart-50/+2
2018-01-22Auto merge of #47507 - alexcrichton:rerun-bat-scripts, r=michaelwoeristerbors-0/+103
rustc: Lower link args to `@`-files on Windows more When spawning a linker rustc has historically been known to blow OS limits for the command line being too large, notably on Windows. This is especially true of incremental compilation where there can be dozens of object files per compilation. The compiler currently has logic for detecting a failure to spawn and instead passing arguments via a file instead, but this failure detection only triggers if a process actually fails to spawn. Unfortunately on Windows we've got something else to worry about which is `cmd.exe`. The compiler may be running a linker through `cmd.exe` where `cmd.exe` has a limit of 8192 on the command line vs 32k on `CreateProcess`. Moreso rustc actually succeeds in spawning `cmd.exe` today, it's just that after it's running `cmd.exe` fails to spawn its child, which rustc doesn't currently detect. Consequently this commit updates the logic for the spawning the linker on Windows to instead have a heuristic to see if we need to pass arguments via a file. This heuristic is an overly pessimistic and "inaccurate" calculation which just calls `len` on a bunch of `OsString` instances (where `len` is not precisely the length in u16 elements). This number, when exceeding the 6k threshold, will force rustc to always pass arguments through a file. This strategy should avoid us trying to parse the output on Windows of the linker to see if it successfully spawned yet failed to actually sub-spawn the linker. We may just be passing arguments through files a little more commonly now... The motivation for this commit was a recent bug in Gecko [1] when beta testing, notably when incremental compilation was enabled it blew out the limit on `cmd.exe`. This commit will also fix #46999 as well though as emscripten uses a bat script as well (and we're blowing the limit there). [1]: https://bugzilla.mozilla.org/show_bug.cgi?id=1430886 Closes #46999
2018-01-22Add dynamic-drop test to nll tests alsoSantiago Pastorino-0/+3
2018-01-22Do not suggest private traits that have missing methodEsteban Küber-12/+33
When encountering a method call for an ADT that doesn't have any implementation of it, we search for traits that could be implemented that do have that method. Filter out private non-local traits that would not be able to be implemented. This doesn't account for public traits that are in a private scope, but works as a first approximation and is a more correct behavior than the current one.
2018-01-22Auto merge of #47353 - nikomatsakis:nll-issue-47189, r=pnkfelix+nmatsakisbors-0/+38
renumber regions in generators This fixes #47189, but I think we still have to double check various things around how to treat generators in MIR type check + borrow check (e.g., what borrows should be invalidated by a `Suspend`? What consistency properties should type check be enforcing anyway around the "interior" type?) Also fixes #47587 thanks to @spastorino's commit. r? @pnkfelix
2018-01-22Fix spurious warning on empty proc macro cratesRyan Cumming-0/+31
While attempting to reproduce rust-lang/rust#47086 I noticed the following warning: ```shell > rustc /dev/null --crate-type proc-macro warning: unused variable: `registrar` --> /dev/null:0:1 ``` As there are no macros to register the automatically generated registrar function for the crate has no body. As a result its `registrar` argument is unused triggering the above warning. The warning is confusing and not easily actionable by the developer. It could also be triggered legitimately by e.g. having all of the macros in a crate #[cfg]'ed out. Fix by naming the generated argument `_registrar` inside `mk_registrar()`. This suppresses the unused variable warning.
2018-01-22value-namespace items require a marker, so emit an errorQuietMisdreavus-3/+3
2018-01-22add ambiguity markers to the intra-links testQuietMisdreavus-0/+14
2018-01-22add a macro to the intra-links testQuietMisdreavus-8/+15
2018-01-22add basic test for rustdoc intra linksQuietMisdreavus-0/+39
2018-01-22Auto merge of #47158 - rkruppe:repr-transparent, r=eddybbors-1/+454
Implement repr(transparent) r? @eddyb for the functional changes. The bulk of the PR is error messages and docs, might be good to have a doc person look over those. cc #43036 cc @nox
2018-01-22Auto merge of #47144 - estebank:moved-closure-arg, r=nikomatsakisbors-7/+195
Custom error when moving arg outside of its closure When given the following code: ```rust fn give_any<F: for<'r> FnOnce(&'r ())>(f: F) { f(&()); } fn main() { let mut x = None; give_any(|y| x = Some(y)); } ``` provide a custom error: ``` error: borrowed data cannot be moved outside of its closure --> file.rs:7:27 | 6 | let mut x = None; | ----- borrowed data cannot be moved into here... 7 | give_any(|y| x = Some(y)); | --- ^ cannot be moved outside of its closure | | | ...because it cannot outlive this closure ``` instead of the generic lifetime error: ``` error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements --> file.rs:7:27 | 7 | give_any(|y| x = Some(y)); | ^ | note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 7:14... --> file.rs:7:14 | 7 | give_any(|y| x = Some(y)); | ^^^^^^^^^^^^^^^ note: ...so that expression is assignable (expected &(), found &()) --> file.rs:7:27 | 7 | give_any(|y| x = Some(y)); | ^ note: but, the lifetime must be valid for the block suffix following statement 0 at 6:5... --> file.rs:6:5 | 6 | / let mut x = None; 7 | | give_any(|y| x = Some(y)); 8 | | } | |_^ note: ...so that variable is valid at time of its declaration --> file.rs:6:9 | 6 | let mut x = None; | ^^^^^ ``` Fix #45983.
2018-01-21rustc: Lower link args to `@`-files on Windows moreAlex Crichton-0/+103
When spawning a linker rustc has historically been known to blow OS limits for the command line being too large, notably on Windows. This is especially true of incremental compilation where there can be dozens of object files per compilation. The compiler currently has logic for detecting a failure to spawn and instead passing arguments via a file instead, but this failure detection only triggers if a process actually fails to spawn. Unfortunately on Windows we've got something else to worry about which is `cmd.exe`. The compiler may be running a linker through `cmd.exe` where `cmd.exe` has a limit of 8192 on the command line vs 32k on `CreateProcess`. Moreso rustc actually succeeds in spawning `cmd.exe` today, it's just that after it's running `cmd.exe` fails to spawn its child, which rustc doesn't currently detect. Consequently this commit updates the logic for the spawning the linker on Windows to instead have a heuristic to see if we need to pass arguments via a file. This heuristic is an overly pessimistic and "inaccurate" calculation which just calls `len` on a bunch of `OsString` instances (where `len` is not precisely the length in u16 elements). This number, when exceeding the 6k threshold, will force rustc to always pass arguments through a file. This strategy should avoid us trying to parse the output on Windows of the linker to see if it successfully spawned yet failed to actually sub-spawn the linker. We may just be passing arguments through files a little more commonly now... The motivation for this commit was a recent bug in Gecko [1] when beta testing, notably when incremental compilation was enabled it blew out the limit on `cmd.exe`. This commit will also fix #46999 as well though as emscripten uses a bat script as well (and we're blowing the limit there). [1]: https://bugzilla.mozilla.org/show_bug.cgi?id=1430886 Closes #46999
2018-01-21Rollup merge of #47633 - pietroalbini:fix-ice-use-self, r=nagisaGuillaume Gomez-0/+21
Fix ICE with `use self;` Closes #47623
2018-01-21Rollup merge of #47512 - GuillaumeGomez:e0659, r=petrochenkovGuillaume Gomez-11/+37
Add E0659 for ambiguous names Still on the tracks of the "no error without error code" road.
2018-01-21Rollup merge of #47247 - estebank:suggest-cast, r=petrochenkovGuillaume Gomez-0/+1242
Suggest casting on numeric type error Re #47168.
2018-01-21Auto merge of #47116 - estebank:non-accessible-ctor, r=petrochenkovbors-85/+407
Tweaks to invalid ctor messages - Do not suggest using a constructor that isn't accessible - Suggest the appropriate syntax (`()`/`{}` as appropriate) - Add note when trying to use `Self` as a ctor CC #22488, fix #47085.
2018-01-21Auto merge of #47001 - arielb1:private-match, r=nikomatsakisbors-0/+28
check_match: fix handling of privately uninhabited types the match-checking code used to use TyErr for signaling "unknown, inhabited" types for a long time. It had been switched to using the exact type in #38069, to handle uninhabited types. However, in #39980, we discovered that we still needed the "unknown inhabited" logic, but I used `()` instead of `TyErr` to handle that. Revert to using `TyErr` to fix that problem. Fixes #46964. r? @nikomatsakis
2018-01-21Fix ICE with `use self;`Pietro Albini-0/+21
2018-01-21Auto merge of #45684 - bjorn3:runtime_choose_trans2, r=eddybbors-98/+125
Allow runtime switching between trans backends The driver callback after_llvm has been removed as it doesnt work with multiple backends. r? @eddyb
2018-01-21Auto merge of #47622 - GuillaumeGomez:rollup, r=GuillaumeGomezbors-24/+119
Rollup of 10 pull requests - Successful merges: #46938, #47193, #47508, #47510, #47532, #47535, #47559, #47568, #47573, #47578 - Failed merges:
2018-01-21Auto merge of #47495 - nikomatsakis:nll-issue-47153, r=pnkfelixbors-0/+27
remove bogus assertion and comments The code (incorrectly) assumed that constants could not have generics in scope, but it's not really a problem if they do. Fixes #47153 r? @pnkfelix