about summary refs log tree commit diff
path: root/tests/ui/lint
AgeCommit message (Collapse)AuthorLines
2023-09-12Tests passingChinedu Francis Nwafili-2/+6
2023-09-11Rollup merge of #115631 - compiler-errors:ctypes-unsized, r=davidtwcoMatthias Krüger-0/+24
Don't ICE when computing ctype's `repr_nullable_ptr` for possibly-unsized ty We may not always be able to compute the layout of a type like `&T` when `T: ?Sized`, even if we're able to estimate its size skeleton. r? davidtwco Fixes #115628
2023-09-11Auto merge of #115387 - weihanglo:merge-check-and-lint, r=oli-obkbors-13/+168
Make unknown/renamed/removed lints passed via command line respect lint levels
2023-09-09Fix ICE in improper_ctypes_definitions lintGurinder Singh-9/+25
The lint panicked for an input like 'extern "C" fn(Option<&<T as FooTrait>::FooType>)' because the type T therein cannot be normalized. The normalization failure caused SizeSkeleton::compute() to return an error and trigger a panic in the unwrap().
2023-09-08Rename the feature, but not the attribute, to `coverage_attribute`Andy Caldwell-1/+1
2023-09-08Rework no_coverage to coverage(off)Andy Caldwell-56/+56
2023-09-07Don't ICE when computing ctype's repr_nullable_ptr for possibly-unsized tyMichael Goulet-0/+24
2023-09-07Auto merge of #115166 - Urgau:invalid_ref_casting-invalid-unsafecell-usage, ↵bors-20/+76
r=est31 Lint on invalid usage of `UnsafeCell::raw_get` in reference casting This PR proposes to take into account `UnsafeCell::raw_get` method call for non-Freeze types for the `invalid_reference_casting` lint. The goal of this is to catch those kind of invalid reference casting: ```rust fn as_mut<T>(x: &T) -> &mut T { unsafe { &mut *std::cell::UnsafeCell::raw_get(x as *const _ as *const _) } //~^ ERROR casting `&T` to `&mut T` is undefined behavior } ``` r? `@est31`
2023-09-06still accept references to u8 slices and str in packed fieldsRalf Jung-11/+41
2023-09-05fix detecting references to packed unsized fieldsRalf Jung-11/+34
2023-09-04Add help to allow lint for the implied by suggestionUrgau-0/+10
2023-09-03Emit unused doc comment warnings for pat and expr fieldsGurinder Singh-4/+52
2023-09-01Rollup merge of #115424 - notriddle:notriddle/issue-106413, r=oli-obkMatthias Krüger-0/+159
diagnostics: avoid wrong `unused_parens` on `x as (T) < y` Fixes #106413 Fixes #80636
2023-09-01Auto merge of #113126 - Bryanskiy:delete_old, r=petrochenkovbors-3/+3
Replace old private-in-public diagnostic with type privacy lints Next part of RFC https://github.com/rust-lang/rust/issues/48054. r? `@petrochenkov`
2023-08-31diagnostics: avoid wrong `unused_parens` on `x as (T) < y`Michael Howell-0/+159
2023-08-30feat(rustc_lint): make `CheckLintName` respect lint levelWeihang Lo-47/+75
2023-08-30test(ui/lint): demonstrate the current cmdline lint behaviorWeihang Lo-0/+127
This demonstrates the current behavior of adding lint form the command line. generally the lint levels are ignored as the current implementation unconditionally emit errors for those lints.
2023-08-24Lint on invalid UnsafeCell::raw_get with invalid_reference_casting lintUrgau-20/+76
2023-08-23Improve note for the invalid_reference_casting lintUrgau-0/+57
Add link to the book interior mutability chapter, https://doc.rust-lang.org/book/ch15-05-interior-mutability.html.
2023-08-22Add support for ptr::write for the invalid_reference_casting lintUrgau-5/+53
2023-08-16Rollup merge of #114784 - Urgau:many-improve-invalid_reference_casting-lint, ↵Matthias Krüger-17/+102
r=est31 Improve `invalid_reference_casting` lint This PR improves the `invalid_reference_casting` lint: - by considering an unlimited number of casts instead only const to mut ptr - by also considering ptr-to-integer and integer-to-ptr casts - by also taking into account [`ptr::cast`](https://doc.rust-lang.org/std/primitive.pointer.html#method.cast), [`ptr::cast`](https://doc.rust-lang.org/std/primitive.pointer.html#method.cast-1) and [`ptr::cast_const`](https://doc.rust-lang.org/std/primitive.pointer.html#method.cast_const) Most of this improvements comes from skimming Github Code Search result for [`&mut \*.*as \*const`](https://github.com/search?q=lang%3Arust+%2F%26mut+%5C*.*as+%5C*const%2F&type=code) r? ``@est31`` (maybe)
2023-08-15Misc progressChinedu Francis Nwafili-0/+3
2023-08-15Rollup merge of #114820 - ehuss:unknown-lint-mod-warning, r=compiler-errorsGuillaume Gomez-0/+36
Add test for unknown_lints from another file. This adds a test for #84936 which was incidentally fixed via #97266. It is a strange issue where `#![allow(unknown_lints)]` at the crate root was not applying to unknown lints that fired in a non-inline-module. I did not dig further into how #97266 fixed it, but I did verify it. I couldn't find any existing tests which did anything similar. Closes #84936
2023-08-15Improve `invalid_reference_casting` lintUrgau-17/+102
2023-08-14Add test for unknown_lints from another file.Eric Huss-0/+36
2023-08-14match scrutinee need necessary parentheses for structsyukang-0/+50
2023-08-13Auto merge of #114757 - Urgau:transmute-with-invalid_reference_casting, r=est31bors-9/+26
Also consider `mem::transmute` with the `invalid_reference_casting` lint This PR extend the `invalid_reference_casting` lint with regard to the `std::mem::transmute` function. ``` error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` --> $DIR/reference_casting.rs:27:16 | LL | let _num = &mut *std::mem::transmute::<_, *mut i32>(&num); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` *I encourage anyone reviewing this PR to do so [without whitespaces](https://github.blog/2011-10-21-github-secrets/#whitespace).*
2023-08-12Auto merge of #114710 - Urgau:fix-expect-dead_code-114557, r=cjgillotbors-0/+70
Respect `#[expect]` the same way `#[allow]` is with the `dead_code` lint This PR makes the `#[expect]` attribute being respected in the same way the `#[allow]` attribute is with the `dead_code` lint. The fix is much more involved than I would have liked (and it's not because I didn't tried!), because the implementation took advantage of the fact that firing a lint in a allow context is a nop (for the user, as the lint is suppressed) to not fire-it at all. And will it's fine for `#[allow]`, it definitively isn't for `#[expect]`, as the presence and absence of the lint is significant. So a big part of the PR is just adding the context information of whenever an item is on the worklist because of an `[allow]`/`#[expect]` or not. Fixes https://github.com/rust-lang/rust/issues/114557
2023-08-12Also consider `transmute` with the `invalid_reference_casting` lintUrgau-9/+26
2023-08-10Respect `#[expect]` the same way `#[allow]` is with the `dead_code` lintUrgau-0/+70
2023-08-08Fix multiple `expect` attribs in impl blockChinedu Francis Nwafili-0/+25
Closes #114416
2023-08-07Auto merge of #113902 - Enselic:lint-recursive-drop, r=oli-obkbors-0/+55
Make `unconditional_recursion` warning detect recursive drops Closes #55388 Also closes #50049 unless we want to keep it for the second example which this PR does not solve, but I think it is better to track that work in #57965. r? `@oli-obk` since you are the mentor for #55388 Unresolved questions: - [x] There are two false positives that must be fixed before merging (see diff). I suspect the best way to solve them is to perform analysis after drop elaboration instead of before, as now, but I have not explored that any further yet. Could that be an option? **Answer:** Yes, that solved the problem. `@rustbot` label +T-compiler +C-enhancement +A-lint
2023-08-06Improve diagnostics and add tests for function callsest31-21/+31
2023-08-06Rollup merge of #114486 - Urgau:const-context-nan-suggestion-114471, ↵Matthias Krüger-5/+0
r=compiler-errors Avoid invalid NaN lint machine-applicable suggestion in const context This PR removes the machine-applicable suggestion in const context for the `invalid_nan_comparision` lint ~~and replace it with a simple help~~. Fixes https://github.com/rust-lang/rust/issues/114471
2023-08-05Avoid invalid NaN lint machine-applicable suggestion in const contextUrgau-5/+0
2023-08-05Rollup merge of #114248 - fmease:neg-copy-rules-out-missing-copy-impl, r=b-naberMatthias Krüger-0/+15
Make lint missing-copy-implementations honor negative `Copy` impls Fixes #101980. ``@rustbot`` label A-lint F-negative_impls
2023-08-05Auto merge of #113734 - cjgillot:no-crate-lint, r=petrochenkovbors-151/+145
Convert builtin "global" late lints to run per module The compiler currently has 4 non-incremental lints: 1. `clashing_extern_declarations`; 2. `missing_debug_implementations`; 3. ~`unnameable_test_items`;~ changed by https://github.com/rust-lang/rust/pull/114414 4. `missing_docs`. Non-incremental lints get reexecuted for each compilation, which is slow. Moreover, those lints are allow-by-default, so run for nothing most of the time. This PR attempts to make them more incremental-friendly. `clashing_extern_declarations` is moved to a standalone query. `missing_debug_implementation` can use `non_blanket_impls_for_ty` instead of recomputing it. `missing_docs` is harder as it needs to track if there is a `doc(hidden)` module surrounding. I hack around this using the lint level engine. That's easy to implement and allows to re-enable the lint for a re-exported module, while a more proper solution would reuse the same device as `unnameable_test_items`.
2023-08-04Rollup merge of #114472 - estebank:issue-76140, r=compiler-errorsMatthias Krüger-8/+8
Reword `confusable_idents` lint Fix #76140.
2023-08-04Rollup merge of #114434 - Nilstrieb:indexing-spans, r=est31Matthias Krüger-1/+1
Improve spans for indexing expressions fixes #114388 Indexing is similar to method calls in having an arbitrary left-hand-side and then something on the right, which is the main part of the expression. Method calls already have a span for that right part, but indexing does not. This means that long method chains that use indexing have really bad spans, especially when the indexing panics and that span in coverted into a panic location. This does the same thing as method calls for the AST and HIR, storing an extra span which is then put into the `fn_span` field in THIR. r? compiler-errors
2023-08-04Reword confusable idents lintEsteban Küber-8/+8
Fix #76140.
2023-08-04Make MissingDoc a module lint.Camille GILLOT-42/+42
2023-08-04Make MissingDebugImplementation a module lint.Camille GILLOT-8/+8
2023-08-04Bless ui tests.Camille GILLOT-101/+95
2023-08-04Improve spans for indexing expressionsNilstrieb-1/+1
Indexing is similar to method calls in having an arbitrary left-hand-side and then something on the right, which is the main part of the expression. Method calls already have a span for that right part, but indexing does not. This means that long method chains that use indexing have really bad spans, especially when the indexing panics and that span in coverted into a panic location. This does the same thing as method calls for the AST and HIR, storing an extra span which is then put into the `fn_span` field in THIR.
2023-08-03Rollup merge of #113657 - Urgau:expand-incorrect_fn_null_check-lint, r=cjgillotMatthias Krüger-97/+301
Expand, rename and improve `incorrect_fn_null_checks` lint This PR, - firstly, expand the lint by now linting on references - secondly, it renames the lint `incorrect_fn_null_checks` -> `useless_ptr_null_checks` - and thirdly it improves the lint by catching `ptr::from_mut`, `ptr::from_ref`, as well as `<*mut _>::cast` and `<*const _>::cast_mut` Fixes https://github.com/rust-lang/rust/issues/113601 cc ```@est31```
2023-08-03Also add label with original type for function pointersUrgau-11/+33
2023-08-03Also lint on cast/cast_mut and ptr::from_mut/ptr::from_refUrgau-20/+84
2023-08-03Make lint missing-copy-implementations honor negative Copy implsLeón Orell Valerian Liehr-0/+15
2023-08-02Replace old private-in-public diagnostic with type privacy lintsBryanskiy-3/+3
2023-08-01Add more tests for useless_ptr_null_checks lintUrgau-17/+50