about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2023-06-12Auto merge of #112543 - GuillaumeGomez:revert-112429, r=lcnrbors-59/+30
[rustdoc] Fix infinite loop when retrieving impls for type alias Fixes #112515. Reverts #112429. r? `@lcnr`
2023-06-12Add regression test for #112515Guillaume Gomez-0/+30
2023-06-12Revert "Add regression test for #32077"Guillaume Gomez-59/+0
This reverts commit 6f552c800b38b3e71c5e33a295e8b490d2018c71.
2023-06-12Auto merge of #112261 - jieyouxu:c-like-ptr-arithmetics-diagnostics, ↵bors-0/+74
r=WaffleLapkin Add help for trying to do C-like pointer arithmetics This PR adds help messages for these cases: ```rust fn main() { let ptr1: *const u32 = std::ptr::null(); let ptr2: *const u32 = std::ptr::null(); let a = ptr1 + 5; let b = ptr1 - 5; let c = ptr2 - ptr1; let d = ptr1[5]; } ``` ### Current Output ``` error[E0369]: cannot add `{integer}` to `*const u32` --> tests/ui/typeck/issue-112252-ptr-arithmetics-help.rs:4:18 | 4 | let a = ptr1 + 5; //~ ERROR cannot add | ---- ^ - {integer} | | | *const u32 error[E0369]: cannot subtract `{integer}` from `*const u32` --> tests/ui/typeck/issue-112252-ptr-arithmetics-help.rs:5:18 | 5 | let b = ptr1 - 5; //~ ERROR cannot subtract | ---- ^ - {integer} | | | *const u32 error[E0369]: cannot subtract `*const u32` from `*const u32` --> tests/ui/typeck/issue-112252-ptr-arithmetics-help.rs:6:18 | 6 | let c = ptr2 - ptr1; //~ ERROR cannot subtract | ---- ^ ---- *const u32 | | | *const u32 error[E0608]: cannot index into a value of type `*const u32` --> tests/ui/typeck/issue-112252-ptr-arithmetics-help.rs:7:13 | 7 | let d = ptr1[5]; //~ ERROR cannot index | ^^^^^^^ error: aborting due to 4 previous errors ``` ### Output After This PR ``` error[E0369]: cannot add `{integer}` to `*const u32` --> $DIR/issue-112252-ptr-arithmetics-help.rs:6:20 | LL | let _a = _ptr1 + 5; | ------^-- | | | | | {integer} | *const u32 | help: consider using `wrapping_add` or `add` for pointer + {integer}: `_ptr1.wrapping_add(5)` error[E0369]: cannot subtract `{integer}` from `*const u32` --> $DIR/issue-112252-ptr-arithmetics-help.rs:7:20 | LL | let _b = _ptr1 - 5; | ------^-- | | | | | {integer} | *const u32 | help: consider using `offset` for pointer - {integer}: `unsafe { _ptr1.offset(-5) }` error[E0369]: cannot subtract `*const u32` from `*const u32` --> $DIR/issue-112252-ptr-arithmetics-help.rs:8:20 | LL | let _c = _ptr2 - _ptr1; | ------^------ | | | | | *const u32 | *const u32 | help: consider using `offset_from` for pointer - pointer if the pointers point to the same allocation: `_ptr2.offset_from(_ptr1)` error[E0608]: cannot index into a value of type `*const u32` --> $DIR/issue-112252-ptr-arithmetics-help.rs:9:14 | LL | let _d = _ptr1[5]; | ^^^^^^^^ | help: consider using `wrapping_add` or `add` for indexing into raw pointer | LL | let _d = _ptr1.wrapping_add(5); | ~~~~~~~~~~~~~~~~~~~~~ error: aborting due to 4 previous errors ``` Closes #112252.
2023-06-11Auto merge of #111801 - Bryanskiy:lints1, r=petrochenkovbors-36/+541
Private-in-public lints implementation Next part of RFC https://github.com/rust-lang/rust/issues/48054. r? `@petrochenkov`
2023-06-12Private-in-public lints implementationBryanskiy-36/+541
2023-06-11Auto merge of #112530 - matthiaskrgr:rollup-qee1kc1, r=matthiaskrgrbors-0/+25
Rollup of 3 pull requests Successful merges: - #112487 (Update documentation for `tools` defaults) - #112513 (Dont compute `opt_suggest_box_span` span for TAIT) - #112528 (bootstrap: Don't override `debuginfo-level = 1` to mean `line-tables-only`) r? `@ghost` `@rustbot` modify labels: rollup
2023-06-11Rollup merge of #112513 - compiler-errors:dont-compute-box-span-for-tait, ↵Matthias Krüger-0/+25
r=cjgillot Dont compute `opt_suggest_box_span` span for TAIT Fixes #112434 Also a couple more commits on top, pruning some dead code and fixing another weird suggestion encountered in the above issue.
2023-06-11Auto merge of #111958 - notriddle:notriddle/type-search-slice-array, ↵bors-0/+342
r=GuillaumeGomez rustdoc: search for slices and arrays by type with `[]` This feature extends rustdoc to support the syntax that most users will naturally attempt to use to search for slices and arrays. Part of #60485 Function signature searches already support arrays and slices. The explicit name `primitive:slice<u8>` and `primitive:array<u8>` can be used to match a slice or array of bytes, while square brackets `[u8]` will match either one. Empty square brackets, `[]`, will match any slice regardless of what it contains. Preview: * [`option -> []`](https://notriddle.com/rustdoc-demo-html-3/search-slice-array/std/index.html?search=option%20-%3E%20%5B%5D) * [`[u8] -> str`](https://notriddle.com/rustdoc-demo-html-3/search-slice-array/std/index.html?search=%5Bu8%5D%20-%3E%20str) * [`Box<[u8]> -> str`](https://notriddle.com/rustdoc-demo-html-3/search-slice-array/std/index.html?search=Box%3C%5Bu8%5D%3E%20-%3E%20str) Motivation: When type-based search was first landed, it was directly described as "incomplete". Here's [a comment] from the discussion thread: [a comment]: https://github.com/rust-lang/rust/pull/23289#issuecomment-79437386 > This is looking really great, nice work! I can think of a number of cases that aren't quite covered by this, but I feel like this is a great improvement regardless and it can always be iterated on so I'm fine landing with a few known cases where it may not work :) Filling out the missing functionality is going to mean adding support for more of Rust's [type expression] syntax, such as slices (in this PR), tuples, references, raw pointers, function pointers, and generics. [type expression]: https://doc.rust-lang.org/reference/types.html#type-expressions There does seem to be demand for this sort of thing, such as [this Discord message](https://discord.com/channels/442252698964721669/443150878111694848/1042145740065099796) expressing regret at rustdoc not supporting tuples in search queries.
2023-06-11Don't suggest boxing an empty if/else armMichael Goulet-0/+25
2023-06-11Rollup merge of #112498 - SamZhang3:rust-reference-link-update, r=NilstriebMatthias Krüger-8/+8
Update links to Rust Reference in diagnostic Instead of linking to the [old Rust Reference site](https://static.rust-lang.org/doc/master/reference.html#literals), which is severely outdated (Rust 1.17), link to the [current website](https://doc.rust-lang.org/stable/reference/expressions/literal-expr.html) in diagnostic about incorrect literals.
2023-06-11Rollup merge of #112493 - fmease:iat-select-complete-bound-var-erasure, ↵Matthias Krüger-0/+35
r=compiler-errors iat selection: normalize self ty & completely erase bound vars Erase bound vars (most notably late-bound regions) irrespective of their binding level instead of just at the innermost one. Fixes #111404.
2023-06-11Rollup merge of #112492 - GuillaumeGomez:migrate-gui-test-color-13, r=notriddleMatthias Krüger-2/+2
Migrate GUI colors test to original CSS color format Follow-up of https://github.com/rust-lang/rust/pull/111459. r? `@notriddle`
2023-06-11Rollup merge of #112475 - chenyukang:yukang-fix-112278, r=compiler-errorsMatthias Krüger-1/+79
Fix issue for module name when surround the struct literal with parentheses Fixes #112278
2023-06-11iat selection: normalize self ty & completely erase bound varsLeón Orell Valerian Liehr-0/+35
2023-06-10rustdoc: add note about slice/array searches to help popupMichael Howell-22/+18
2023-06-10rustdoc: search for slices and arrays by type with `[]`Michael Howell-0/+336
Part of #60485
2023-06-10rustdoc: add test case for `OsString::into_string`Michael Howell-0/+10
2023-06-10Use a better linkHankai Zhang-8/+8
2023-06-10Auto merge of #107637 - fmease:rustdoc-reelide-x-crate-def-tr-obj-lt-bnds, ↵bors-19/+167
r=notriddle,cgillot,GuillaumeGomez rustdoc: re-elide cross-crate default trait-object lifetime bounds Hide trait-object lifetime bounds (re-exported from an external crate) if they coincide with [their default](https://doc.rust-lang.org/reference/lifetime-elision.html#default-trait-object-lifetimes). Partially addresses #44306. Follow-up to #103885. [Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/clean_middle_ty.3A.20I.20need.20to.20add.20a.20parameter/near/307143097). Most notably, if `std` exported something from `core` containing a type like `Box<dyn Fn()>`, then it would now be rendered as `Box<dyn Fn(), Global>` instead of `Box<dyn Fn() + 'static, Global>` (hiding `+ 'static` as it is the default in this case). Showing `Global` here is a separate issue, #80379, which is on my agenda. Note that I am not really fond of the fact that I had to add a parameter to such a widely used function (30+ call sites) to address such a niche bug. CC `@GuillaumeGomez` Requesting a review from a compiler contributor or team member as recommended on Zulip. r? compiler --- `@rustbot` label T-compiler T-rustdoc A-cross-crate-reexports
2023-06-10Update links to Rust Reference page on literals in diagnosticHankai Zhang-8/+8
Instead of linking to the old Rust Reference site on static.rust-lang.org, link to the current website doc.rust-lang.org/stable/reference instead in diagnostic about incorrect literals.
2023-06-10Auto merge of #112494 - matthiaskrgr:rollup-xdf3om8, r=matthiaskrgrbors-13/+36
Rollup of 5 pull requests Successful merges: - #112297 (bootstrap: Disallow `--exclude test::std`) - #112298 (Update field-offset and enable unstable_offset_of) - #112335 (ci: Upgrade loongarch64-linux-gnu GCC to 13.1.0) - #112413 (Adjust span labels for `HIDDEN_GLOB_REEXPORTS`) - #112483 (Add deprecation warning to python versions <3.6 in x.py) r? `@ghost` `@rustbot` modify labels: rollup
2023-06-10Rollup merge of #112413 - jieyouxu:fix-hidden-glob-reexports-span-order, ↵Matthias Krüger-13/+36
r=petrochenkov Adjust span labels for `HIDDEN_GLOB_REEXPORTS` Addresses https://github.com/rust-lang/rust/pull/111378#issuecomment-1581226063. ### Before This PR The possibility that the private item comes before the glob re-export was not account for, causing the span label messages to say "but private item here shadows it" before "the name `Foo` in the type namespace is supposed to be publicly re-exported here". ### After This PR ```rust warning: private item shadows public glob re-export --> $DIR/hidden_glob_reexports.rs:9:5 | LL | struct Foo; | ^^^^^^^^^^^ the private item here shadows the name `Foo` in the type namespace ... LL | pub use self::inner::*; | -------------- but it is supposed to be publicly re-exported here | = note: `#[warn(hidden_glob_reexports)]` on by default warning: private item shadows public glob re-export --> $DIR/hidden_glob_reexports.rs:27:9 | LL | pub use self::inner::*; | -------------- the name `Foo` in the type namespace is supposed to be publicly re-exported here LL | LL | use self::other::Foo; | ^^^^^^^^^^^^^^^^ but the private item here shadows it ```
2023-06-10Auto merge of #111818 - Urgau:uplift_cmp_nan, r=cjgillotbors-0/+400
Uplift `clippy::cmp_nan` lint This PR aims at uplifting the `clippy::cmp_nan` lint into rustc. ## `invalid_nan_comparisons` ~~(deny-by-default)~~ (warn-by-default) The `invalid_nan_comparisons` lint checks comparison with `f32::NAN` or `f64::NAN` as one of the operand. ### Example ```rust,compile_fail let a = 2.3f32; if a == f32::NAN {} ``` ### Explanation NaN does not compare meaningfully to anything – not even itself – so those comparisons are always false. ----- Mostly followed the instructions for uplifting a clippy lint described here: https://github.com/rust-lang/rust/pull/99696#pullrequestreview-1134072751 `@rustbot` label: +I-lang-nominated r? compiler
2023-06-10Migrate GUI colors test to original CSS color formatGuillaume Gomez-2/+2
2023-06-10Rollup merge of #112481 - compiler-errors:new-solver-ignore-bad-tests, r=lqdMatthias Krüger-7/+13
Ignore tests that hang in new solver This makes it easier to run `--compare-mode=next-solver`, and we can revisit these tests later to find out how to make them less overflowy 😅 r? `@lcnr`
2023-06-10Rollup merge of #112468 - GuillaumeGomez:change-rustdoc-js-formats, r=notriddleMatthias Krüger-400/+236
Change format of rustdoc-js tests by putting query and correction directly alongside the expected values As I was working on fixing merge conflicts in #108537, I faced quite a big issue when trying to update the `rustdoc-js*` tests. To make it much simpler, this PR moves the `query` and `correction` directly alongside the expected data so now we know what is the query that is being run without needing to add comments or going back to the top of the file. r? ```@notriddle```
2023-06-10Rollup merge of #110141 - petrochenkov:cratecfg2, r=WaffleLapkinMatthias Krüger-24/+42
expand: Change how `#![cfg(FALSE)]` behaves on crate root Previously it removed all other attributes from the crate root. Now it removes only attributes below itself (during both regular expansion and pre-configuration). So it becomes possible to configure some global crate properties even for fully unconfigured crates. Fixes https://github.com/rust-lang/rust/issues/104633 Part of https://github.com/rust-lang/rust/issues/110082
2023-06-10Uplift improved version of `clippy::cmp_nan` to rustcUrgau-0/+400
2023-06-10Adjust span labels for `HIDDEN_GLOB_REEXPORTS`许杰友 Jieyou Xu (Joe)-13/+36
2023-06-10Auto merge of #112452 - MU001999:fix/issue-112439, r=petrochenkovbors-21/+40
Make "consider importing" consistent for macros Fixes #112439
2023-06-10Auto merge of #112426 - Bryanskiy:full_priv_ev, r=petrochenkovbors-0/+47
increase the accuracy of effective visibilities calculation Effective visibilities are calculated lazily due to performance restrictions. Therefore - crate should be walked at least 1 time in `compute_effective_visibilities` pass - Impl's should always be in the effective visibilities table to ensure that the table is filled in correctly. r? `@petrochenkov`
2023-06-10reword the message to suggest surrounding with parenthesesyukang-5/+5
2023-06-10take care module name for suggesting surround the struct literal in parenthesesyukang-0/+78
2023-06-09Ignore tests that hang in new solverMichael Goulet-7/+13
2023-06-10expand: Change how `#![cfg(FALSE)]` behaves on crate rootVadim Petrochenkov-24/+42
Previously it removed all other attributes from the crate root. Now it removes only attributes below itself. So it becomes possible to configure some global crate properties even for fully unconfigured crates.
2023-06-09Auto merge of #112216 - est31:offset_of_deep_tuple, r=petrochenkovbors-18/+298
Support float-like tuple indices in offset_of!() Supports invocations like `offset_of!((((), ()), ()), 0.0)`. This `0.0` gets tokenized as float literal, so it has to be broken up again. The code that did the breaking up was returning a finished `Expr`, while we need a `Ident`, so this PR splits up the `parse_expr_tuple_field_access_float` function into: * a function that breaks up the float literal (similar to `TokenKind::break_two_token_op`, but we do access the parser during this splitting operation, so we keep it as an inherent function on the parser) * and a function that constructs an `Expr` from it The former we can then re-use in `offset_of` parsing. The edge cases especially involving whitespaces are tricky so this adds a bunch of new tests as well. fixes #112204
2023-06-10Make "consider importing" consistent for macrosMu001999-21/+40
2023-06-09Auto merge of #112465 - GuillaumeGomez:rollup-gyh5buc, r=GuillaumeGomezbors-0/+90
Rollup of 3 pull requests Successful merges: - #112260 (Improve document of `unsafe_code` lint) - #112429 ([rustdoc] List matching impls on type aliases) - #112442 (Deduplicate identical region constraints in new solver) r? `@ghost` `@rustbot` modify labels: rollup
2023-06-09Update rustdoc-js* formatGuillaume Gomez-400/+236
2023-06-09Rollup merge of #112442 - ↵Guillaume Gomez-0/+31
compiler-errors:next-solver-deduplicate-region-constraints, r=lcnr Deduplicate identical region constraints in new solver the new solver doesn't track whether we've already proven a goal like the fulfillment context's obligation forest does, so we may be instantiating a canonical response (and specifically, its nested region obligations) quite a few times. This may lead to exponentially gathering up identical region constraints for things like auto traits, so let's deduplicate region constraints when in `compute_external_query_constraints`. r? ``@lcnr``
2023-06-09Rollup merge of #112429 - GuillaumeGomez:ty-alias-impls, r=notriddle,lcnrGuillaume Gomez-0/+59
[rustdoc] List matching impls on type aliases Fixes #32077. Thanks a lot to ``@lcnr`` who helped me a lot with this fix! cc ``@notriddle`` r? ``@lcnr``
2023-06-09Auto merge of #111530 - Urgau:uplift_undropped_manually_drops, r=compiler-errorsbors-0/+61
Uplift `clippy::undropped_manually_drops` lint This PR aims at uplifting the `clippy::undropped_manually_drops` lint. ## `undropped_manually_drops` (warn-by-default) The `undropped_manually_drops` lint check for calls to `std::mem::drop` with a value of `std::mem::ManuallyDrop` which doesn't drop. ### Example ```rust struct S; drop(std::mem::ManuallyDrop::new(S)); ``` ### Explanation `ManuallyDrop` does not drop it's inner value so calling `std::mem::drop` will not drop the inner value of the `ManuallyDrop` either. ----- Mostly followed the instructions for uplifting an clippy lint described here: https://github.com/rust-lang/rust/pull/99696#pullrequestreview-1134072751 `@rustbot` label: +I-lang-nominated r? compiler ----- For Clippy: changelog: Moves: Uplifted `clippy::undropped_manually_drops` into rustc
2023-06-09Auto merge of #111626 - pjhades:output, r=b-naberbors-5/+85
Write to stdout if `-` is given as output file With this PR, if `-o -` or `--emit KIND=-` is provided, output will be written to stdout instead. Binary output (those of type `obj`, `llvm-bc`, `link` and `metadata`) being written this way will result in an error unless stdout is not a tty. Multiple output types going to stdout will trigger an error too, as they will all be mixded together. This implements https://github.com/rust-lang/compiler-team/issues/431 The idea behind the changes is to introduce an `OutFileName` enum that represents the output - be it a real path or stdout - and to use this enum along the code paths that handle different output types.
2023-06-09Add regression test for #32077Guillaume Gomez-0/+59
2023-06-09Auto merge of #112450 - matthiaskrgr:rollup-fdbazkr, r=matthiaskrgrbors-9/+22
Rollup of 5 pull requests Successful merges: - #112323 (Don't mention already-set fields in struct constructor missing field error) - #112395 (Add Terminator::InlineAsm conversion from MIR to SMIR) - #112411 (add programmerjake to portable-simd cc list) - #112428 (Structurally resolve pointee in `check_pat_lit`) - #112444 (Don't debug-print `Interned` or `PrivateZst`) r? `@ghost` `@rustbot` modify labels: rollup
2023-06-09Rollup merge of #112428 - compiler-errors:next-solver-struct-resolv-pat, r=lcnrMatthias Krüger-0/+11
Structurally resolve pointee in `check_pat_lit` Gotta make sure to eager norm the pointee of the match scrutinee with the new solver. r? ``@lcnr``
2023-06-09Rollup merge of #112323 - compiler-errors:dont-mention-set-fields, ↵Matthias Krüger-9/+11
r=WaffleLapkin Don't mention already-set fields in struct constructor missing field error Fixes #111149
2023-06-09Auto merge of #112116 - compiler-errors:misc-hir-typeck-mismatch-tweaks, ↵bors-29/+92
r=WaffleLapkin Misc HIR typeck type mismatch tweaks These are all intended to improve #112104, but I couldn't get it to actually suggest adding `as_ref` to the LHS of the equality expr without some hacks that I may play around with some more. Each commit's title should explain what it's doing except for perhaps the last one, which addresses the bogus suggestion on #112104 itself.
2023-06-09Add help for trying to do C-like pointer arithmetics许杰友 Jieyou Xu (Joe)-0/+74