about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2022-06-09Use `multipart_suggestion` to create an applicable suggestion.Aaron Kofsky-4/+4
The "consider explicitly droping" can now suggest a machine applicable suggestion now.
2022-06-05Add diagnostic items to MutexGuard and RwLock GuardsAaron Kofsky-1/+1
I forgot to add the diagnostic to the actual types in `std` earlier.
2022-06-05Remove `let_underscore_must_use`Aaron Kofsky-46/+0
The `let_underscore_must_use` lint was really only added because clippy included it, but it doesn't actually seem very useful.
2022-06-04Use `check-pass` instead of `run-pass`Aaron Kofsky-2/+3
We don't actually care about running these programs, only checking the warnings they generate.
2022-06-04Move `let_underscore` tests into the `lint` subfolder.Aaron Kofsky-0/+0
2022-06-04Set `let_underscore_lock` to Deny by default.Aaron Kofsky-7/+5
Clippy sets this lint to Deny by default, and it having the lint be Deny is useful for when we test the lint against a Crater run.
2022-06-04Show code suggestions in `let_undescore` lint messages.Aaron Kofsky-8/+32
This commit uses `span_suggestion_verbose` to add what specific code changes can be done as suggested by the lint--in this case, either binding the expression to an unused variable or using `std::mem::drop` to drop the value explicitly.
2022-06-04Allow `let_underscore_drop` and `let_underscore_must_use` by default.Aaron Kofsky-5/+7
These lints are very noisy and are allow-by-default in clippy anyways. Hence, setting them to allow-by-default here makes more sense than warning constantly on these cases.
2022-06-04Move let_underscore tests to their own subfolder.Aaron Kofsky-0/+0
This was done to pass `tidy`.
2022-06-04 Add `let_underscore_must_use` lint.Aaron Kofsky-0/+33
Similar to `let_underscore_drop`, this lint checks for statements similar to `let _ = foo`, where `foo` is an expression marked `must_use`.
2022-06-04Add `let_underscore_lock` lint.Aaron Kofsky-0/+20
Similar to `let_underscore_drop`, this lint checks for statements similar to `let _ = foo`, where `foo` is a lock guard. These types of let statements are especially problematic because the lock gets released immediately, instead of at the end of the scope. This behavior is almost always the wrong thing.
2022-05-29Add `let_underscore_drop` lint.Aaron Kofsky-0/+25
This lint checks for statements similar to `let _ = foo`, where `foo` is a type that implements `Drop`. These types of let statements cause the expression in them to be dropped immediately, instead of at the end of the scope. Such behavior can be surprizing, especially if you are relying on the value to be dropped at the end of the scope. Instead, the binding should be an underscore prefixed name (like `_unused`) or the value should explicitly be passed to `std::mem::drop()` if the value really should be dropped immediately.
2022-05-20Auto merge of #97224 - matthiaskrgr:rollup-it5nw68, r=matthiaskrgrbors-9/+208
Rollup of 7 pull requests Successful merges: - #97109 (Fix misleading `cannot infer type for type parameter` error) - #97187 (Reverse condition in Vec::retain_mut doctest) - #97201 (Fix typo) - #97203 (Minor tweaks to rustc book summary formatting.) - #97208 (Do not emit the lint `unused_attributes` for *inherent* `#[doc(hidden)]` associated items) - #97215 (Add complexity estimation of iterating over HashSet and HashMap) - #97220 (Add regression test for#81827) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-05-20Rollup merge of #97220 - JohnTitor:issue-81827, r=compiler-errorsMatthias Krüger-0/+46
Add regression test for#81827 Closes #81827 r? `@compiler-errors`
2022-05-20Rollup merge of #97208 - fmease:fix-issue-97205, r=oli-obkMatthias Krüger-9/+35
Do not emit the lint `unused_attributes` for *inherent* `#[doc(hidden)]` associated items Fixes #97205 (embarrassing oversight from #96008). `@rustbot` label A-lint
2022-05-20Rollup merge of #97109 - ↵Matthias Krüger-0/+127
TaKO8Ki:fix-misleading-cannot-infer-type-for-type-parameter-error, r=oli-obk Fix misleading `cannot infer type for type parameter` error closes #93198
2022-05-21Add regression test for #81827Yuki Okushi-0/+46
2022-05-20Auto merge of #96833 - cjgillot:ast-lifetimes-single, r=petrochenkovbors-36/+98
Lint single-use lifetimes during AST resolution This PR rewrites `single_use_lifetime` and `unused_lifetime` lints to be based on the AST. We have more information at our disposal, so we can reduce the amount of false positives. Remaining false positive: single-use lifetimes in argument-position impl-trait. I'm waiting for https://github.com/rust-lang/rust/issues/96529 to be fixed to have a clean and proper solution here. Closes https://github.com/rust-lang/rust/issues/54079 Closes https://github.com/rust-lang/rust/issues/55057 Closes https://github.com/rust-lang/rust/issues/55058 Closes https://github.com/rust-lang/rust/issues/60554 Closes https://github.com/rust-lang/rust/issues/69952 r? `@petrochenkov`
2022-05-20report ambiguous type parameters when their parents are impl or fnTakayuki Maeda-0/+90
fix ci error emit err for `impl_item`
2022-05-20Auto merge of #97211 - GuillaumeGomez:rollup-jul7x7e, r=GuillaumeGomezbors-35/+51
Rollup of 6 pull requests Successful merges: - #96565 (rustdoc: show implementations on `#[fundamental]` wrappers) - #97179 (Add new lint to enforce whitespace after keywords) - #97185 (interpret/validity: separately control checking numbers for being init and non-ptr) - #97188 (Remove unneeded null pointer asserts in ptr2int casts) - #97189 (Update .mailmap) - #97192 (Say "last" instead of "rightmost" in the documentation for `std::str:rfind`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-05-20Rollup merge of #97185 - RalfJung:number-validity, r=oli-obkGuillaume Gomez-35/+35
interpret/validity: separately control checking numbers for being init and non-ptr This lets Miri control this in a more fine-grained way. r? `@oli-obk`
2022-05-20Rollup merge of #96565 - notriddle:notriddle/impl-box, r=camelidGuillaume Gomez-0/+16
rustdoc: show implementations on `#[fundamental]` wrappers Fixes #92940
2022-05-20Lint single-use-lifetimes on the AST.Camille GILLOT-36/+98
2022-05-20update error messagelcnr-7/+7
2022-05-20rewrite `ensure_drop_params_and_item_params_correspond`lcnr-45/+35
2022-05-20Do not warn on inherent doc(hidden) assoc itemsLeón Orell Valerian Liehr-9/+35
2022-05-20Auto merge of #97029 - eholk:drop-tracking-yielding-in-match-guard, ↵bors-0/+12
r=nikomatsakis generator_interior: Count match pattern bindings as borrowed for the whole guard expression The test case `yielding-in-match-guard.rs` was failing with `-Zdrop-tracking` enabled. The reason is that the copy of a local (`y`) was not counted as a borrow in typeck, while MIR did consider this as borrowed. The correct thing to do here is to count pattern bindings are borrowed for the whole guard. Instead, what we were doing is to record the type at the use site of the variable and check if the variable comes from a borrowed pattern. Due to the fix for #57017, we were considering too small of a scope for this variable, which meant it was not counted as borrowed. Because we now unconditionally record the borrow, rather than only for bindings that are used, this PR is also able to remove a lot of the logic around match bindings that was there before. r? `@nikomatsakis`
2022-05-20Auto merge of #97027 - cuviper:yesalias-refcell, r=thomccbors-0/+50
Use pointers in `cell::{Ref,RefMut}` to avoid `noalias` When `Ref` and `RefMut` were based on references, they would get LLVM `noalias` attributes that were incorrect, because that alias guarantee is only true until the guard drops. A `&RefCell` on the same value can get a new borrow that aliases the previous guard, possibly leading to miscompilation. Using `NonNull` pointers in `Ref` and `RefCell` avoids `noalias`. Fixes the library side of #63787, but we still might want to explore language solutions there.
2022-05-19Borrow guard patterns for the body of the guardEric Holk-9/+0
2022-05-19Revert "Count copies of locals as borrowed temporaries"Eric Holk-13/+1
This reverts commit 0d270b5e9f48268735f9a05462df65c9d1039855.
2022-05-19Count copies of locals as borrowed temporariesEric Holk-1/+13
2022-05-19Further reduce test caseEric Holk-9/+5
Thanks to @tmiasko for this one!
2022-05-19Add drop tracking version of yielding-in-match-guard.rsEric Holk-0/+25
2022-05-19bless 32bitRalf Jung-11/+11
2022-05-19interpret/validity: separately control checking numbers for being init and ↵Ralf Jung-24/+24
non-ptr
2022-05-19Rollup merge of #97171 - JohnTitor:issue-88119, r=compiler-errorsDylan DPC-0/+35
Add regression test for #88119 Closes #88119
2022-05-19Rollup merge of #97169 - gimbles:u32-diagnostic, r=petrochenkovDylan DPC-18/+9
Improve `u32 as char` cast diagnostic Fixes #97160
2022-05-19Improve u32 to char diagnosticgimbles-18/+9
2022-05-19Add regression test for #88119Yuki Okushi-0/+35
2022-05-19Auto merge of #97103 - luqmana:asm-unwind-cleanup, r=Amanieu,tmiaskobors-0/+40
Update MIR passes to handle unwinding Inline Asm Some more follow up fixes from https://github.com/rust-lang/rust/pull/95864#issuecomment-1094165398 r? `@Amanieu`
2022-05-18Add mir-opt test for asm_unwind + panic=abortLuqman Aden-0/+40
2022-05-18Auto merge of #97019 - b-naber:transition-to-valtrees-pt1, r=oli-obkbors-6/+12
Transition to valtrees pt1 Compartmentalising https://github.com/rust-lang/rust/pull/96591 as much as possible. r? `@oli-obk`
2022-05-18Auto merge of #96863 - SparrowLii:let, r=michaelwoeristerbors-2/+6
use `hir::Let` in `hir::Guard::IfLet` This PR fixes the FIXME about using `hir::Let` in `hir::Guard::IfLet`
2022-05-18Auto merge of #96800 - nbdd0121:const, r=nagisabors-20/+73
Permit `asm_const` and `asm_sym` to reference generic params Related #96557 These constructs will be allowed: ```rust fn foofoo<const N: usize>() {} unsafe fn foo<const N: usize>() { asm!("/* {0} */", const N); asm!("/* {0} */", const N + 1); asm!("/* {0} */", sym foofoo::<N>); } fn barbar<T>() {} unsafe fn bar<T>() { asm!("/* {0} */", const std::mem::size_of::<T>()); asm!("/* {0} */", const std::mem::size_of::<(T, T)>()); asm!("/* {0} */", sym barbar::<T>); asm!("/* {0} */", sym barbar::<(T, T)>); } ``` `@Amanieu,` I didn't switch inline asms to use `DefKind::InlineAsm`, as I see little value doing that; given that no type inference is needed, it will only make typecking slower and more complex but will have no real gains. I did switch them to follow the same code path as inline asm during symbol resolution, though. The `error: unconstrained generic constant` you mentioned in #76001 is due to the fact that `to_const` will actually add a wfness obligation to the constant, which we don't need for `asm_const`, so I have that removed. `@rustbot` label: +A-inline-assembly +F-asm
2022-05-18Auto merge of #96867 - michaelwoerister:path-prefix-fixes-2, r=davidtwcobors-1/+83
--remap-path-prefix: Fix duplicated path components in debuginfo This PR fixes an issue with `--remap-path-prefix` where path components could appear twice in the remapped version of the path (e.g. https://github.com/rust-lang/rust/issues/78479). The underlying problem was that `--remap-path-prefix` is often used to map an absolute path to something that looks like a relative path, e.g.: ``` --remap-path-prefix=/home/calvin/.cargo/registry/src/github.com-1ecc6299db9ec823=crates.io", ``` and relative paths in debuginfo are interpreted as being relative to the compilation directory. So if Cargo invokes the compiler with `/home/calvin/.cargo/registry/src/github.com-1ecc6299db9ec823/some_crate-0.1.0/src/lib.rs` as input and `/home/calvin/.cargo/registry/src/github.com-1ecc6299db9ec823/some_crate-0.1.0` as the compiler's working directory, then debuginfo will state that the working directory was `crates.io/some_crate-0.1.0` and the file is question was `crates.io/some_crate-0.1.0/src/lib.rs`, which combined gives the path: ``` crates.io/some_crate-0.1.0/crates.io/some_crate-0.1.0/src/lib.rs ``` With this PR the compiler will detect this situation and set up debuginfo in LLVM in a way that makes it strip the duplicated path components when emitting DWARF. The PR also extracts the logic for making remapped paths absolute into a common helper function that is now used by debuginfo too (instead of just during crate metadata generation).
2022-05-18Properly apply path prefix remapping paths emitted into debuginfo.Michael Woerister-1/+83
2022-05-18Rollup merge of #97123 - ricked-twice:issue-96223-clean-fix, r=jackh726Dylan DPC-10/+5
Clean fix for #96223 Okay, so here we are (hopefully) :+1: Closes #96223 Thanks a lot to `@jackh726` for your help and explanation :pray: - Modified `InferCtxt::mk_trait_obligation_with_new_self_ty` to take as argument a `Binder<(TraitPredicate, Ty)>` instead of a `Binder<TraitPredicate>` and a separate `Ty` with no bound vars. - Modified all call places to avoid calling `Binder::no_bounds_var` or `Binder::skip_binder` when it is not safe. r? `@jackh726`
2022-05-18Rollup merge of #96378 - compiler-errors:trait-upcast-error, r=nagisaDylan DPC-2/+4
Mention traits and types involved in unstable trait upcasting Fixes #95972 by printing the traits being upcasted and the types being coerced that cause that upcasting... --- the poor span mentioned in the original issue has nothing to do with trait upcasting diagnostic here... > The original example I had that made me run into this issue had an even longer expression there (multiple chained iterator methods) which just got all highlighted as one big block saying "somewhere here trait coercion is used and it's not allowed". I don't think I can solve that issue in general without fixing the ObligationCauseCode and span that gets passed into Coerce.
2022-05-18Rollup merge of #95979 - lcnr:coherence-docs, r=compiler-errorsDylan DPC-0/+82
update coherence docs, fix generator + opaque type ICE the world is confusing, this makes it slightly less so
2022-05-18Rollup merge of #94639 - compiler-errors:rval-mutref, r=wesleywiserDylan DPC-7/+181
Suggest dereferencing non-lval mutable reference on assignment 1. Adds deref suggestions for LHS of assignment (or assign-binop) when it implements `DerefMut` 2. Fixes missing deref suggestions for LHS when it isn't a place expr Fixes #46276 Fixes #93980