@@ -249,20 +249,20 @@ fn parse_error_uri() {
249249 }
250250
251251 // No scheme
252- fail ( "foo" , 3 , UnexpectedChar ) ;
252+ fail ( "foo" , 3 , UnexpectedCharOrEnd ) ;
253253
254254 // Empty scheme
255- fail ( ":hello" , 0 , UnexpectedChar ) ;
255+ fail ( ":hello" , 0 , UnexpectedCharOrEnd ) ;
256256
257257 // Scheme starts with non-letter
258- fail ( "3ttp://a.com" , 0 , UnexpectedChar ) ;
258+ fail ( "3ttp://a.com" , 0 , UnexpectedCharOrEnd ) ;
259259
260260 // Unexpected char in scheme
261- fail ( "exam=ple:foo" , 4 , UnexpectedChar ) ;
262- fail ( "(:" , 0 , UnexpectedChar ) ;
261+ fail ( "exam=ple:foo" , 4 , UnexpectedCharOrEnd ) ;
262+ fail ( "(:" , 0 , UnexpectedCharOrEnd ) ;
263263
264264 // Percent-encoded scheme
265- fail ( "a%20:foo" , 1 , UnexpectedChar ) ;
265+ fail ( "a%20:foo" , 1 , UnexpectedCharOrEnd ) ;
266266}
267267
268268#[ track_caller]
@@ -275,64 +275,64 @@ fn fail(input: &str, index: usize, kind: ParseErrorKind) {
275275#[ test]
276276fn parse_error_uri_ref ( ) {
277277 // Empty scheme
278- fail ( ":hello" , 0 , UnexpectedChar ) ;
278+ fail ( ":hello" , 0 , UnexpectedCharOrEnd ) ;
279279
280280 // Scheme starts with non-letter
281- fail ( "3ttp://a.com" , 0 , UnexpectedChar ) ;
281+ fail ( "3ttp://a.com" , 0 , UnexpectedCharOrEnd ) ;
282282
283283 // After rewriting the parser, the following two cases are interpreted as
284284 // containing colon in the first path segment of a relative reference.
285285
286286 // Unexpected char in scheme
287- fail ( "exam=ple:foo" , 8 , UnexpectedChar ) ;
288- fail ( "(:" , 1 , UnexpectedChar ) ;
287+ fail ( "exam=ple:foo" , 8 , UnexpectedCharOrEnd ) ;
288+ fail ( "(:" , 1 , UnexpectedCharOrEnd ) ;
289289
290290 // Percent-encoded scheme
291- fail ( "a%20:foo" , 4 , UnexpectedChar ) ;
291+ fail ( "a%20:foo" , 4 , UnexpectedCharOrEnd ) ;
292292
293293 // Unexpected char in path
294- fail ( "foo\\ bar" , 3 , UnexpectedChar ) ;
294+ fail ( "foo\\ bar" , 3 , UnexpectedCharOrEnd ) ;
295295
296296 // Non-hexadecimal percent-encoded octet
297- fail ( "foo%xxd" , 3 , InvalidPctEncodedOctet ) ;
297+ fail ( "foo%xxd" , 4 , UnexpectedCharOrEnd ) ;
298298
299299 // Incomplete percent-encoded octet
300- fail ( "text%a" , 4 , InvalidPctEncodedOctet ) ;
300+ fail ( "text%a" , 6 , UnexpectedCharOrEnd ) ;
301301
302302 // A single percent
303- fail ( "%" , 0 , InvalidPctEncodedOctet ) ;
303+ fail ( "%" , 1 , UnexpectedCharOrEnd ) ;
304304
305305 // Non-decimal port
306- fail ( "http://example.com:80ab" , 21 , UnexpectedChar ) ;
307- fail ( "http://user@example.com:80ab" , 26 , UnexpectedChar ) ;
306+ fail ( "http://example.com:80ab" , 21 , UnexpectedCharOrEnd ) ;
307+ fail ( "http://user@example.com:80ab" , 26 , UnexpectedCharOrEnd ) ;
308308
309309 // Multiple colons in authority
310- fail ( "http://user:pass:example.com/" , 16 , UnexpectedChar ) ;
310+ fail ( "http://user:pass:example.com/" , 16 , UnexpectedCharOrEnd ) ;
311311
312312 // Unclosed bracket
313- fail ( "https://[::1/" , 12 , UnexpectedChar ) ;
313+ fail ( "https://[::1/" , 12 , UnexpectedCharOrEnd ) ;
314314
315315 // Not port after IP literal
316- fail ( "https://[::1]wrong" , 13 , UnexpectedChar ) ;
316+ fail ( "https://[::1]wrong" , 13 , UnexpectedCharOrEnd ) ;
317317
318318 // IP literal too short
319319 fail ( "http://[:]" , 8 , InvalidIpv6Addr ) ;
320- fail ( "http://[]" , 8 , UnexpectedChar ) ;
320+ fail ( "http://[]" , 8 , UnexpectedCharOrEnd ) ;
321321
322322 // Non-hexadecimal version in IPvFuture
323- fail ( "http://[vG.addr]" , 9 , UnexpectedChar ) ;
323+ fail ( "http://[vG.addr]" , 9 , UnexpectedCharOrEnd ) ;
324324
325325 // Empty version in IPvFuture
326- fail ( "http://[v.addr]" , 9 , UnexpectedChar ) ;
326+ fail ( "http://[v.addr]" , 9 , UnexpectedCharOrEnd ) ;
327327
328328 // Empty address in IPvFuture
329- fail ( "ftp://[vF.]" , 10 , UnexpectedChar ) ;
329+ fail ( "ftp://[vF.]" , 10 , UnexpectedCharOrEnd ) ;
330330
331331 // Percent-encoded address in IPvFuture
332- fail ( "ftp://[vF.%20]" , 10 , UnexpectedChar ) ;
332+ fail ( "ftp://[vF.%20]" , 10 , UnexpectedCharOrEnd ) ;
333333
334334 // With zone identifier
335- fail ( "ftp://[fe80::abcd%eth0]" , 17 , UnexpectedChar ) ;
335+ fail ( "ftp://[fe80::abcd%eth0]" , 17 , UnexpectedCharOrEnd ) ;
336336
337337 // Invalid IPv6 address
338338 fail ( "example://[44:55::66::77]" , 11 , InvalidIpv6Addr ) ;
0 commit comments