diff --git a/tests/run-make/json-bom-plus-crlf-multifile/json-bom-plus-crlf-multifile.stderr b/tests/run-make/json-bom-plus-crlf-multifile/json-bom-plus-crlf-multifile.stderr new file mode 100644 index 0000000000000..2701d56d81647 --- /dev/null +++ b/tests/run-make/json-bom-plus-crlf-multifile/json-bom-plus-crlf-multifile.stderr @@ -0,0 +1,114 @@ +{"$message_type":"diagnostic","message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type. + +Erroneous code examples: + +```compile_fail,E0308 +fn plus_one(x: i32) -> i32 { + x + 1 +} + +plus_one(\"Not a number\"); +// ^^^^^^^^^^^^^^ expected `i32`, found `&str` + +if \"Not a bool\" { +// ^^^^^^^^^^^^ expected `bool`, found `&str` +} + +let x: f32 = \"Not a float\"; +// --- ^^^^^^^^^^^^^ expected `f32`, found `&str` +// | +// expected due to this +``` + +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-multifile-aux.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":true,"text":[{"text":"let s : String = 1; // Error in the middle of line.","highlight_start":XX,"highlight_end":XX}],"label":"expected `String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":false,"text":[{"text":"let s : String = 1; // Error in the middle of line.","highlight_start":XX,"highlight_end":XX}],"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-multifile-aux.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":true,"text":[{"text":"let s : String = 1; // Error in the middle of line.","highlight_start":XX,"highlight_end":XX}],"label":null,"suggested_replacement":".to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf-multifile-aux.rs:LL:CC: 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. + +Erroneous code examples: + +```compile_fail,E0308 +fn plus_one(x: i32) -> i32 { + x + 1 +} + +plus_one(\"Not a number\"); +// ^^^^^^^^^^^^^^ expected `i32`, found `&str` + +if \"Not a bool\" { +// ^^^^^^^^^^^^ expected `bool`, found `&str` +} + +let x: f32 = \"Not a float\"; +// --- ^^^^^^^^^^^^^ expected `f32`, found `&str` +// | +// expected due to this +``` + +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-multifile-aux.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":true,"text":[{"text":"let s : String = 1","highlight_start":XX,"highlight_end":XX}],"label":"expected `String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":false,"text":[{"text":"let s : String = 1","highlight_start":XX,"highlight_end":XX}],"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-multifile-aux.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":true,"text":[{"text":"let s : String = 1","highlight_start":XX,"highlight_end":XX}],"label":null,"suggested_replacement":".to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf-multifile-aux.rs:LL:CC: 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. + +Erroneous code examples: + +```compile_fail,E0308 +fn plus_one(x: i32) -> i32 { + x + 1 +} + +plus_one(\"Not a number\"); +// ^^^^^^^^^^^^^^ expected `i32`, found `&str` + +if \"Not a bool\" { +// ^^^^^^^^^^^^ expected `bool`, found `&str` +} + +let x: f32 = \"Not a float\"; +// --- ^^^^^^^^^^^^^ expected `f32`, found `&str` +// | +// expected due to this +``` + +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-multifile-aux.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":XX,"highlight_end":XX}],"label":"expected `String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":false,"text":[{"text":"let s : String =","highlight_start":XX,"highlight_end":XX}],"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-multifile-aux.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":XX,"highlight_end":XX}],"label":null,"suggested_replacement":".to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf-multifile-aux.rs:LL:CC: 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. + +Erroneous code examples: + +```compile_fail,E0308 +fn plus_one(x: i32) -> i32 { + x + 1 +} + +plus_one(\"Not a number\"); +// ^^^^^^^^^^^^^^ expected `i32`, found `&str` + +if \"Not a bool\" { +// ^^^^^^^^^^^^ expected `bool`, found `&str` +} + +let x: f32 = \"Not a float\"; +// --- ^^^^^^^^^^^^^ expected `f32`, found `&str` +// | +// expected due to this +``` + +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-multifile-aux.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":true,"text":[{"text":"let s : String = (","highlight_start":XX,"highlight_end":XX},{"text":"); // Error spanning the newline.","highlight_start":XX,"highlight_end":XX}],"label":"expected `String`, found `()`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":false,"text":[{"text":"let s : String = (","highlight_start":XX,"highlight_end":XX}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"$DIR/json-bom-plus-crlf-multifile-aux.rs:LL:CC: 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 +"} diff --git a/tests/run-make/json-bom-plus-crlf-multifile/rmake.rs b/tests/run-make/json-bom-plus-crlf-multifile/rmake.rs new file mode 100644 index 0000000000000..e297c2ee78369 --- /dev/null +++ b/tests/run-make/json-bom-plus-crlf-multifile/rmake.rs @@ -0,0 +1,73 @@ +//@ reference: input.byte-order-mark +//@ reference: input.crlf +//@ ignore-cross-compile + +use run_make_support::{cwd, diff, rfs, rustc}; + +fn main() { + let aux_content = "\u{FEFF}\ +pub fn test() {\r\n\ +\r\n\ + let s : String = 1; // Error in the middle of line.\r\n\ +\r\n\ + let s : String = 1\r\n\ + ; // Error before the newline.\r\n\ +\r\n\ + let s : String =\r\n\ +1; // Error after the newline.\r\n\ +\r\n\ + let s : String = (\r\n\ + ); // Error spanning the newline.\r\n\ +}\r\n"; + + rfs::write(cwd().join("json-bom-plus-crlf-multifile-aux.rs"), aux_content); + + let aux_bytes = rfs::read(cwd().join("json-bom-plus-crlf-multifile-aux.rs")); + assert!(aux_bytes.starts_with(b"\xEF\xBB\xBF"), "File must start with UTF-8 BOM"); + assert!(aux_bytes.windows(2).any(|w| w == b"\r\n"), "File must contain CRLF line endings"); + + let main_content = "\u{FEFF}\ +#[path = \"json-bom-plus-crlf-multifile-aux.rs\"]\r\n\ +mod json_bom_plus_crlf_multifile_aux;\r\n\ +\r\n\ +fn main() {\r\n\ + json_bom_plus_crlf_multifile_aux::test();\r\n\ +}\r\n"; + + rfs::write(cwd().join("json-bom-plus-crlf-multifile.rs"), main_content); + + let output = rustc() + .input(cwd().join("json-bom-plus-crlf-multifile.rs")) + .json("diagnostic-short") + .error_format("json") + .ui_testing() + .run_fail() + .stderr_utf8(); + + diff() + .expected_file("json-bom-plus-crlf-multifile.stderr") + .actual_text("stderr", &output) + .normalize(r"\\n", "\n") + .normalize(r"\\r\\n", "\n") + .normalize(r#""line_start":\d+"#, r#""line_start":LL"#) + .normalize(r#""line_end":\d+"#, r#""line_end":LL"#) + .normalize(r#""column_start":\d+"#, r#""column_start":CC"#) + .normalize(r#""column_end":\d+"#, r#""column_end":CC"#) + .normalize(r#""byte_start":\d+"#, r#""byte_start":XXX"#) + .normalize(r#""byte_end":\d+"#, r#""byte_end":XXX"#) + .normalize(r#""highlight_start":\d+"#, r#""highlight_start":XX"#) + .normalize(r#""highlight_end":\d+"#, r#""highlight_end":XX"#) + .normalize( + r#""file_name":"[^"]*json-bom-plus-crlf-multifile-aux\.rs""#, + r#""file_name":"$$DIR/json-bom-plus-crlf-multifile-aux.rs""#, + ) + .normalize( + r#""rendered":"(?:[^"]*/)?json-bom-plus-crlf-multifile-aux\.rs:\d+:\d+:"#, + r#""rendered":"$$DIR/json-bom-plus-crlf-multifile-aux.rs:LL:CC:"#, + ) + .normalize( + r#""rendered":"(?:[^"]*/)?json-bom-plus-crlf-multifile-aux\.rs:\d+:\d+ error"#, + r#""rendered":"$$DIR/json-bom-plus-crlf-multifile-aux.rs:LL:CC error"#, + ) + .run(); +} diff --git a/tests/run-make/json-bom-plus-crlf/json-bom-plus-crlf.stderr b/tests/run-make/json-bom-plus-crlf/json-bom-plus-crlf.stderr new file mode 100644 index 0000000000000..b76e27ab239dd --- /dev/null +++ b/tests/run-make/json-bom-plus-crlf/json-bom-plus-crlf.stderr @@ -0,0 +1,114 @@ +{"$message_type":"diagnostic","message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type. + +Erroneous code examples: + +```compile_fail,E0308 +fn plus_one(x: i32) -> i32 { + x + 1 +} + +plus_one(\"Not a number\"); +// ^^^^^^^^^^^^^^ expected `i32`, found `&str` + +if \"Not a bool\" { +// ^^^^^^^^^^^^ expected `bool`, found `&str` +} + +let x: f32 = \"Not a float\"; +// --- ^^^^^^^^^^^^^ expected `f32`, found `&str` +// | +// expected due to this +``` + +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":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":true,"text":[{"text":"let s : String = 1; // Error in the middle of line.","highlight_start":XX,"highlight_end":XX}],"label":"expected `String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":false,"text":[{"text":"let s : String = 1; // Error in the middle of line.","highlight_start":XX,"highlight_end":XX}],"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":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":true,"text":[{"text":"let s : String = 1; // Error in the middle of line.","highlight_start":XX,"highlight_end":XX}],"label":null,"suggested_replacement":".to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf.rs:LL:CC: 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. + +Erroneous code examples: + +```compile_fail,E0308 +fn plus_one(x: i32) -> i32 { + x + 1 +} + +plus_one(\"Not a number\"); +// ^^^^^^^^^^^^^^ expected `i32`, found `&str` + +if \"Not a bool\" { +// ^^^^^^^^^^^^ expected `bool`, found `&str` +} + +let x: f32 = \"Not a float\"; +// --- ^^^^^^^^^^^^^ expected `f32`, found `&str` +// | +// expected due to this +``` + +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":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":true,"text":[{"text":"let s : String = 1","highlight_start":XX,"highlight_end":XX}],"label":"expected `String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":false,"text":[{"text":"let s : String = 1","highlight_start":XX,"highlight_end":XX}],"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":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":true,"text":[{"text":"let s : String = 1","highlight_start":XX,"highlight_end":XX}],"label":null,"suggested_replacement":".to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf.rs:LL:CC: 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. + +Erroneous code examples: + +```compile_fail,E0308 +fn plus_one(x: i32) -> i32 { + x + 1 +} + +plus_one(\"Not a number\"); +// ^^^^^^^^^^^^^^ expected `i32`, found `&str` + +if \"Not a bool\" { +// ^^^^^^^^^^^^ expected `bool`, found `&str` +} + +let x: f32 = \"Not a float\"; +// --- ^^^^^^^^^^^^^ expected `f32`, found `&str` +// | +// expected due to this +``` + +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":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":XX,"highlight_end":XX}],"label":"expected `String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":false,"text":[{"text":"let s : String =","highlight_start":XX,"highlight_end":XX}],"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":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":XX,"highlight_end":XX}],"label":null,"suggested_replacement":".to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf.rs:LL:CC: 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. + +Erroneous code examples: + +```compile_fail,E0308 +fn plus_one(x: i32) -> i32 { + x + 1 +} + +plus_one(\"Not a number\"); +// ^^^^^^^^^^^^^^ expected `i32`, found `&str` + +if \"Not a bool\" { +// ^^^^^^^^^^^^ expected `bool`, found `&str` +} + +let x: f32 = \"Not a float\"; +// --- ^^^^^^^^^^^^^ expected `f32`, found `&str` +// | +// expected due to this +``` + +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":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":true,"text":[{"text":"let s : String = (","highlight_start":XX,"highlight_end":XX},{"text":"); // Error spanning the newline.","highlight_start":XX,"highlight_end":XX}],"label":"expected `String`, found `()`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":false,"text":[{"text":"let s : String = (","highlight_start":XX,"highlight_end":XX}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"$DIR/json-bom-plus-crlf.rs:LL:CC: 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 +"} diff --git a/tests/run-make/json-bom-plus-crlf/rmake.rs b/tests/run-make/json-bom-plus-crlf/rmake.rs new file mode 100644 index 0000000000000..f2f60d69a9a04 --- /dev/null +++ b/tests/run-make/json-bom-plus-crlf/rmake.rs @@ -0,0 +1,64 @@ +//@ reference: input.byte-order-mark +//@ reference: input.crlf +//@ ignore-cross-compile + +use run_make_support::{cwd, diff, rfs, rustc}; + +fn main() { + let main_content = "\u{FEFF}\ +fn main() {\r\n\ +\r\n\ + let s : String = 1; // Error in the middle of line.\r\n\ +\r\n\ + let s : String = 1\r\n\ + ; // Error before the newline.\r\n\ +\r\n\ + let s : String =\r\n\ +1; // Error after the newline.\r\n\ +\r\n\ + let s : String = (\r\n\ + ); // Error spanning the newline.\r\n\ +}\r\n"; + + let main_path = cwd().join("json-bom-plus-crlf.rs"); + rfs::write(&main_path, main_content); + + let main_bytes = rfs::read(&main_path); + assert!(main_bytes.starts_with(b"\xEF\xBB\xBF"), "File must start with UTF-8 BOM"); + assert!(main_bytes.windows(2).any(|w| w == b"\r\n"), "File must contain CRLF line endings"); + + let output = rustc() + .input(&main_path) + .json("diagnostic-short") + .error_format("json") + .ui_testing() + .run_fail() + .stderr_utf8(); + + diff() + .expected_file("json-bom-plus-crlf.stderr") + .actual_text("stderr", &output) + .normalize(r"\\n", "\n") + .normalize(r"\\r\\n", "\n") + .normalize(r#""line_start":\d+"#, r#""line_start":LL"#) + .normalize(r#""line_end":\d+"#, r#""line_end":LL"#) + .normalize(r#""column_start":\d+"#, r#""column_start":CC"#) + .normalize(r#""column_end":\d+"#, r#""column_end":CC"#) + .normalize(r#""byte_start":\d+"#, r#""byte_start":XXX"#) + .normalize(r#""byte_end":\d+"#, r#""byte_end":XXX"#) + .normalize(r#""highlight_start":\d+"#, r#""highlight_start":XX"#) + .normalize(r#""highlight_end":\d+"#, r#""highlight_end":XX"#) + .normalize( + r#""file_name":"[^"]*json-bom-plus-crlf\.rs""#, + r#""file_name":"$$DIR/json-bom-plus-crlf.rs""#, + ) + .normalize( + r#""rendered":"(?:[^"]*/)?json-bom-plus-crlf\.rs:\d+:\d+:"#, + r#""rendered":"$$DIR/json-bom-plus-crlf.rs:LL:CC:"#, + ) + .normalize( + r#""rendered":"(?:[^"]*/)?json-bom-plus-crlf\.rs:\d+:\d+ error"#, + r#""rendered":"$$DIR/json-bom-plus-crlf.rs:LL:CC error"#, + ) + .run(); +} diff --git a/tests/run-make/lexer-crlf-line-endings-string-literal-doc-comment/rmake.rs b/tests/run-make/lexer-crlf-line-endings-string-literal-doc-comment/rmake.rs new file mode 100644 index 0000000000000..0f66311a6b138 --- /dev/null +++ b/tests/run-make/lexer-crlf-line-endings-string-literal-doc-comment/rmake.rs @@ -0,0 +1,40 @@ +//@ reference: input.crlf +//@ ignore-cross-compile + +use run_make_support::{cwd, rfs, run, rustc}; + +fn main() { + let test_content = "/// Doc comment that ends in CRLF\r\n\ +pub fn foo() {}\r\n\ +\r\n\ +/** Block doc comment that\r\n\ + * contains CRLF characters\r\n\ + */\r\n\ +pub fn bar() {}\r\n\ +\r\n\ +fn main() {\r\n\ + let s = \"string\r\nliteral\";\r\n\ + assert_eq!(s, \"string\\nliteral\");\r\n\ +\r\n\ + let s = \"literal with \\\r\n\ + escaped newline\";\r\n\ + assert_eq!(s, \"literal with escaped newline\");\r\n\ +\r\n\ + let s = r\"string\r\nliteral\";\r\n\ + assert_eq!(s, \"string\\nliteral\");\r\n\ + let s = br\"byte string\r\nliteral\";\r\n\ + assert_eq!(s, \"byte string\\nliteral\".as_bytes());\r\n\ +\r\n\ + // validate that our source file has CRLF endings\r\n\ + let source = include_str!(file!());\r\n\ + assert!(source.contains(\"string\\r\\nliteral\"));\r\n\ +}\r\n"; + + let test_path = cwd().join("lexer-crlf-line-endings-string-literal-doc-comment.rs"); + rfs::write(&test_path, test_content); + + let test_bytes = rfs::read(&test_path); + assert!(test_bytes.windows(2).any(|w| w == b"\r\n"), "File must contain CRLF line endings"); + + rustc().input(&test_path).run(); +} diff --git a/tests/run-make/trailing-carriage-return-in-string/rmake.rs b/tests/run-make/trailing-carriage-return-in-string/rmake.rs new file mode 100644 index 0000000000000..50a64b786bd1c --- /dev/null +++ b/tests/run-make/trailing-carriage-return-in-string/rmake.rs @@ -0,0 +1,23 @@ +//@ ignore-cross-compile + +use run_make_support::{cwd, diff, rfs, rustc}; + +fn main() { + let test_content = "fn main() {\n\ + // \\r\\n\n\ + let ok = \"This is \\\r\n a test\";\n\ + // \\r only\n\ + let bad = \"This is \\\r a test\";\n\ +}\n"; + + let test_path = cwd().join("trailing-carriage-return-in-string.rs"); + rfs::write(&test_path, test_content); + + let output = rustc().input(&test_path).ui_testing().run_fail().stderr_utf8(); + + diff() + .expected_file("trailing-carriage-return-in-string.stderr") + .actual_text("stderr", &output) + .normalize(r#"--> [^\n]+"#, "--> trailing-carriage-return-in-string.rs:LL:CC") + .run(); +} diff --git a/tests/ui/parser/trailing-carriage-return-in-string.stderr b/tests/run-make/trailing-carriage-return-in-string/trailing-carriage-return-in-string.stderr similarity index 56% rename from tests/ui/parser/trailing-carriage-return-in-string.stderr rename to tests/run-make/trailing-carriage-return-in-string/trailing-carriage-return-in-string.stderr index c5949432af893..4adafc08e0450 100644 --- a/tests/ui/parser/trailing-carriage-return-in-string.stderr +++ b/tests/run-make/trailing-carriage-return-in-string/trailing-carriage-return-in-string.stderr @@ -1,8 +1,8 @@ error: unknown character escape: `\r` - --> $DIR/trailing-carriage-return-in-string.rs:10:25 + --> trailing-carriage-return-in-string.rs:LL:CC | -LL | let bad = "This is \␍ a test"; - | ^ unknown character escape +LL | let bad = "This is \␍ a test"; + | ^ unknown character escape | = help: this is an isolated carriage return; consider checking your editor and version control settings diff --git a/tests/ui/.gitattributes b/tests/ui/.gitattributes index 9ea3d3fb0e1f1..e72d32c601a75 100644 --- a/tests/ui/.gitattributes +++ b/tests/ui/.gitattributes @@ -1,6 +1 @@ -lexer-crlf-line-endings-string-literal-doc-comment.rs -text -json-bom-plus-crlf.rs -text -json-bom-plus-crlf-multifile.rs -text -json-bom-plus-crlf-multifile-aux.rs -text -trailing-carriage-return-in-string.rs -text *.bin -text diff --git a/tests/ui/json/json-bom-plus-crlf-multifile-aux.rs b/tests/ui/json/json-bom-plus-crlf-multifile-aux.rs deleted file mode 100644 index 94b1e188ced97..0000000000000 --- a/tests/ui/json/json-bom-plus-crlf-multifile-aux.rs +++ /dev/null @@ -1,27 +0,0 @@ -// (This line has BOM so it's ignored by compiletest for directives) -// -//@ ignore-test Not a test. Used by other tests -// ignore-tidy-cr - -// For easier verifying, the byte offsets in this file should match those -// in the json-bom-plus-crlf.rs - given the actual fn is identical (just with -// a different, but equally sized name), the easiest way to do this is to -// ensure the two files are of equal size on disk. -// Padding............................ - -// N.B., this file needs CRLF line endings. The .gitattributes file in -// this directory should enforce it. - -pub fn test() { - - let s : String = 1; // Error in the middle of line. - - let s : String = 1 - ; // Error before the newline. - - let s : String = -1; // Error after the newline. - - let s : String = ( - ); // Error spanning the newline. -} diff --git a/tests/ui/json/json-bom-plus-crlf-multifile.rs b/tests/ui/json/json-bom-plus-crlf-multifile.rs deleted file mode 100644 index 074a2583e8276..0000000000000 --- a/tests/ui/json/json-bom-plus-crlf-multifile.rs +++ /dev/null @@ -1,18 +0,0 @@ -// (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"] -mod json_bom_plus_crlf_multifile_aux; - -fn main() { - json_bom_plus_crlf_multifile_aux::test(); -} - -//~? ERROR mismatched types -//~? ERROR mismatched types -//~? ERROR mismatched types -//~? ERROR mismatched types diff --git a/tests/ui/json/json-bom-plus-crlf-multifile.stderr b/tests/ui/json/json-bom-plus-crlf-multifile.stderr deleted file mode 100644 index 9c88a7e5a2564..0000000000000 --- a/tests/ui/json/json-bom-plus-crlf-multifile.stderr +++ /dev/null @@ -1,114 +0,0 @@ -{"$message_type":"diagnostic","message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type. - -Erroneous code examples: - -```compile_fail,E0308 -fn plus_one(x: i32) -> i32 { - x + 1 -} - -plus_one(\"Not a number\"); -// ^^^^^^^^^^^^^^ expected `i32`, found `&str` - -if \"Not a bool\" { -// ^^^^^^^^^^^^ expected `bool`, found `&str` -} - -let x: f32 = \"Not a float\"; -// --- ^^^^^^^^^^^^^ expected `f32`, found `&str` -// | -// expected due to this -``` - -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-multifile-aux.rs","byte_start":622,"byte_end":623,"line_start":17,"line_end":17,"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-multifile-aux.rs","byte_start":613,"byte_end":619,"line_start":17,"line_end":17,"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-multifile-aux.rs","byte_start":623,"byte_end":623,"line_start":17,"line_end":17,"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-multifile-aux.rs:17: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. - -Erroneous code examples: - -```compile_fail,E0308 -fn plus_one(x: i32) -> i32 { - x + 1 -} - -plus_one(\"Not a number\"); -// ^^^^^^^^^^^^^^ expected `i32`, found `&str` - -if \"Not a bool\" { -// ^^^^^^^^^^^^ expected `bool`, found `&str` -} - -let x: f32 = \"Not a float\"; -// --- ^^^^^^^^^^^^^ expected `f32`, found `&str` -// | -// expected due to this -``` - -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-multifile-aux.rs","byte_start":682,"byte_end":683,"line_start":19,"line_end":19,"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-multifile-aux.rs","byte_start":673,"byte_end":679,"line_start":19,"line_end":19,"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-multifile-aux.rs","byte_start":683,"byte_end":683,"line_start":19,"line_end":19,"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-multifile-aux.rs:19: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. - -Erroneous code examples: - -```compile_fail,E0308 -fn plus_one(x: i32) -> i32 { - x + 1 -} - -plus_one(\"Not a number\"); -// ^^^^^^^^^^^^^^ expected `i32`, found `&str` - -if \"Not a bool\" { -// ^^^^^^^^^^^^ expected `bool`, found `&str` -} - -let x: f32 = \"Not a float\"; -// --- ^^^^^^^^^^^^^ expected `f32`, found `&str` -// | -// expected due to this -``` - -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-multifile-aux.rs","byte_start":746,"byte_end":747,"line_start":23,"line_end":23,"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-multifile-aux.rs","byte_start":736,"byte_end":742,"line_start":22,"line_end":22,"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-multifile-aux.rs","byte_start":747,"byte_end":747,"line_start":23,"line_end":23,"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-multifile-aux.rs:23: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. - -Erroneous code examples: - -```compile_fail,E0308 -fn plus_one(x: i32) -> i32 { - x + 1 -} - -plus_one(\"Not a number\"); -// ^^^^^^^^^^^^^^ expected `i32`, found `&str` - -if \"Not a bool\" { -// ^^^^^^^^^^^^ expected `bool`, found `&str` -} - -let x: f32 = \"Not a float\"; -// --- ^^^^^^^^^^^^^ expected `f32`, found `&str` -// | -// expected due to this -``` - -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-multifile-aux.rs","byte_start":802,"byte_end":810,"line_start":25,"line_end":26,"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-multifile-aux.rs","byte_start":793,"byte_end":799,"line_start":25,"line_end":25,"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-multifile-aux.rs:25: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 -"} diff --git a/tests/ui/json/json-bom-plus-crlf.rs b/tests/ui/json/json-bom-plus-crlf.rs deleted file mode 100644 index 900a92f368298..0000000000000 --- a/tests/ui/json/json-bom-plus-crlf.rs +++ /dev/null @@ -1,32 +0,0 @@ -// (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 -// in the json_bom_plus_crlf_multifile_aux.rs - given the actual fn is -// identical (just with a different, but equally sized name), the easiest way -// to do this is to ensure the two files are of equal size on disk. - -// N.B., this file needs CRLF line endings. The .gitattributes file in -// this directory should enforce it. - -fn main() { - - let s : String = 1; // Error in the middle of line. - //~^ ERROR mismatched types - - let s : String = 1 - ; // Error before the newline. - //~^^ ERROR mismatched types - - let s : String = -1; // Error after the newline. - //~^ ERROR mismatched types - - let s : String = ( - ); // Error spanning the newline. - //~^^ ERROR mismatched types -} diff --git a/tests/ui/json/json-bom-plus-crlf.stderr b/tests/ui/json/json-bom-plus-crlf.stderr deleted file mode 100644 index 59f0e8178f0e3..0000000000000 --- a/tests/ui/json/json-bom-plus-crlf.stderr +++ /dev/null @@ -1,114 +0,0 @@ -{"$message_type":"diagnostic","message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type. - -Erroneous code examples: - -```compile_fail,E0308 -fn plus_one(x: i32) -> i32 { - x + 1 -} - -plus_one(\"Not a number\"); -// ^^^^^^^^^^^^^^ expected `i32`, found `&str` - -if \"Not a bool\" { -// ^^^^^^^^^^^^ expected `bool`, found `&str` -} - -let x: f32 = \"Not a float\"; -// --- ^^^^^^^^^^^^^ expected `f32`, found `&str` -// | -// expected due to this -``` - -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":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. - -Erroneous code examples: - -```compile_fail,E0308 -fn plus_one(x: i32) -> i32 { - x + 1 -} - -plus_one(\"Not a number\"); -// ^^^^^^^^^^^^^^ expected `i32`, found `&str` - -if \"Not a bool\" { -// ^^^^^^^^^^^^ expected `bool`, found `&str` -} - -let x: f32 = \"Not a float\"; -// --- ^^^^^^^^^^^^^ expected `f32`, found `&str` -// | -// expected due to this -``` - -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":765,"byte_end":766,"line_start":21,"line_end":21,"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":756,"byte_end":762,"line_start":21,"line_end":21,"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":766,"byte_end":766,"line_start":21,"line_end":21,"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:21: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. - -Erroneous code examples: - -```compile_fail,E0308 -fn plus_one(x: i32) -> i32 { - x + 1 -} - -plus_one(\"Not a number\"); -// ^^^^^^^^^^^^^^ expected `i32`, found `&str` - -if \"Not a bool\" { -// ^^^^^^^^^^^^ expected `bool`, found `&str` -} - -let x: f32 = \"Not a float\"; -// --- ^^^^^^^^^^^^^ expected `f32`, found `&str` -// | -// expected due to this -``` - -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":863,"byte_end":864,"line_start":26,"line_end":26,"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":853,"byte_end":859,"line_start":25,"line_end":25,"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":864,"byte_end":864,"line_start":26,"line_end":26,"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:26: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. - -Erroneous code examples: - -```compile_fail,E0308 -fn plus_one(x: i32) -> i32 { - x + 1 -} - -plus_one(\"Not a number\"); -// ^^^^^^^^^^^^^^ expected `i32`, found `&str` - -if \"Not a bool\" { -// ^^^^^^^^^^^^ expected `bool`, found `&str` -} - -let x: f32 = \"Not a float\"; -// --- ^^^^^^^^^^^^^ expected `f32`, found `&str` -// | -// expected due to this -``` - -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":952,"byte_end":960,"line_start":29,"line_end":30,"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":943,"byte_end":949,"line_start":29,"line_end":29,"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:29: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 -"} diff --git a/tests/ui/lexer/lexer-crlf-line-endings-string-literal-doc-comment.rs b/tests/ui/lexer/lexer-crlf-line-endings-string-literal-doc-comment.rs deleted file mode 100644 index ee193a58ce1b2..0000000000000 --- a/tests/ui/lexer/lexer-crlf-line-endings-string-literal-doc-comment.rs +++ /dev/null @@ -1,38 +0,0 @@ -//@ 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. - -// N.B., this file needs CRLF line endings. The .gitattributes file in -// this directory should enforce it. - - -/// Doc comment that ends in CRLF -pub fn foo() {} - -/** Block doc comment that - * contains CRLF characters - */ -pub fn bar() {} - -fn main() { - let s = "string -literal"; - assert_eq!(s, "string\nliteral"); - - let s = "literal with \ - escaped newline"; - assert_eq!(s, "literal with escaped newline"); - - let s = r"string -literal"; - assert_eq!(s, "string\nliteral"); - let s = br"byte string -literal"; - assert_eq!(s, "byte string\nliteral".as_bytes()); - - // validate that our source file has CRLF endings - let source = include_str!("lexer-crlf-line-endings-string-literal-doc-comment.rs"); - assert!(source.contains("string\r\nliteral")); -} diff --git a/tests/ui/parser/trailing-carriage-return-in-string.rs b/tests/ui/parser/trailing-carriage-return-in-string.rs deleted file mode 100644 index 5d3c31944064a..0000000000000 --- a/tests/ui/parser/trailing-carriage-return-in-string.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Issue #11669 - -// ignore-tidy-cr - -fn main() { - // \r\n - let ok = "This is \ - a test"; - // \r only - let bad = "This is \ a test"; - //~^ ERROR unknown character escape: `\r` - //~| HELP this is an isolated carriage return - -}