Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / tools@v0.0.0-20201028153306-37f0764111ff / internal / lsp / analysis / simplifycompositelit / testdata / src / a / a.go
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         T{},     // want "redundant type from array, slice, or map composite literal"
17         T{1, 2}, // want "redundant type from array, slice, or map composite literal"
18         T{3, 4}, // want "redundant type from array, slice, or map composite literal"
19 }
20
21 var _ = [...]T{
22         T{},     // want "redundant type from array, slice, or map composite literal"
23         T{1, 2}, // want "redundant type from array, slice, or map composite literal"
24         T{3, 4}, // want "redundant type from array, slice, or map composite literal"
25 }
26
27 var _ = []T{
28         T{},     // want "redundant type from array, slice, or map composite literal"
29         T{1, 2}, // want "redundant type from array, slice, or map composite literal"
30         T{3, 4}, // want "redundant type from array, slice, or map composite literal"
31 }
32
33 var _ = []T{
34         T{}, // want "redundant type from array, slice, or map composite literal"
35         10:  T{1, 2}, // want "redundant type from array, slice, or map composite literal"
36         20:  T{3, 4}, // want "redundant type from array, slice, or map composite literal"
37 }
38
39 var _ = []struct {
40         x, y int
41 }{
42         struct{ x, y int }{}, // want "redundant type from array, slice, or map composite literal"
43         10:                   struct{ x, y int }{1, 2}, // want "redundant type from array, slice, or map composite literal"
44         20:                   struct{ x, y int }{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         []int{},     // want "redundant type from array, slice, or map composite literal"
55         []int{1, 2}, // want "redundant type from array, slice, or map composite literal"
56         []int{3, 4}, // want "redundant type from array, slice, or map composite literal"
57 }
58
59 var _ = [][]int{
60         ([]int{}),
61         ([]int{1, 2}),
62         []int{3, 4}, // want "redundant type from array, slice, or map composite literal"
63 }
64
65 var _ = [][][]int{
66         [][]int{}, // want "redundant type from array, slice, or map composite literal"
67         [][]int{ // want "redundant type from array, slice, or map composite literal"
68                 []int{},           // want "redundant type from array, slice, or map composite literal"
69                 []int{0, 1, 2, 3}, // want "redundant type from array, slice, or map composite literal"
70                 []int{4, 5},       // want "redundant type from array, slice, or map composite literal"
71         },
72 }
73
74 var _ = map[string]T{
75         "foo": T{},     // want "redundant type from array, slice, or map composite literal"
76         "bar": T{1, 2}, // want "redundant type from array, slice, or map composite literal"
77         "bal": T{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": struct{ x, y int }{},     // want "redundant type from array, slice, or map composite literal"
84         "bar": struct{ x, y int }{1, 2}, // want "redundant type from array, slice, or map composite literal"
85         "bal": struct{ x, y int }{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": []int{},     // want "redundant type from array, slice, or map composite literal"
96         "bar": []int{1, 2}, // want "redundant type from array, slice, or map composite literal"
97         "bal": []int{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": []int{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         Piece{0, 0, Point{4, 1}, []Point{Point{0, 0}, Point{1, 0}, Point{1, 0}, Point{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         Piece{1, 0, Point{1, 4}, []Point{Point{0, 0}, Point{0, 1}, Point{0, 1}, Point{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         Piece{2, 0, Point{4, 1}, []Point{Point{0, 0}, Point{1, 0}, Point{1, 0}, Point{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         Piece{3, 0, Point{1, 4}, []Point{Point{0, 0}, Point{0, 1}, Point{0, 1}, Point{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         &T{},     // want "redundant type from array, slice, or map composite literal"
130         &T{1, 2}, // want "redundant type from array, slice, or map composite literal"
131         &T{3, 4}, // want "redundant type from array, slice, or map composite literal"
132 }
133
134 var _ = [...]*T{
135         &T{},     // want "redundant type from array, slice, or map composite literal"
136         &T{1, 2}, // want "redundant type from array, slice, or map composite literal"
137         &T{3, 4}, // want "redundant type from array, slice, or map composite literal"
138 }
139
140 var _ = []*T{
141         &T{},     // want "redundant type from array, slice, or map composite literal"
142         &T{1, 2}, // want "redundant type from array, slice, or map composite literal"
143         &T{3, 4}, // want "redundant type from array, slice, or map composite literal"
144 }
145
146 var _ = []*T{
147         &T{}, // want "redundant type from array, slice, or map composite literal"
148         10:   &T{1, 2}, // want "redundant type from array, slice, or map composite literal"
149         20:   &T{3, 4}, // want "redundant type from array, slice, or map composite literal"
150 }
151
152 var _ = []*struct {
153         x, y int
154 }{
155         &struct{ x, y int }{}, // want "redundant type from array, slice, or map composite literal"
156         10:                    &struct{ x, y int }{1, 2}, // want "redundant type from array, slice, or map composite literal"
157         20:                    &struct{ x, y int }{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         &[]int{},     // want "redundant type from array, slice, or map composite literal"
168         &[]int{1, 2}, // want "redundant type from array, slice, or map composite literal"
169         &[]int{3, 4}, // want "redundant type from array, slice, or map composite literal"
170 }
171
172 var _ = []*[]int{
173         (&[]int{}),
174         (&[]int{1, 2}),
175         &[]int{3, 4}, // want "redundant type from array, slice, or map composite literal"
176 }
177
178 var _ = []*[]*[]int{
179         &[]*[]int{}, // want "redundant type from array, slice, or map composite literal"
180         &[]*[]int{ // want "redundant type from array, slice, or map composite literal"
181                 &[]int{},           // want "redundant type from array, slice, or map composite literal"
182                 &[]int{0, 1, 2, 3}, // want "redundant type from array, slice, or map composite literal"
183                 &[]int{4, 5},       // want "redundant type from array, slice, or map composite literal"
184         },
185 }
186
187 var _ = map[string]*T{
188         "foo": &T{},     // want "redundant type from array, slice, or map composite literal"
189         "bar": &T{1, 2}, // want "redundant type from array, slice, or map composite literal"
190         "bal": &T{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": &struct{ x, y int }{},     // want "redundant type from array, slice, or map composite literal"
197         "bar": &struct{ x, y int }{1, 2}, // want "redundant type from array, slice, or map composite literal"
198         "bal": &struct{ x, y int }{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": &[]int{},     // want "redundant type from array, slice, or map composite literal"
209         "bar": &[]int{1, 2}, // want "redundant type from array, slice, or map composite literal"
210         "bal": &[]int{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": &[]int{3, 4}, // want "redundant type from array, slice, or map composite literal"
217 }
218
219 var pieces4 = []*Piece{
220         &Piece{0, 0, Point{4, 1}, []Point{Point{0, 0}, Point{1, 0}, Point{1, 0}, Point{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         &Piece{1, 0, Point{1, 4}, []Point{Point{0, 0}, Point{0, 1}, Point{0, 1}, Point{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         &Piece{2, 0, Point{4, 1}, []Point{Point{0, 0}, Point{1, 0}, Point{1, 0}, Point{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         &Piece{3, 0, Point{1, 4}, []Point{Point{0, 0}, Point{0, 1}, Point{0, 1}, Point{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         T{1, 2}: T2{3, 4}, // want "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal"
228         T{5, 6}: T2{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         &T{1, 2}: &T2{3, 4}, // want "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal"
233         &T{5, 6}: &T2{7, 8}, // want "redundant type from array, slice, or map composite literal" "redundant type from array, slice, or map composite literal"
234 }