rust/clippy_lints/src
bors 519799f099 Auto merge of #75800 - Aaron1011:feature/full-nt-tokens, r=petrochenkov
Attach tokens to all AST types used in `Nonterminal`

We perform token capturing when we have outer attributes (for nonterminals that support attributes - e.g. `Stmt`), or when we parse a `Nonterminal` for a `macro_rules!` argument. The full list of `Nonterminals` affected by this PR is:

* `NtBlock`
* `NtStmt`
* `NtTy`
* `NtMeta`
* `NtPath`
* `NtVis`
* `NtLiteral`

Of these nonterminals, only `NtStmt` and `NtLiteral` (which is actually just an `Expr`), support outer attributes - the rest only ever have token capturing perform when they match a `macro_rules!` argument.

This makes progress towards solving https://github.com/rust-lang/rust/issues/43081 - we now collect tokens for everything that might need them. However, we still need to handle `#[cfg]`, inner attributes, and misc pretty-printing issues (e.g. #75734)

I've separated the changes into (mostly) independent commits, which could be split into individual PRs for each `Nonterminal` variant. The purpose of having them all in one PR is to do a single Crater run for all of them.

Most of the changes in this PR are trivial (adding `tokens: None` everywhere we construct the various AST structs). The significant changes are:

* `ast::Visibility` is changed from `type Visibility = Spanned<VisibilityKind>` to a `struct Visibility { kind, span, tokens }`.
* `maybe_collect_tokens` is made generic, and used for both `ast::Expr` and `ast::Stmt`.
* Some of the statement-parsing functions are refactored so that we can capture the trailing semicolon.
* `Nonterminal` and `Expr` both grew by 8 bytes, as some of the structs which are stored inline (rather than behind a `P`) now have an `Option<TokenStream>` field. Hopefully the performance impact of doing this is negligible.
2020-09-11 02:35:01 +00:00
..
methods Merge commit '5034d47f72' into clippyup 2020-09-10 17:47:07 +02:00
utils Auto merge of #75800 - Aaron1011:feature/full-nt-tokens, r=petrochenkov 2020-09-11 02:35:01 +00:00
approx_const.rs Use 'tcx for references to AccessLevels wherever possible. 2020-07-03 00:04:48 +03:00
arithmetic.rs Rename TypeckTables to TypeckResults. 2020-07-17 08:47:04 +00:00
as_conversions.rs Add an Option<Span> argument to span_lint_and_help. 2020-04-18 18:28:29 +08:00
assertions_on_constants.rs Rename TypeckTables to TypeckResults. 2020-07-17 08:47:04 +00:00
assign_ops.rs Merge commit '3d0b0e66af' into clippyup 2020-08-28 18:43:25 +02:00
async_yields_async.rs Merge commit '5034d47f72' into clippyup 2020-09-10 17:47:07 +02:00
atomic_ordering.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
attrs.rs Merge commit '5034d47f72' into clippyup 2020-09-10 17:47:07 +02:00
await_holding_lock.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
bit_mask.rs Rename TypeckTables to TypeckResults. 2020-07-17 08:47:04 +00:00
blacklisted_name.rs Use 'tcx for references to AccessLevels wherever possible. 2020-07-03 00:04:48 +03:00
blocks_in_if_conditions.rs Use 'tcx for references to AccessLevels wherever possible. 2020-07-03 00:04:48 +03:00
booleans.rs Merge commit '3d0b0e66af' into clippyup 2020-08-28 18:43:25 +02:00
bytecount.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
cargo_common_metadata.rs Use 'tcx for references to AccessLevels wherever possible. 2020-07-03 00:04:48 +03:00
checked_conversions.rs Merge commit '09bd400243' into clippyup 2020-08-11 17:50:45 +02:00
cognitive_complexity.rs Rename TypeckTables to TypeckResults. 2020-07-17 08:47:04 +00:00
collapsible_if.rs Merge commit '2ca58e7dda' into clippyup 2020-07-14 14:59:59 +02:00
comparison_chain.rs Rename TypeckTables to TypeckResults. 2020-07-17 08:47:04 +00:00
consts.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
copies.rs Merge commit '3d0b0e66af' into clippyup 2020-08-28 18:43:25 +02:00
copy_iterator.rs Use 'tcx for references to AccessLevels wherever possible. 2020-07-03 00:04:48 +03:00
create_dir.rs Merge commit '5034d47f72' into clippyup 2020-09-10 17:47:07 +02:00
dbg_macro.rs Add an Option<Span> argument to span_lint_and_help. 2020-04-18 18:28:29 +08:00
default_trait_access.rs Merge commit '5034d47f72' into clippyup 2020-09-10 17:47:07 +02:00
deprecated_lints.rs Merge commit 'da5a6fb1b6' into clippyup 2020-07-26 21:07:07 +02:00
dereference.rs Merge commit 'da5a6fb1b6' into clippyup 2020-07-26 21:07:07 +02:00
derive.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
doc.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
double_comparison.rs Merge commit '3d0b0e66af' into clippyup 2020-08-28 18:43:25 +02:00
double_parens.rs Merge commit '09bd400243' into clippyup 2020-08-11 17:50:45 +02:00
drop_bounds.rs Merge commit '09bd400243' into clippyup 2020-08-11 17:50:45 +02:00
drop_forget_ref.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
duration_subsec.rs Merge commit '3d0b0e66af' into clippyup 2020-08-28 18:43:25 +02:00
else_if_without_else.rs Add an Option<Span> argument to span_lint_and_help. 2020-04-18 18:28:29 +08:00
empty_enum.rs Use 'tcx for references to AccessLevels wherever possible. 2020-07-03 00:04:48 +03:00
entry.rs Rename TypeckTables to TypeckResults. 2020-07-17 08:47:04 +00:00
enum_clike.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
enum_variants.rs Fully integrate token collection for additional AST structs 2020-09-10 17:58:14 -04:00
eq_op.rs Merge commit '3d0b0e66af' into clippyup 2020-08-28 18:43:25 +02:00
erasing_op.rs Rename TypeckTables to TypeckResults. 2020-07-17 08:47:04 +00:00
escape.rs Rename TypeckTables to TypeckResults. 2020-07-17 08:47:04 +00:00
eta_reduction.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
eval_order_dependence.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
excessive_bools.rs Add an Option<Span> argument to span_lint_and_help. 2020-04-18 18:28:29 +08:00
exit.rs Use 'tcx for references to AccessLevels wherever possible. 2020-07-03 00:04:48 +03:00
explicit_write.rs Use 'tcx for references to AccessLevels wherever possible. 2020-07-03 00:04:48 +03:00
fallible_impl_from.rs Rename TypeckTables to TypeckResults. 2020-07-17 08:47:04 +00:00
float_equality_without_abs.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
float_literal.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
floating_point_arithmetic.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
format.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
formatting.rs Merge commit '2ca58e7dda' into clippyup 2020-07-14 14:59:59 +02:00
functions.rs Merge commit '5034d47f72' into clippyup 2020-09-10 17:47:07 +02:00
future_not_send.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
get_last_with_len.rs Rename TypeckTables to TypeckResults. 2020-07-17 08:47:04 +00:00
identity_op.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
if_let_mutex.rs Rename TypeckTables to TypeckResults. 2020-07-17 08:47:04 +00:00
if_let_some_result.rs Merge commit '3d0b0e66af' into clippyup 2020-08-28 18:43:25 +02:00
if_not_else.rs Merge commit '3d0b0e66af' into clippyup 2020-08-28 18:43:25 +02:00
implicit_return.rs Use 'tcx for references to AccessLevels wherever possible. 2020-07-03 00:04:48 +03:00
implicit_saturating_sub.rs Merge commit '3d0b0e66af' into clippyup 2020-08-28 18:43:25 +02:00
indexing_slicing.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
infinite_iter.rs clippy: support QPath::LangItem 2020-08-17 13:55:05 +01:00
inherent_impl.rs Merge commit '3d0b0e66af' into clippyup 2020-08-28 18:43:25 +02:00
inherent_to_string.rs Use 'tcx for references to AccessLevels wherever possible. 2020-07-03 00:04:48 +03:00
inline_fn_without_body.rs rustc_ast: (Nested)MetaItem::check_name -> has_name 2020-08-04 00:34:11 +03:00
int_plus_one.rs Merge commit '3d0b0e66af' into clippyup 2020-08-28 18:43:25 +02:00
integer_division.rs Rename TypeckTables to TypeckResults. 2020-07-17 08:47:04 +00:00
items_after_statements.rs Merge commit 'ff0993c5e9' into clippy 2020-06-09 14:36:01 +00:00
large_const_arrays.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
large_enum_variant.rs Use 'tcx for references to AccessLevels wherever possible. 2020-07-03 00:04:48 +03:00
large_stack_arrays.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
len_zero.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
let_if_seq.rs Rename TypeckTables to TypeckResults. 2020-07-17 08:47:04 +00:00
let_underscore.rs Rename TypeckTables to TypeckResults. 2020-07-17 08:47:04 +00:00
lib.rs Merge commit '5034d47f72' into clippyup 2020-09-10 17:47:07 +02:00
lifetimes.rs Merge commit '09bd400243' into clippyup 2020-08-11 17:50:45 +02:00
literal_representation.rs Merge commit '2ca58e7dda' into clippyup 2020-07-14 14:59:59 +02:00
loops.rs Merge commit '5034d47f72' into clippyup 2020-09-10 17:47:07 +02:00
macro_use.rs Use 'tcx for references to AccessLevels wherever possible. 2020-07-03 00:04:48 +03:00
main_recursion.rs Use 'tcx for references to AccessLevels wherever possible. 2020-07-03 00:04:48 +03:00
manual_async_fn.rs Merge commit '09bd400243' into clippyup 2020-08-11 17:50:45 +02:00
manual_non_exhaustive.rs Fully integrate token collection for additional AST structs 2020-09-10 17:58:14 -04:00
map_clone.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
map_identity.rs Rename TypeckTables to TypeckResults. 2020-07-17 08:47:04 +00:00
map_unit_fn.rs Merge commit '5034d47f72' into clippyup 2020-09-10 17:47:07 +02:00
match_on_vec_items.rs Merge commit '3d0b0e66af' into clippyup 2020-08-28 18:43:25 +02:00
matches.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
mem_discriminant.rs Rename TypeckTables to TypeckResults. 2020-07-17 08:47:04 +00:00
mem_forget.rs Rename TypeckTables to TypeckResults. 2020-07-17 08:47:04 +00:00
mem_replace.rs Rename TypeckTables to TypeckResults. 2020-07-17 08:47:04 +00:00
minmax.rs Merge commit '09bd400243' into clippyup 2020-08-11 17:50:45 +02:00
misc.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
misc_early.rs Merge commit '09bd400243' into clippyup 2020-08-11 17:50:45 +02:00
missing_const_for_fn.rs Merge commit 'da5a6fb1b6' into clippyup 2020-07-26 21:07:07 +02:00
missing_doc.rs rustc_ast: (Nested)MetaItem::check_name -> has_name 2020-08-04 00:34:11 +03:00
missing_inline.rs rustc_ast: (Nested)MetaItem::check_name -> has_name 2020-08-04 00:34:11 +03:00
modulo_arithmetic.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
multiple_crate_versions.rs Use 'tcx for references to AccessLevels wherever possible. 2020-07-03 00:04:48 +03:00
mut_key.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
mut_mut.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
mut_reference.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
mutable_debug_assertion.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
mutex_atomic.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
needless_arbitrary_self_type.rs Merge commit '09bd400243' into clippyup 2020-08-11 17:50:45 +02:00
needless_bool.rs Merge commit '09bd400243' into clippyup 2020-08-11 17:50:45 +02:00
needless_borrow.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
needless_borrowed_ref.rs Use 'tcx for references to AccessLevels wherever possible. 2020-07-03 00:04:48 +03:00
needless_continue.rs Merge commit 'ff0993c5e9' into clippy 2020-06-09 14:36:01 +00:00
needless_pass_by_value.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
needless_update.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
neg_cmp_op_on_partial_ord.rs Merge commit '09bd400243' into clippyup 2020-08-11 17:50:45 +02:00
neg_multiply.rs Merge commit '09bd400243' into clippyup 2020-08-11 17:50:45 +02:00
new_without_default.rs merge as_local_hir_id with local_def_id_to_hir_id 2020-08-13 16:55:16 +02:00
no_effect.rs Rename TypeckTables to TypeckResults. 2020-07-17 08:47:04 +00:00
non_copy_const.rs ty.flags -> ty.flags() 2020-09-04 18:28:20 +02:00
non_expressive_names.rs Eliminate the SessionGlobals from librustc_ast. 2020-08-08 12:03:42 +10:00
open_options.rs Rename TypeckTables to TypeckResults. 2020-07-17 08:47:04 +00:00
option_env_unwrap.rs Update Clippy for MethodCall changes 2020-06-10 17:30:11 -04:00
option_if_let_else.rs Merge commit 'da5a6fb1b6' into clippyup 2020-07-26 21:07:07 +02:00
overflow_check_conditional.rs Merge commit '09bd400243' into clippyup 2020-08-11 17:50:45 +02:00
panic_unimplemented.rs Merge commit 'da5a6fb1b6' into clippyup 2020-07-26 21:07:07 +02:00
partialeq_ne_impl.rs Use 'tcx for references to AccessLevels wherever possible. 2020-07-03 00:04:48 +03:00
path_buf_push_overwrite.rs Merge commit '09bd400243' into clippyup 2020-08-11 17:50:45 +02:00
pattern_type_mismatch.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
precedence.rs Merge commit '3d0b0e66af' into clippyup 2020-08-28 18:43:25 +02:00
ptr.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
ptr_offset_with_cast.rs Rename TypeckTables to TypeckResults. 2020-07-17 08:47:04 +00:00
question_mark.rs Merge commit '3d0b0e66af' into clippyup 2020-08-28 18:43:25 +02:00
ranges.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
redundant_clone.rs Auto merge of #76044 - ecstatic-morse:dataflow-lattice, r=oli-obk 2020-09-07 21:29:43 +00:00
redundant_closure_call.rs Merge commit '3d0b0e66af' into clippyup 2020-08-28 18:43:25 +02:00
redundant_field_names.rs Merge commit '7ea7cd165a' into clippyup2 2020-05-28 15:45:24 +02:00
redundant_pub_crate.rs Use 'tcx for references to AccessLevels wherever possible. 2020-07-03 00:04:48 +03:00
redundant_static_lifetimes.rs Merge commit '09bd400243' into clippyup 2020-08-11 17:50:45 +02:00
reference.rs Merge commit '09bd400243' into clippyup 2020-08-11 17:50:45 +02:00
regex.rs Rename TypeckTables to TypeckResults. 2020-07-17 08:47:04 +00:00
repeat_once.rs Merge commit '3d0b0e66af' into clippyup 2020-08-28 18:43:25 +02:00
returns.rs Merge commit '3d0b0e66af' into clippyup 2020-08-28 18:43:25 +02:00
self_assignment.rs Merge commit '3d0b0e66af' into clippyup 2020-08-28 18:43:25 +02:00
serde_api.rs Use 'tcx for references to AccessLevels wherever possible. 2020-07-03 00:04:48 +03:00
shadow.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
single_component_path_imports.rs Fully integrate token collection for additional AST structs 2020-09-10 17:58:14 -04:00
slow_vector_initialization.rs Use 'tcx for references to AccessLevels wherever possible. 2020-07-03 00:04:48 +03:00
stable_sort_primitive.rs Merge commit '3d0b0e66af' into clippyup 2020-08-28 18:43:25 +02:00
strings.rs rust_ast::ast => rustc_ast 2020-08-17 20:32:32 +00:00
suspicious_trait_impl.rs Merge commit '3d0b0e66af' into clippyup 2020-08-28 18:43:25 +02:00
swap.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
tabs_in_doc_comments.rs Add some comments for magic numbers + Add tests 2020-08-06 22:55:26 +03:00
temporary_assignment.rs Merge commit '5034d47f72' into clippyup 2020-09-10 17:47:07 +02:00
to_digit_is_some.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
to_string_in_display.rs Merge commit '3d0b0e66af' into clippyup 2020-08-28 18:43:25 +02:00
trait_bounds.rs Merge commit '09bd400243' into clippyup 2020-08-11 17:50:45 +02:00
transmute.rs Merge commit '5034d47f72' into clippyup 2020-09-10 17:47:07 +02:00
transmuting_null.rs rust_ast::ast => rustc_ast 2020-08-17 20:32:32 +00:00
trivially_copy_pass_by_ref.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
try_err.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
types.rs Merge commit '5034d47f72' into clippyup 2020-09-10 17:47:07 +02:00
unicode.rs Use 'tcx for references to AccessLevels wherever possible. 2020-07-03 00:04:48 +03:00
unit_return_expecting_ord.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
unnamed_address.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
unnecessary_sort_by.rs Merge commit '5034d47f72' into clippyup 2020-09-10 17:47:07 +02:00
unnested_or_patterns.rs Merge commit '3d0b0e66af' into clippyup 2020-08-28 18:43:25 +02:00
unsafe_removed_from_name.rs Avoid storing SymbolStr in a struct. 2020-07-17 08:28:22 +10:00
unused_io_amount.rs clippy: support QPath::LangItem 2020-08-17 13:55:05 +01:00
unused_self.rs Use 'tcx for references to AccessLevels wherever possible. 2020-07-03 00:04:48 +03:00
unused_unit.rs Merge commit '3d0b0e66af' into clippyup 2020-08-28 18:43:25 +02:00
unwrap.rs Merge commit '09bd400243' into clippyup 2020-08-11 17:50:45 +02:00
unwrap_in_result.rs Merge commit '3d0b0e66af' into clippyup 2020-08-28 18:43:25 +02:00
use_self.rs Merge commit '3d0b0e66af' into clippyup 2020-08-28 18:43:25 +02:00
useless_conversion.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
vec.rs ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
vec_resize_to_zero.rs rust_ast::ast => rustc_ast 2020-08-17 20:32:32 +00:00
verbose_file_reads.rs Rename TypeckTables to TypeckResults. 2020-07-17 08:47:04 +00:00
wildcard_dependencies.rs Use 'tcx for references to AccessLevels wherever possible. 2020-07-03 00:04:48 +03:00
wildcard_imports.rs Merge commit '3d0b0e66af' into clippyup 2020-08-28 18:43:25 +02:00
write.rs Merge commit '3d0b0e66af' into clippyup 2020-08-28 18:43:25 +02:00
zero_div_zero.rs Rename TypeckTables to TypeckResults. 2020-07-17 08:47:04 +00:00