about summary refs log tree commit diff
path: root/compiler/rustc_lint/src
AgeCommit message (Collapse)AuthorLines
2024-07-12Rollup merge of #127631 - compiler-errors:yeet-fully-norm, r=lcnrJubilee-13/+14
Remove `fully_normalize` Yeet this function and replace it w/ some `ObligationCtxt` instead. It wasn't called very often anyways. r? lcnr
2024-07-12Rollup merge of #127535 - spastorino:unsafe_code-unsafe_extern_blocks, r=oli-obkJubilee-0/+8
Fire unsafe_code lint on unsafe extern blocks Fixes #126738
2024-07-12Rollup merge of #126922 - asquared31415:asm_binary_label, r=estebankJubilee-34/+129
add lint for inline asm labels that look like binary fixes #94426 Due to a bug/feature in LLVM, labels composed of only the digits `0` and `1` can sometimes be confused with binary literals, even if a binary literal would not be valid in that position. This PR adds detection for such labels and also as a drive-by change, adds a note to cases such as `asm!(include_str!("file"))` that the label that it found came from an expansion of a macro, it wasn't found in the source code. I expect this PR to upset some people that were using labels `0:` or `1:` without issue because they never hit the case where LLVM got it wrong, but adding a heuristic to the lint to prevent this is not feasible - it would involve writing a whole assembly parser for every target that we have assembly support for. [zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202024-06-20/near/445870628) r? ``@estebank``
2024-07-11Remove fully_normalizeMichael Goulet-13/+14
2024-07-11Auto merge of #127097 - compiler-errors:async-closure-lint, r=oli-obkbors-5/+136
Implement simple, unstable lint to suggest turning closure-of-async-block into async-closure We want to eventually suggest people to turn `|| async {}` to `async || {}`. This begins doing that. It's a pretty rudimentary lint, but I wanted to get something down so I wouldn't lose the code. Tracking: * #62290
2024-07-10Auto merge of #127549 - jhpratt:rollup-o1mbmhr, r=jhprattbors-0/+165
Rollup of 8 pull requests Successful merges: - #124211 (Bump `elided_lifetimes_in_associated_constant` to deny) - #125627 (migration lint for `expr2024` for the edition 2024) - #127091 (impl FusedIterator and a size hint for the error sources iter) - #127461 (Fixup failing fuchsia tests) - #127484 (`#[doc(alias)]`'s doc: say that ASCII spaces are allowed) - #127508 (small search graph refactor) - #127521 (Remove spastorino from SMIR) - #127532 (documentation: update cmake version) r? `@ghost` `@rustbot` modify labels: rollup
2024-07-10Rollup merge of #125627 - vincenzopalazzo:macros/cargo-fix-expr2024, ↵Jacob Pratt-0/+165
r=compiler-errors,eholk migration lint for `expr2024` for the edition 2024 This is adding a migration lint for the current (in the 2021 edition and previous) to move expr to expr_2021 from expr Issue https://github.com/rust-lang/rust/issues/123742 I created also a repository to test out the migration https://github.com/vincenzopalazzo/expr2024-cargo-fix-migration Co-Developed-by: ``@eholk``
2024-07-10Auto merge of #127496 - tgross35:f16-f128-pattern-fixme, r=Nadrierilbors-1/+2
Update `f16`/`f128` FIXMEs that needed `(NEG_)INFINITY` Just a small fix to the pattern matching tests now that we can. Also contains a small unrelated comment tweak.
2024-07-09Fire unsafe_code lint on unsafe extern blocksSantiago Pastorino-0/+8
2024-07-09Adds expr_2024 migration litVincenzo Palazzo-0/+165
This is adding a migration lint for the current (in the 2021 edition and previous) to move expr to expr_2021 from expr Co-Developed-by: Eric Holk Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2024-07-09add lint for inline asm labels that look like binaryasquared31415-34/+129
2024-07-08Update a f16/f128 FIXME to be more accurateTrevor Gross-1/+2
2024-07-08Move trait selection error reporting to its own top-level moduleMichael Goulet-3/+3
2024-07-07iter_identity is a better nameMichael Goulet-6/+2
2024-07-05Rollup merge of #127221 - Urgau:check-cfg-std-diag, r=pnkfelixMichael Goulet-6/+12
Improve well known value check-cfg diagnostic for the standard library This PR adjust the current logic for hidding the rustc/Cargo suggestion to add a value to a well-known name to exclude the standard library and rustc crates. This is done in order to improve the contributor experience, in particular when adding a new target, which often requires adding some cfgs like `target_os` which may not be available yet in stage0. <details> The diagnostic code would look like this. ```text error: unexpected `cfg` condition value: `blable` --> library/core/src/lib.rs:369:7 | 369 | #[cfg(target_os = "blable")] | ^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `teeos`, `tvos`, `uefi`, `unknown`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, and `windows` and 2 more = help: consider using a Cargo feature instead = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint: [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(target_os, values("blable"))'] } = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(target_os, values(\"blable\"))");` to the top of the `build.rs` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration = note: `-D unexpected-cfgs` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(unexpected_cfgs)]` ``` </details>
2024-07-02Instance::resolve -> Instance::try_resolve, and other nitsMichael Goulet-3/+5
2024-07-01Improve well known value check-cfg diagnostic for the standard libraryUrgau-6/+12
2024-06-30Rollup merge of #126018 - nnethercote:rm-box_pointers-lint, r=lcnrMatthias Krüger-86/+7
Remove the `box_pointers` lint. As the comment says, this lint "is mostly historical, and not particularly useful". It's not worth keeping it around. r? ``@estebank``
2024-06-29Rollup merge of #127045 - compiler-errors:explicit, r=oli-obkMatthias Krüger-1/+1
Rename `super_predicates_of` and similar queries to `explicit_*` to note that they're not elaborated Rename: * `super_predicates_of` -> `explicit_super_predicates_of` * `implied_predicates_of` -> `explicit_implied_predicates_of` * `supertraits_containing_assoc_item` -> `explicit_supertraits_containing_assoc_item` This makes it clearer that, unlike (for example) [`TyCtxt::super_traits_of`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.super_traits_of), we don't automatically elaborate this set of predicates. r? ``@lcnr`` or ``@oli-obk`` or someone from t-types idc
2024-06-28Make it into a structured suggestion, maybe-incorrectMichael Goulet-2/+21
2024-06-28Basic lint detecting closure-returning-async-blockMichael Goulet-0/+113
2024-06-28Only require symbol name for @feature_gateMichael Goulet-5/+4
2024-06-28Rollup merge of #127015 - Urgau:non_local_def-tmp-allow, r=lqdMatthias Krüger-1/+1
Switch back `non_local_definitions` lint to allow-by-default This PR switch back (again) the `non_local_definitions` lint to allow-by-default as T-lang is requesting some (major) changes in the lint inner workings in https://github.com/rust-lang/rust/issues/126768#issuecomment-2192634762. This PR will need to be beta-backported, as the lint is currently warn-by-default in beta.
2024-06-27Make queries more explicitMichael Goulet-1/+1
2024-06-27Switch back `non_local_definitions` lint to allow-by-defaultUrgau-1/+1
as request T-lang is requesting some major changes in the lint inner workings in #126768#issuecomment-2192634762
2024-06-27Remove the `box_pointers` lint.Nicholas Nethercote-86/+7
As the comment says, this lint "is mostly historical, and not particularly useful". It's not worth keeping it around.
2024-06-25RFC 2383: Stabilize `lint_reasons` :tada:xFrednet-15/+0
2024-06-25Auto merge of #125741 - petrochenkov:atvisord, r=davidtwcobors-0/+10
ast: Standardize visiting order for attributes and node IDs This should only affect `macro_rules` scopes and order of diagnostics. Also add a deprecation lint for `macro_rules` called outside of their scope, like in https://github.com/rust-lang/rust/issues/124535.
2024-06-24Split out IntoIterator and non-Iterator constructors for ↵Michael Goulet-1/+1
AliasTy/AliasTerm/TraitRef/projection
2024-06-24resolve: Implement a lint for out-of-scope use of `macro_rules`Vadim Petrochenkov-0/+10
2024-06-23Add hard error and migration lint for unsafe attrscarbotaniuman-0/+31
2024-06-21Rename a bunch of thingsMichael Goulet-1/+1
2024-06-19Rollup merge of #126422 - Urgau:doctest-impl-non-local-def, r=fmease许杰友 Jieyou Xu (Joe)-46/+55
Suggest using a standalone doctest for non-local impl defs This PR tweaks the lint output of the `non_local_definitions` lint to suggest using a standalone doctest instead of a moving the `impl` def to an impossible place as was already done with `macro_rules!` case in https://github.com/rust-lang/rust/pull/124568. Fixes #126339 r? ```@fmease```
2024-06-18Remove redundant argument from `subdiagnostic` methodOli Scherer-3/+3
2024-06-18Use a dedicated type instead of a reference for the diagnostic contextOli Scherer-2/+2
This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle
2024-06-17Rework precise capturing syntaxMichael Goulet-8/+12
2024-06-17Rollup merge of #125258 - compiler-errors:static-if-no-lt, r=nnethercote许杰友 Jieyou Xu (Joe)-3/+14
Resolve elided lifetimes in assoc const to static if no other lifetimes are in scope Implements the change to elided lifetime resolution in *associated consts* subject to FCP here: https://github.com/rust-lang/rust/issues/125190#issue-2301532282 Specifically, walk the enclosing lifetime ribs in an associated const, and if we find no other lifetimes, then resolve to `'static`. Also make it work for traits, but don't lint -- just give a hard error in that case.
2024-06-16boxed_slice_into_iter: tiny doc correctionKalle Wachsmuth-1/+1
2024-06-15Also simplify macro_rules doctest codeUrgau-10/+6
2024-06-15Suggest standalone doctest for non-local impl defsUrgau-38/+51
2024-06-15Auto merge of #125722 - Urgau:non_local_defs-macro-to-change, r=estebankbors-3/+19
Indicate in `non_local_defs` lint that the macro needs to change This PR adds a note to indicate that the macro needs to change in the `non_local_definitions` lint output. Address https://github.com/rust-lang/rust/pull/125089#discussion_r1616311862 Fixes #125681 r? `@estebank`
2024-06-14Use is_lang_item more aggressivelyMichael Goulet-10/+10
2024-06-14Resolve elided lifetimes in assoc const to static if no other lifetimes are ↵Michael Goulet-3/+14
in scope
2024-06-12Auto merge of #126273 - pietroalbini:pa-bootstrap-update, r=Mark-Simulacrumbors-2/+2
Bump stage0 to 1.80.0 r? `@Mark-Simulacrum`
2024-06-12Auto merge of #126319 - workingjubilee:rollup-lendnud, r=workingjubileebors-3/+5
Rollup of 16 pull requests Successful merges: - #123374 (DOC: Add FFI example for slice::from_raw_parts()) - #124514 (Recommend to never display zero disambiguators when demangling v0 symbols) - #125978 (Cleanup: HIR ty lowering: Consolidate the places that do assoc item probing & access checking) - #125980 (Nvptx remove direct passmode) - #126187 (For E0277 suggest adding `Result` return type for function when using QuestionMark `?` in the body.) - #126210 (docs(core): make more const_ptr doctests assert instead of printing) - #126249 (Simplify `[T; N]::try_map` signature) - #126256 (Add {{target}} substitution to compiletest) - #126263 (Make issue-122805.rs big endian compatible) - #126281 (set_env: State the conclusion upfront) - #126286 (Make `storage-live.rs` robust against rustc internal changes.) - #126287 (Update a cranelift patch file for formatting changes.) - #126301 (Use `tidy` to sort crate attributes for all compiler crates.) - #126305 (Make PathBuf less Ok with adding UTF-16 then `into_string`) - #126310 (Migrate run make prefer rlib) - #126314 (fix RELEASES: we do not support upcasting to auto traits) r? `@ghost` `@rustbot` modify labels: rollup
2024-06-12Add a `fn main() {}` to a doctest to prevent the test from being wrapped in ↵Oli Scherer-0/+2
a `fn main() {}` body
2024-06-12Use `tidy` to sort crate attributes for all compiler crates.Nicholas Nethercote-3/+5
We already do this for a number of crates, e.g. `rustc_middle`, `rustc_span`, `rustc_metadata`, `rustc_span`, `rustc_errors`. For the ones we don't, in many cases the attributes are a mess. - There is no consistency about order of attribute kinds (e.g. `allow`/`deny`/`feature`). - Within attribute kind groups (e.g. the `feature` attributes), sometimes the order is alphabetical, and sometimes there is no particular order. - Sometimes the attributes of a particular kind aren't even grouped all together, e.g. there might be a `feature`, then an `allow`, then another `feature`. This commit extends the existing sorting to all compiler crates, increasing consistency. If any new attribute line is added there is now only one place it can go -- no need for arbitrary decisions. Exceptions: - `rustc_log`, `rustc_next_trait_solver` and `rustc_type_ir_macros`, because they have no crate attributes. - `rustc_codegen_gcc`, because it's quasi-external to rustc (e.g. it's ignored in `rustfmt.toml`).
2024-06-11Rollup merge of #125659 - tbu-:pr_rm_isize, r=pnkfelix许杰友 Jieyou Xu (Joe)-1/+1
Remove usage of `isize` in example `isize` is a rare integer type, replace it with a more common one.
2024-06-11replace version placeholderPietro Albini-2/+2
2024-06-11Rollup merge of #125913 - fmease:early-lints-spruce-up-some-diags, r=Nadrieril许杰友 Jieyou Xu (Joe)-2/+7
Spruce up the diagnostics of some early lints Implement the various "*(note to myself) in a follow-up PR we should turn parts of this message into a subdiagnostic (help msg or even struct sugg)*" drive-by comments I left in #124417 during my review. For context, before #124417, only a few early lints touched/decorated/customized their diagnostic because the former API made it a bit awkward. Likely because of that, things that should've been subdiagnostics were just crammed into the primary message. This PR rectifies this.