about summary refs log tree commit diff
path: root/tests/ui
AgeCommit message (Collapse)AuthorLines
2023-05-12Auto merge of #109732 - Urgau:uplift_drop_forget_ref_lints, r=davidtwcobors-64/+829
Uplift `clippy::{drop,forget}_{ref,copy}` lints This PR aims at uplifting the `clippy::drop_ref`, `clippy::drop_copy`, `clippy::forget_ref` and `clippy::forget_copy` lints. Those lints are/were declared in the correctness category of clippy because they lint on useless and most probably is not what the developer wanted. ## `drop_ref` and `forget_ref` The `drop_ref` and `forget_ref` lint checks for calls to `std::mem::drop` or `std::mem::forget` with a reference instead of an owned value. ### Example ```rust let mut lock_guard = mutex.lock(); std::mem::drop(&lock_guard) // Should have been drop(lock_guard), mutex // still locked operation_that_requires_mutex_to_be_unlocked(); ``` ### Explanation Calling `drop` or `forget` on a reference will only drop the reference itself, which is a no-op. It will not call the `drop` or `forget` method on the underlying referenced value, which is likely what was intended. ## `drop_copy` and `forget_copy` The `drop_copy` and `forget_copy` lint checks for calls to `std::mem::forget` or `std::mem::drop` with a value that derives the Copy trait. ### Example ```rust let x: i32 = 42; // i32 implements Copy std::mem::forget(x) // A copy of x is passed to the function, leaving the // original unaffected ``` ### Explanation Calling `std::mem::forget` [does nothing for types that implement Copy](https://doc.rust-lang.org/std/mem/fn.drop.html) since the value will be copied and moved into the function on invocation. ----- Followed the instructions for uplift a clippy describe here: https://github.com/rust-lang/rust/pull/99696#pullrequestreview-1134072751 cc `@m-ou-se` (as T-libs-api leader because the uplifting was discussed in a recent meeting)
2023-05-12Auto merge of #111493 - matthiaskrgr:rollup-iw1z59b, r=matthiaskrgrbors-1/+19
Rollup of 6 pull requests Successful merges: - #111179 (Fix instrument-coverage tests by using Python to sort instantiation groups) - #111393 (bump windows crate 0.46 -> 0.48) - #111441 (Verify copies of mutable pointers in 2 stages in ReferencePropagation) - #111456 (Update cargo) - #111490 (Don't ICE in layout computation for placeholder types) - #111492 (use by ref TokenTree iterator to avoid a few clones) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-05-12Rollup merge of #111490 - compiler-errors:layout-placeholder, r=aliemjayMatthias Krüger-1/+19
Don't ICE in layout computation for placeholder types We use `layout_of` for the built-in `PointerLike` trait to check if a type can be coerced to a `dyn*`. Since the new solver canonicalizes parameter types to placeholders, that code needs to be able to treat placeholders like params, and for the most part it does, **except** for a call to `is_trivially_sized`. This PR fixes that.
2023-05-12Auto merge of #111489 - compiler-errors:rollup-g3vgzss, r=compiler-errorsbors-0/+180
Rollup of 7 pull requests Successful merges: - #106038 (use implied bounds when checking opaque types) - #111366 (Make `NonUseContext::AscribeUserTy` carry `ty::Variance`) - #111375 (CFI: Fix SIGILL reached via trait objects) - #111439 (Fix backtrace normalization in ice-bug-report-url.rs) - #111444 (Only warn single-use lifetime when the binders match.) - #111459 (Update browser-ui-test version to 0.16.0) - #111460 (Improve suggestion for `self: Box<self>`) Failed merges: - #110454 (Require impl Trait in associated types to appear in method signatures) r? `@ghost` `@rustbot` modify labels: rollup
2023-05-12Don't ICE in layout computation for placeholder typesMichael Goulet-1/+19
2023-05-11Rollup merge of #111460 - clubby789:lowercase-box-self, r=compiler-errorsMichael Goulet-0/+16
Improve suggestion for `self: Box<self>` Fixes #110642
2023-05-11Rollup merge of #111444 - cjgillot:issue-111400, r=oli-obkMichael Goulet-0/+1
Only warn single-use lifetime when the binders match. Fixes https://github.com/rust-lang/rust/issues/111400
2023-05-11Rollup merge of #106038 - aliemjay:opaque-implied, r=lcnrMichael Goulet-0/+163
use implied bounds when checking opaque types During opaque type inference, we check for the well-formedness of the hidden type in the opaque type's own environment, not the one of the defining site, which are different in the case of TAIT. However in the case of associated-type-impl-trait, we don't use implied bounds from the impl header. This caused us to reject the following: ```rust trait Service<Req> { type Output; fn call(req: Req) -> Self::Output; } impl<'a, Req> Service<&'a Req> for u8 { type Output= impl Sized; // we can't prove WF of hidden type `WF(&'a Req)` although it's implied by the impl //~^ ERROR type parameter Req doesn't live long enough fn call(req: &'a Req) -> Self::Output { req } } ``` although adding an explicit bound would make it pass: ```diff - impl<'a, Req> Service<&'a Req> for u8 { + impl<'a, Req> Service<&'a Req> for u8 where Req: 'a, { ``` I believe it should pass as we already allow the concrete type to be used: ```diff impl<'a, Req> Service<&'a Req> for u8 { - type Output= impl Sized; + type Output= &'a Req; ``` Fixes #95922 Builds on #105982 cc ``@lcnr`` (because implied bounds) r? ``@oli-obk``
2023-05-11Bless tests for portable-simd syncJubilee Young-1/+1
API changes resulted in subtle MIR and impl differences
2023-05-11Improve error for `self: Box<self>`clubby789-0/+16
2023-05-11Rollup merge of #111292 - Urgau:check-cfg-issue-111291, r=petrochenkovMatthias Krüger-0/+54
Fix mishandled `--check-cfg` arguments order This PR fixes a bug in `--check-cfg` where the order of `--check-cfg=names(a)` and `--check-cfg=values(a,…)` would trip the compiler. Fixes https://github.com/rust-lang/rust/issues/111291 cc `@taiki-e` `@petrochenkov`
2023-05-11Rollup merge of #108705 - clubby789:refutable-let-closure-borrow, r=cjgillotMatthias Krüger-0/+136
Prevent ICE with broken borrow in closure r? `@Nilstrieb` Fixes #108683 This solution isn't ideal, I'm hoping to find a way to continue compilation without ICEing.
2023-05-10Only warn single-use lifetime when the binders match.Camille GILLOT-0/+1
2023-05-10Add note to suggest using `let _ = x` to ignore the valueUrgau-0/+72
2023-05-10Improve warning message by saying that it "does nothing"Urgau-39/+39
2023-05-10Use label instead of note to be more consistent with other lintsUrgau-267/+117
2023-05-10Adjust tests for new drop and forget lintsUrgau-64/+136
2023-05-10Uplift clippy::forget_copy to rustcUrgau-0/+160
2023-05-10Uplift clippy::forget_ref to rustcUrgau-0/+154
2023-05-10Uplift clippy::drop_copy to rustcUrgau-0/+207
2023-05-10Uplift clippy::drop_ref to rustcUrgau-0/+250
2023-05-10Rollup merge of #110673 - compiler-errors:alias-bounds-2, r=lcnrMatthias Krüger-0/+71
Make alias bounds sound in the new solver (take 2) Make alias bounds sound in the new solver (in a way that does not require coinduction) by only considering them for projection types whose corresponding trait refs come from a param-env candidate. That is, given `<T as Trait>::Assoc: Bound`, we only *really* need to consider the alias bound if `T: Trait` is satisfied via a param-env candidate. If it's instead satisfied, e.g., via an user provided impl candidate or a , then that impl should have a concrete type to which we could otherwise normalize `<T as Trait>::Assoc`, and that concrete type is then responsible to prove the `Bound` on it. Similar consideration is given to opaque types, since we only need to consider alias bounds if we're *not* in reveal-all mode, since similarly we'd be able to reveal the opaque types and prove any bounds that way. This does not remove that hacky "eager projection replacement" logic from object bounds, which are somewhat like alias bounds. But removing this eager normalization behavior (added in #108333) would require full coinduction to be enabled. Compare to #110628, which does remove this object-bound custom logic but requires coinduction to be sound. r? `@lcnr`
2023-05-09Make alias bounds sound in the new solverMichael Goulet-0/+71
2023-05-09Rollup merge of #111215 - BoxyUwU:resolve_anon_consts_differently, r=cjgillotMatthias Krüger-416/+459
Various changes to name resolution of anon consts Sorry this PR is kind of all over the place ^^' Fixes #111012 - Rewrites anon const nameres to all go through `fn resolve_anon_const` explicitly instead of `visit_anon_const` to ensure that we do not accidentally resolve anon consts as if they are allowed to use generics when they aren't. Also means that we dont have bits of code for resolving anon consts that will get out of sync (i.e. legacy const generics and resolving path consts that were parsed as type arguments) - Renames two of the `LifetimeRibKind`, `AnonConst -> ConcreteAnonConst` and `ConstGeneric -> ConstParamTy` - Noticed while doing this that under `generic_const_exprs` all lifetimes currently get resolved to errors without any error being emitted which was causing a bunch of tests to pass without their bugs having been fixed, incidentally fixed that in this PR and marked those tests as `// known-bug:`. I'm fine to break those since `generic_const_exprs` is a very unstable incomplete feature and this PR _does_ make generic_const_exprs "less broken" as a whole, also I can't be assed to figure out what the underlying causes of all of them are. This PR reopens #77357 #83993 - Changed `generics_of` to stop providing generics and predicates to enum variant discriminant anon consts since those are not allowed to use generic parameters - Updated the error for non 'static lifetime in const arguments and the error for non 'static lifetime in const param tys to use `derive(Diagnostic)` I have a vague idea why const-arg-in-const-arg.rs, in-closure.rs and simple.rs have started failing which is unfortunate since these were deliberately made to work, I think lifetime resolution being broken just means this regressed at some point and nobody noticed because the tests were not testing anything :( I'm fine breaking these too for the same reason as the tests for #77357 #83993. I couldn't get `// known-bug` to work for these ICEs and just kept getting different stderr between CI and local `--bless` so I just removed them and will create an issue to track re-adding (and fixing) the bugs if this PR lands. r? `@cjgillot` cc `@compiler-errors`
2023-05-09Rollup merge of #111021 - c410-f3r:dqewdas, r=petrochenkovMatthias Krüger-17/+0
Move some tests r? ``@petrochenkov``
2023-05-09Rollup merge of #97320 - usbalbin:stabilize_const_ptr_read, r=m-ou-seMatthias Krüger-31/+26
Stabilize const_ptr_read Stabilizes const_ptr_read, with tracking issue #80377
2023-05-09Auto merge of #111371 - compiler-errors:revert-110907, r=petrochenkovbors-0/+33
Revert "Populate effective visibilities in `rustc_privacy`" This reverts commit cff85f22f5030fbe7266d272da74a9e76160523c, cc #110907. It needs to be fixed, but there are too many issues being reported that I wanted to put up a revert until a proper fix can be committed. Fixes a ton of issues where private but still reachable impls were missing during codegen: Fixes #111320 Fixes #111321 Fixes #111334 Fixes #111357 Fixes #111368 Fixes #111373 Fixes #111377 Fixes #111386 Fixes #111387 `@bors` p=1 r? `@petrochenkov`
2023-05-09Rollup merge of #111252 - matthewjasper:min-spec-improvements, r=compiler-errorsDylan DPC-20/+243
Min specialization improvements - Don't allow specialization impls with no items, such implementations are probably not correct and only occur as mistakes in the compiler and standard library - Fix a missing normalization call - Adds spans for lifetime errors from overly general specializations Closes #79457 Closes #109815
2023-05-09Rollup merge of #111120 - chenyukang:yukang-suggest-let, r=NilstriebDylan DPC-2/+73
Suggest let for possible binding with ty Origin from https://github.com/rust-lang/rust/pull/109128#discussion_r1179866137 r? `@Nilstrieb`
2023-05-09Rollup merge of #110694 - est31:builtin, r=petrochenkovDylan DPC-13/+219
Implement builtin # syntax and use it for offset_of!(...) Add `builtin #` syntax to the parser, as well as a generic infrastructure to support both item and expression position builtin syntaxes. The PR also uses this infrastructure for the implementation of the `offset_of!` macro, added by #106934. cc `@petrochenkov` `@DrMeepster` cc #110680 `builtin #` tracking issue cc #106655 `offset_of!` tracking issue
2023-05-09Rollup merge of #110583 - Ezrashaw:tweak-make-mut-spans, r=estebankDylan DPC-78/+74
tweak "make mut" spans when assigning to locals Work towards fixing #106857 This PR just cleans up a lot of spans which is helpful before properly fixing the issues. Best reviewed commit-by-commit. r? `@estebank`
2023-05-09Rollup merge of #110504 - compiler-errors:tweak-borrow-sugg, r=cjgillotDylan DPC-286/+416
Tweak borrow suggestion span Avoids a `span_to_snippet` call when we don't need to surround the expression in parentheses. The fact that the suggestion was using the whole span of the expression rather than just appending a `&` was prevented me from using `// run-rustfix` in another PR (https://github.com/rust-lang/rust/pull/110432#discussion_r1170500484). Also some drive-by renames of functions that have been annoying me for a bit.
2023-05-08test for reachable private implMichael Goulet-0/+33
2023-05-08Move testsCaio-17/+0
2023-05-08Rollup merge of #111118 - chenyukang:yukang-sugg-struct, r=compiler-errorsMichael Goulet-5/+28
Suggest struct when we get colon in fileds in enum A follow-up fix for https://github.com/rust-lang/rust/pull/109128 From: https://github.com/rust-lang/rust/pull/109128#discussion_r1179304932 r? `@estebank`
2023-05-08Rollup merge of #109410 - fmease:iat-alias-kind-inherent, r=compiler-errorsMichael Goulet-67/+673
Introduce `AliasKind::Inherent` for inherent associated types Allows us to check (possibly generic) inherent associated types for well-formedness. Type inference now also works properly. Follow-up to #105961. Supersedes #108430. Fixes #106722. Fixes #108957. Fixes #109768. Fixes #109789. Fixes #109790. ~Not to be merged before #108860 (`AliasKind::Weak`).~ CC `@jackh726` r? `@compiler-errors` `@rustbot` label T-types F-inherent_associated_types
2023-05-08Rollup merge of #111211 - compiler-errors:negative-bounds-super, r=TaKO8KiYuki Okushi-0/+19
Don't compute trait super bounds unless they're positive Fixes #111207 The comment is modified to explain the rationale for why we even have this recursive call to supertraits in the first place, which doesn't apply to negative bounds since they don't elaborate at all.
2023-05-08Rollup merge of #105354 - BlackHoleFox:apple-deployment-printer, r=oli-obkYuki Okushi-0/+14
Add deployment-target --print flag for Apple targets This is very useful for crates that need to know what the Apple OS deployment target is for their build scripts or inside of a build environment. Right now, the defaults just get copy/pasted around the ecosystem since they've been stable for so long. But with #104385 in progress, that won't be true anymore and everything will need to move. Ideally whenever it happens again, this could be less painful as everything can ask the compiler what its default is instead. To show examples of the copy/paste proliferation, here's some crates and/or apps that do: - [cc](https://github.com/rust-lang/cc-rs/pull/708/files), Soon - [mac-notification-sys](https://github.com/h4llow3En/mac-notification-sys/pull/46/files#diff-d0d98998092552a1d3259338c2c71e118a5b8343dd4703c0c7f552ada7f9cb42R10-R12) - [PyO3](https://github.com/PyO3/maturin/blob/ccb02d1aa1cc41e82a3572a3c8b35cace15f3e78/src/target.rs#L755-L758) - [Anki](https://github.com/ankitects/anki/blob/613b5c1034cc9943f3f68d818ae22b2e0acec877/build/runner/src/bundle/artifacts.rs#L49-L54) - [jsc-rs](https://github.com/Brooooooklyn/jsc-rs/blob/37767267568fb2de62fc441473e7d158dd980520/xtask/src/build.rs#L402-L405) ... and probably more that a simple GitHub codesearch didn't see
2023-05-08suggest struct when we get colon in fileds in enumyukang-5/+28
2023-05-08code refactor and fix wrong suggestionyukang-0/+15
2023-05-08Rollup merge of #111262 - ChrisDenton:normalize-msvc-output, r=cjgillotDylan DPC-10/+3
Further normalize msvc-non-utf8-ouput Fixes #111256 by normalizing this tests down to the essential part so that it only tests for the Unicode output we expect. Also uses a file name that should never occur outside of this test.
2023-05-08Rollup merge of #111056 - JohnBobbo96:fix_box_suggestions, r=compiler-errorsDylan DPC-0/+103
Fix some suggestions where a `Box<T>` is expected. This fixes #111011, and also adds a suggestion for boxing a unit type when a `Box<T>` was expected and an empty block was found.
2023-05-08Rollup merge of #110827 - compiler-errors:issue-110761-followup, r=cjgillotDylan DPC-0/+54
Fix lifetime suggestion for type aliases with objects in them Fixes an issue identified in https://github.com/rust-lang/rust/issues/110761#issuecomment-1520678479 This suggestion, like many other borrowck suggestions, are very fragile and there are other ways to trigger strange behavior even after this PR, so this is just a small improvement and not a total rework :skull:
2023-05-08Make suggest_deref_or_ref return a multipart suggestionMichael Goulet-114/+170
2023-05-08Tweak borrow suggestionMichael Goulet-172/+246
2023-05-07Fix suggestion for boxing an async closure body, andJohn Bobbo-0/+103
also add a suggestion for boxing empty blocks.
2023-05-08fix ice in suggestingyukang-0/+15
2023-05-08Suggest let for possible binding with tyyukang-2/+43
2023-05-08Auto merge of #111309 - saethlin:InstSimplify, r=scottmcmbors-1/+1
Rename InstCombine to InstSimplify ``` ╭ ➜ ben@archlinux:~/rust ╰ ➤ rg -i instcombine src/doc/rustc-dev-guide/src/mir/optimizations.md 134:may have been misapplied. Examples of this are `InstCombine` and `ConstantPropagation`. src/ci/docker/host-x86_64/disabled/dist-x86_64-haiku/llvm-config.sh 38: instcombine instrumentation interpreter ipo irreader lanai \ tests/codegen/slice_as_from_ptr_range.rs 4:// min-llvm-version: 15.0 (because this is a relatively new instcombine) ``` r? `@scottmcm`
2023-05-07Auto merge of #111161 - compiler-errors:rtn-super, r=cjgillotbors-2/+89
Support return-type bounds on associated methods from supertraits Support `T: Trait<method(): Bound>` when `method` comes from a supertrait, aligning it with the behavior of associated type bounds (both equality and trait bounds). The only wrinkle is that I have to extend `super_predicates_that_define_assoc_type` to look for *all* items, not just `AssocKind::Ty`. This will also be needed to support `feature(associated_const_equality)` as well, which is subtly broken when it comes to supertraits, though this PR does not fix those yet. There's a slight chance there's a perf regression here, in which case I guess I could split it out into a separate query.