@@ -146,53 +146,21 @@ def concat_multi_lines(f):
146
146
if lastline is not None :
147
147
print_err (lineno , line , "Trailing backslash at the end of the file" )
148
148
149
-
150
- def get_known_directive_names ():
151
- def filter_line (line ):
152
- line = line .strip ()
153
- return line .startswith ('"' ) and (line .endswith ('",' ) or line .endswith ('"' ))
154
-
155
- # Equivalent to `src/tools/compiletest/src/header.rs` constant of the same name.
156
- with open (
157
- os .path .join (
158
- # We go back to `src`.
159
- os .path .dirname (os .path .dirname (__file__ )),
160
- "tools/compiletest/src/directive-list.rs" ,
161
- ),
162
- "r" ,
163
- encoding = "utf8" ,
164
- ) as fd :
165
- content = fd .read ()
166
- return [
167
- line .strip ().replace ('",' , "" ).replace ('"' , "" )
168
- for line in content .split ("\n " )
169
- if filter_line (line )
170
- ]
171
-
172
-
173
- # To prevent duplicating the list of commmands between `compiletest` and `htmldocck`, we put
174
- # it into a common file which is included in rust code and parsed here.
175
- # FIXME: This setup is temporary until we figure out how to improve this situation.
176
- # See <https://github.com/rust-lang/rust/issues/125813#issuecomment-2141953780>.
177
- KNOWN_DIRECTIVE_NAMES = get_known_directive_names ()
178
-
179
149
LINE_PATTERN = re .compile (
180
150
r"""
181
151
//@\s+
182
- (?P<negated>!?)(?P<cmd>[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*)
152
+ (?P<negated>!?)(?P<cmd>.+?)
153
+ [\s:]
183
154
(?P<args>.*)$
184
155
""" ,
185
156
re .X | re .UNICODE ,
186
157
)
187
158
188
159
DEPRECATED_LINE_PATTERN = re .compile (
189
- r"""
190
- //\s+@
191
- """ ,
160
+ r"//\s+@" ,
192
161
re .X | re .UNICODE ,
193
162
)
194
163
195
-
196
164
def get_commands (template ):
197
165
with io .open (template , encoding = "utf-8" ) as f :
198
166
for lineno , line in concat_multi_lines (f ):
@@ -209,12 +177,7 @@ def get_commands(template):
209
177
210
178
cmd = m .group ("cmd" )
211
179
negated = m .group ("negated" ) == "!"
212
- if not negated and cmd in KNOWN_DIRECTIVE_NAMES :
213
- continue
214
180
args = m .group ("args" )
215
- if args and not args [:1 ].isspace ():
216
- print_err (lineno , line , "Invalid template syntax" )
217
- continue
218
181
try :
219
182
args = shlex .split (args )
220
183
except UnicodeEncodeError :
@@ -632,14 +595,10 @@ def check_command(c, cache):
632
595
else :
633
596
raise InvalidCheck ("Invalid number of {} arguments" .format (c .cmd ))
634
597
635
- elif c .cmd == "valid-html" :
636
- raise InvalidCheck ("Unimplemented valid-html" )
637
-
638
- elif c .cmd == "valid-links" :
639
- raise InvalidCheck ("Unimplemented valid-links" )
640
-
641
598
else :
642
- raise InvalidCheck ("Unrecognized {}" .format (c .cmd ))
599
+ # Ignore unknown directives, they might be compiletest directives.
600
+ # In any case, compiletest rejects unknown directives for us.
601
+ return
643
602
644
603
if ret == c .negated :
645
604
raise FailedCheck (cerr )
0 commit comments