about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2020-12-25Auto merge of #80296 - ↵bors-16/+37
wesleywiser:revert_missing_fragment_specifier_hard_error, r=Mark-Simulacrum Revert missing fragment specifier hard error Closes #76605 Reopens #40107 r? `@Mark-Simulacrum`
2020-12-25Auto merge of #80187 - 0dvictor:nativelib, r=bjorn3bors-0/+6
Exclude unnecessary info from CodegenResults `foreign_module` and `wasm_import_module` are not needed for linking, and hence can be removed from CodegenResults. Fixes #77857
2020-12-25Auto merge of #80364 - Dylan-DPC:rollup-0y96okz, r=Dylan-DPCbors-27/+73
Rollup of 11 pull requests Successful merges: - #79213 (Stabilize `core::slice::fill`) - #79999 (Refactored verbose print into a function) - #80160 (Implemented a compiler diagnostic for move async mistake) - #80274 (Rename rustc_middle::lint::LintSource) - #80280 (Add installation commands to `x` tool README) - #80319 (Fix elided lifetimes shown as `'_` on async functions) - #80327 (Updated the match with the matches macro) - #80330 (Fix typo in simplify_try.rs) - #80340 (Don't unnecessarily override attrs for Module) - #80342 (Fix typo) - #80352 (BTreeMap: make test cases more explicit on failure) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2020-12-25Rollup merge of #80319 - jyn514:async-lifetimes, r=tmandryDylan DPC-0/+44
Fix elided lifetimes shown as `'_` on async functions Closes https://github.com/rust-lang/rust/issues/63037. r? `@tmandry` on the implementation, `@Darksonn` on the test cases.
2020-12-25Rollup merge of #80160 - diondokter:move_async_fix, r=davidtwcoDylan DPC-0/+29
Implemented a compiler diagnostic for move async mistake Fixes #79694 First time contributing, so I hope I'm doing everything right. (If not, please correct me!) This code performs a check when a move capture clause is parsed. The check is to detect if the user has reversed the async move keywords and to provide a diagnostic with a suggestion to fix it. Checked code: ```rust fn main() { move async { }; } ``` Previous output: ```txt PS C:\Repos\move_async_test> cargo build Compiling move_async_test v0.1.0 (C:\Repos\move_async_test) error: expected one of `|` or `||`, found keyword `async` --> src\main.rs:2:10 | 2 | move async { }; | ^^^^^ expected one of `|` or `||` error: aborting due to previous error error: could not compile `move_async_test` ``` New output: ```txt PS C:\Repos\move_async_test> cargo +dev build Compiling move_async_test v0.1.0 (C:\Repos\move_async_test) error: the order of `move` and `async` is incorrect --> src\main.rs:2:13 | 2 | let _ = move async { }; | ^^^^^^^^^^ | help: try switching the order | 2 | let _ = async move { }; | ^^^^^^^^^^ error: aborting due to previous error error: could not compile `move_async_test` ``` Is there a file/module where these kind of things are tested? Would love some feedback 😄
2020-12-25Rollup merge of #79999 - hencrice:yenlinc/79799, r=oli-obkDylan DPC-27/+0
Refactored verbose print into a function Also handle Tuple and Array separately, which was not explicitly checked. Fixes #79799.
2020-12-25Auto merge of #79762 - Swatinem:remap-doctest-coverage, r=Swatinembors-10/+490
Remap instrument-coverage line numbers in doctests This uses the `SourceMap::doctest_offset_line` method to re-map line numbers from doctests. Remapping columns is not yet done, and rustdoc still does not output the correct filename when running doctests in a workspace. Part of #79417 although I dont consider that fixed until both filenames and columns are mapped correctly. r? `@richkadel` I might jump on zulip the comming days. Still need to figure out how to properly write tests for this, and deal with other doctest issues in the meantime.
2020-12-24Auto merge of #79742 - GuillaumeGomez:move-tooltips-messages-out-of-html, ↵bors-6/+5
r=Nemo157 Move tooltips messages out of html First thing first: nothing in the output has changed. You still have the "i" on the left of code blocks examples when they have `ignore`, `compile_fail`, `should_panic` and `edition`. The behavior also remains the same: when you hover the "i", you have the corresponding message showing up. So now, why this PR then? I realized recently that we were actually generating those messages into the HTML every time whereas all messages are the same (except for the edition ones, I'll come back to it later). So instead of generating more content, I simply moved it inside the CSS thanks to pseudo elements (`::before` and `::after`). The message is now inside `::after` and we use the `::before` to have the small triangle on the left of the message. So now, we have less HTML generated which is seems pretty nice. So now, back to the `edition` change: the message is globally the same, but the "edition" itself can be different (2015 or 2018 currently, I expect 2021 to arrive not too far in the future). So the only difference for it is that I added a new attribute on the tooltip called `edition` which contains this information. Then, the `::after` uses it inside its `content` (you can get the content of an element's attribute by using `attr` and concat different strings by simply having them after the other). Don't hesitate if a part of my explanations isn't clear. r? `@jyn514`
2020-12-24Auto merge of #77692 - PankajChaudhary5:issue-76630, r=davidtwcobors-14/+14
Added better error message for shared borrow treated as unique for purposes of lifetimes Part of Issue #76630 r? `@jyn514`
2020-12-23Update HTML DOM attribute "edition" to "data-edition"Guillaume Gomez-1/+1
2020-12-23Addressed feedbacksYenlin Chen-27/+0
Also updated the mir-opt test output files.
2020-12-23Add more testsJoshua Nelson-0/+15
2020-12-23Auto merge of #79261 - faern:deprecate-compare-and-swap, r=Amanieubors-3/+18
Deprecate atomic compare_and_swap method Finish implementing [RFC 1443](https://github.com/rust-lang/rfcs/blob/master/text/1443-extended-compare-and-swap.md) (https://github.com/rust-lang/rfcs/pull/1443). It was decided to deprecate `compare_and_swap` [back in Rust 1.12 already](https://github.com/rust-lang/rust/issues/31767#issuecomment-215903038). I can't find any info about that decision being reverted. My understanding is just that it has been forgotten. If there has been a decision on keeping `compare_and_swap` then it's hard to find, and even if this PR does not go through it can act as a place where people can find out about the decision being reverted. Atomic operations are hard to understand, very hard. And it does not help that there are multiple similar methods to do compare and swap with. They are so similar that for a reader it might be hard to understand the difference. This PR aims to make that simpler by finally deprecating `compare_and_swap` which is essentially just a more limited version of `compare_exchange`. The documentation is also updated (according to the RFC text) to explain the differences a bit better. Even if we decide to not deprecate `compare_and_swap`. I still think the documentation for the atomic operations should be improved to better describe their differences and similarities. And the documentation can be written nicer than the PR currently proposes, but I wanted to start somewhere. Most of it is just copied from the RFC. The documentation for `compare_exchange` and `compare_exchange_weak` indeed describe how they work! The problem is that they are more complex and harder to understand than `compare_and_swap`. So for someone who does not fully grasp this they might fall back to using `compare_and_swap`. Making the documentation outline the similarities and differences might build a bridge for people so they can cross over to the more powerful and sometimes more efficient operations. The conversions I do to avoid the `std` internal deprecation errors are very straight forward `compare_and_swap -> compare_exchange` changes where the orderings are just using the mapping in the new documentation. Only in one place did I use `compare_exchange_weak`. This can probably be improved further. But the goal here was not for those operations to be perfect. Just to not get worse and to allow the deprecation to happen.
2020-12-23Add a test that rustc compiles and links separatelyVictor Ding-0/+6
2020-12-22Fix elided lifetimes shown as `'_` on async functionsJoshua Nelson-0/+29
2020-12-23Auto merge of #80314 - GuillaumeGomez:rollup-9rc48vx, r=GuillaumeGomezbors-16/+54
Rollup of 17 pull requests Successful merges: - #80136 (Add test for issue #74824) - #80203 (Edit rustc_middle::lint::LintSource docs) - #80204 (docs: Edit rustc_middle::ty::query::on_disk_cache) - #80219 (Fix labels for 'Library Tracking Issue' template) - #80222 (Fix rustc-std-workspace-core documentation) - #80223 (docs: Fix outdated crate reference) - #80225 (Add module-level docs to rustc_middle::ty) - #80241 (Fix typo) - #80248 (Remove `I-prioritize` from Zulip topic) - #80266 (Remove redundant test) - #80272 (rustc_span: Provide a reserved identifier check for a specific edition) - #80285 (Update books) - #80286 (docs: Edit rustc_middle::middle::privacy) - #80297 (Add some intra-doc links to compiler docs) - #80298 (Improve the code quality by using matches macro) - #80299 (Turn helper method into a closure) - #80302 (docs: Update rustc_middle::middle::region::ScopeTree) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2020-12-23Rollup merge of #80266 - bugadani:dup-test, r=jyn514Guillaume Gomez-16/+0
Remove redundant test Remove ignored test. This test can also be found at src/test/rustdoc-ui/intra-doc/double-anchor.rs and the second version isn't ignored. r? ``@jyn514``
2020-12-23Rollup merge of #80136 - aDotInTheVoid:74824-test, r=Mark-SimulacrumGuillaume Gomez-0/+54
Add test for issue #74824 It was fixed a while ago, but doesn't have a test. Closes #74824
2020-12-22Add some testsNadrieril-28/+71
2020-12-22Revert "Promote missing_fragment_specifier to hard error"Wesley Wiser-16/+37
This reverts commit 02eae432e7476a0686633a8c2b7cb1d5aab1bd2c.
2020-12-22Migrate standard library away from compare_and_swapLinus Färnstrand-3/+18
2020-12-22Auto merge of #78242 - Nadrieril:rename-overlapping_endpoints-lint, r=varkorbors-88/+105
Rename `overlapping_patterns` lint As discussed in https://github.com/rust-lang/rust/issues/65477. I also tweaked a few things along the way. r? `@varkor` `@rustbot` modify labels: +A-exhaustiveness-checking
2020-12-21Remove redundant testDániel Buga-16/+0
2020-12-21Auto merge of #79270 - RalfJung:array-repeat-consts, r=oli-obkbors-0/+27
Acknowledge that `[CONST; N]` is stable When `const_in_array_repeat_expressions` (RFC 2203) got unstably implemented as part of https://github.com/rust-lang/rust/pull/61749, accidentally, the special case of repeating a *constant* got stabilized immediately. That is why the following code works on stable: ```rust const EMPTY: Vec<i32> = Vec::new(); pub const fn bar() -> [Vec<i32>; 2] { [EMPTY; 2] } fn main() { let x = bar(); } ``` In contrast, if we had written `[expr; 2]` for some expression that is not *literally* a constant but could be evaluated at compile-time (e.g. `(EMPTY,).0`), this would have failed. We could take back this stabilization as it was clearly accidental. However, I propose we instead just officially accept this and stabilize a small subset of RFC 2203, while leaving the more complex case of general expressions that could be evaluated at compile-time unstable. Making that case work well is pretty much blocked on inline `const` expressions (to avoid relying too much on [implicit promotion](https://github.com/rust-lang/const-eval/blob/master/promotion.md)), so it could take a bit until it comes to full fruition. `[CONST; N]` is an uncontroversial subset of this feature that has no semantic ambiguities, does not rely on promotion, and basically provides the full expressive power of RFC 2203 but without the convenience (people have to define constants to repeat them, possibly using associated consts if generics are involved). Well, I said "no semantic ambiguities", that is only almost true... the one point I am not sure about is `[CONST; 0]`. There are two possible behaviors here: either this is equivalent to `let x = CONST; [x; 0]`, or it is a NOP (if we argue that the constant is never actually instantiated). The difference between the two is that if `CONST` has a destructor, it should run in the former case (but currently doesn't, due to https://github.com/rust-lang/rust/issues/74836); but should not run if it is considered a NOP. For regular `[x; 0]` there seems to be consensus on running drop (there isn't really an alternative); any opinions for the `CONST` special case? Should this instantiate the const only to immediately run its destructors? That seems somewhat silly to me. After all, the `let`-expansion does *not* work in general, for `N > 1`. Cc `@rust-lang/lang` `@rust-lang/wg-const-eval` Cc https://github.com/rust-lang/rust/issues/49147
2020-12-21Implemented a compiler diagnostic for move async mistakeDion Dokter-0/+29
Ran the tidy check Following the diagnostic guide better Diagnostic generation is now relegated to its own function in the diagnostics module. Added tests Fixed the ui test
2020-12-21make path normalization compatible with mac python2Arpad Borsos-0/+2
2020-12-21Auto merge of #80205 - tomprogrammer:prettyprint-pattern-mut-binding, ↵bors-0/+19
r=davidtwco Fix pretty printing an AST representing `&(mut ident)` The PR fixes a misguiding help diagnostic in the parser that I reported in #80186. I discovered that the parsers recovery and reporting logic was correct but the pretty printer produced wrong code for the example. (Details in https://github.com/rust-lang/rust/issues/80186#issuecomment-748498676) Example: ```rust #![allow(unused_variables)] fn main() { let mut &x = &0; } ``` The AST fragment `PatKind::Ref(PatKind::Ident(BindingMode::ByValue(Mutability::Mut), ..), Mutability::Not)` was printed to be `&mut ident`. But this wouldn't round trip through parsing again, because then it would be: `PatKind::Ref(PatKind::Ident(BindingMode::ByValue(Mutability::Not), ..), Mutability::Mut)` Now the pretty-printer prints `&(mut ident)`. Reparsing that code results in the AST fragment `PatKind::Ref(PatKind::Paren(PatKind::Ident(BindingMode::ByValue(Mutability::Mut), ..)), Mutability::Not)` which I think should behave like the original pattern. Old diagnostic: ``` error: `mut` must be attached to each individual binding --> src/main.rs:3:9 | 3 | let mut &x = &0; | ^^^^^^ help: add `mut` to each binding: `&mut x` | = note: `mut` may be followed by `variable` and `variable @ pattern` ``` New diagnostic: ``` error: `mut` must be attached to each individual binding --> src/main.rs:3:9 | 3 | let mut &x = &0; | ^^^^^^ help: add `mut` to each binding: `&(mut x)` | = note: `mut` may be followed by `variable` and `variable @ pattern` ``` Fixes #80186
2020-12-21Rollup merge of #80211 - wabain:async-fn-trait-bound-suggestion, r=petrochenkovDylan DPC-1/+89
Handle desugaring in impl trait bound suggestion Fixes #79843. When an associated type of a generic function parameter needs extra bounds, the diagnostics may suggest replacing an `impl Trait` with a named type parameter so that it can be referenced in the where clause. On stable and nightly, the suggestion can be malformed, for instance transforming: ```rust async fn run(_: &(), foo: impl Foo) -> std::io::Result<()> ``` Into: ```rust async fn run(_: &, F: Foo(), foo: F) -> std::io::Result<()> where <F as Foo>::Bar: Send ^^^^^^^^ ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` Where we want something like: ```rust async fn run<F: Foo>(_: &(), foo: F) -> std::io::Result<()> where <F as Foo>::Bar: Send ^^^^^^^^ ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` The problem is that the elided lifetime of `&()` is added as a generic parameter when desugaring the async fn; the suggestion code sees this as an existing generic parameter and tries to use its span as an anchor to inject `F` into the parameter list. There doesn't seem to be an entirely principled way to check which generic parameters in the HIR were explicitly named in the source, so this commit changes the heuristics when generating the suggestion to only consider type parameters whose spans are contained within the span of the `Generics` when determining how to insert an additional type parameter into the declaration. (And to be safe it also excludes parameters whose spans are marked as originating from desugaring, although that doesn't seem to handle this elided lifetime.)
2020-12-21Rollup merge of #80199 - RalfJung:const-fake, r=oli-obkDylan DPC-1/+35
also const-check FakeRead We need to const-check all statements, including `FakeRead`, to avoid issues like https://github.com/rust-lang/rust/issues/77694. Fixes https://github.com/rust-lang/rust/issues/77694. r? ``@oli-obk``
2020-12-21Rollup merge of #80170 - ldm0:fixice, r=lcnrDylan DPC-0/+57
Fix ICE when lookup method in trait for type that have bound vars Closes #77910
2020-12-20Auto merge of #78317 - est31:linear_in_impl_count, r=matthewjasperbors-0/+206
Turn quadratic time on number of impl blocks into linear time Previously, if you had a lot of inherent impl blocks on a type like: ```Rust struct Foo; impl Foo { fn foo_1() {} } // ... impl Foo { fn foo_100_000() {} } ``` The compiler would be very slow at processing it, because an internal algorithm would run in O(n^2), where n is the number of impl blocks. Now, we add a new algorithm that allocates but is faster asymptotically. Comparing rustc nightly with a local build of rustc as of this PR (results in seconds): | N | real time before | real time after | | - | - | - | | 4_000 | 0.57 | 0.46 | | 8_000 | 1.31 | 0.84 | | 16_000 | 3.56 | 1.69 | | 32_000 | 10.60 | 3.73 | I've tuned up the numbers to make the effect larger than the startup noise of rustc, but the asymptotic difference should hold for smaller n as well. Note: current state of the PR omits error messages if there are other errors present already. For now, I'm mainly interested in a perf run to study whether this issue is present at all. Please queue one for this PR. Thanks!
2020-12-20Auto merge of #74699 - notriddle:fd-non-negative, r=m-ou-sebors-4/+18
Mark `-1` as an available niche for file descriptors Based on discussion from <https://internals.rust-lang.org/t/can-the-standard-library-shrink-option-file/12768>, the file descriptor `-1` is chosen based on the POSIX API designs that use it as a sentinel to report errors. A bigger niche could've been chosen, particularly on Linux, but would not necessarily be portable. This PR also adds a test case to ensure that the -1 niche (which is kind of hacky and has no obvious test case) works correctly. It requires the "upper" bound, which is actually -1, to be expressed in two's complement.
2020-12-21Move test from compile-fail to ui/binopDonough Liu-0/+37
2020-12-20make sure [CONST; N] drops N timesRalf Jung-2/+16
2020-12-20add test that repeating non-Copy constants worksRalf Jung-0/+13
2020-12-20Fix pretty printing an AST representing `&(mut ident)`Thomas Bahn-0/+19
`PatKind::Ref(PatKind::Ident(BindingMode::ByValue(Mutability::Mut), ..), ..)` is an AST representing `&(mut ident)`. It was errorneously printed as `&mut ident` which reparsed into a syntactically different AST. This affected help diagnostics in the parser.
2020-12-20Fix ICE on suggesting calling functionDonough Liu-0/+20
2020-12-20Auto merge of #80163 - jackh726:binder-refactor-part-3, r=lcnrbors-15/+15
Make BoundRegion have a kind of BoungRegionKind Split from #76814 Also includes making `replace_escaping_bound_vars` only return `T` Going to r? `@lcnr` Feel free to reassign
2020-12-20Auto merge of #80100 - mark-i-m:pattORns-2, r=petrochenkovbors-56/+126
or_patterns: implement :pat edition-specific behavior cc #54883 `@joshtriplett` This PR implements the edition-specific behavior of `:pat` wrt or-patterns, as determined by the crater runs and T-lang consensus in https://github.com/rust-lang/rust/issues/54883#issuecomment-745509090. I believe this can unblock stabilization of or_patterns. r? `@petrochenkov`
2020-12-19Handle desugaring in impl trait bound suggestionWilliam Bain-1/+89
2020-12-20Auto merge of #79635 - lcnr:const-eval-idk, r=oli-obkbors-0/+32
const_evaluatable_checked: fix occurs check fixes #79615 this is kind of a hack because we use `TypeRelation` for both the `Generalizer` and the `ConstInferUnifier` but i am not sure if there is a useful way to disentangle this without unnecessarily duplicating some code. The error in the added test is kind of unavoidable until we erase the unused substs of `ConstKind::Unevaluated`. We talked a bit about this in the cg lazy norm meeting (https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/lazy_normalization_consts)
2020-12-19also const-check FakeReadRalf Jung-1/+35
2020-12-19Auto merge of #80104 - Nadrieril:usefulness-merging, r=varkorbors-25/+101
Improve and fix diagnostics of exhaustiveness checking Primarily, this fixes https://github.com/rust-lang/rust/issues/56379. This also fixes incorrect interactions between or-patterns and slice patterns that I discovered while working on #56379. Those two examples show the incorrect diagnostics: ```rust match &[][..] { [true] => {} [true // detected as unreachable but that's not true | false, ..] => {} _ => {} } match (true, None) { (true, Some(_)) => {} (false, Some(true)) => {} (true | false, None | Some(true // should be detected as unreachable | false)) => {} } ``` I did not measure any perf impact. However, I suspect that [`616ba9f`](https://github.com/rust-lang/rust/pull/80104/commits/616ba9f9f7f5845777a36e1a41a515e6c33a8776) should have a negative impact on large or-patterns. I'll see what the perf run says; I have optimization ideas up my sleeve if needed. EDIT: I initially had a noticeable perf impact that I thought unavoidable. I then proceeded to avoid it x) r? `@varkor` `@rustbot` label +A-exhaustiveness-checking
2020-12-19Tweak diagnosticsNadrieril-8/+8
2020-12-19Auto merge of #80132 - matthewjasper:revert-eval-order, r=nikomatsakisbors-0/+39
Revert change to trait evaluation order This change breaks some code and doesn't appear to enable any new code. closes #79902 r? `@nikomatsakis`
2020-12-19implement edition-specific :pat behavior for 2015/18mark-56/+126
2020-12-19Remap instrument-coverage line numbers in doctestsArpad Borsos-10/+488
This uses the `SourceMap::doctest_offset_line` method to re-map line numbers from doctests. Remapping columns is not yet done. Part of issue #79417.
2020-12-19Auto merge of #80180 - JohnTitor:rollup-a31s996, r=JohnTitorbors-8/+16
Rollup of 7 pull requests Successful merges: - #78083 (Stabilize or_insert_with_key) - #79211 (Add the "async" and "promise" doc aliases to `core::future::Future`) - #79612 (Switch some links in compiler/ to intra-doc links) - #80068 (Add `&mut` as an alias for 'reference' primitive) - #80129 (docs: Edit rustc_ast::token::Token) - #80133 (Suppress `CONST_ITEM_MUTATION` lint if a dereference occurs anywhere) - #80155 (Fix typo) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2020-12-19Rollup merge of #80133 - Aaron1011:fix/const-mut-deref, r=estebankYuki Okushi-8/+16
Suppress `CONST_ITEM_MUTATION` lint if a dereference occurs anywhere Fixes #79971
2020-12-19Auto merge of #79073 - davidtwco:issue-78957-const-param-attrs, r=lcnrbors-5/+112
passes: prohibit invalid attrs on generic params Fixes #78957. This PR modifies the `check_attr` pass so that attribute placement on generic parameters is checked for validity. r? `@lcnr`