github.com/v2fly/tools@v0.100.0/internal/lsp/analysis/simplifycompositelit/testdata/src/a/a.go.golden (about) 1 // Copyright 2020 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package testdata 6 7 type T struct { 8 x, y int 9 } 10 11 type T2 struct { 12 w, z int 13 } 14 15 var _ = [42]T{ 16 {}, // want "redundant type from array, slice, or map composite literal" 17 {1, 2}, // want "redundant type from array, slice, or map composite literal" 18 {3, 4}, // want "redundant type from array, slice, or map composite literal" 19 } 20 21 var _ = [...]T{ 22 {}, // want "redundant type from array, slice, or map composite literal" 23 {1, 2}, // want "redundant type from array, slice, or map composite literal" 24 {3, 4}, // want "redundant type from array, slice, or map composite literal" 25 } 26 27 var _ = []T{ 28 {}, // want "redundant type from array, slice, or map composite literal" 29 {1, 2}, // want "redundant type from array, slice, or map composite literal" 30 {3, 4}, // want "redundant type from array, slice, or map composite literal" 31 } 32 33 var _ = []T{ 34 {}, // want "redundant type from array, slice, or map composite literal" 35 10: {1, 2}, // want "redundant type from array, slice, or map composite literal" 36 20: {3, 4}, // want "redundant type from array, slice, or map composite literal" 37 } 38 39 var _ = []struct { 40 x, y int 41 }{ 42 {}, // want "redundant type from array, slice, or map composite literal" 43 10: {1, 2}, // want "redundant type from array, slice, or map composite literal" 44 20: {3, 4}, // want "redundant type from array, slice, or map composite literal" 45 } 46 47 var _ = []interface{}{ 48 T{}, 49 10: T{1, 2}, 50 20: T{3, 4}, 51 } 52 53 var _ = [][]int{ 54 {}, // want "redundant type from array, slice, or map composite literal" 55 {1, 2}, // want "redundant type from array, slice, or map composite literal" 56 {3, 4}, // want "redundant type from array, slice, or map composite literal" 57 } 58 59 var _ = [][]int{ 60 ([]int{}), 61 ([]int{1, 2}), 62 {3, 4}, // want "redundant type from array, slice, or map composite literal" 63 } 64 65 var _ = [][][]int{ 66 {}, // want "redundant type from array, slice, or map composite literal" 67 { // want "redundant type from array, slice, or map composite literal" 68 {}, // want "redundant type from array, slice, or map composite literal" 69 {0, 1, 2, 3}, // want "redundant type from array, slice, or map composite literal" 70 {4, 5}, // want "redundant type from array, slice, or map composite literal" 71 }, 72 } 73 74 var _ = map[string]T{ 75 "foo": {}, // want "redundant type from array, slice, or map composite literal" 76 "bar": {1, 2}, // want "redundant type from array, slice, or map composite literal" 77 "bal": {3, 4}, // want "redundant type from array, slice, or map composite literal" 78 } 79 80 var _ = map[string]struct { 81 x, y int 82 }{ 83 "foo": {}, // want "redundant type from array, slice, or map composite literal" 84 "bar": {1, 2}, // want "redundant type from array, slice, or map composite literal" 85 "bal": {3, 4}, // want "redundant type from array, slice, or map composite literal" 86 } 87 88 var _ = map[string]interface{}{ 89 "foo": T{}, 90 "bar": T{1, 2}, 91 "bal": T{3, 4}, 92 } 93 94 var _ = map[string][]int{ 95 "foo": {}, // want "redundant type from array, slice, or map composite literal" 96 "bar": {1, 2}, // want "redundant type from array, slice, or map composite literal" 97 "bal": {3, 4}, // want "redundant type from array, slice, or map composite literal" 98 } 99 100 var _ = map[string][]int{ 101 "foo": ([]int{}), 102 "bar": ([]int{1, 2}), 103 "bal": {3, 4}, // want "redundant type from array, slice, or map composite literal" 104 } 105 106 type Point struct { 107 a int 108 b int 109 } 110 111 type Piece struct { 112 a int 113 b int 114 c Point 115 d []Point 116 e *Point 117 f *Point 118 } 119 120 // from exp/4s/data.go 121 var pieces3 = []Piece{ 122 {0, 0, Point{4, 1}, []Point{{0, 0}, {1, 0}, {1, 0}, {1, 0}}, nil, nil}, // want "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" 123 {1, 0, Point{1, 4}, []Point{{0, 0}, {0, 1}, {0, 1}, {0, 1}}, nil, nil}, // want "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" 124 {2, 0, Point{4, 1}, []Point{{0, 0}, {1, 0}, {1, 0}, {1, 0}}, nil, nil}, // want "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" 125 {3, 0, Point{1, 4}, []Point{{0, 0}, {0, 1}, {0, 1}, {0, 1}}, nil, nil}, // want "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" 126 } 127 128 var _ = [42]*T{ 129 {}, // want "redundant type from array, slice, or map composite literal" 130 {1, 2}, // want "redundant type from array, slice, or map composite literal" 131 {3, 4}, // want "redundant type from array, slice, or map composite literal" 132 } 133 134 var _ = [...]*T{ 135 {}, // want "redundant type from array, slice, or map composite literal" 136 {1, 2}, // want "redundant type from array, slice, or map composite literal" 137 {3, 4}, // want "redundant type from array, slice, or map composite literal" 138 } 139 140 var _ = []*T{ 141 {}, // want "redundant type from array, slice, or map composite literal" 142 {1, 2}, // want "redundant type from array, slice, or map composite literal" 143 {3, 4}, // want "redundant type from array, slice, or map composite literal" 144 } 145 146 var _ = []*T{ 147 {}, // want "redundant type from array, slice, or map composite literal" 148 10: {1, 2}, // want "redundant type from array, slice, or map composite literal" 149 20: {3, 4}, // want "redundant type from array, slice, or map composite literal" 150 } 151 152 var _ = []*struct { 153 x, y int 154 }{ 155 {}, // want "redundant type from array, slice, or map composite literal" 156 10: {1, 2}, // want "redundant type from array, slice, or map composite literal" 157 20: {3, 4}, // want "redundant type from array, slice, or map composite literal" 158 } 159 160 var _ = []interface{}{ 161 &T{}, 162 10: &T{1, 2}, 163 20: &T{3, 4}, 164 } 165 166 var _ = []*[]int{ 167 {}, // want "redundant type from array, slice, or map composite literal" 168 {1, 2}, // want "redundant type from array, slice, or map composite literal" 169 {3, 4}, // want "redundant type from array, slice, or map composite literal" 170 } 171 172 var _ = []*[]int{ 173 (&[]int{}), 174 (&[]int{1, 2}), 175 {3, 4}, // want "redundant type from array, slice, or map composite literal" 176 } 177 178 var _ = []*[]*[]int{ 179 {}, // want "redundant type from array, slice, or map composite literal" 180 { // want "redundant type from array, slice, or map composite literal" 181 {}, // want "redundant type from array, slice, or map composite literal" 182 {0, 1, 2, 3}, // want "redundant type from array, slice, or map composite literal" 183 {4, 5}, // want "redundant type from array, slice, or map composite literal" 184 }, 185 } 186 187 var _ = map[string]*T{ 188 "foo": {}, // want "redundant type from array, slice, or map composite literal" 189 "bar": {1, 2}, // want "redundant type from array, slice, or map composite literal" 190 "bal": {3, 4}, // want "redundant type from array, slice, or map composite literal" 191 } 192 193 var _ = map[string]*struct { 194 x, y int 195 }{ 196 "foo": {}, // want "redundant type from array, slice, or map composite literal" 197 "bar": {1, 2}, // want "redundant type from array, slice, or map composite literal" 198 "bal": {3, 4}, // want "redundant type from array, slice, or map composite literal" 199 } 200 201 var _ = map[string]interface{}{ 202 "foo": &T{}, 203 "bar": &T{1, 2}, 204 "bal": &T{3, 4}, 205 } 206 207 var _ = map[string]*[]int{ 208 "foo": {}, // want "redundant type from array, slice, or map composite literal" 209 "bar": {1, 2}, // want "redundant type from array, slice, or map composite literal" 210 "bal": {3, 4}, // want "redundant type from array, slice, or map composite literal" 211 } 212 213 var _ = map[string]*[]int{ 214 "foo": (&[]int{}), 215 "bar": (&[]int{1, 2}), 216 "bal": {3, 4}, // want "redundant type from array, slice, or map composite literal" 217 } 218 219 var pieces4 = []*Piece{ 220 {0, 0, Point{4, 1}, []Point{{0, 0}, {1, 0}, {1, 0}, {1, 0}}, nil, nil}, // want "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" 221 {1, 0, Point{1, 4}, []Point{{0, 0}, {0, 1}, {0, 1}, {0, 1}}, nil, nil}, // want "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" 222 {2, 0, Point{4, 1}, []Point{{0, 0}, {1, 0}, {1, 0}, {1, 0}}, nil, nil}, // want "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" 223 {3, 0, Point{1, 4}, []Point{{0, 0}, {0, 1}, {0, 1}, {0, 1}}, nil, nil}, // want "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" 224 } 225 226 var _ = map[T]T2{ 227 {1, 2}: {3, 4}, // want "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" 228 {5, 6}: {7, 8}, // want "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" 229 } 230 231 var _ = map[*T]*T2{ 232 {1, 2}: {3, 4}, // want "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" 233 {5, 6}: {7, 8}, // want "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal" 234 }