about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2020-09-03Remove a number of vec UI tests, make them unit tests in the alloc libraryRune Tynan-62/+0
2020-09-03Rollup merge of #76245 - tmiasko:inline-generators, r=ecstatic-morseDylan DPC-0/+18
inliner: Avoid query cycles when optimizing generators The HIR Id trick is insufficient to prevent query cycles when optimizing generators, since merely requesting a layout of a generator also computes its `optimized_mir`. Make no attempts to inline functions into generators within the same crate to avoid query cycles. Fixes #76181.
2020-09-03Rollup merge of #76142 - CDirkx:const-ip, r=ecstatic-morseDylan DPC-0/+58
Make all methods of `std::net::Ipv4Addr` const Make the following methods of `std::net::Ipv4Addr` unstable const under the `const_ipv4` feature: - `octets` - `is_loopback` - `is_private` - `is_link_local` - `is_global` (unstable) - `is_shared` (unstable) - `is_ietf_protocol_assignment` (unstable) - `is_benchmarking` (unstable) - `is_reserved` (unstable) - `is_multicast` - `is_broadcast` - `is_documentation` - `to_ipv6_compatible` - `to_ipv6_mapped` This would make all methods of `Ipv6Addr` const. Of these methods, `is_global`, `is_broadcast`, `to_ipv6_compatible`, and `to_ipv6_mapped` require a change in implementation. Part of #76205
2020-09-02Auto merge of #76160 - scileo:format-recovery, r=petrochenkovbors-42/+61
Improve recovery on malformed format call The token following a format expression should be a comma. However, when it is replaced with a similar token (such as a dot), then the corresponding error is emitted, but the token is treated as a comma, and the parsing step continues. r? @petrochenkov
2020-09-02Improve recovery on malformed format callSasha-42/+61
If a comma in a format call is replaced with a similar token, then we emit an error and continue parsing, instead of stopping at this point.
2020-09-01Rollup merge of #76218 - petrochenkov:shebang3, r=matkladTyler Mandry-8/+5
lexer: Tiny improvement to shebang detection Lexer now discerns between regular comments and doc comments, so use that. The change only affects the choice of reported errors.
2020-09-01Rollup merge of #76206 - CDirkx:const-ipv6, r=ecstatic-morseTyler Mandry-0/+53
Make all methods of `std::net::Ipv6Addr` const Make the following methods of `std::net::Ipv6Addr` unstable const under the `const_ipv6` feature: - `segments` - `is_unspecified` - `is_loopback` - `is_global` (unstable) - `is_unique_local` - `is_unicast_link_local_strict` - `is_documentation` - `multicast_scope` - `is_multicast` - `to_ipv4_mapped` - `to_ipv4` This would make all methods of `Ipv6Addr` const. Changed the implementation of `is_unspecified` and `is_loopback` to use a `match` instead of `==`, all other methods did not require a change. All these methods are dependent on `segments`, the current implementation of which requires unstable `const_fn_transmute` ([PR#75085](https://github.com/rust-lang/rust/pull/75085)). Part of #76205
2020-09-01Rollup merge of #76143 - jyn514:duplicate-builtin-macros, r=petrochenkovTyler Mandry-3/+48
Give a better error message for duplicate built-in macros Minor follow-up to https://github.com/rust-lang/rust/pull/75176 giving a better error message for duplicate builtin macros. This would have made it a little easier to debug. r? @petrochenkov
2020-09-01Rollup merge of #76126 - camelid:crate-list-font, r=GuillaumeGomezTyler Mandry-2/+2
Use "Fira Sans" for crate list font Fira Sans is what's used for module lists and other item lists. Previously, the default body font, "Source Serif Pro", was used for crate lists, which didn't visually match other item lists. @rustbot modify labels: T-rustdoc
2020-09-01Rollup merge of #76074 - richkadel:llvm-coverage-map-gen-6b.5.1, r=wesleywiserTyler Mandry-0/+215
Add new `-Z dump-mir-spanview` option Similar to `-Z dump-mir-graphviz`, this adds the option to write HTML+CSS files that allow users to analyze the spans associated with MIR elements (by individual statement, just terminator, or overall basic block). This PR was split out from PR #76004, and exposes an API for spanview HTML+CSS files that is also used to analyze code regions chosen for coverage instrumentation (in a follow-on PR). Rust compiler MCP rust-lang/compiler-team#278 Relevant issue: #34701 - Implement support for LLVMs code coverage instrumentation r? @tmandry FYI @wesleywiser
2020-09-02inliner: Avoid query cycles when optimizing generatorsTomasz Miąsko-0/+18
The HIR Id trick is insufficient to prevent query cycles when optimizing generators, since merely requesting a layout of a generator also computes its `optimized_mir`. Make no attempts to inline functions into generators within the same crate to avoid query cycles.
2020-09-01Make all remaining methods of `std::net::Ipv4Addr` constChristiaan Dirkx-1/+18
Makes the following methods of `std::net::Ipv4Addr` unstable const under the `const_ipv4` feature: - `is_global` - `is_reserved` - `is_broadcast` - `to_ipv6_compatible` - `to_ipv6_mapped` This results in all methods of `Ipv4Addr` being const. Also adds tests for these methods in a const context.
2020-09-02lexer: Tiny improvement to shebang detectionVadim Petrochenkov-8/+5
Lexer now discerns between regular comments and doc comments, so use that. The change only affects the choice of reported errors.
2020-09-01Use "Fira Sans" for crate list fontCamelid-2/+2
Fira Sans is what's used for module lists and other item lists. Previously, the default body font, "Source Serif Pro", was used for crate lists, which didn't visually match other item lists.
2020-09-01Auto merge of #76010 - Aaron1011:fix/cfg-generic-param, r=petrochenkovbors-0/+251
Run cfg-stripping on generic parameters before invoking derive macros Fixes #75930 This changes the tokens seen by a proc-macro. However, ising a `#[cfg]` attribute on a generic paramter is unusual, and combining it with a proc-macro derive is probably even more unusual. I don't expect this to cause any breakage.
2020-09-01Add test for `Ipv4Addr` methods in a const contextChristiaan Dirkx-0/+41
2020-09-01Add trailing newline to `ipv6.rs`CDirkx-1/+1
2020-09-01Add test for `Ipv6Addr` methods in a const contextCDirkx-0/+53
2020-09-01Auto merge of #75529 - bugadani:bounds-check, r=nagisabors-0/+56
Eliminate some other bound checks when index comes from an enum #36962 introduced an assumption for the upper limit of the enum's value. This PR adds an assumption to the lower value as well. I've modified the original codegen test to show that derived (in that case, adding 1) values also don't generate bounds checks. However, this test is actually carefully crafted to not hit a bug: if the enum's variants are modified to 1 and 2 instead of 2 and 3, the test fails by adding a bounds check. I suppose this is an LLVM issue and #75525, while not exactly in this context should be tracking it. I'm not at all confident if this patch can be accepted, or even if it _should_ be accepted in this state. But I'm curious about what others think :) ~Improves~ Should improve #13926 but does not close it because it's not exactly predictable, where bounds checks may pop up against the assumptions.
2020-09-01Give a better error message for duplicate built-in macrosJoshua Nelson-3/+48
Previously, this would say no such macro existed, but this was misleading, since the macro _did_ exist, it was just already seen. - Say where the macro was previously defined - Add long-form error message
2020-08-31Add new `-Z dump-mir-spanview` optionRich Kadel-0/+215
Similar to `-Z dump-mir-graphviz`, this adds the option to write HTML+CSS files that allow users to analyze the spans associated with MIR elements (by individual statement, just terminator, or overall basic block). This PR was split out from PR #76004, and exposes an API for spanview HTML+CSS files that is also used to analyze code regions chosen for coverage instrumentation (in a follow-on PR). Rust compiler MCP rust-lang/compiler-team#278 Relevant issue: #34701 - Implement support for LLVMs code coverage instrumentation
2020-08-31Rollup merge of #76172 - ecstatic-morse:revert-75463, r=RalfJungTyler Mandry-15/+0
Revert #75463 This was approved by me prematurely. It needs T-libs approval. Sorry @CDirkx. r? @RalfJung
2020-08-31Rollup merge of #76139 - CDirkx:cow-is-borrowed, r=ecstatic-morseTyler Mandry-0/+15
Make `cow_is_borrowed` methods const Constify the following methods of `alloc::borrow::Cow`: - `is_borrowed` - `is_owned` Analogous to the const methods `is_some` and `is_none` for Option, and `is_ok` and `is_err` for Result. These methods are still unstable under `cow_is_borrowed`. Possible because of #49146 (Allow if and match in constants). Tracking issue: #65143
2020-09-01Auto merge of #75931 - estebank:suggest-if-let, r=petrochenkovbors-88/+203
Suggest `if let x = y` when encountering `if x = y` Detect potential cases where `if let` was meant but `let` was left out. Fix #44990.
2020-09-01Add a test for constCDirkx-0/+15
Similar to the tests for Option and Result.
2020-08-31Revert #75463Dylan MacKenzie-15/+0
This was approved by me prematurely. It needs T-libs approval.
2020-08-31Rollup merge of #75938 - Amjad50:min_const_generics-tests-revisions, r=lcnrAleksey Kladov-375/+762
Added some `min_const_generics` revisions into `const_generics` tests Help in #75279. still a lot more to cover though r? @lcnr
2020-08-31Fix duplicate error messages in const_generics testsAmjad Alsharafi-64/+42
2020-08-31Add codegen testsDániel Buga-0/+56
2020-08-31Auto merge of #76027 - davidtwco:issue-61139-remove-obsolete-pretty-printer, ↵bors-360/+358
r=eddyb ty: remove obsolete pretty printer Fixes #61139. This PR removes the obsolete printer and replaces all uses of it with `FmtPrinter`. Of the replaced uses, all but one use was in `debug!` logging, two cases were notable: - `MonoItem::to_string` is used in `-Z print-mono-items` and therefore affects the output of all codegen-units tests (which have been updated). - `DefPathBasedNames` was used in `librustc_codegen_llvm/type_of.rs` with `LLVMStructCreateNamed` and that'll now get different values, but nothing will break as a result of this. cc @eddyb (whom I've discussed this with)
2020-08-31Auto merge of #75082 - Aaron1011:feature/proc-macro-backtrace, r=petrochenkovbors-0/+32
Add `-Z proc-macro-backtrace` to allow showing proc-macro panics Fixes #75050 Previously, we would unconditionally suppress the panic hook during proc-macro execution. This commit adds a new flag `-Z proc-macro-backtrace`, which allows running the panic hook for easier debugging.
2020-08-30Add `-Z proc-macro-backtrace` to allow showing proc-macro panicsAaron Hill-0/+32
Fixes #75050 Previously, we would unconditionally suppress the panic hook during proc-macro execution. This commit adds a new flag -Z proc-macro-backtrace, which allows running the panic hook for easier debugging.
2020-08-31Auto merge of #75463 - CDirkx:ordering-const, r=CDirkxbors-0/+15
Make some Ordering methods const Constify the following methods of `core::cmp::Ordering`: - `reverse` - `then` Possible because of #49146 (Allow `if` and `match` in constants). Tracking issue: #76113
2020-08-30Suggest `if let x = y` when encountering `if x = y`Esteban Küber-88/+203
Detect potential cases where `if let` was meant but `let` was left out. Fix #44990.
2020-08-30Stabilize feature `const_ordering`CDirkx-2/+0
2020-08-30Use string literal directly when available in formatSasha-0/+54
Previous implementation used the `Parser::parse_expr` function in order to extract the format expression. If the first comma following the format expression was mistakenly replaced with a dot, then the next format expression was eaten by the function, because it looked as a syntactically valid expression, which resulted in incorrectly spanned error messages. The way the format expression is exctracted is changed: we first look at the first available token in the first argument supplied to the `format!` macro call. If it is a string literal, then it is promoted as a format expression immediatly, otherwise we fall back to the original `parse_expr`-related method. This allows us to ensure that the parser won't consume too much tokens when a typo is made. A test has been created so that it is ensured that the issue is properly fixed.
2020-08-30ty: remove obsolete printerDavid Wood-360/+358
This commit removes the obsolete printer and replaces all uses of it with `FmtPrinter`. Of the replaced uses, all but one use was in `debug!` logging, two cases were notable: - `MonoItem::to_string` is used in `-Z print-mono-items` and therefore affects the output of all codegen-units tests. - `DefPathBasedNames` was used in `librustc_codegen_llvm/type_of.rs` with `LLVMStructCreateNamed` and that'll now get different values, but this should result in no functional change. Signed-off-by: David Wood <david@davidtw.co>
2020-08-30Run cfg-stripping on generic parameters before invoking derive macrosAaron Hill-0/+251
Fixes #75930 This changes the tokens seen by a proc-macro. However, ising a `#[cfg]` attribute on a generic paramter is unusual, and combining it with a proc-macro derive is probably even more unusual. I don't expect this to cause any breakage.
2020-08-30Add unstable `const_ordering` feature, and some tests.CDirkx-0/+17
2020-08-30mv compiler to compiler/mark-7/+7
2020-08-30Auto merge of #75176 - jyn514:impl-link, r=GuillaumeGomez,petrochenkovbors-2/+0
Fix intra-doc links for cross-crate re-exports of default trait methods The original fix for this was very simple: https://github.com/rust-lang/rust/pull/58972 ignored `extern_traits` because before https://github.com/rust-lang/rust/issues/65983 was fixed, they would always fail to resolve, giving spurious warnings. So the first commit just undoes that change, so extern traits are now seen by the `collect_intra_doc_links` pass. There are also some minor changes in `librustdoc/fold.rs` to avoid borrowing the `extern_traits` RefCell more than once at a time. However, that brought up a much more thorny problem. `rustc_resolve` started giving 'error: cannot find a built-in macro with name `cfg`' when documenting `libproc_macro` (I still haven't been able to reproduce on anything smaller than the full standard library). The chain of events looked like this (thanks @eddyb for the help debugging!): 0. `x.py build --stage 1` builds the standard library and creates a sysroot 1. `cargo doc` does something like `cargo check` to create `rmeta`s for all the crates (unrelated to what was built above) 2. the `cargo check`-like `libcore-*.rmeta` is loaded as a transitive dependency *and claims ownership* of builtin macros 3. `rustdoc` later tries to resolve some path in a doc link 4. suggestion logic fires and loads "extern prelude" crates by name 5. the sysroot `libcore-*.rlib` is loaded and *fails to claim ownership* of builtin macros `rustc_resolve` gives the error after step 5. However, `rustdoc` doesn't need suggestions at all - `resolve_str_path_error` completely discards the `ResolutionError`! The fix implemented in this PR is to skip the suggestion logic for `resolve_ast_path`: pass `record_used: false` and skip `lookup_import_candidates` when `record_used` isn't set. It's possible that if/when https://github.com/rust-lang/rust/issues/74207 is implemented this will need a more in-depth fix which returns a `ResolutionError` from `compile_macro`, to allow rustdoc to reuse the suggestions from rustc_resolve. However, that's a much larger change and there's no need for it yet, so I haven't implemented it here. Fixes https://github.com/rust-lang/rust/issues/73829. r? @GuillaumeGomez
2020-08-30Auto merge of #75867 - estebank:async-lt-sugg-fix, r=matthewjasperbors-12/+36
Account for async functions when suggesting new named lifetime Fix #75850.
2020-08-30Auto merge of #76093 - jyn514:prim-assoc-items, r=Manishearthbors-0/+5
Fix intra-doc links for associated constants Previously, only associated functions would be resolved. Fixes the issues in https://github.com/rust-lang/rust/pull/75969#discussion_r477898003. I'm a little uncomfortable hard-coding the string constants, but it looks like that's how it's done elsewhere. I might make a follow-up PR at some point putting it in one place. Not sure how to test associated types, since AFAIK there aren't any on primitives. r? @Manishearth
2020-08-29Fix intra-doc links for associated constantsJoshua Nelson-0/+5
Previously, only associated functions would be resolved.
2020-08-30Auto merge of #76090 - Dylan-DPC:rollup-eksndcr, r=Dylan-DPCbors-14/+111
Rollup of 14 pull requests Successful merges: - #75832 (Move to intra-doc links for wasi/ext/fs.rs, os_str_bytes.rs…) - #75852 (Switch to intra-doc links in `core::hash`) - #75874 (Shorten liballoc doc intra link while readable) - #75881 (Expand rustdoc theme chooser x padding) - #75885 (Fix another clashing_extern_declarations false positive.) - #75892 (Fix typo in TLS Model in Unstable Book) - #75910 (Add test for issue #27130) - #75917 (Move to intra doc links for core::ptr::non_null) - #75975 (Allow --bess ing expect-tests in tools) - #75990 (Add __fastfail for Windows on arm/aarch64) - #76015 (Fix loading pretty-printers in rust-lldb script) - #76022 (Clean up rustdoc front-end source code) - #76029 (Move to intra-doc links for library/core/src/sync/atomic.rs) - #76057 (Move retokenize hack to save_analysis) Failed merges: r? @ghost
2020-08-30Rollup merge of #75910 - bugadani:testcase, r=oli-obkDylan DPC-0/+22
Add test for issue #27130 #27130 seems to be fixed by the llvm 11 update. The issue is marked with needs-test, so here it is. As some historical context, the generated code was fine until 1.38, and remained unoptimized from 1.38 up until the current nightly. I've also added a pattern matching version that was fine on 1.45.2.
2020-08-30Rollup merge of #75885 - ↵Dylan DPC-14/+89
jumbatm:issue75739-clashing-extern-declarations-transparent-nonzero, r=lcnr Fix another clashing_extern_declarations false positive. Fixes #75739. Fix another clashing_extern_declarations false positive, this time for transparent newtype with a non-zero member. r? @lcnr
2020-08-29Auto merge of #75775 - matklad:rustc-lexer-rustdoc-highlight, r=GuillaumeGomezbors-6/+6
Use rustc_lexer for rustdoc syntax highlighting r? @ghost
2020-08-29rustdoc: Fix intra-doc links for cross-crate re-exports of traitsJoshua Nelson-2/+0
#58972 ignored extern_traits because before #65983 was fixed, they would always fail to resolve, giving spurious warnings. This undoes that change, so extern traits are now seen by the `collect_intra_doc_links` pass. There are also some minor changes in librustdoc/fold.rs to avoid borrowing the extern_traits RefCell more than once at a time.
2020-08-29Auto merge of #75370 - simonvandel:optimize-if-condition-on-int-to-switch, ↵bors-0/+411
r=oli-obk New pass to optimize `if`conditions on integrals to switches on the integer Fixes #75144 Pass to convert `if` conditions on integrals into switches on the integral. For an example, it turns something like ``` _3 = Eq(move _4, const 43i32); StorageDead(_4); switchInt(_3) -> [false: bb2, otherwise: bb3]; ``` into: ``` switchInt(_4) -> [43i32: bb3, otherwise: bb2]; ```