rust/compiler/rustc_lint/src
Matthias Krüger 915576935a
Rollup merge of #138685 - nnethercote:use-Option-Ident-for-lowered-param-names, r=compiler-errors
Use `Option<Ident>` for lowered param names.

Parameter patterns are lowered to an `Ident` by `lower_fn_params_to_names`, which is used when lowering bare function types, trait methods, and foreign functions. Currently, there are two exceptional cases where the lowered param can become an empty `Ident`.

- If the incoming pattern is an empty `Ident`. This occurs if the parameter is anonymous, e.g. in a bare function type.

- If the incoming pattern is neither an ident nor an underscore. Any such parameter will have triggered a compile error (hence the `span_delayed_bug`), but lowering still occurs.

This commit replaces these empty `Ident` results with `None`, which eliminates a number of `kw::Empty` uses, and makes it impossible to fail to check for these exceptional cases.

Note: the `FIXME` comment in `is_unwrap_or_empty_symbol` is removed. It actually should have been removed in #138482, the precursor to this PR. That PR changed the lowering of wild patterns to `_` symbols instead of empty symbols, which made the mentioned underscore check load-bearing.

r? ``@compiler-errors``
2025-03-20 15:36:17 +01:00
..
early Reword message 2025-02-20 17:55:31 +00:00
nonstandard_style
types Add helper methods checking for "#[non_exhaustive] that's active" 2025-03-07 16:16:36 +01:00
async_closures.rs Move some Map methods onto TyCtxt. 2025-02-17 13:21:02 +11:00
async_fn_in_trait.rs nightly feature tracking: get rid of the per-feature bool fields 2024-10-23 09:14:41 +01:00
builtin.rs Move hir::Item::ident into hir::ItemKind. 2025-03-18 06:29:50 +11:00
context.rs Fix false-positive in expr_or_init and in the invalid_from_utf8 lint 2025-03-11 21:56:53 +01:00
dangling.rs Implement .use keyword as an alias of clone 2025-03-06 17:58:32 -03:00
default_could_be_derived.rs Move hir::Item::ident into hir::ItemKind. 2025-03-18 06:29:50 +11:00
deref_into_dyn_supertrait.rs update version placeholders 2025-02-18 08:50:21 -08:00
drop_forget_useless.rs Move methods from Map to TyCtxt, part 3. 2025-02-21 14:31:09 +11:00
early.rs fix empty after lint on impl/trait items 2025-02-07 16:47:26 +01:00
enum_intrinsics_non_enums.rs Fold visit into ty 2025-03-15 06:34:36 +00:00
errors.rs Add warn(unreachable_pub) to rustc_lint. 2024-08-27 15:24:11 +10:00
expect.rs Move methods from Map to TyCtxt, part 4. 2025-03-12 08:55:37 +11:00
for_loops_over_fallibles.rs Move methods from Map to TyCtxt, part 2. 2025-02-18 10:17:44 +11:00
foreign_modules.rs Stop relying on rustc_type_ir in non-type-system crates 2025-03-15 06:42:48 +00:00
hidden_unicode_codepoints.rs Rustfmt 2025-02-08 22:12:13 +00:00
if_let_rescope.rs Print out destructor 2025-02-26 19:03:29 +00:00
impl_trait_overcaptures.rs Stop relying on rustc_type_ir in non-type-system crates 2025-03-15 06:42:48 +00:00
internal.rs Move hir::Item::ident into hir::ItemKind. 2025-03-18 06:29:50 +11:00
invalid_from_utf8.rs invalid_from_utf8[_unchecked]: also lint inherent methods 2025-02-16 16:34:51 +03:00
late.rs Move methods from Map to TyCtxt, part 4. 2025-03-12 08:55:37 +11:00
let_underscore.rs Rustfmt 2025-02-08 22:12:13 +00:00
levels.rs Rollup merge of #138434 - compiler-errors:lint-level-pat-field, r=jieyouxu 2025-03-14 01:37:34 -04:00
lib.rs Auto merge of #138414 - matthiaskrgr:rollup-9ablqdb, r=matthiaskrgr 2025-03-12 17:27:43 +00:00
lints.rs Reword message 2025-02-20 17:55:31 +00:00
macro_expr_fragment_specifier_2024_migration.rs Rename RefTokenTreeCursor. 2024-12-18 10:39:07 +11:00
map_unit_fn.rs Rustfmt 2025-02-08 22:12:13 +00:00
multiple_supertrait_upcastable.rs Move hir::Item::ident into hir::ItemKind. 2025-03-18 06:29:50 +11:00
non_ascii_idents.rs Fix binding mode problems 2025-02-22 00:13:19 +00:00
non_fmt_panic.rs Rustfmt 2025-02-08 22:12:13 +00:00
non_local_def.rs Move hir::Item::ident into hir::ItemKind. 2025-03-18 06:29:50 +11:00
nonstandard_style.rs Use Option<Ident> for lowered param names. 2025-03-19 20:54:10 +11:00
noop_method_call.rs Rustfmt 2025-02-08 22:12:13 +00:00
opaque_hidden_inferred_bound.rs Squash fold into ty 2025-03-15 06:34:36 +00:00
pass_by_value.rs Rustfmt 2025-02-08 22:12:13 +00:00
passes.rs fix empty after lint on impl/trait items 2025-02-07 16:47:26 +01:00
precedence.rs Temporarily switch ambiguous_negative_literals lint to allow 2024-07-31 19:36:47 +02:00
ptr_nulls.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
redundant_semicolon.rs Rustfmt 2025-02-08 22:12:13 +00:00
reference_casting.rs move fn is_item_raw to TypingEnv 2024-11-19 18:06:20 +01:00
shadowed_into_iter.rs Move methods from Map to TyCtxt, part 3. 2025-02-21 14:31:09 +11:00
static_mut_refs.rs Rustfmt 2025-02-08 22:12:13 +00:00
tests.rs update cfg(bootstrap) 2025-01-08 21:26:39 +01:00
traits.rs Rustfmt 2025-02-08 22:12:13 +00:00
types.rs Rollup merge of #138001 - meithecatte:privately-uninhabited, r=Nadrieril 2025-03-19 16:52:54 +01:00
unit_bindings.rs Rustfmt 2025-02-08 22:12:13 +00:00
unqualified_local_imports.rs Move methods from Map to TyCtxt, part 3. 2025-02-21 14:31:09 +11:00
unused.rs Remove unnecessary check code in unused_delims 2025-02-15 07:35:28 +08:00