Commit 66099cd
committed
Don't trim non-parenthesis spans in unused_parens for bounds
`poly_trait_ref.parens` only records that the parser saw parentheses
around a trait-object/impl-trait bound; it does not guarantee that the
bound's span actually points at those parentheses in the source. A
proc-macro can synthesize the parentheses while reusing an unrelated span
from its input, so the span may not be wrapped in parentheses at all.
Previously the lint unconditionally trimmed the first and last byte of the
span to build the "remove these parentheses" suggestion. On such reused
spans this produced an invalid suggestion (e.g. rewriting a field
`val: u8` to `al: u`) and could even ICE when the span started or ended on
a multibyte character.
Only emit the lint when the source text at the span really is wrapped in
parentheses.0 parents commit 66099cd
60,053 files changed
Lines changed: 6067885 additions & 0 deletions
File tree
- .github
- ISSUE_TEMPLATE
- workflows
- LICENSES
- compiler
- rustc_abi
- src
- callconv
- extern_abi
- layout
- rustc_arena
- src
- rustc_ast_ir
- src
- rustc_ast_lowering
- src
- delegation
- expr
- rustc_ast_passes
- src
- rustc_ast_pretty
- src
- pprust
- state
- pp
- rustc_ast
- src
- attr
- expand
- util
- comments
- rustc_attr_parsing
- src
- attributes
- diagnostic
- rustc_baked_icu_data
- src
- data
- rustc_borrowck
- src
- constraints
- diagnostics
- polonius
- legacy
- region_infer
- opaque_types
- type_check
- liveness
- rustc_builtin_macros
- src
- assert
- deriving
- cmp
- generic
- format_foreign
- printf
- shell
- rustc_codegen_cranelift
- .github
- scripts
- workflows
- .vscode
- .zed
- build_system
- docs
- example
- patches
- scripts
- src
- abi
- debuginfo
- driver
- intrinsics
- optimize
- rustc_codegen_gcc
- .github/workflows
- build_system
- src
- fuzz
- doc
- example
- patches
- crates
- cross_patches
- libgccjit12
- src
- back
- intrinsic
- target_specs
- tests
- compile
- cross_lang_lto
- src
- hello-world
- mylib
- src
- src
- no_builtins
- run
- tools
- cspell_dicts
- rustc_codegen_llvm
- src
- back
- builder
- coverageinfo
- mapgen
- debuginfo
- metadata
- enums
- llvm
- rustc_codegen_ssa
- src
- back
- apple
- linker
- link
- rpath
- debuginfo
- mir
- traits
- rustc_const_eval
- src
- check_consts
- const_eval
- type_info
- interpret
- intrinsics
- util
- rustc_data_structures
- src
- base_n
- binary_search_util
- fingerprint
- flock
- graph
- dominators
- iterate
- linked_graph
- scc
- vec_graph
- intern
- obligation_forest
- owned_slice
- profiling
- small_c_str
- snapshot_map
- sorted_map
- sso
- stable_hash
- sync
- tagged_ptr
- thousands
- transitive_relation
- union_find
- vec_cache
- rustc_driver_impl
- src
- rustc_driver
- src
- rustc_error_codes
- src
- error_codes
- rustc_error_messages
- src
- rustc_errors
- src
- json
- markdown
- tests
- rustc_expand
- src
- mbe
- rustc_feature
- src
- rustc_fs_util
- src
- rustc_graphviz
- src
- rustc_hashes
- src
- rustc_hir_analysis
- src
- check
- compare_impl_item
- coherence
- collect
- type_of
- errors
- hir_ty_lowering
- impl_wf_check
- outlives
- variance
- rustc_hir_id
- src
- rustc_hir_pretty
- src
- rustc_hir_typeck
- src
- fn_ctxt
- method
- rustc_hir
- src
- attrs
- hir
- rustc_incremental
- src
- persist
- fs
- rustc_index_macros
- src
- rustc_index
- src
- bit_set
- interval
- vec
- rustc_infer
- src
- infer
- canonical
- lexical_region_resolve
- opaque_types
- outlives
- region_constraints
- relate
- snapshot
- traits
- rustc_interface
- src
- rustc_lexer
- src
- rustc_lint_defs
- src
- rustc_lint
- src
- early
- nonstandard_style
- types
- unused
- rustc_llvm
- llvm-wrapper
- src
- rustc_log
- src
- rustc_macros
- src
- diagnostics
- symbols
- rustc_metadata
- src
- rmeta
- decoder
- rustc_middle
- src
- dep_graph
- hir
- hooks
- infer
- middle
- mir
- interpret
- allocation
- init_mask
- query
- thir
- traits
- ty
- consts
- context
- inhabitedness
- print
- util
- rustc_mir_build
- src
- builder
- custom
- parse
- expr
- matches
- thir
- cx
- pattern
- rustc_mir_dataflow
- src
- framework
- impls
- move_paths
- rustc_mir_transform
- src
- coroutine
- coverage
- counters
- node_flow
- inline
- shim
- rustc_monomorphize
- src
- graph_checks
- mono_checks
- rustc_next_trait_solver
- src
- canonical
- solve
- assembly
- eval_ctxt
- inspect
- normalizes_to
- rustc_parse_format
- src
- rustc_parse
- src
- lexer
- parser
- tokenstream
- rustc_passes
- src
- rustc_pattern_analysis
- src
- rustc
- tests
- common
- rustc_privacy
- src
- rustc_proc_macro
- rustc_public_bridge
- src
- context
- rustc_public
- src
- mir
- rustc_internal
- unstable
- convert
- stable
- internal_cx
- rustc_query_impl
- src
- rustc_resolve
- src
- late
- rustdoc
- rustc_sanitizers
- src
- cfi
- typeid
- itanium_cxx_abi
- kcfi
- typeid
- rustc_serialize
- src
- leb128
- opaque
- rustc_session
- src
- config
- externs
- native_libs
- options
- rustc_span
- src
- analyze_source_file
- edit_distance
- source_map
- symbol
- rustc_symbol_mangling
- src
- rustc_target
- src
- asm
- callconv
- spec
- base
- apple
- targets
- rustc_thread_pool
- src
- broadcast
- compile_fail
- join
- scope
- sleep
- spawn
- thread_pool
- tests
- rustc_trait_selection
- src
- error_reporting
- infer
- nice_region_error
- traits
- errors
- solve
- fulfill
- inspect
- traits
- query
- type_op
- select
- specialize
- rustc_traits
- src
- rustc_transmute
- src
- layout
- tree
- maybe_transmutable
- rustc_ty_utils
- src
- layout
- rustc_type_ir_macros
- src
- rustc_type_ir
- src
- data_structures
- relate
- search_graph
- solve
- ty_kind
- rustc_windows_rc
- src
- rustc
- src
- library
- alloctests
- benches
- btree
- testing
- tests
- collections
- alloc
- src
- boxed
- collections
- binary_heap
- btree
- borrow
- map
- node
- set
- linked_list
- vec_deque
- ffi
- raw_vec
- vec
- wtf8
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
0 commit comments