Skip to content

Commit

Permalink
fix nim-lang#13218: avoid some irrelevant warnings for nim doc,rst2html
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed Mar 1, 2020
1 parent 5151b17 commit 6ac1322
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 27 deletions.
2 changes: 1 addition & 1 deletion compiler/main.nim
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ proc mainCommand*(graph: ModuleGraph) =
defineSymbol(conf.symbols, "nimdoc")
commandDoc2(graph, false)
of "rst2html":
conf.setNoteDefaults(warnRedefinitionOfLabel, false) # issue #13218
conf.setNoteDefaults(warnRedefinitionOfLabel, false) # similar to issue #13218
when defined(leanCompiler):
quit "compiler wasn't built with documentation generator"
else:
Expand Down
29 changes: 3 additions & 26 deletions compiler/options.nim
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ type
modifiedyNotes*: TNoteKinds # notes that have been set/unset from either cmdline/configs
cmdlineNotes*: TNoteKinds # notes that have been set/unset from cmdline
foreignPackageNotes*: TNoteKinds
notesImpl*: TNoteKinds # notes after resolving all logic(defaults, verbosity)/cmdline/configs
notes*: TNoteKinds # notes after resolving all logic(defaults, verbosity)/cmdline/configs
mainPackageNotes*: TNoteKinds
mainPackageId*: int
errorCounter*: int
Expand Down Expand Up @@ -287,26 +287,6 @@ type
severity: Severity) {.closure, gcsafe.}
cppCustomNamespace*: string

# proc notesImpl
var first = true
template fun(conf) =
if warnLockLevel notin conf.notesImpl:
first = true
elif first:
first = false
if warnLockLevel in conf.notesImpl:
# echo0b getStackTrace()
discard

template `notes`*(a: ConfigRef): untyped =
fun(a)
a.notesImpl

template `notes=`*(a: ConfigRef, val) =
fun(a)
a.notesImpl = val
fun(a)

proc setNoteDefaults*(conf: ConfigRef, note: TNoteKind, enabled = true) =
template fun(op) =
conf.notes.op note
Expand All @@ -318,7 +298,6 @@ proc setNote*(conf: ConfigRef, note: TNoteKind, enabled = true) =
# see also `prepareConfigNotes` which sets notes
if note notin conf.cmdlineNotes:
if enabled: incl(conf.notes, note) else: excl(conf.notes, note)
fun(conf)

proc hasHint*(conf: ConfigRef, note: TNoteKind): bool =
optHints in conf.options and note in conf.notes
Expand Down Expand Up @@ -385,8 +364,7 @@ proc newConfigRef*(): ConfigRef =
cppDefines: initHashSet[string](),
headerFile: "", features: {}, legacyFeatures: {}, foreignPackageNotes: {hintProcessing, warnUnknownMagic,
hintQuitCalled, hintExecuting},
# notes: NotesVerbosity[1], mainPackageNotes: NotesVerbosity[1],
notesImpl: NotesVerbosity[1], mainPackageNotes: NotesVerbosity[1],
notes: NotesVerbosity[1], mainPackageNotes: NotesVerbosity[1],
configVars: newStringTable(modeStyleInsensitive),
symbols: newStringTable(modeStyleInsensitive),
packageCache: newPackageCache(),
Expand Down Expand Up @@ -440,8 +418,7 @@ proc newPartialConfigRef*(): ConfigRef =
globalOptions: DefaultGlobalOptions,
foreignPackageNotes: {hintProcessing, warnUnknownMagic,
hintQuitCalled, hintExecuting},
# notes: NotesVerbosity[1], mainPackageNotes: NotesVerbosity[1])
notesImpl: NotesVerbosity[1], mainPackageNotes: NotesVerbosity[1])
notes: NotesVerbosity[1], mainPackageNotes: NotesVerbosity[1])

proc cppDefine*(c: ConfigRef; define: string) =
c.cppDefines.incl define
Expand Down

0 comments on commit 6ac1322

Please sign in to comment.