Skip to content

Commit 856ceb0

Browse files
authored
Upgrade Scalafmt to 3.8.5 and reformat (#4566)
1 parent c0bed84 commit 856ceb0

File tree

209 files changed

+1943
-2274
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

209 files changed

+1943
-2274
lines changed

.scalafmt.conf

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
1-
version = 2.6.4
1+
version = 3.8.5
22

3+
runner.dialect = scala213source3
4+
fileOverride {
5+
"glob:**/scala-3/**" {
6+
runner.dialect = scala3
7+
}
8+
}
39
maxColumn = 120
410
align = most
511
continuationIndent.defnSite = 2
612
assumeStandardLibraryStripMargin = true
7-
docstrings = ScalaDoc
13+
# TODO eventually enable, but audit handling of @define and @example {{{ (curly brace on same line)
14+
docstrings.style = keep
815
lineEndings = preserve
916
includeCurlyBraceInSelectChains = false
10-
danglingParentheses = true
17+
danglingParentheses.preset = true
1118

12-
align.tokens.add = [
19+
align.tokens."+" = [
1320
{
1421
code = ":"
1522
}
1623
]
1724

18-
newlines.alwaysBeforeCurlyBraceLambdaParams = false
19-
newlines.alwaysBeforeMultilineDef = false
20-
newlines.implicitParamListModifierForce = [before]
21-
22-
verticalMultiline.atDefnSite = true
25+
newlines.beforeCurlyLambdaParams = never
26+
newlines.forceBeforeMultilineAssign = never
27+
newlines.implicitParamListModifierPrefer = before
28+
newlines.sometimesBeforeColonInMethodReturnType = true
2329

2430
optIn.annotationNewlines = true
2531

build.mill

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ trait Chisel extends CrossSbtModule with HasScala2MacroAnno with HasScala2Plugin
266266

267267
object test extends SbtTests with TestModule.ScalaTest with ScalafmtModule {
268268
def ivyDeps = Agg(v.scalatest, v.scalacheck)
269-
269+
270270
// TODO: enable sandbox and run tests in parallel
271271
override def testSandboxWorkingDir = false
272272

core/src/main/scala-2/chisel3/Aggregate.scala

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,8 @@ object VecInit extends VecInitImpl with SourceInfoDoc {
117117

118118
/** @group SourceInfoTransformMacro */
119119
def do_tabulate[T <: Data](
120-
n: Int
121-
)(gen: (Int) => T
122-
)(
120+
n: Int
121+
)(gen: (Int) => T)(
123122
implicit sourceInfo: SourceInfo
124123
): Vec[T] = _tabulateImpl(n)(gen)
125124

@@ -136,10 +135,9 @@ object VecInit extends VecInitImpl with SourceInfoDoc {
136135

137136
/** @group SourceInfoTransformMacro */
138137
def do_tabulate[T <: Data](
139-
n: Int,
140-
m: Int
141-
)(gen: (Int, Int) => T
142-
)(
138+
n: Int,
139+
m: Int
140+
)(gen: (Int, Int) => T)(
143141
implicit sourceInfo: SourceInfo
144142
): Vec[Vec[T]] = _tabulateImpl(n, m)(gen)
145143

@@ -157,11 +155,10 @@ object VecInit extends VecInitImpl with SourceInfoDoc {
157155

158156
/** @group SourceInfoTransformMacro */
159157
def do_tabulate[T <: Data](
160-
n: Int,
161-
m: Int,
162-
p: Int
163-
)(gen: (Int, Int, Int) => T
164-
)(
158+
n: Int,
159+
m: Int,
160+
p: Int
161+
)(gen: (Int, Int, Int) => T)(
165162
implicit sourceInfo: SourceInfo
166163
): Vec[Vec[Vec[T]]] = _tabulateImpl(n, m, p)(gen)
167164

@@ -189,10 +186,9 @@ object VecInit extends VecInitImpl with SourceInfoDoc {
189186

190187
/** @group SourceInfoTransformMacro */
191188
def do_fill[T <: Data](
192-
n: Int,
193-
m: Int
194-
)(gen: => T
195-
)(
189+
n: Int,
190+
m: Int
191+
)(gen: => T)(
196192
implicit sourceInfo: SourceInfo
197193
): Vec[Vec[T]] = _fillImpl(n, m)(gen)
198194

@@ -209,11 +205,10 @@ object VecInit extends VecInitImpl with SourceInfoDoc {
209205

210206
/** @group SourceInfoTransformMacro */
211207
def do_fill[T <: Data](
212-
n: Int,
213-
m: Int,
214-
p: Int
215-
)(gen: => T
216-
)(
208+
n: Int,
209+
m: Int,
210+
p: Int
211+
)(gen: => T)(
217212
implicit sourceInfo: SourceInfo
218213
): Vec[Vec[Vec[T]]] = _fillImpl(n, m, p)(gen)
219214

@@ -231,8 +226,7 @@ object VecInit extends VecInitImpl with SourceInfoDoc {
231226
def do_iterate[T <: Data](
232227
start: T,
233228
len: Int
234-
)(f: (T) => T
235-
)(
229+
)(f: (T) => T)(
236230
implicit sourceInfo: SourceInfo
237231
): Vec[T] = _iterateImpl(start, len)(f)
238232
}

core/src/main/scala-2/chisel3/ChiselEnum.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ abstract class EnumType(factory: ChiselEnum, selfAnnotating: Boolean = true)
2626
}
2727

2828
abstract class ChiselEnum extends ChiselEnumImpl {
29-
protected def Value: Type = macro EnumMacros.ValImpl
29+
protected def Value: Type = macro EnumMacros.ValImpl
3030
protected def Value(id: UInt): Type = macro EnumMacros.ValCustomImpl
3131
}
3232

core/src/main/scala-2/chisel3/Mem.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,15 +185,15 @@ object SyncReadMem extends ObjectSyncReadMemImpl {
185185
* @param size number of elements in the memory
186186
* @param t data type of memory element
187187
*/
188-
def apply[T <: Data](size: BigInt, t: T): SyncReadMem[T] = macro MemTransform.apply[T]
188+
def apply[T <: Data](size: BigInt, t: T): SyncReadMem[T] = macro MemTransform.apply[T]
189189
def apply[T <: Data](size: BigInt, t: T, ruw: ReadUnderWrite): SyncReadMem[T] = macro MemTransform.apply_ruw[T]
190190

191191
/** Creates a sequential/synchronous-read, sequential/synchronous-write [[SyncReadMem]].
192192
*
193193
* @param size number of elements in the memory
194194
* @param t data type of memory element
195195
*/
196-
def apply[T <: Data](size: Int, t: T): SyncReadMem[T] = macro MemTransform.apply[T]
196+
def apply[T <: Data](size: Int, t: T): SyncReadMem[T] = macro MemTransform.apply[T]
197197
def apply[T <: Data](size: Int, t: T, ruw: ReadUnderWrite): SyncReadMem[T] = macro MemTransform.apply_ruw[T]
198198

199199
/** @group SourceInfoTransformMacro */
@@ -239,8 +239,8 @@ sealed class SyncReadMem[T <: Data] private[chisel3] (
239239
t: T,
240240
n: BigInt,
241241
val readUnderWrite: SyncReadMem.ReadUnderWrite,
242-
sourceInfo: SourceInfo)
243-
extends MemBase[T](t, n, sourceInfo)
242+
sourceInfo: SourceInfo
243+
) extends MemBase[T](t, n, sourceInfo)
244244
with SyncReadMemImpl[T] {
245245

246246
override def read(x: UInt): T = macro SourceInfoTransform.xArg

core/src/main/scala-2/chisel3/Num.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import chisel3.experimental.SourceInfo
2929
trait Num[T <: Data] extends NumImpl[T] {
3030
// def << (b: T): T
3131
// def >> (b: T): T
32-
//def unary_-: T
32+
// def unary_-: T
3333

3434
// REVIEW TODO: double check ops conventions against FIRRTL
3535

core/src/main/scala-2/chisel3/PrintfMacros.scala

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,8 @@ import scala.reflect.macros.blackbox
1111

1212
object PrintfMacrosCompat {
1313
def _applyMacroWithInterpolatorCheck(
14-
c: blackbox.Context
15-
)(fmt: c.Tree,
16-
data: c.Tree*
17-
)(sourceInfo: c.Tree
18-
): c.Tree = {
14+
c: blackbox.Context
15+
)(fmt: c.Tree, data: c.Tree*)(sourceInfo: c.Tree): c.Tree = {
1916
import c.universe._
2017
_checkFormatString(c)(fmt)
2118
val apply_impl_do = symbolOf[this.type].asClass.module.info.member(TermName("printfWithReset"))

core/src/main/scala-2/chisel3/VerificationStatementMacros.scala

Lines changed: 20 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,8 @@ object VerifStmtMacrosCompat {
4646

4747
/** @group VerifPrintMacros */
4848
def _applyMacroWithInterpolatorCheck(
49-
c: blackbox.Context
50-
)(cond: c.Tree,
51-
message: c.Tree,
52-
data: c.Tree*
53-
)(sourceInfo: c.Tree
54-
): c.Tree = {
49+
c: blackbox.Context
50+
)(cond: c.Tree, message: c.Tree, data: c.Tree*)(sourceInfo: c.Tree): c.Tree = {
5551
import c.universe._
5652
_checkFormatString(c)(message)
5753
val apply_impl_do = symbolOf[this.type].asClass.module.info.member(TermName("_applyWithSourceLinePrintable"))
@@ -60,35 +56,26 @@ object VerifStmtMacrosCompat {
6056

6157
/** @group VerifPrintMacros */
6258
def _applyMacroWithStringMessage(
63-
c: blackbox.Context
64-
)(cond: c.Tree,
65-
message: c.Tree,
66-
data: c.Tree
67-
)(sourceInfo: c.Tree
68-
): c.Tree = {
59+
c: blackbox.Context
60+
)(cond: c.Tree, message: c.Tree, data: c.Tree)(sourceInfo: c.Tree): c.Tree = {
6961
import c.universe._
7062
val apply_impl_do = symbolOf[this.type].asClass.module.info.member(TermName("_applyWithSourceLinePrintable"))
7163
q"$apply_impl_do($cond, ${getLine(c)},_root_.scala.Some(_root_.chisel3.Printable.pack($message,..$data)))($sourceInfo)"
7264
}
7365

7466
/** @group VerifPrintMacros */
7567
def _applyMacroWithPrintableMessage(
76-
c: blackbox.Context
77-
)(cond: c.Tree,
78-
message: c.Tree
79-
)(sourceInfo: c.Tree
80-
): c.Tree = {
68+
c: blackbox.Context
69+
)(cond: c.Tree, message: c.Tree)(sourceInfo: c.Tree): c.Tree = {
8170
import c.universe._
8271
val apply_impl_do = symbolOf[this.type].asClass.module.info.member(TermName("_applyWithSourceLinePrintable"))
8372
q"$apply_impl_do($cond, ${getLine(c)}, _root_.scala.Some($message))($sourceInfo)"
8473
}
8574

8675
/** @group VerifPrintMacros */
8776
def _applyMacroWithNoMessage(
88-
c: blackbox.Context
89-
)(cond: c.Tree
90-
)(sourceInfo: c.Tree
91-
): c.Tree = {
77+
c: blackbox.Context
78+
)(cond: c.Tree)(sourceInfo: c.Tree): c.Tree = {
9279
import c.universe._
9380
val apply_impl_do = symbolOf[this.type].asClass.module.info.member(TermName("_applyWithSourceLinePrintable"))
9481
q"$apply_impl_do($cond, ${getLine(c)}, _root_.scala.None)($sourceInfo)"
@@ -127,12 +114,8 @@ object VerifStmtMacrosCompat {
127114

128115
/** @group VerifPrintMacros */
129116
def _applyMacroWithInterpolatorCheck(
130-
c: blackbox.Context
131-
)(cond: c.Tree,
132-
message: c.Tree,
133-
data: c.Tree*
134-
)(sourceInfo: c.Tree
135-
): c.Tree = {
117+
c: blackbox.Context
118+
)(cond: c.Tree, message: c.Tree, data: c.Tree*)(sourceInfo: c.Tree): c.Tree = {
136119
import c.universe._
137120
_checkFormatString(c)(message)
138121
val apply_impl_do = symbolOf[this.type].asClass.module.info.member(TermName("_applyWithSourceLinePrintable"))
@@ -141,35 +124,26 @@ object VerifStmtMacrosCompat {
141124

142125
/** @group VerifPrintMacros */
143126
def _applyMacroWithStringMessage(
144-
c: blackbox.Context
145-
)(cond: c.Tree,
146-
message: c.Tree,
147-
data: c.Tree
148-
)(sourceInfo: c.Tree
149-
): c.Tree = {
127+
c: blackbox.Context
128+
)(cond: c.Tree, message: c.Tree, data: c.Tree)(sourceInfo: c.Tree): c.Tree = {
150129
import c.universe._
151130
val apply_impl_do = symbolOf[this.type].asClass.module.info.member(TermName("_applyWithSourceLinePrintable"))
152131
q"$apply_impl_do($cond, ${getLine(c)}, _root_.scala.Some(_root_.chisel3.Printable.pack($message, ..$data)))($sourceInfo)"
153132
}
154133

155134
/** @group VerifPrintMacros */
156135
def _applyMacroWithPrintableMessage(
157-
c: blackbox.Context
158-
)(cond: c.Tree,
159-
message: c.Tree
160-
)(sourceInfo: c.Tree
161-
): c.Tree = {
136+
c: blackbox.Context
137+
)(cond: c.Tree, message: c.Tree)(sourceInfo: c.Tree): c.Tree = {
162138
import c.universe._
163139
val apply_impl_do = symbolOf[this.type].asClass.module.info.member(TermName("_applyWithSourceLinePrintable"))
164140
q"$apply_impl_do($cond, ${getLine(c)}, _root_.scala.Some($message))($sourceInfo)"
165141
}
166142

167143
/** @group VerifPrintMacros */
168144
def _applyMacroWithNoMessage(
169-
c: blackbox.Context
170-
)(cond: c.Tree
171-
)(sourceInfo: c.Tree
172-
): c.Tree = {
145+
c: blackbox.Context
146+
)(cond: c.Tree)(sourceInfo: c.Tree): c.Tree = {
173147
import c.universe._
174148
val apply_impl_do = symbolOf[this.type].asClass.module.info.member(TermName("_applyWithSourceLinePrintable"))
175149
q"$apply_impl_do($cond, ${getLine(c)}, _root_.scala.None)($sourceInfo)"
@@ -199,22 +173,17 @@ object VerifStmtMacrosCompat {
199173

200174
/** @group VerifPrintMacros */
201175
def _applyMacroWithNoMessage(
202-
c: blackbox.Context
203-
)(cond: c.Tree
204-
)(sourceInfo: c.Tree
205-
): c.Tree = {
176+
c: blackbox.Context
177+
)(cond: c.Tree)(sourceInfo: c.Tree): c.Tree = {
206178
import c.universe._
207179
val apply_impl_do = symbolOf[this.type].asClass.module.info.member(TermName("_applyWithSourceLine"))
208180
q"$apply_impl_do($cond, ${getLine(c)}, _root_.scala.None)($sourceInfo)"
209181
}
210182

211183
/** @group VerifPrintMacros */
212184
def _applyMacroWithMessage(
213-
c: blackbox.Context
214-
)(cond: c.Tree,
215-
message: c.Tree
216-
)(sourceInfo: c.Tree
217-
): c.Tree = {
185+
c: blackbox.Context
186+
)(cond: c.Tree, message: c.Tree)(sourceInfo: c.Tree): c.Tree = {
218187
import c.universe._
219188
val apply_impl_do = symbolOf[this.type].asClass.module.info.member(TermName("_applyWithSourceLine"))
220189
q"$apply_impl_do($cond, ${getLine(c)}, _root_.scala.Some($message))($sourceInfo)"

core/src/main/scala-2/chisel3/experimental/SerializableModuleGenerator.scala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ object SerializableModuleGenerator {
4949
/** cache instance of a generator. */
5050
private case class CacheKey[P <: SerializableModuleParameter, M <: SerializableModule[P]](
5151
parameter: P,
52-
mTypeTag: universe.TypeTag[M])
53-
extends BuilderContextCache.Key[Definition[M with BaseModule]]
52+
mTypeTag: universe.TypeTag[M]
53+
) extends BuilderContextCache.Key[Definition[M with BaseModule]]
5454

5555
}
5656

@@ -61,9 +61,7 @@ object SerializableModuleGenerator {
6161
case class SerializableModuleGenerator[M <: SerializableModule[P], P <: SerializableModuleParameter](
6262
generator: Class[M],
6363
parameter: P
64-
)(
65-
implicit val pTag: universe.TypeTag[P],
66-
implicit val mTag: universe.TypeTag[M]) {
64+
)(implicit val pTag: universe.TypeTag[P], implicit val mTag: universe.TypeTag[M]) {
6765
private[chisel3] def construct: M with BaseModule = {
6866
require(
6967
generator.getConstructors.length == 1,

core/src/main/scala-2/chisel3/experimental/SourceInfo.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ sealed trait SourceInfo {
3434

3535
sealed trait NoSourceInfo extends SourceInfo {
3636
def makeMessage(f: String => String = x => x): String = ""
37-
def filenameOption: Option[String] = None
37+
def filenameOption: Option[String] = None
3838
}
3939

4040
/** For when source info can't be generated because of a technical limitation, like for Reg because

0 commit comments

Comments
 (0)