about summary refs log tree commit diff
path: root/tests/ui/lint
AgeCommit message (Collapse)AuthorLines
2023-12-15Stabilize `ptr::{from_ref, from_mut}`Maybe Waffle-73/+69
2023-12-14Recurse into let bindings if possible in ref casting lintUrgau-8/+35
2023-12-11Auto merge of #117758 - Urgau:lint_pointer_trait_comparisons, r=davidtwcobors-0/+590
Add lint against ambiguous wide pointer comparisons This PR is the resolution of https://github.com/rust-lang/rust/issues/106447 decided in https://github.com/rust-lang/rust/issues/117717 by T-lang. ## `ambiguous_wide_pointer_comparisons` *warn-by-default* The `ambiguous_wide_pointer_comparisons` lint checks comparison of `*const/*mut ?Sized` as the operands. ### Example ```rust let ab = (A, B); let a = &ab.0 as *const dyn T; let b = &ab.1 as *const dyn T; let _ = a == b; ``` ### Explanation The comparison includes metadata which may not be expected. ------- This PR also drops `clippy::vtable_address_comparisons` which is superseded by this one. ~~One thing: is the current naming right? `invalid` seems a bit too much.~~ Fixes https://github.com/rust-lang/rust/issues/117717
2023-12-06Rollup merge of #118504 - compiler-errors:must-use, r=WaffleLapkinMatthias Krüger-0/+53
Enforce `must_use` on associated types and RPITITs that have a must-use trait in bounds Warn when an RPITIT or (un-normalized) associated type with a `#[must_use]` trait in its bounds is unused. This is pending T-lang approval, since it changes the semantics of the `#[must_use]` attribute slightly, but I think it strictly catches more strange errors. I could also limit this to just RPITITs, but that seems less useful. Fixes #118444
2023-12-06Add warn-by-default lint against ambiguous wide pointer comparisonsUrgau-0/+590
2023-12-05Rollup merge of #118123 - RalfJung:internal-lib-features, r=compiler-errorsMichael Goulet-0/+34
Add support for making lib features internal We have the notion of an "internal" lang feature: a feature that is never intended to be stabilized, and using which can cause ICEs and other issues without that being considered a bug. This extends that idea to lib features as well. It is an alternative to https://github.com/rust-lang/rust/pull/115623: instead of using an attribute to declare lib features internal, we simply do this based on the name. Everything ending in `_internals` or `_internal` is considered internal. Then we rename `core_intrinsics` to `core_intrinsics_internal`, which fixes https://github.com/rust-lang/rust/issues/115597.
2023-11-30Enforce must_use on associated types and RPITITsMichael Goulet-0/+53
2023-11-29Change how `for (x in foo) {}` is handledEsteban Küber-13/+17
Use the same approach used for match arm patterns.
2023-11-29Bubble parse error when expecting `)`Esteban Küber-14/+2
2023-11-24Show number in error message even for one errorNilstrieb-90/+90
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-21lib features ending in '_internals?' are internalRalf Jung-0/+34
2023-11-21Auto merge of #115691 - jsgf:typed-json-diags, r=est31,dtolnaybors-13/+33
Add `$message_type` field to distinguish json diagnostic outputs Currently the json-formatted outputs have no way to unambiguously determine which kind of message is being output. A consumer can look for specific fields in the json object (eg "message"), but there's no guarantee that in future some other kind of output will have a field of the same name. This PR adds a `"type"` field to add json outputs which can be used to unambiguously determine which kind of output it is. The mapping is: `diagnostic`: regular compiler diagnostics `artifact`: artifact notifications `future_incompat`: Future incompatibility report `unused_extern`: Unused crate warnings/errors This matches the "internally tagged" representation for serde enums.
2023-11-18add test for pinned `must_use` pointersMax Niederman-0/+65
2023-10-30Rollup merge of #117395 - gurry:117380-wrong-parent-sugg, r=NilstriebGuillaume Gomez-1/+89
Fix missing leading space in suggestion For a local pattern with no space between `let` and `(` e.g.: ```rust let(_a) = 3; ``` we were previously suggesting this illegal code: ```rust let_a = 3; ``` After this change the suggestion will instead be: ```rust let _a = 3; ``` Fixes #117380
2023-10-30Fix #117284, Fix unused variables lint issue for args in macroyukang-0/+46
2023-10-30Fix missing leading space in suggestionGurinder Singh-1/+89
For a local pattern with no space between `let` and `(` e.g.: let(_a) = 3; we were previously suggesting this illegal code: let_a =3; After this change the suggestion will instead be: let _a =3; (Note the space after `let`)
2023-10-22use visibility to check unused imports and delete some stmtsbohan-1/+1
2023-10-20s/generator/coroutine/Oli Scherer-6/+6
2023-10-20s/Generator/Coroutine/Oli Scherer-1/+1
2023-10-18Rollup merge of #116812 - ↵Ali MJ Al-Nasrawy-0/+25
rmehri01:missing_copy_implementations_non_exhaustive, r=petrochenkov Disable missing_copy_implementations lint on non_exhaustive types Fixes #116766
2023-10-17Unify suggestion wordingEsteban Küber-1/+1
2023-10-17disable missing_copy_implementations lint on non_exhaustive typesRyan Mehri-0/+25
use is_variant_list_non_exhaustive/is_field_list_non_exhaustive remove unused tcx inline non_exhaustive def/variant check
2023-10-13Use `$message_type` as the tagJeremy Fitzhardinge-14/+14
`type` turned out to be controversial.
2023-10-11Auto merge of #116623 - Nadrieril:validate-range-endpoints, r=oli-obkbors-21/+21
Fix overflow checking in range patterns When a range pattern contains an overflowing literal, if we're not careful we might not notice the overflow and use the wrapped value. This makes for confusing error messages because linting against overflowing literals is only done in a later pass. So when a range is invalid we check for overflows to provide a better error. This check didn't use to handle negative types; this PR fixes that. First commit adds tests, second cleans up without changing behavior, third does the fix. EDIT: while I was at it, I fixed a small annoyance about the span of the overflow lint on negated literals. Fixes https://github.com/rust-lang/rust/issues/94239
2023-10-11Fix span of overflow lint for negated literalsNadrieril-21/+21
2023-10-07Auto merge of #115583 - RalfJung:packed-unsized, r=lcnrbors-11/+64
fix detecting references to packed unsized fields Fixes https://github.com/rust-lang/rust/issues/115396 This is a breaking change, but permitted as a soundness fix.
2023-10-06Rollup merge of #116421 - Urgau:inter-mut-invalid_ref_casting, r=oli-obkMatthias Krüger-21/+47
Clarify `invalid_reference_casting` lint around interior mutable types This is PR intends to clarify the `invalid_reference_casting` lint around interior mutable types by adding a note for them saying that they should go through `UnsafeCell::get`. So for this code: ```rust let cell = &std::cell::UnsafeCell::new(0); let _num = &mut *(cell as *const _ as *mut i32); ``` the following note will be added to the lint output: ```diff error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` --> $DIR/reference_casting.rs:68:16 | LL | let _num = &mut *(cell as *const _ as *mut i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> + = note: even for types with interior mutability, the only legal way to obtain a mutable pointer from a shared reference is through `UnsafeCell::get` ``` Suggestion are welcome around the note contents. Fixes https://github.com/rust-lang/rust/issues/116410 cc `@RalfJung`
2023-10-05Rollup merge of #116428 - Alexendoo:note-duplicate-diagnostics, ↵Matthias Krüger-142/+97
r=compiler-errors,estebank Add a note to duplicate diagnostics Helps explain why there may be a difference between manual testing and the test suite output and highlights them as something to potentially look into For existing duplicate diagnostics I just blessed them other than a few files that had other `NOTE` annotations in
2023-10-05Add a note to duplicate diagnosticsAlex Macleod-142/+97
2023-10-04Auto merge of #114417 - ↵bors-0/+30
chinedufn:fix-expect-unused-in-impl-block-rust-issue-114416, r=cjgillot Fix multiple `expect` attribs in impl block Closes #114416
2023-10-04Clarify `invalid_reference_casting` lint around interior mutable typesUrgau-21/+47
2023-10-02Address misc feedbackChinedu Francis Nwafili-3/+1
2023-09-29Rollup merge of #116201 - Jarcho:noop_fix, r=fee1-deadMatthias Krüger-7/+33
Fix `noop_method_call` detection This needs to be merged before #116198 can compile. The error occurs before the compiler is built so this needs to be a separate PR.
2023-09-28Fix `noop_method_call` detection for new diagnostic itemsJason Newcomb-7/+33
2023-09-27Fix ICE by introducing an expr_or_init variant for outside bodiesUrgau-0/+4
2023-09-27Simplify casting logic of the invalid_reference_casting lintUrgau-25/+55
2023-09-27Prefer expr_or_init over manual init detectionUrgau-20/+66
2023-09-23Bless tests.Camille GILLOT-21/+29
2023-09-23Revert duplication of tests.Camille GILLOT-394/+26
2023-09-22Auto merge of #115696 - RalfJung:closure-ty-print, r=oli-obkbors-1/+1
adjust how closure/generator types are printed I saw `&[closure@$DIR/issue-20862.rs:2:5]` and I thought it is a slice type, because that's usually what `&[_]` is... it took me a while to realize that this is just a confusing printer and actually there's no slice. Let's use something that cannot be mistaken for a regular type.
2023-09-21adjust how closure/generator types and rvalues are printedRalf Jung-1/+1
2023-09-21tests/ui: Split large_moves.rs and move to lint/large_assignmentsMartin Nordholts-0/+124
To make failing tests easier to debug with --emit=mir, etc.
2023-09-21Rollup merge of #115257 - Urgau:invalid-utf8-walk-up-hir, r=NilstriebGuillaume Gomez-39/+123
Improve invalid UTF-8 lint by finding the expression initializer This PR introduce a small mechanism to walk up the HIR through bindings, if/else, consts, ... when trying lint on invalid UTF-8. Fixes https://github.com/rust-lang/rust/issues/115208
2023-09-21Improve invalid UTF-8 lint by finding the expression initializerUrgau-39/+123
2023-09-19Add test for future-incompat diagnostics with json outputJeremy Fitzhardinge-0/+20
2023-09-19Add `type` field to json diagnostic outputsJeremy Fitzhardinge-13/+13
Currently the json-formatted outputs have no way to unambiguously determine which kind of message is being output. A consumer can look for specific fields in the json object (eg "message"), but there's no guarantee that in future some other kind of output will have a field of the same name. This PR adds a `"type"` field to add json outputs which can be used to unambiguously determine which kind of output it is. The mapping is: diagnostic: regular compiler diagnostics artifact: artifact notifications future_incompat: Report of future incompatibility unused_extern: Unused crate warnings/errors This matches the "internally tagged" representation for serde enums.
2023-09-16Auto merge of #114494 - est31:extend_useless_ptr_null_checks, r=jackh726bors-21/+31
Make useless_ptr_null_checks smarter about some std functions This teaches the `useless_ptr_null_checks` lint that some std functions can't ever return null pointers, because they need to point to valid data, get references as input, etc. This is achieved by introducing an `#[rustc_never_returns_null_ptr]` attribute and adding it to these std functions (gated behind bootstrap `cfg_attr`). Later on, the attribute could maybe be used to tell LLVM that the returned pointer is never null. I don't expect much impact of that though, as the functions are pretty shallow and usually the input data is already never null. Follow-up of PR #113657 Fixes #114442
2023-09-14Auto merge of #115825 - cjgillot:expr-field-lint, r=compiler-errorsbors-0/+15
Visit ExprField for lint levels. Fixes https://github.com/rust-lang/rust/issues/115823
2023-09-14Auto merge of #114656 - bossmc:rework-no-coverage-attr, r=oli-obkbors-56/+56
Rework `no_coverage` to `coverage(off)` As discussed at the tail of https://github.com/rust-lang/rust/issues/84605 this replaces the `no_coverage` attribute with a `coverage` attribute that takes sub-parameters (currently `off` and `on`) to control the coverage instrumentation. Allows future-proofing for things like `coverage(off, reason="Tested live", issue="#12345")` or similar.
2023-09-13Visit ExprField for lint levels.Camille GILLOT-0/+15