about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2020-05-27Rollup merge of #72548 - rossmacarthur:add-mcve-for-50687, r=nikomatsakisDylan DPC-0/+57
Add test for old compiler ICE when using `Borrow` The original issue was caused by implementing `Borrow` on a local type and using the tokio-reactor crate which had this impl: https://github.com/tokio-rs/tokio/blob/tokio-0.1.4/tokio-reactor/src/poll_evented.rs#L547-L577 This causes an ICE on Rust 1.27.0: ```console $ RUSTUP_TOOLCHAIN=1.27.0 rustc src/test/ui/issues/issue-50687-ice-on-borrow.rs error: internal compiler error: librustc/traits/structural_impls.rs:180: impossible case reached thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:554:9 note: Run with `RUST_BACKTRACE=1` for a backtrace. error: aborting due to previous error note: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports note: rustc 1.27.0 (3eda71b00 2018-06-19) running on x86_64-apple-darwin ``` Closes #50687
2020-05-27Rollup merge of #72348 - chrissimpkins:fix-72253, r=estebankDylan DPC-0/+16
Fix confusing error message for comma typo in multiline statement Fixes #72253. Expands on the issue with a colon typo check. r? @estebank cc @ehuss
2020-05-26Auto merge of #72627 - Dylan-DPC:rollup-bavnoq5, r=Dylan-DPCbors-18/+252
Rollup of 6 pull requests Successful merges: - #72270 (add a lint against references to packed fields) - #72294 (JS cleanup) - #72342 (Warn about unused crate deps) - #72401 (Use correct function for detecting `const fn` in unsafety checking) - #72581 (Allow unlabeled breaks from desugared `?` in labeled blocks) - #72592 (Update books) Failed merges: r? @ghost
2020-05-26improve error message for unexpected comma token in multiline blockChris Simpkins-0/+16
confusing diagnostics, issue #72253 add test for confusing error message, issue-72253 remove is_multiline check, refactor to self.expect(&token:Semi) update issue-72253 tests return Ok
2020-05-26Rollup merge of #72581 - samrat:allow-desugared-break-in-labeled-block, ↵Dylan DPC-0/+12
r=davidtwco Allow unlabeled breaks from desugared `?` in labeled blocks `?` is desugared into a `break` targeting the innermost `try` scope in which it resides. The `break` however will not have a label. https://github.com/rust-lang/rust/blob/master/src/librustc_ast_lowering/expr.rs#L1560 Since the `target` of the `break` is known, the compiler should not complain about an unlabeled jump for `break`s desugared from `?`. Closes https://github.com/rust-lang/rust/issues/72483
2020-05-26Rollup merge of #72401 - ecstatic-morse:issue-72394, r=eddybDylan DPC-0/+24
Use correct function for detecting `const fn` in unsafety checking Resolves #72394.
2020-05-26Rollup merge of #72342 - jsgf:warn-unused-deps, r=petrochenkovDylan DPC-0/+151
Warn about unused crate deps Implements #57274 by adding -Wunused-crate-dependencies. This will warn about any `--extern` option on the command line which isn't referenced by the crate source either via `use` or `extern crate`. Crates which are added for some side effect but are otherwise unreferenced - such as for symbols they define - the warning can be suppressed with `use somecrate as _;`. If a crate has multiple aliases (eg using `foo = { package = "bar" }` in `Cargo.toml`), then it will warn about each unused alias. This does not consider crate added by some other means than `--extern`, including the standard library. It also doesn't consider any crate without `add_prelude` set (though I'm not sure about this). Unfortunately this probably [does not yet work well with Cargo](https://github.com/rust-lang/rust/issues/57274#issuecomment-624839355) as it will over-specify crates, causing spurious warnings. As a result, this lint is "allow" by default and must be explicitly enabled either via `#![warn(unused_crate_deps)]` or with `-Wunused-crate-deps`.
2020-05-26Rollup merge of #72270 - RalfJung:lint-ref-to-packed, r=oli-obkDylan DPC-18/+65
add a lint against references to packed fields Creating a reference to an insufficiently aligned packed field is UB and should be disallowed, both inside and outside of `unsafe` blocks. However, currently there is no stable alternative (https://github.com/rust-lang/rust/issues/64490) so all we do right now is have a future incompatibility warning when doing this outside `unsafe` (https://github.com/rust-lang/rust/issues/46043). This adds an allow-by-default lint. @retep998 suggested this can help early adopters avoid issues. It also means we can then do a crater run where this is deny-by-default as suggested by @joshtriplett. I guess the main thing to bikeshed is the lint name. I am not particularly happy with "packed_references" as it sounds like the packed field has reference type. I chose this because it is similar to "safe_packed_borrows". What about "reference_to_packed" or "unaligned_reference" or so?
2020-05-26Export ZERO_AR_DATE for macos linker invocationsAlex Crichton-2/+1
This commit attempts to improve reproducibility of builds on macOS by exporting the `ZERO_AR_DATE=1` environment variable for all invocations of the linker. While it looks like this env var is targeted at just the `ar` command (which does actually read this) it appears that recent-ish versions of the linker *also* read this environment variable. This env var forces the linker to set a deterministic zero value for the mtime in the N_OSO field of the object file. Currently it's believe that older versions of the linker will simply ignore this env var, while newer versions will read it and produce a deterministic output for compilations with debuginfo. Closes #47086 Closes #66568
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-25Implement warning for unused dependencies.Jeremy Fitzhardinge-0/+151
This will print a diagnostic for crates which are mentioned as `--extern` arguments on the command line, but are never referenced from the source. This diagnostic is controlled by `-Wunused-crate-dependencies` or `#![warn(unused_crate_dependencies)]` and is "allow" by default. There are cases where certain crates need to be linked in but are not directly referenced - for example if they are providing symbols for C linkage. In this case the warning can be suppressed with `use needed_crate as _;`. Thanks to @petrochenkov for simplified core. Resolves issue #57274
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-26Allow unlabeled breaks from desugared `?` in labeled blocksSamrat Man Singh-0/+12
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-25rename lintRalf Jung-40/+40
2020-05-25more test ref-to-packed testsRalf Jung-1/+19
2020-05-25remove some unused types from the testsRalf Jung-25/+6
2020-05-25add a lint against references to packed fieldsRalf Jung-0/+48
2020-05-25Add test for old compiler ICE when using `Borrow`Ross MacArthur-0/+57
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