Skip to content

Commit

Permalink
Rollup merge of rust-lang#132376 - ehuss:reference-input, r=traviscross
Browse files Browse the repository at this point in the history
Annotate `input` reference tests

This adds test annotations for rules in the [input chapter](https://doc.rust-lang.org/nightly/reference/input-format.html) of the reference.
  • Loading branch information
matthiaskrgr authored Oct 31, 2024
2 parents 39086e4 + 37c3884 commit 49a76c1
Show file tree
Hide file tree
Showing 22 changed files with 55 additions and 33 deletions.
2 changes: 2 additions & 0 deletions tests/ui/json/json-bom-plus-crlf-multifile.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// (This line has BOM so it's ignored by compiletest for directives)
//
//@ compile-flags: --json=diagnostic-short --error-format=json
//@ reference: input.byte-order-mark
//@ reference: input.crlf
// ignore-tidy-cr

#[path = "json-bom-plus-crlf-multifile-aux.rs"]
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/json/json-bom-plus-crlf.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// (This line has BOM so it's ignored by compiletest for directives)
//
//@ compile-flags: --json=diagnostic-short --error-format=json
//@ reference: input.byte-order-mark
//@ reference: input.crlf
// ignore-tidy-cr

// For easier verifying, the byte offsets in this file should match those
Expand Down
8 changes: 4 additions & 4 deletions tests/ui/json/json-bom-plus-crlf.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ This error occurs when an expression was used in a place where the compiler
expected an expression of a different type. It can occur in several cases, the
most common being when calling a function and passing an argument which has a
different type than the matching type in the function declaration.
"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":607,"byte_end":608,"line_start":16,"line_end":16,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":22,"highlight_end":23}],"label":"expected `String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":598,"byte_end":604,"line_start":16,"line_end":16,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":13,"highlight_end":19}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":608,"byte_end":608,"line_start":16,"line_end":16,"column_start":23,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":23,"highlight_end":23}],"label":null,"suggested_replacement":".to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf.rs:16:22: error[E0308]: mismatched types: expected `String`, found integer
"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":672,"byte_end":673,"line_start":18,"line_end":18,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":22,"highlight_end":23}],"label":"expected `String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":663,"byte_end":669,"line_start":18,"line_end":18,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":13,"highlight_end":19}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":673,"byte_end":673,"line_start":18,"line_end":18,"column_start":23,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":23,"highlight_end":23}],"label":null,"suggested_replacement":".to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf.rs:18:22: error[E0308]: mismatched types: expected `String`, found integer
"}
{"$message_type":"diagnostic","message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type.

Expand Down Expand Up @@ -52,7 +52,7 @@ This error occurs when an expression was used in a place where the compiler
expected an expression of a different type. It can occur in several cases, the
most common being when calling a function and passing an argument which has a
different type than the matching type in the function declaration.
"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":667,"byte_end":668,"line_start":18,"line_end":18,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1","highlight_start":22,"highlight_end":23}],"label":"expected `String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":658,"byte_end":664,"line_start":18,"line_end":18,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":" let s : String = 1","highlight_start":13,"highlight_end":19}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":668,"byte_end":668,"line_start":18,"line_end":18,"column_start":23,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1","highlight_start":23,"highlight_end":23}],"label":null,"suggested_replacement":".to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf.rs:18:22: error[E0308]: mismatched types: expected `String`, found integer
"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":732,"byte_end":733,"line_start":20,"line_end":20,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1","highlight_start":22,"highlight_end":23}],"label":"expected `String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":723,"byte_end":729,"line_start":20,"line_end":20,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":" let s : String = 1","highlight_start":13,"highlight_end":19}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":733,"byte_end":733,"line_start":20,"line_end":20,"column_start":23,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1","highlight_start":23,"highlight_end":23}],"label":null,"suggested_replacement":".to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf.rs:20:22: error[E0308]: mismatched types: expected `String`, found integer
"}
{"$message_type":"diagnostic","message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type.

Expand Down Expand Up @@ -80,7 +80,7 @@ This error occurs when an expression was used in a place where the compiler
expected an expression of a different type. It can occur in several cases, the
most common being when calling a function and passing an argument which has a
different type than the matching type in the function declaration.
"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":731,"byte_end":732,"line_start":22,"line_end":22,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":1,"highlight_end":2}],"label":"expected `String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":721,"byte_end":727,"line_start":21,"line_end":21,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":" let s : String =","highlight_start":13,"highlight_end":19}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":732,"byte_end":732,"line_start":22,"line_end":22,"column_start":2,"column_end":2,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":2,"highlight_end":2}],"label":null,"suggested_replacement":".to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf.rs:22:1: error[E0308]: mismatched types: expected `String`, found integer
"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":796,"byte_end":797,"line_start":24,"line_end":24,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":1,"highlight_end":2}],"label":"expected `String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":786,"byte_end":792,"line_start":23,"line_end":23,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":" let s : String =","highlight_start":13,"highlight_end":19}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":797,"byte_end":797,"line_start":24,"line_end":24,"column_start":2,"column_end":2,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":2,"highlight_end":2}],"label":null,"suggested_replacement":".to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf.rs:24:1: error[E0308]: mismatched types: expected `String`, found integer
"}
{"$message_type":"diagnostic","message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type.

Expand Down Expand Up @@ -108,7 +108,7 @@ This error occurs when an expression was used in a place where the compiler
expected an expression of a different type. It can occur in several cases, the
most common being when calling a function and passing an argument which has a
different type than the matching type in the function declaration.
"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":787,"byte_end":795,"line_start":24,"line_end":25,"column_start":22,"column_end":6,"is_primary":true,"text":[{"text":" let s : String = (","highlight_start":22,"highlight_end":23},{"text":" ); // Error spanning the newline.","highlight_start":1,"highlight_end":6}],"label":"expected `String`, found `()`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":778,"byte_end":784,"line_start":24,"line_end":24,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":" let s : String = (","highlight_start":13,"highlight_end":19}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"$DIR/json-bom-plus-crlf.rs:24:22: error[E0308]: mismatched types: expected `String`, found `()`
"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":852,"byte_end":860,"line_start":26,"line_end":27,"column_start":22,"column_end":6,"is_primary":true,"text":[{"text":" let s : String = (","highlight_start":22,"highlight_end":23},{"text":" ); // Error spanning the newline.","highlight_start":1,"highlight_end":6}],"label":"expected `String`, found `()`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":843,"byte_end":849,"line_start":26,"line_end":26,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":" let s : String = (","highlight_start":13,"highlight_end":19}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"$DIR/json-bom-plus-crlf.rs:26:22: error[E0308]: mismatched types: expected `String`, found `()`
"}
{"$message_type":"diagnostic","message":"aborting due to 4 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 4 previous errors
"}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ run-pass
//@ reference: input.crlf
// ignore-tidy-cr
// ignore-tidy-cr (repeated again because of tidy bug)
// license is ignored because tidy can't handle the CRLF here properly.
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/macros/not-utf8.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//@ error-pattern: did not contain valid UTF-8
//@ reference: input.encoding.utf8
//@ reference: input.encoding.invalid

fn foo() {
include!("not-utf8.bin")
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/macros/not-utf8.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: couldn't read $DIR/not-utf8.bin: stream did not contain valid UTF-8
--> $DIR/not-utf8.rs:4:5
--> $DIR/not-utf8.rs:6:5
|
LL | include!("not-utf8.bin")
| ^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/parser/shebang/issue-71471-ignore-tidy.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@

#!B //~ expected `[`, found `B`

//@ reference: input.shebang
1 change: 1 addition & 0 deletions tests/ui/parser/shebang/multiline-attrib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!
[allow(unused_variables)]
//@ check-pass
//@ reference: input.shebang.inner-attribute

fn main() {
let x = 5;
Expand Down
1 change: 1 addition & 0 deletions tests/ui/parser/shebang/regular-attrib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![allow(unused_variables)]
//@ check-pass
//@ reference: input.shebang.inner-attribute
fn main() {
let x = 5;
}
1 change: 1 addition & 0 deletions tests/ui/parser/shebang/shebang-and-attrib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env run-cargo-script

//@ check-pass
//@ reference: input.shebang.inner-attribute
#![allow(unused_variables)]


Expand Down
1 change: 1 addition & 0 deletions tests/ui/parser/shebang/shebang-comment.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!//bin/bash

//@ check-pass
//@ reference: input.shebang
fn main() {
println!("a valid shebang (that is also a rust comment)")
}
2 changes: 2 additions & 0 deletions tests/ui/parser/shebang/shebang-doc-comment.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!///bin/bash
[allow(unused_variables)]
//~^ ERROR expected item, found `[`
//@ reference: input.shebang.inner-attribute
1 change: 1 addition & 0 deletions tests/ui/parser/shebang/shebang-empty.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!

//@ check-pass
//@ reference: input.shebang
fn main() {}
2 changes: 2 additions & 0 deletions tests/ui/parser/shebang/shebang-must-start-file.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// something on the first line for tidy
#!/bin/bash //~ expected `[`, found `/`

//@ reference: input.shebang

fn main() {
println!("ok!");
}
1 change: 1 addition & 0 deletions tests/ui/parser/shebang/shebang-space.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!

//@ check-pass
//@ reference: input.shebang
// ignore-tidy-end-whitespace
fn main() {}
1 change: 1 addition & 0 deletions tests/ui/parser/shebang/sneaky-attrib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
[allow(unused_variables)]
//@ check-pass
//@ reference: input.shebang.inner-attribute
fn main() {
let x = 5;
}
1 change: 1 addition & 0 deletions tests/ui/parser/shebang/valid-shebang.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env run-cargo-script

//@ check-pass
//@ reference: input.shebang
fn main() {
println!("Hello World!");
}
Binary file modified tests/ui/parser/utf16-be-without-bom.rs
Binary file not shown.
28 changes: 14 additions & 14 deletions tests/ui/parser/utf16-be-without-bom.stderr
Original file line number Diff line number Diff line change
@@ -1,109 +1,109 @@
error: unknown start of token: \u{0}
--> $DIR/utf16-be-without-bom.rs:4:1
--> $DIR/utf16-be-without-bom.rs:5:1
|
LL | ␀f␀n␀ ␀m␀a␀i␀n␀(␀)␀ ␀{␀}␀
| ^
|
= help: source files must contain UTF-8 encoded text, unexpected null bytes might occur when a different encoding is used

error: unknown start of token: \u{0}
--> $DIR/utf16-be-without-bom.rs:4:3
--> $DIR/utf16-be-without-bom.rs:5:3
|
LL | ␀f␀n␀ ␀m␀a␀i␀n␀(␀)␀ ␀{␀}␀
| ^
|
= help: source files must contain UTF-8 encoded text, unexpected null bytes might occur when a different encoding is used

error: unknown start of token: \u{0}
--> $DIR/utf16-be-without-bom.rs:4:5
--> $DIR/utf16-be-without-bom.rs:5:5
|
LL | ␀f␀n␀ ␀m␀a␀i␀n␀(␀)␀ ␀{␀}␀
| ^
|
= help: source files must contain UTF-8 encoded text, unexpected null bytes might occur when a different encoding is used

error: unknown start of token: \u{0}
--> $DIR/utf16-be-without-bom.rs:4:7
--> $DIR/utf16-be-without-bom.rs:5:7
|
LL | ␀f␀n␀ ␀m␀a␀i␀n␀(␀)␀ ␀{␀}␀
| ^
|
= help: source files must contain UTF-8 encoded text, unexpected null bytes might occur when a different encoding is used

error: unknown start of token: \u{0}
--> $DIR/utf16-be-without-bom.rs:4:9
--> $DIR/utf16-be-without-bom.rs:5:9
|
LL | ␀f␀n␀ ␀m␀a␀i␀n␀(␀)␀ ␀{␀}␀
| ^
|
= help: source files must contain UTF-8 encoded text, unexpected null bytes might occur when a different encoding is used

error: unknown start of token: \u{0}
--> $DIR/utf16-be-without-bom.rs:4:11
--> $DIR/utf16-be-without-bom.rs:5:11
|
LL | ␀f␀n␀ ␀m␀a␀i␀n␀(␀)␀ ␀{␀}␀
| ^
|
= help: source files must contain UTF-8 encoded text, unexpected null bytes might occur when a different encoding is used

error: unknown start of token: \u{0}
--> $DIR/utf16-be-without-bom.rs:4:13
--> $DIR/utf16-be-without-bom.rs:5:13
|
LL | ␀f␀n␀ ␀m␀a␀i␀n␀(␀)␀ ␀{␀}␀
| ^
|
= help: source files must contain UTF-8 encoded text, unexpected null bytes might occur when a different encoding is used

error: unknown start of token: \u{0}
--> $DIR/utf16-be-without-bom.rs:4:15
--> $DIR/utf16-be-without-bom.rs:5:15
|
LL | ␀f␀n␀ ␀m␀a␀i␀n␀(␀)␀ ␀{␀}␀
| ^
|
= help: source files must contain UTF-8 encoded text, unexpected null bytes might occur when a different encoding is used

error: unknown start of token: \u{0}
--> $DIR/utf16-be-without-bom.rs:4:17
--> $DIR/utf16-be-without-bom.rs:5:17
|
LL | ␀f␀n␀ ␀m␀a␀i␀n␀(␀)␀ ␀{␀}␀
| ^
|
= help: source files must contain UTF-8 encoded text, unexpected null bytes might occur when a different encoding is used

error: unknown start of token: \u{0}
--> $DIR/utf16-be-without-bom.rs:4:19
--> $DIR/utf16-be-without-bom.rs:5:19
|
LL | ␀f␀n␀ ␀m␀a␀i␀n␀(␀)␀ ␀{␀}␀
| ^
|
= help: source files must contain UTF-8 encoded text, unexpected null bytes might occur when a different encoding is used

error: unknown start of token: \u{0}
--> $DIR/utf16-be-without-bom.rs:4:21
--> $DIR/utf16-be-without-bom.rs:5:21
|
LL | ␀f␀n␀ ␀m␀a␀i␀n␀(␀)␀ ␀{␀}␀
| ^
|
= help: source files must contain UTF-8 encoded text, unexpected null bytes might occur when a different encoding is used

error: unknown start of token: \u{0}
--> $DIR/utf16-be-without-bom.rs:4:23
--> $DIR/utf16-be-without-bom.rs:5:23
|
LL | ␀f␀n␀ ␀m␀a␀i␀n␀(␀)␀ ␀{␀}␀
| ^
|
= help: source files must contain UTF-8 encoded text, unexpected null bytes might occur when a different encoding is used

error: unknown start of token: \u{0}
--> $DIR/utf16-be-without-bom.rs:4:25
--> $DIR/utf16-be-without-bom.rs:5:25
|
LL | ␀f␀n␀ ␀m␀a␀i␀n␀(␀)␀ ␀{␀}␀
| ^
|
= help: source files must contain UTF-8 encoded text, unexpected null bytes might occur when a different encoding is used

error: expected one of `!` or `::`, found `n`
--> $DIR/utf16-be-without-bom.rs:4:4
--> $DIR/utf16-be-without-bom.rs:5:4
|
LL | ␀f␀n␀ ␀m␀a␀i␀n␀(␀)␀ ␀{␀}␀
| ^ expected one of `!` or `::`
Expand Down
Binary file modified tests/ui/parser/utf16-le-without-bom.rs
Binary file not shown.
Loading

0 comments on commit 49a76c1

Please sign in to comment.