about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2023-02-10Multiple candidates with same response is not ambiguousMichael Goulet-12/+1
2023-02-09Rollup merge of #107815 - compiler-errors:new-solver-no-auto-if-impl, r=lcnrDylan DPC-0/+8
Disqualify `auto trait` built-in impl in new solver if explicit `impl` exists
2023-02-09Rollup merge of #107803 - ↵Dylan DPC-0/+21
eggyal:do_not_bring_trait_alias_supertraits_into_scope, r=compiler-errors Do not bring trait alias supertraits into scope Fixes #107747 cc #41517
2023-02-09Rollup merge of #107786 - compiler-errors:new-solver-some-tweaks, r=lcnrDylan DPC-9/+44
Implement some tweaks in the new solver I've been testing the new solver on some small codebases, and these are a few small changes I've needed to make. The most "controversial" here is implementing `trait_candidate_should_be_dropped_in_favor_of`, which I just implemented to always return false. This surprisingly allows some code to compile, without us having to actually decide on any semantics yet. r? `@rust-lang/initiative-trait-system-refactor`
2023-02-09Rollup merge of #107659 - bvanjoi:issue-107649, r=estebankDylan DPC-0/+124
test: snapshot for derive suggestion in diff files fixed #107649
2023-02-09Rollup merge of #107655 - notriddle:notriddle/small-url-encode, r=GuillaumeGomezDylan DPC-14/+14
rustdoc: use the same URL escape rules for fragments as for examples Carries over improvements from #107284
2023-02-09Rollup merge of #107648 - matthiaskrgr:unused_lifetime_104432_fix, r=cjgillotDylan DPC-0/+12
unused-lifetimes: don't warn about lifetimes originating from expanded code previously, we would warn like this: ```` warning: lifetime parameter `'s` never used --> /tmp/unusedlif/code.rs:6:62 | 5 | #[derive(Clone)] | - help: elide the unused lifetime 6 | struct ShimMethod4<T: Trait2 + 'static>(pub &'static dyn for<'s> Fn(&'s mut T::As)); | ^^ | = note: requested on the command line with `-W unused-lifetimes` ```` Fixes #104432
2023-02-09Disqualify auto-trait builtin impl in new solver if impl existsMichael Goulet-0/+8
2023-02-09Implement a dummy drop-in-favor-of for the new solverMichael Goulet-9/+32
2023-02-09Use elaborated item bounds for alias typesMichael Goulet-0/+12
2023-02-09test: snapshot for derive suggestion in diff filesbohan-0/+124
2023-02-09Rollup merge of #107446 - clubby789:rustc-parse-diag-migrate, r=compiler-errorsMatthias Krüger-0/+14
Migrate some of `rustc_parse` to derive diagnostics `@rustbot` label +A-translation r? rust-lang/diagnostics cc #100717
2023-02-09Auto merge of #106938 - GuillaumeGomez:normalize-projection-field-ty, r=oli-obkbors-0/+80
Add missing normalization for union fields types Overshadows https://github.com/rust-lang/rust/pull/106808. From the experiment https://github.com/rust-lang/rust/pull/103985. In short, it allows to use projections as a type for union's fields. cc `@compiler-errors` r? `@oli-obk`
2023-02-08Rollup merge of #107813 - compiler-errors:bad-impl-trait-in-macro-is-ok, ↵Michael Goulet-0/+32
r=estebank Do not eagerly recover for bad `impl Trait` types in macros Fixes #107796 cc #106712, ```@estebank``` and ```@Ezrashaw``` please make sure to use [`Parser::may_recover`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_parse/parser/struct.Parser.html#method.may_recover) for all eager-token-consuming parser recoveries. This also fixes a separate regression from #99915, that was introduced before we added `may_recover` though.
2023-02-08Rollup merge of #107799 - lcnr:update-provisional-result, r=oli-obkMichael Goulet-0/+43
correctly update goals in the cache we may want to actually write the response for our goal into the provisional or global cache instead of simply using the result from the last iteration '^^ r? ```@rust-lang/initiative-trait-system-refactor```
2023-02-08Rollup merge of #107761 - oli-obk:miri_🪵, r=TaKO8KiMichael Goulet-3/+2
Replace a command line flag with an env var to allow tools to initialize the tracing loggers at their own discretion fixes https://github.com/rust-lang/miri/issues/2778 this was introduced in https://github.com/rust-lang/rust/pull/104645, so this PR reverts the flag-part and uses an env var instead.
2023-02-09Extend `BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE`.Nicholas Nethercote-1/+41
To temporarily allow a `str` field in a packed struct using `derive`, along with `[u8]`.
2023-02-08Do not assemble supertraits for trait aliasesAlan Egerton-0/+21
2023-02-08add (currently ICEing) testlcnr-0/+43
2023-02-08Do not eagerly recover for bad impl-trait in macrosMichael Goulet-0/+32
2023-02-08Rollup merge of #107777 - ↵Matthias Krüger-3/+24
compiler-errors:derive_const-actually-derive-const, r=fee1-dead Make `derive_const` derive properly const-if-const impls Fixes #107774 Fixes #107666 Also fixes rendering of const-if-const bounds in pretty printing. r? ```@oli-obk``` or ```@fee1-dead```
2023-02-08Rollup merge of #107779 - compiler-errors:issue-107775, r=jackh726Matthias Krüger-0/+56
Remove astconv usage in diagnostic Fixes #107775 Location of the test sucks, I know, but I needed to put it somewhere :sweat: The issue here is that the root cause of the issue has nothing to do with what's being tested, so I couldn't really give it a better name. Oh well.
2023-02-08Rollup merge of #107771 - estebank:ice-msg, r=compiler-errorsMatthias Krüger-13/+8
Tweak ICE message Modify main message to be more conversational and emit one fewer note.
2023-02-08Rollup merge of #107770 - notriddle:notriddle/br2nl, r=GuillaumeGomezMatthias Krüger-22/+47
rustdoc: use a newline instead of `<br>` to format code headers Since these elements now use `white-space: pre-wrap` since #107615, it's fine to use newlines for formatting, which is smaller and a bit less complicated.
2023-02-08Rollup merge of #107769 - compiler-errors:pointer-like, r=eholkMatthias Krüger-53/+55
Rename `PointerSized` to `PointerLike` The old name was unnecessarily vague. This PR renames a nightly language feature that I added, so I don't think it needs any additional approval, though anyone can feel free to speak up if you dislike the rename. It's still unsatisfying that we don't the user which of {size, alignment} is wrong, but this trait really is just a stepping stone for a more generalized mechanism to create `dyn*`, just meant for nightly testing, so I don't think it really deserves additional diagnostic machinery for now. Fixes #107696, cc ``@RalfJung`` r? ``@eholk``
2023-02-08Auto merge of #107688 - lukas-code:projection-with-lifetime, r=jackh726bors-1/+65
ReErased regions are local fix https://github.com/rust-lang/rust/issues/107678 fix https://github.com/rust-lang/rust/issues/107684 fix https://github.com/rust-lang/rust/issues/107686 fix https://github.com/rust-lang/rust/issues/107691 fix https://github.com/rust-lang/rust/issues/107730
2023-02-07Remove astconv usage in diagnosticMichael Goulet-0/+56
2023-02-07Add ~const bounds trait bounds when using derive_constMichael Goulet-0/+13
2023-02-07Expand const-if-const trait bounds correctlyMichael Goulet-3/+11
2023-02-07Tweak ICE messageEsteban Küber-13/+8
Modify main message to be more conversational and emit one fewer note.
2023-02-07Rename PointerSized to PointerLikeMichael Goulet-53/+55
2023-02-07rustdoc: use a newline instead of `<br>` to format code headersMichael Howell-22/+47
Since these elements now use `white-space: pre-wrap` since 784665d4ce59c5239791f1f96fa2137e47ca1817, it's fine to use newlines for formatting, which is smaller and a bit less complicated.
2023-02-07Auto merge of #107767 - matthiaskrgr:rollup-9m1qfso, r=matthiaskrgrbors-16/+344
Rollup of 8 pull requests Successful merges: - #100599 (Add compiler error E0523 long description and test) - #107471 (rustdoc: do not include empty default-settings tag in HTML) - #107555 (Modify existing bounds if they exist) - #107662 (Turn projections into copies in CopyProp.) - #107695 (Add test for Future inflating arg size to 3x ) - #107700 (Run the tools builder on all PRs) - #107706 (Mark 'atomic_mut_ptr' methods const) - #107709 (Fix problem noticed in PR106859 with char -> u8 suggestion) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-02-07Rollup merge of #107709 - tialaramex:master, r=compiler-errorsMatthias Krüger-2/+55
Fix problem noticed in PR106859 with char -> u8 suggestion HN reader `@ayosec` noticed that my #106859 a few weeks back, malfunctions if you have a Unicode escape, the code suggested b'\u{0}' if you tried to use '\u{0}' where a byte should be, when of course b'\u{0}' is not a byte literal, regardless of the codepoint you can't write Unicode escapes in a byte literal at all. My proposed fix here just checks that the "character" you wrote is fewer than 5 bytes, thus allowing \x7F and similar escapes but conveniently forbidding even the smallest Unicode escape \u{0} before offering the suggestion as before. I have provided an updated test which includes examples which do and don't work because of this additional rule.
2023-02-07Rollup merge of #107695 - Swatinem:futcallx3, r=compiler-errorsMatthias Krüger-0/+96
Add test for Future inflating arg size to 3x This adds one more test that should track improvements to generator layout, like https://github.com/rust-lang/rust/issues/62958 and https://github.com/rust-lang/rust/issues/62575. In particular, this test highlights suboptimal layout, as the storage for the argument future is not being reused across its usage as `upvar`, `local` and `awaitee` (being polled to completion). This is on top of https://github.com/rust-lang/rust/pull/107692 (as those would conflict with each other) It is a minimal repro for code mentioned in https://github.com/moka-rs/moka/issues/212#issuecomment-1416914616 (CC `@tatsuya6502)`
2023-02-07Rollup merge of #107662 - cjgillot:copy-projection, r=oli-obkMatthias Krüger-1/+66
Turn projections into copies in CopyProp. The current implementation can leave behind projections that are moved out several times. This PR widens the check to turn such moves into copies: a move out of a projection of a copy is equivalent to a copy of the original projection.
2023-02-07Rollup merge of #107555 - edward-shen:edward-shen/dup-trait-suggestion, ↵Matthias Krüger-13/+100
r=compiler-errors Modify existing bounds if they exist Fixes #107335. This implementation is kinda gross but I don't really see a better way to do it. This primarily does two things: Modifies `suggest_constraining_type_param` to accept a new parameter that indicates a span to be replaced instead of added, if presented, and limit the additive suggestions to either suggest a new bound on an existing bound (see newly added unit test) or add the generics argument if a generics argument wasn't found. The former change is required to retain the capability to add an entirely new bounds if it was entirely omitted. r? ``@compiler-errors``
2023-02-07Rollup merge of #100599 - MatthewPeterKelly:add-E0523-description-and-test, ↵Matthias Krüger-0/+27
r=compiler-errors,GuillaumeGomez Add compiler error E0523 long description and test This PR is one step towards addressing: https://github.com/rust-lang/rust/issues/61137.
2023-02-07Replace a command line flag with an env var to allow tools to initialize the ↵Oli Scherer-3/+2
tracing loggers at their own discretion
2023-02-07Auto merge of #107671 - CastilloDel:master, r=estebankbors-0/+79
Fix suggestions rendering when the diff span is multiline Fixes #92741 cc `@estebank` I think, I finally fixed. I still want to go back and try to clean up the code a bit. I'm open to suggestions. Some examples of the new suggestions: ``` help: consider removing the borrow | 2 - & | ``` ``` help: consider removing the borrow | 2 - & 3 - mut | ``` ``` help: consider removing the borrow | 2 - & 3 - mut if true { true } else { false } 2 + if true { true } else { false } | ``` Should we add a test to ensure this behavior doesn't disappear in the future?
2023-02-07Add test for Future inflating arg size to 3xArpad Borsos-0/+96
This adds one more test that should track improvements to generator layout, like #62958 and #62575. In particular, this test highlights suboptimal layout, as the storage for the argument future is not being reused across its usage as `upvar`, `local` and `awaitee` (being polled to completion).
2023-02-07Auto merge of #106180 - RalfJung:dereferenceable-generators, r=nbdd0121bors-3/+29
make &mut !Unpin not dereferenceable, and Box<!Unpin> not noalias See https://github.com/rust-lang/unsafe-code-guidelines/issues/381 and [this LLVM discussion](https://discourse.llvm.org/t/interaction-of-noalias-and-dereferenceable/66979). The exact semantics of how `noalias` and `dereferenceable` interact are unclear, and `@comex` found a case of LLVM actually exploiting that ambiguity for optimizations. I think for now we should treat LLVM `dereferenceable` as implying a "fake read" to happen immediately at the top of the function (standing in for the spurious reads that LLVM might introduce), and that fake read is subject to all the usual `noalias` restrictions. This means we cannot put `dereferenceable` on `&mut !Unpin` references as those references can alias with other references that are being read and written inside the function (e.g. for self-referential generators), meaning the fake read introduces aliasing conflicts with those other accesses. For `&` this is already not a problem due to https://github.com/rust-lang/rust/pull/98017 which removed the `dereferenceable` attribute for other reasons. Regular `&mut Unpin` references are unaffected, so I hope the impact of this is going to be tiny. The first commit does some refactoring of the `PointerKind` enum since I found the old code very confusing each time I had to touch it. It doesn't change behavior. Fixes https://github.com/rust-lang/miri/issues/2714 EDIT: Turns out our `Box<!Unpin>` treatment was incorrect, too, so the PR also fixes that now (in codegen and Miri): we do not put `noalias` on these boxes any more.
2023-02-06Fix problem noticed in PR106859 with char -> u8 suggestionNick Lamb-2/+55
2023-02-06Rollup merge of #107692 - Swatinem:printsizeyield, r=compiler-errorsMatthias Krüger-10/+10
Sort Generator `print-type-sizes` according to their yield points Especially when trying to diagnose runaway future sizes, it might be more intuitive to sort the variants according to the control flow (aka their yield points) rather than the size of the variants.
2023-02-06Rollup merge of #106477 - ↵Matthias Krüger-14/+588
Nathan-Fenner:nathanf/refined-error-span-trait-impl, r=compiler-errors Refine error spans for "The trait bound `T: Trait` is not satisfied" when passing literal structs/tuples This PR adds a new heuristic which refines the error span reported for "`T: Trait` is not satisfied" errors, by "drilling down" into individual fields of structs/enums/tuples to point to the "problematic" value. Here's a self-contained example of the difference in error span: ```rs struct Burrito<Filling> { filling: Filling, } impl <Filling: Delicious> Delicious for Burrito<Filling> {} fn eat_delicious_food<Food: Delicious>(food: Food) {} fn will_type_error() { eat_delicious_food(Burrito { filling: Kale }); // ^~~~~~~~~~~~~~~~~~~~~~~~~ (before) The trait bound `Kale: Delicious` is not satisfied // ^~~~ (after) The trait bound `Kale: Delicious` is not satisfied } ``` (kale is fine, this is just a silly food-based example) Before this PR, the error span is identified as the entire argument to the generic function `eat_delicious_food`. However, since only `Kale` is the "problematic" part, we can point at it specifically. In particular, the primary error message itself mentions the missing `Kale: Delicious` trait bound, so it's much clearer if this part is called out explicitly. --- The _existing_ heuristic tries to label the right function argument in `point_at_arg_if_possible`. It goes something like this: - Look at the broken base trait `Food: Delicious` and find which generics it mentions (in this case, only `Food`) - Look at the parameter type definitions and find which of them mention `Filling` (in this case, only `food`) - If there is exactly one relevant parameter, label the corresponding argument with the error span, instead of the entire call This PR extends this heuristic by further refining the resulting expression span in the new `point_at_specific_expr_if_possible` function. For each `impl` in the (broken) chain, we apply the following strategy: The strategy to determine this span involves connecting information about our generic `impl` with information about our (struct) type and the (struct) literal expression: - Find the `impl` (`impl <Filling: Delicious> Delicious for Burrito<Filling>`) that links our obligation (`Kale: Delicious`) with the parent obligation (`Burrito<Kale>: Delicious`) - Find the "original" predicate constraint in the impl (`Filling: Delicious`) which produced our obligation. - Find all of the generics that are mentioned in the predicate (`Filling`). - Examine the `Self` type in the `impl`, and see which of its type argument(s) mention any of those generics. - Examing the definition for the `Self` type, and identify (for each of its variants) if there's a unique field which uses those generic arguments. - If there is a unique field mentioning the "blameable" arguments, use that field for the error span. Before we do any of this logic, we recursively call `point_at_specific_expr_if_possible` on the parent obligation. Hence we refine the `expr` "outwards-in" and bail at the first kind of expression/impl we don't recognize. This function returns a `Result<&Expr, &Expr>` - either way, it returns the `Expr` whose span should be reported as an error. If it is `Ok`, then it means it refined successfull. If it is `Err`, then it may be only a partial success - but it cannot be refined even further. --- I added a new test file which exercises this new behavior. A few existing tests were affected, since their error spans are now different. In one case, this leads to a different code suggestion for the autofix - although the new suggestion isn't _wrong_, it is different from what used to be. This change doesn't create any new errors or remove any existing ones, it just adjusts the spans where they're presented. --- Some considerations: right now, this check occurs in addition to some similar logic in `adjust_fulfillment_error_for_expr_obligation` function, which tidies up various kinds of error spans (not just trait-fulfillment error). It's possible that this new code would be better integrated into that function (or another one) - but I haven't looked into this yet. Although this code only occurs when there's a type error, it's definitely not as efficient as possible. In particular, there are definitely some cases where it degrades to quadratic performance (e.g. for a trait `impl` with 100+ generic parameters or 100 levels deep nesting of generic types). I'm not sure if these are realistic enough to worry about optimizing yet. There's also still a lot of repetition in some of the logic, where the behavior for different types (namely, `struct` vs `enum` variant) is _similar_ but not the same. --- I think the biggest win here is better targeting for tuples; in particular, if you're using tuples + traits to express variadic-like functions, the compiler can't tell you which part of a tuple has the wrong type, since the span will cover the entire argument. This change allows the individual field in the tuple to be highlighted, as in this example: ``` // NEW LL | want(Wrapper { value: (3, q) }); | ---- ^ the trait `T3` is not implemented for `Q` // OLD LL | want(Wrapper { value: (3, q) }); | ---- ^~~~~~~~~~~~~~~~~~~~~~~~~ the trait `T3` is not implemented for `Q` ``` Especially with large tuples, the existing error spans are not very effective at quickly narrowing down the source of the problem.
2023-02-06Modify existing bounds if they existEdward Shen-13/+100
2023-02-06Auto merge of #107727 - Dylan-DPC:rollup-b1yexcl, r=Dylan-DPCbors-133/+550
Rollup of 5 pull requests Successful merges: - #107553 (Suggest std::ptr::null if literal 0 is given to a raw pointer function argument) - #107580 (Recover from lifetimes with default lifetimes in generic args) - #107669 (rustdoc: combine duplicate rules in ayu CSS) - #107685 (Suggest adding a return type for async functions) - #107687 (Adapt SROA MIR opt for aggregated MIR) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-02-06Migrate `rustc_parse` to derive diagnosticsclubby789-0/+14
2023-02-06Add `run-rustfix` to tests/ui/issues/issue-92741.rsCastilloDel-15/+29
2023-02-06Add more test cases to tests/ui/issues/issue-92741.rsCastilloDel-1/+41