about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2020-05-26Auto merge of #72093 - jonas-schievink:unmut, r=oli-obkbors-2/+2
Avoid `Operand::Copy` with `&mut T` This is generally unsound to do, as the copied type is assumed to implement `Copy`. Closes https://github.com/rust-lang/rust/issues/46420
2020-05-26Auto merge of #71487 - rcoh:71471-shebang, r=petrochenkovbors-0/+73
Fix bug in shebang handling Shebang handling was too agressive in stripping out the first line in cases where it is actually _not_ a shebang, but instead, valid rust (#70528). This is a second attempt at resolving this issue (the first attempt was reverted, for, among other reasons, causing an ICE in certain cases (#71372, #71471). The behavior is now codified by a number of UI tests, but simply: For the first line to be a shebang, the following must all be true: 1. The line must start with `#!` 2. The line must contain a non-whitespace character after `#!` 3. The next character in the file, ignoring comments & whitespace must not be `[` I believe this is a strict superset of what we used to allow, so perhaps a crater run is unnecessary, but probably not a terrible idea. Fixes #70528
2020-05-25Rollup merge of #72450 - csmoe:issue-72442, r=oli-obkDylan DPC-0/+40
Fix ice-#72442 Closes #72442 Closes #72426 r? @oli-obk
2020-05-25Rollup merge of #72061 - lcnr:const-inference-test, r=eddybDylan DPC-0/+70
add regression tests for stalled_on const vars closes #70180 Afaict this has been fixed sometime after #70213 `trait_ref_type_vars` correctly adds const infers and I did not find any remaining `FIXME`s which correspond to this issue. https://github.com/rust-lang/rust/blob/7c59a81a5fcbaaca311f744cd7c68d99bfbb05d3/src/librustc_trait_selection/traits/fulfill.rs#L555-L557 Added both examples from the issue as regression tests and renamed `trait_ref_type_vars` -> `trait_ref_infer_vars`. r? @eddyb
2020-05-25Avoid `Operand::Copy` with `&mut T`Jonas Schievink-2/+2
2020-05-25Auto merge of #72575 - Dylan-DPC:rollup-zo679hv, r=Dylan-DPCbors-0/+97
Rollup of 4 pull requests Successful merges: - #72153 (exhaustively check `ty::Kind` during structural match checking) - #72308 (Emit a better diagnostic when function actually has a 'self' parameter) - #72560 (Enable `glacier` command via triagebot) - #72567 (Clean up E0608 explanation) Failed merges: r? @ghost
2020-05-25Rollup merge of #72308 - Aaron1011:fix/hygiene-error-message, r=matthewjasperDylan DPC-0/+40
Emit a better diagnostic when function actually has a 'self' parameter Fixes #66898 When we are unable to resolve a reference to `self`, we current assume that the containing function doesn't have a `self` parameter, and emit an error message accordingly. However, if the reference to `self` was created by a macro invocation, then resolution will correctly fail, due to hygiene. In this case, we don't want to tell the user that the containing fuction doesn't have a 'self' paramter if it actually has one. This PR checks for the precense of a 'self' parameter, and adjusts the error message we emit accordingly. TODO: The exact error message we emit could probably be improved. Should we explicitly mention hygiene?
2020-05-25Rollup merge of #72153 - lcnr:exhaustively-match, r=pnkfelixDylan DPC-0/+57
exhaustively check `ty::Kind` during structural match checking This was prone to errors as we may forget new kinds in the future. I am also not yet sure about some kinds. `ty::GeneratorWitness(..) | ty::Infer(_) | ty::Placeholder(_) | ty::UnnormalizedProjection(..) | ty::Bound(..)` might be unreachable here. We may want to forbid `ty::Projection`, similar to `ty::Param`. `ty::Opaque` seems fine afaict, should not be possible in a match atm. I believe `ty::Foreign` should not be structurally match, as I don't even know what that would actually mean. r? @pnkfelix cc @eddyb
2020-05-25Fix bug in shebang handlingRussell Cohen-0/+73
Shebang handling was too agressive in stripping out the first line in cases where it is actually _not_ a shebang, but instead, valid rust (#70528). This is a second attempt at resolving this issue (the first attempt was flawed, for, among other reasons, causing an ICE in certain cases (#71372, #71471). The behavior is now codified by a number of UI tests, but simply: For the first line to be a shebang, the following must all be true: 1. The line must start with `#!` 2. The line must contain a non whitespace character after `#!` 3. The next character in the file, ignoring comments & whitespace must not be `[` I believe this is a strict superset of what we used to allow, so perhaps a crater run is unnecessary, but probably not a terrible idea.
2020-05-25Auto merge of #72354 - tamird:remove-copyright, r=Mark-Simulacrumbors-18/+9
Remove dangling COPYRIGHT references Missed in 2a663555ddf36f6b041445894a8c175cd1bc718c. r? @Mark-Simulacrum
2020-05-25Auto merge of #72520 - jonas-schievink:cleanup-userty, r=matthewjasperbors-17/+17
Clear MIR local type annotations after borrowck
2020-05-24Collect tokens for `ast::Expr`Aaron Hill-0/+32
2020-05-24Auto merge of #72529 - RalfJung:rollup-ydthv90, r=RalfJungbors-2/+2
Rollup of 3 pull requests Successful merges: - #72284 (Remove `macro_defs` map) - #72393 (Rewrite `Parser::collect_tokens`) - #72528 (Fix typo in doc comment.) Failed merges: r? @ghost
2020-05-24Rollup merge of #72393 - Aaron1011:feature/rewrite-collect-tokens, ↵Ralf Jung-2/+2
r=petrochenkov Rewrite `Parser::collect_tokens` The previous implementation did not work when called on an opening delimiter, or when called re-entrantly from the same `TokenCursor` stack depth. I'm not sure how to test this apart from https://github.com/rust-lang/rust/pull/72287
2020-05-24Auto merge of #72524 - RalfJung:rollup-s9f1pcc, r=RalfJungbors-0/+30
Rollup of 2 pull requests Successful merges: - #72388 (Recursively expand `TokenKind::Interpolated` in `probably_equal_for_proc_macro`) - #72517 (small select cleanup) Failed merges: r? @ghost
2020-05-24Rollup merge of #72388 - Aaron1011:fix/deep-tokenstream-equality, r=petrochenkovRalf Jung-0/+30
Recursively expand `TokenKind::Interpolated` in `probably_equal_for_proc_macro` Fixes #68430 When comparing the captured and re-parsed `TokenStream` for a `TokenKind::Interpolated`, we currently treat any nested `TokenKind::Interpolated` tokens as unequal. If a `TokenKind::Interpolated` token shows up in the captured `TokenStream` due to a `macro_rules!` expansion, we will throw away the captured `TokenStream`, losing span information. This PR recursively invokes `nt_to_tokenstream` on nested `TokenKind::Interpolated` tokens, effectively flattening the stream into a sequence of non-interpolated tokens. This allows it to compare equal with the re-parsed stream, allowing us to keep the original captured `TokenStream` (with span information). This requires all of the `probably_equal_for_proc_macro` methods to be moved from `librustc_ast` to `librustc_parse` so that they can call `nt_to_tokenstream`.
2020-05-24Auto merge of #72362 - matthewjasper:remove-rescope, r=nikomatsakisbors-883/+462
Remove ReScope `ReScope` is unnecessary now that AST borrowck is gone and we're erasing the results of region inference in function bodies. This removes about as much of the old regionck code as possible without having to enable NLL fully. cc #68261 r? @nikomatsakis
2020-05-24Clear MIR local type annotations after borrowckJonas Schievink-17/+17
2020-05-24Rollup merge of #72502 - RalfJung:generator-discr-ty, r=jonas-schievinkDylan DPC-2/+2
fix discriminant type in generator transform The generator transform assumed that the discriminant type is always `isize`, which is not correct, leading to [ICEs in Miri](https://github.com/rust-lang/rust/pull/72419/files#r429543536) when some extra sanity checking got enabled. r? @jonas-schievink @eddyb
2020-05-24Rollup merge of #72400 - Aaron1011:fix/asm-incr-ice, r=AmanieuDylan DPC-0/+22
Add missing ASM arena declarations to librustc_middle Fixes #72386 These types also need to get allocated on the `librustc_middle` arena when we deserialize MIR. @Amanieu: If we end up using your approach in https://github.com/rust-lang/rust/pull/72392 instead, feel free to copy the test I added over to your PR.
2020-05-24Rollup merge of #71618 - ecstatic-morse:issue-71394, r=nikomatsakisDylan DPC-1/+16
Preserve substitutions when making trait obligations for suggestions Resolves #71394. I *think* `map_bound_ref` is correct here. In any case, I think a lot of the diagnostic code is using `skip_binder` more aggressively than it should be, so I doubt that this is worse than the status quo. The assertion that `new_self_ty` has no escaping bound vars should be enough. r? @estebank cc @nikomatsakis Is the call to `skip_binder` on line 551 (and elsewhere in this file) appropriate? https://github.com/rust-lang/rust/blob/46ec74e60f238f694b46c976d6217e7cf8d4cf1a/src/librustc_trait_selection/traits/error_reporting/suggestions.rs#L537-L565
2020-05-23Add missing ASM arena declaration to librustc_middleAaron Hill-0/+22
Fixes #72386 This type also needs to get allocated on the `librustc_middle` arena when we deserialize MIR.
2020-05-23Rollup merge of #72492 - JohnTitor:add-tests, r=matthewjasperDylan DPC-16/+46
Add some regression tests Closes #69415 Closes #72455 r? @matthewjasper
2020-05-23bless mir-opt testsRalf Jung-2/+2
2020-05-23Add test for #72455Yuki Okushi-0/+27
2020-05-23Add test for #69415Yuki Okushi-16/+19
2020-05-22Bless other example of #71394Dylan MacKenzie-1/+0
2020-05-22Add regression test for #71394Dylan MacKenzie-0/+16
2020-05-22Rollup merge of #71289 - xliiv:70802-intra-self, r=GuillaumeGomezDylan DPC-0/+88
Allow using `Self::` in doc Closes #70802
2020-05-22Add test for macro_rules! invoking a proc-macro with capture groupsAaron Hill-0/+30
2020-05-22Update testsMatthew Jasper-883/+462
2020-05-22Rollup merge of #72123 - jsgf:stabilize-arg0, r=sfacklerRalf Jung-4/+0
Stabilize process_set_argv0 feature for Unix This stabilizes process_set_argv0 targeting 1.45.0. It has been useful in practice and seems useful as-is. The equivalent feature could be implemented for Windows, but as far as I know nobody has. That can be done separately. Tracking issue: #66510
2020-05-22Rollup merge of #71829 - kper:issue71136, r=matthewjasperRalf Jung-0/+21
Fix suggestion to borrow in struct The corresponding issue is #71136. The compiler suggests that borrowing `the_foos` might solve the problem. This is obviously incorrect. ``` struct Foo(u8); #[derive(Clone)] struct FooHolster { the_foos: Vec<Foo>, } ``` I propose as fix to check if there is any colon in the span. However, there might a case where `my_method(B { a: 1, b : foo })` would be appropriate to show a suggestion for `&B ...`. To fix that too, we can simply check if there is a bracket in the span. This is only possible because both spans are different. Issue's span: `the_foos: Vec<Foo>` other's span: `B { a : 1, b : foo }`
2020-05-22Allow using `Self::` in docTymoteusz Jankowski-0/+88
2020-05-22Rollup merge of #72306 - Aaron1011:feature/turbo-spacing, r=petrochenkovRalf Jung-2/+46
Break tokens before checking if they are 'probably equal' Fixes #68489 Fixes #70987 When checking two `TokenStreams` to see if they are 'probably equal', we ignore the `IsJoint` information associated with each `TokenTree`. However, the `IsJoint` information determines whether adjacent tokens will be 'glued' (if possible) when construction the `TokenStream` - e.g. `[Gt Gt]` can be 'glued' to `BinOp(Shr)`. Since we are ignoring the `IsJoint` information, 'glued' and 'unglued' tokens are equivalent for determining if two `TokenStreams` are 'probably equal'. Therefore, we need to 'unglue' all tokens in the stream to avoid false negatives (which cause us to throw out the cached tokens, losing span information).
2020-05-22bless issue-72442csmoe-1/+16
2020-05-22Rewrite `Parser::collect_tokens`Aaron Hill-2/+2
The previous implementation did not work when called on an opening delimiter, or when called re-entrantly from the same `TokenCursor` stack depth.
2020-05-22add mcve for issue 72442csmoe-0/+25
2020-05-22Auto merge of #71956 - ecstatic-morse:remove-requires-storage-analysis, ↵bors-2/+2
r=tmandry Clean up logic around live locals in generator analysis Resolves #69902. Requires #71893. I've found it difficult to make changes in the logic around live locals in `generator/transform.rs`. It uses a custom dataflow analysis, `MaybeRequiresStorage`, that AFAICT computes whether a local is either initialized or borrowed. That analysis is using `before` effects, which we should try to avoid if possible because they are harder to reason about than ones only using the unprefixed effects. @pnkfelix has suggested removing "before" effects entirely to simplify the dataflow framework, which I might pursue someday. This PR replaces `MaybeRequiresStorage` with a combination of the existing `MaybeBorrowedLocals` and a new `MaybeInitializedLocals`. `MaybeInitializedLocals` is just `MaybeInitializedPlaces` with a coarser resolution: it works on whole locals instead of move paths. As a result, I was able to simplify the logic in `compute_storage_conflicts` and `locals_live_across_suspend_points`. This is not exactly equivalent to the old logic; some generators are now smaller than before. I believe this was because the old logic was too conservative, but I'm not as familiar with the constraints as the original implementers were, so I could be wrong. For example, I don't see a reason the size of the `mixed_sizes` future couldn't be 5K. It went from 7K to 6K in this PR. r? @jonas-schievink @tmandry
2020-05-21Auto merge of #72433 - RalfJung:rollup-srft8nx, r=RalfJungbors-10/+67
Rollup of 7 pull requests Successful merges: - #72055 (Intern predicates) - #72149 (Don't `type_of` on trait assoc ty without default) - #72347 (Make intra-link resolve links for both trait and impl items) - #72350 (Improve documentation of `slice::from_raw_parts`) - #72382 (Show default values for debug-assertions & debug-assertions-std) - #72421 (Fix anchor display when hovering impl) - #72425 (fix discriminant_value sign extension) Failed merges: r? @ghost
2020-05-21Rollup merge of #72347 - xliiv:72340-impl-for-default, r=GuillaumeGomezRalf Jung-0/+19
Make intra-link resolve links for both trait and impl items Closes #72340
2020-05-21Rollup merge of #72149 - estebank:icemation, r=eddybRalf Jung-10/+48
Don't `type_of` on trait assoc ty without default Fix #72076.
2020-05-21Auto merge of #71930 - Nadrieril:exhaustiveness-remove-tyerr, r=varkorbors-0/+22
De-abuse TyKind::Error in exhaustiveness checking Replaces https://github.com/rust-lang/rust/pull/71074. Context: https://github.com/rust-lang/rust/issues/70866. In order to remove the use of `TyKind::Error`, I had to make sure we skip over those fields whose inhabitedness should not be observed. This is potentially error-prone however, since we must be careful not to mix filtered and unfiltered lists of patterns. I managed to hide away most of the filtering behind a new `Fields` struct, that I used everywhere relevant. I quite like the result; I think the twin concepts of `Constructor` and `Fields` make a good mental model. As usual, I tried to separate commits that shuffle code around from commits that require more thought to review. cc @varkor @Centril
2020-05-21Auto merge of #71718 - NeoRaider:ffi_const_pure, r=Amanieubors-0/+105
Experimentally add `ffi_const` and `ffi_pure` extern fn attributes Add FFI function attributes corresponding to clang/gcc/... `const` and `pure`. Rebased version of #58327 by @gnzlbg with the following changes: - Switched back from the `c_ffi_const` and `c_ffi_pure` naming to `ffi_const` and `ffi_pure`, as I agree with https://github.com/rust-lang/rust/pull/58327#issuecomment-462718772 and this nicely aligns with `ffi_returns_twice` - (Hopefully) took care of all of @hanna-kruppe's change requests in the original PR r? @hanna-kruppe
2020-05-21Auto merge of #72205 - ecstatic-morse:nrvo, r=oli-obkbors-47/+108
Dumb NRVO This is a very simple version of an NRVO pass, which scans backwards from the `return` terminator to see if there is an an assignment like `_0 = _1`. If a basic block with two or more predecessors is encountered during this scan without first seeing an assignment to the return place, we bail out. This avoids running a full "reaching definitions" dataflow analysis. I wanted to see how much `rustc` would benefit from even a very limited version of this optimization. We should be able to use this as a point of comparison for more advanced versions that are based on live ranges. r? @ghost
2020-05-21Auto merge of #70705 - lcnr:generic_discriminant, r=nikomatsakisbors-15/+204
Use `T`'s discriminant type in `mem::Discriminant<T>` instead of `u64`. fixes #70509 Adds the lang-item `discriminant_kind`. Updates the function signature of `intrinsics::discriminant_value`. Adds the *probably permanently unstable* trait `DiscriminantKind`. `mem::Discriminant` should now be smaller in some cases. r? @ghost
2020-05-20Fix testsAaron Hill-3/+10
2020-05-20Auto merge of #72378 - Dylan-DPC:rollup-m87bp2d, r=Dylan-DPCbors-36/+125
Rollup of 6 pull requests Successful merges: - #71863 (Suggest fixes and add error recovery for `use foo::self`) - #72139 (Make `fold` standalone.) - #72275 (Continue lowering for unsupported async generator instead of returning an error.) - #72361 (split_inclusive: add tracking issue number (72360)) - #72364 (Remove unused dependencies) - #72366 (Adjust the zero check in `RawVec::grow`.) Failed merges: r? @ghost
2020-05-20Rollup merge of #72139 - nnethercote:standalone-fold, r=cuviperDylan DPC-24/+0
Make `fold` standalone. `fold` is currently implemented via `try_fold`, but implementing it directly results in slightly less LLVM IR being generated, speeding up compilation of some benchmarks. r? @cuviper
2020-05-20Rollup merge of #71863 - mibac138:self-import, r=estebankDylan DPC-12/+125
Suggest fixes and add error recovery for `use foo::self` Fixes #63741. I have implemented 2 suggestions on how to fix a `use foo::self` import, however I feel like showing them both might be too verbose. Additionally, I have also implemented error recovery as [menitoned](https://github.com/rust-lang/rust/issues/63741#issuecomment-602391091) by @comex. I believe r? @estebank deals with diagnostics.