rust/compiler/rustc_lint/src
Nicholas Nethercote 90db033955 Folding revamp.
This commit makes type folding more like the way chalk does it.

Currently, `TypeFoldable` has `fold_with` and `super_fold_with` methods.
- `fold_with` is the standard entry point, and defaults to calling
  `super_fold_with`.
- `super_fold_with` does the actual work of traversing a type.
- For a few types of interest (`Ty`, `Region`, etc.) `fold_with` instead
  calls into a `TypeFolder`, which can then call back into
  `super_fold_with`.

With the new approach, `TypeFoldable` has `fold_with` and
`TypeSuperFoldable` has `super_fold_with`.
- `fold_with` is still the standard entry point, *and* it does the
  actual work of traversing a type, for all types except types of
  interest.
- `super_fold_with` is only implemented for the types of interest.

Benefits of the new model.
- I find it easier to understand. The distinction between types of
  interest and other types is clearer, and `super_fold_with` doesn't
  exist for most types.
- With the current model is easy to get confused and implement a
  `super_fold_with` method that should be left defaulted. (Some of the
  precursor commits fixed such cases.)
- With the current model it's easy to call `super_fold_with` within
  `TypeFolder` impls where `fold_with` should be called. The new
  approach makes this mistake impossible, and this commit fixes a number
  of such cases.
- It's potentially faster, because it avoids the `fold_with` ->
  `super_fold_with` call in all cases except types of interest. A lot of
  the time the compile would inline those away, but not necessarily
  always.
2022-06-08 09:24:03 +10:00
..
nonstandard_style mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
array_into_iter.rs errors: span_suggestion takes impl ToString 2022-04-29 02:05:20 +01:00
builtin.rs Auto merge of #97086 - 5225225:link-section-is-unsafe, r=davidtwco 2022-06-06 10:43:27 +00:00
context.rs Lint single-use-lifetimes on the AST. 2022-05-20 12:26:37 +02:00
early.rs Emit weird lint name lints after expansion 2022-05-24 17:27:34 +02:00
enum_intrinsics_non_enums.rs initial revert 2022-01-15 01:16:55 +00:00
expect.rs Move lint expectation checking into a separate query (RFC 2383) 2022-05-08 14:37:14 +02:00
hidden_unicode_codepoints.rs Remove unnecessary sigils around Symbol::as_str() calls. 2021-12-15 17:32:14 +11:00
internal.rs Fix TyKind lint, make consts no longer fn, etc 2022-05-28 11:38:22 -07:00
late.rs Remove crate visibility usage in compiler 2022-05-20 20:04:54 -04:00
levels.rs Lint single-use-lifetimes on the AST. 2022-05-20 12:26:37 +02:00
lib.rs Fully stabilize NLL 2022-06-03 17:16:41 -04:00
methods.rs Improve AdtDef interning. 2022-03-11 13:31:24 +11:00
non_ascii_idents.rs rustc_error: make ErrorReported impossible to construct 2022-03-16 10:35:24 -05:00
non_fmt_panic.rs Make rustc_parse_format compile on stable 2022-05-03 11:26:58 +02:00
nonstandard_style.rs Stop visiting visibility. 2022-04-23 09:53:45 +02:00
noop_method_call.rs Spellchecking compiler comments 2022-03-30 15:14:15 -04:00
pass_by_value.rs Improve AdtDef interning. 2022-03-11 13:31:24 +11:00
passes.rs Do not pass hir::Crate to lints. 2021-09-30 17:39:54 +02:00
redundant_semicolon.rs Lint on redundant trailing semicolon after item 2020-12-29 16:30:02 -05:00
tests.rs Update to last upstream version 2021-07-08 17:14:28 +02:00
traits.rs Rename ~const Drop to ~const Destruct 2022-03-21 17:04:03 +11:00
types.rs Folding revamp. 2022-06-08 09:24:03 +10:00
unused.rs only_local: always check for misuse 2022-05-10 12:07:35 +02:00