From e68edb89ad1b34a3112c1cddd5541917743ccecd Mon Sep 17 00:00:00 2001 From: Vitaliy Busko Date: Thu, 19 Oct 2023 04:24:35 +0700 Subject: refactor(compiler/resolve): simplify some code Removes unnecessary allocates and double-sorting the same vector, makes the code a little nicer. --- compiler/rustc_resolve/src/check_unused.rs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/compiler/rustc_resolve/src/check_unused.rs b/compiler/rustc_resolve/src/check_unused.rs index 7dbbd4c34ea..6b39d7907f1 100644 --- a/compiler/rustc_resolve/src/check_unused.rs +++ b/compiler/rustc_resolve/src/check_unused.rs @@ -338,7 +338,7 @@ impl Resolver<'_, '_> { for unused in visitor.unused_imports.values() { let mut fixes = Vec::new(); - let mut spans = match calc_unused_spans(unused, unused.use_tree, unused.use_tree_id) { + let spans = match calc_unused_spans(unused, unused.use_tree, unused.use_tree_id) { UnusedSpanResult::Used => continue, UnusedSpanResult::FlatUnused(span, remove) => { fixes.push((remove, String::new())); @@ -356,20 +356,19 @@ impl Resolver<'_, '_> { } }; - let len = spans.len(); - spans.sort(); - let ms = MultiSpan::from_spans(spans.clone()); - let mut span_snippets = spans + let ms = MultiSpan::from_spans(spans); + + let mut span_snippets = ms + .primary_spans() .iter() - .filter_map(|s| match tcx.sess.source_map().span_to_snippet(*s) { - Ok(s) => Some(format!("`{s}`")), - _ => None, - }) + .filter_map(|span| tcx.sess.source_map().span_to_snippet(*span).ok()) + .map(|s| format!("`{s}`")) .collect::>(); span_snippets.sort(); + let msg = format!( "unused import{}{}", - pluralize!(len), + pluralize!(ms.primary_spans().len()), if !span_snippets.is_empty() { format!(": {}", span_snippets.join(", ")) } else { @@ -379,7 +378,7 @@ impl Resolver<'_, '_> { let fix_msg = if fixes.len() == 1 && fixes[0].0 == unused.item_span { "remove the whole `use` item" - } else if spans.len() > 1 { + } else if ms.primary_spans().len() > 1 { "remove the unused imports" } else { "remove the unused import" -- cgit 1.4.1-3-g733a5 From 855444ec54d1a745c5c53375792957170244e7c3 Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Tue, 24 Oct 2023 21:27:05 +0000 Subject: mv tests --- tests/ui/parser/issue-100197-mut-let.fixed | 6 -- tests/ui/parser/issue-100197-mut-let.rs | 6 -- tests/ui/parser/issue-100197-mut-let.stderr | 8 -- tests/ui/parser/issue-101477-enum.fixed | 10 -- tests/ui/parser/issue-101477-enum.rs | 10 -- tests/ui/parser/issue-101477-enum.stderr | 18 ---- tests/ui/parser/issue-101477-let.fixed | 6 -- tests/ui/parser/issue-101477-let.rs | 6 -- tests/ui/parser/issue-101477-let.stderr | 8 -- tests/ui/parser/issue-102806.rs | 25 ----- tests/ui/parser/issue-102806.stderr | 50 ---------- tests/ui/parser/issue-103143.rs | 5 - tests/ui/parser/issue-103143.stderr | 20 ---- tests/ui/parser/issue-103381.fixed | 59 ------------ tests/ui/parser/issue-103381.rs | 59 ------------ tests/ui/parser/issue-103381.stderr | 50 ---------- tests/ui/parser/issue-103425.rs | 15 --- tests/ui/parser/issue-103425.stderr | 29 ------ tests/ui/parser/issue-103451.rs | 4 - tests/ui/parser/issue-103451.stderr | 12 --- tests/ui/parser/issue-103748-ICE-wrong-braces.rs | 8 -- .../ui/parser/issue-103748-ICE-wrong-braces.stderr | 51 ---------- tests/ui/parser/issue-104620.rs | 4 - tests/ui/parser/issue-104620.stderr | 8 -- tests/ui/parser/issue-104867-inc-dec-2.rs | 52 ---------- tests/ui/parser/issue-104867-inc-dec-2.stderr | 107 --------------------- tests/ui/parser/issue-104867-inc-dec.rs | 45 --------- tests/ui/parser/issue-104867-inc-dec.stderr | 81 ---------------- tests/ui/parser/issue-105366.fixed | 12 --- tests/ui/parser/issue-105366.rs | 12 --- tests/ui/parser/issue-105366.stderr | 13 --- tests/ui/parser/issue-105634.rs | 8 -- tests/ui/parser/issue-107705.rs | 3 - tests/ui/parser/issue-107705.stderr | 10 -- tests/ui/parser/issue-108495-dec.rs | 39 -------- tests/ui/parser/issue-108495-dec.stderr | 69 ------------- tests/ui/parser/issue-112188.fixed | 14 --- tests/ui/parser/issue-112188.rs | 14 --- tests/ui/parser/issue-112188.stderr | 37 ------- tests/ui/parser/issue-113342.rs | 9 -- tests/ui/parser/issue-113342.stderr | 11 --- tests/ui/parser/issue-17718-parse-const.rs | 7 -- tests/ui/parser/issue-39616.rs | 3 - tests/ui/parser/issue-39616.stderr | 8 -- tests/ui/parser/issue-49257.rs | 14 --- tests/ui/parser/issue-49257.stderr | 42 -------- tests/ui/parser/issue-61858.rs | 3 - tests/ui/parser/issue-61858.stderr | 14 --- .../parser/issue-68091-unicode-ident-after-if.rs | 10 -- .../issue-68091-unicode-ident-after-if.stderr | 10 -- ...ue-68092-unicode-ident-after-incomplete-expr.rs | 9 -- ...8092-unicode-ident-after-incomplete-expr.stderr | 8 -- tests/ui/parser/issue-68987-unmatch-issue-1.rs | 12 --- tests/ui/parser/issue-68987-unmatch-issue-1.stderr | 16 --- tests/ui/parser/issue-68987-unmatch-issue-2.rs | 14 --- tests/ui/parser/issue-68987-unmatch-issue-2.stderr | 19 ---- tests/ui/parser/issue-68987-unmatch-issue-3.rs | 8 -- tests/ui/parser/issue-68987-unmatch-issue-3.stderr | 19 ---- tests/ui/parser/issue-68987-unmatch-issue.rs | 12 --- tests/ui/parser/issue-68987-unmatch-issue.stderr | 16 --- tests/ui/parser/issue-81804.rs | 6 -- tests/ui/parser/issue-81804.stderr | 19 ---- tests/ui/parser/issue-81827.rs | 10 -- tests/ui/parser/issue-81827.stderr | 21 ---- tests/ui/parser/issue-87694-duplicated-pub.rs | 5 - tests/ui/parser/issue-87694-duplicated-pub.stderr | 17 ---- tests/ui/parser/issue-87694-misplaced-pub.rs | 5 - tests/ui/parser/issue-87694-misplaced-pub.stderr | 11 --- tests/ui/parser/issue-90728.rs | 6 -- tests/ui/parser/issue-90728.stderr | 20 ---- tests/ui/parser/issue-91421.rs | 9 -- tests/ui/parser/issue-91421.stderr | 14 --- ...ssue-99625-enum-struct-mutually-exclusive.fixed | 13 --- .../issue-99625-enum-struct-mutually-exclusive.rs | 13 --- ...sue-99625-enum-struct-mutually-exclusive.stderr | 8 -- .../issue-99910-const-let-mutually-exclusive.fixed | 8 -- .../issue-99910-const-let-mutually-exclusive.rs | 8 -- ...issue-99910-const-let-mutually-exclusive.stderr | 14 --- tests/ui/parser/issues/issue-100197-mut-let.fixed | 6 ++ tests/ui/parser/issues/issue-100197-mut-let.rs | 6 ++ tests/ui/parser/issues/issue-100197-mut-let.stderr | 8 ++ tests/ui/parser/issues/issue-101477-enum.fixed | 10 ++ tests/ui/parser/issues/issue-101477-enum.rs | 10 ++ tests/ui/parser/issues/issue-101477-enum.stderr | 18 ++++ tests/ui/parser/issues/issue-101477-let.fixed | 6 ++ tests/ui/parser/issues/issue-101477-let.rs | 6 ++ tests/ui/parser/issues/issue-101477-let.stderr | 8 ++ tests/ui/parser/issues/issue-102806.rs | 25 +++++ tests/ui/parser/issues/issue-102806.stderr | 50 ++++++++++ tests/ui/parser/issues/issue-103143.rs | 5 + tests/ui/parser/issues/issue-103143.stderr | 20 ++++ tests/ui/parser/issues/issue-103381.fixed | 59 ++++++++++++ tests/ui/parser/issues/issue-103381.rs | 59 ++++++++++++ tests/ui/parser/issues/issue-103381.stderr | 50 ++++++++++ tests/ui/parser/issues/issue-103425.rs | 15 +++ tests/ui/parser/issues/issue-103425.stderr | 29 ++++++ tests/ui/parser/issues/issue-103451.rs | 4 + tests/ui/parser/issues/issue-103451.stderr | 12 +++ .../parser/issues/issue-103748-ICE-wrong-braces.rs | 8 ++ .../issues/issue-103748-ICE-wrong-braces.stderr | 51 ++++++++++ tests/ui/parser/issues/issue-104620.rs | 4 + tests/ui/parser/issues/issue-104620.stderr | 8 ++ tests/ui/parser/issues/issue-104867-inc-dec-2.rs | 52 ++++++++++ .../ui/parser/issues/issue-104867-inc-dec-2.stderr | 107 +++++++++++++++++++++ tests/ui/parser/issues/issue-104867-inc-dec.rs | 45 +++++++++ tests/ui/parser/issues/issue-104867-inc-dec.stderr | 81 ++++++++++++++++ tests/ui/parser/issues/issue-105366.fixed | 12 +++ tests/ui/parser/issues/issue-105366.rs | 12 +++ tests/ui/parser/issues/issue-105366.stderr | 13 +++ tests/ui/parser/issues/issue-105634.rs | 8 ++ tests/ui/parser/issues/issue-107705.rs | 3 + tests/ui/parser/issues/issue-107705.stderr | 10 ++ tests/ui/parser/issues/issue-108495-dec.rs | 39 ++++++++ tests/ui/parser/issues/issue-108495-dec.stderr | 69 +++++++++++++ tests/ui/parser/issues/issue-112188.fixed | 14 +++ tests/ui/parser/issues/issue-112188.rs | 14 +++ tests/ui/parser/issues/issue-112188.stderr | 37 +++++++ tests/ui/parser/issues/issue-113342.rs | 9 ++ tests/ui/parser/issues/issue-113342.stderr | 11 +++ tests/ui/parser/issues/issue-17718-parse-const.rs | 7 ++ tests/ui/parser/issues/issue-39616.rs | 3 + tests/ui/parser/issues/issue-39616.stderr | 8 ++ tests/ui/parser/issues/issue-49257.rs | 14 +++ tests/ui/parser/issues/issue-49257.stderr | 42 ++++++++ tests/ui/parser/issues/issue-61858.rs | 3 + tests/ui/parser/issues/issue-61858.stderr | 14 +++ .../issues/issue-68091-unicode-ident-after-if.rs | 10 ++ .../issue-68091-unicode-ident-after-if.stderr | 10 ++ ...ue-68092-unicode-ident-after-incomplete-expr.rs | 9 ++ ...8092-unicode-ident-after-incomplete-expr.stderr | 8 ++ .../parser/issues/issue-68987-unmatch-issue-1.rs | 12 +++ .../issues/issue-68987-unmatch-issue-1.stderr | 16 +++ .../parser/issues/issue-68987-unmatch-issue-2.rs | 14 +++ .../issues/issue-68987-unmatch-issue-2.stderr | 19 ++++ .../parser/issues/issue-68987-unmatch-issue-3.rs | 8 ++ .../issues/issue-68987-unmatch-issue-3.stderr | 19 ++++ .../ui/parser/issues/issue-68987-unmatch-issue.rs | 12 +++ .../parser/issues/issue-68987-unmatch-issue.stderr | 16 +++ tests/ui/parser/issues/issue-81804.rs | 6 ++ tests/ui/parser/issues/issue-81804.stderr | 19 ++++ tests/ui/parser/issues/issue-81827.rs | 10 ++ tests/ui/parser/issues/issue-81827.stderr | 21 ++++ .../ui/parser/issues/issue-87694-duplicated-pub.rs | 5 + .../issues/issue-87694-duplicated-pub.stderr | 17 ++++ .../ui/parser/issues/issue-87694-misplaced-pub.rs | 5 + .../parser/issues/issue-87694-misplaced-pub.stderr | 11 +++ tests/ui/parser/issues/issue-90728.rs | 6 ++ tests/ui/parser/issues/issue-90728.stderr | 20 ++++ tests/ui/parser/issues/issue-91421.rs | 9 ++ tests/ui/parser/issues/issue-91421.stderr | 14 +++ ...ssue-99625-enum-struct-mutually-exclusive.fixed | 13 +++ .../issue-99625-enum-struct-mutually-exclusive.rs | 13 +++ ...sue-99625-enum-struct-mutually-exclusive.stderr | 8 ++ .../issue-99910-const-let-mutually-exclusive.fixed | 8 ++ .../issue-99910-const-let-mutually-exclusive.rs | 8 ++ ...issue-99910-const-let-mutually-exclusive.stderr | 14 +++ 156 files changed, 1464 insertions(+), 1464 deletions(-) delete mode 100644 tests/ui/parser/issue-100197-mut-let.fixed delete mode 100644 tests/ui/parser/issue-100197-mut-let.rs delete mode 100644 tests/ui/parser/issue-100197-mut-let.stderr delete mode 100644 tests/ui/parser/issue-101477-enum.fixed delete mode 100644 tests/ui/parser/issue-101477-enum.rs delete mode 100644 tests/ui/parser/issue-101477-enum.stderr delete mode 100644 tests/ui/parser/issue-101477-let.fixed delete mode 100644 tests/ui/parser/issue-101477-let.rs delete mode 100644 tests/ui/parser/issue-101477-let.stderr delete mode 100644 tests/ui/parser/issue-102806.rs delete mode 100644 tests/ui/parser/issue-102806.stderr delete mode 100644 tests/ui/parser/issue-103143.rs delete mode 100644 tests/ui/parser/issue-103143.stderr delete mode 100644 tests/ui/parser/issue-103381.fixed delete mode 100644 tests/ui/parser/issue-103381.rs delete mode 100644 tests/ui/parser/issue-103381.stderr delete mode 100644 tests/ui/parser/issue-103425.rs delete mode 100644 tests/ui/parser/issue-103425.stderr delete mode 100644 tests/ui/parser/issue-103451.rs delete mode 100644 tests/ui/parser/issue-103451.stderr delete mode 100644 tests/ui/parser/issue-103748-ICE-wrong-braces.rs delete mode 100644 tests/ui/parser/issue-103748-ICE-wrong-braces.stderr delete mode 100644 tests/ui/parser/issue-104620.rs delete mode 100644 tests/ui/parser/issue-104620.stderr delete mode 100644 tests/ui/parser/issue-104867-inc-dec-2.rs delete mode 100644 tests/ui/parser/issue-104867-inc-dec-2.stderr delete mode 100644 tests/ui/parser/issue-104867-inc-dec.rs delete mode 100644 tests/ui/parser/issue-104867-inc-dec.stderr delete mode 100644 tests/ui/parser/issue-105366.fixed delete mode 100644 tests/ui/parser/issue-105366.rs delete mode 100644 tests/ui/parser/issue-105366.stderr delete mode 100644 tests/ui/parser/issue-105634.rs delete mode 100644 tests/ui/parser/issue-107705.rs delete mode 100644 tests/ui/parser/issue-107705.stderr delete mode 100644 tests/ui/parser/issue-108495-dec.rs delete mode 100644 tests/ui/parser/issue-108495-dec.stderr delete mode 100644 tests/ui/parser/issue-112188.fixed delete mode 100644 tests/ui/parser/issue-112188.rs delete mode 100644 tests/ui/parser/issue-112188.stderr delete mode 100644 tests/ui/parser/issue-113342.rs delete mode 100644 tests/ui/parser/issue-113342.stderr delete mode 100644 tests/ui/parser/issue-17718-parse-const.rs delete mode 100644 tests/ui/parser/issue-39616.rs delete mode 100644 tests/ui/parser/issue-39616.stderr delete mode 100644 tests/ui/parser/issue-49257.rs delete mode 100644 tests/ui/parser/issue-49257.stderr delete mode 100644 tests/ui/parser/issue-61858.rs delete mode 100644 tests/ui/parser/issue-61858.stderr delete mode 100644 tests/ui/parser/issue-68091-unicode-ident-after-if.rs delete mode 100644 tests/ui/parser/issue-68091-unicode-ident-after-if.stderr delete mode 100644 tests/ui/parser/issue-68092-unicode-ident-after-incomplete-expr.rs delete mode 100644 tests/ui/parser/issue-68092-unicode-ident-after-incomplete-expr.stderr delete mode 100644 tests/ui/parser/issue-68987-unmatch-issue-1.rs delete mode 100644 tests/ui/parser/issue-68987-unmatch-issue-1.stderr delete mode 100644 tests/ui/parser/issue-68987-unmatch-issue-2.rs delete mode 100644 tests/ui/parser/issue-68987-unmatch-issue-2.stderr delete mode 100644 tests/ui/parser/issue-68987-unmatch-issue-3.rs delete mode 100644 tests/ui/parser/issue-68987-unmatch-issue-3.stderr delete mode 100644 tests/ui/parser/issue-68987-unmatch-issue.rs delete mode 100644 tests/ui/parser/issue-68987-unmatch-issue.stderr delete mode 100644 tests/ui/parser/issue-81804.rs delete mode 100644 tests/ui/parser/issue-81804.stderr delete mode 100644 tests/ui/parser/issue-81827.rs delete mode 100644 tests/ui/parser/issue-81827.stderr delete mode 100644 tests/ui/parser/issue-87694-duplicated-pub.rs delete mode 100644 tests/ui/parser/issue-87694-duplicated-pub.stderr delete mode 100644 tests/ui/parser/issue-87694-misplaced-pub.rs delete mode 100644 tests/ui/parser/issue-87694-misplaced-pub.stderr delete mode 100644 tests/ui/parser/issue-90728.rs delete mode 100644 tests/ui/parser/issue-90728.stderr delete mode 100644 tests/ui/parser/issue-91421.rs delete mode 100644 tests/ui/parser/issue-91421.stderr delete mode 100644 tests/ui/parser/issue-99625-enum-struct-mutually-exclusive.fixed delete mode 100644 tests/ui/parser/issue-99625-enum-struct-mutually-exclusive.rs delete mode 100644 tests/ui/parser/issue-99625-enum-struct-mutually-exclusive.stderr delete mode 100644 tests/ui/parser/issue-99910-const-let-mutually-exclusive.fixed delete mode 100644 tests/ui/parser/issue-99910-const-let-mutually-exclusive.rs delete mode 100644 tests/ui/parser/issue-99910-const-let-mutually-exclusive.stderr create mode 100644 tests/ui/parser/issues/issue-100197-mut-let.fixed create mode 100644 tests/ui/parser/issues/issue-100197-mut-let.rs create mode 100644 tests/ui/parser/issues/issue-100197-mut-let.stderr create mode 100644 tests/ui/parser/issues/issue-101477-enum.fixed create mode 100644 tests/ui/parser/issues/issue-101477-enum.rs create mode 100644 tests/ui/parser/issues/issue-101477-enum.stderr create mode 100644 tests/ui/parser/issues/issue-101477-let.fixed create mode 100644 tests/ui/parser/issues/issue-101477-let.rs create mode 100644 tests/ui/parser/issues/issue-101477-let.stderr create mode 100644 tests/ui/parser/issues/issue-102806.rs create mode 100644 tests/ui/parser/issues/issue-102806.stderr create mode 100644 tests/ui/parser/issues/issue-103143.rs create mode 100644 tests/ui/parser/issues/issue-103143.stderr create mode 100644 tests/ui/parser/issues/issue-103381.fixed create mode 100644 tests/ui/parser/issues/issue-103381.rs create mode 100644 tests/ui/parser/issues/issue-103381.stderr create mode 100644 tests/ui/parser/issues/issue-103425.rs create mode 100644 tests/ui/parser/issues/issue-103425.stderr create mode 100644 tests/ui/parser/issues/issue-103451.rs create mode 100644 tests/ui/parser/issues/issue-103451.stderr create mode 100644 tests/ui/parser/issues/issue-103748-ICE-wrong-braces.rs create mode 100644 tests/ui/parser/issues/issue-103748-ICE-wrong-braces.stderr create mode 100644 tests/ui/parser/issues/issue-104620.rs create mode 100644 tests/ui/parser/issues/issue-104620.stderr create mode 100644 tests/ui/parser/issues/issue-104867-inc-dec-2.rs create mode 100644 tests/ui/parser/issues/issue-104867-inc-dec-2.stderr create mode 100644 tests/ui/parser/issues/issue-104867-inc-dec.rs create mode 100644 tests/ui/parser/issues/issue-104867-inc-dec.stderr create mode 100644 tests/ui/parser/issues/issue-105366.fixed create mode 100644 tests/ui/parser/issues/issue-105366.rs create mode 100644 tests/ui/parser/issues/issue-105366.stderr create mode 100644 tests/ui/parser/issues/issue-105634.rs create mode 100644 tests/ui/parser/issues/issue-107705.rs create mode 100644 tests/ui/parser/issues/issue-107705.stderr create mode 100644 tests/ui/parser/issues/issue-108495-dec.rs create mode 100644 tests/ui/parser/issues/issue-108495-dec.stderr create mode 100644 tests/ui/parser/issues/issue-112188.fixed create mode 100644 tests/ui/parser/issues/issue-112188.rs create mode 100644 tests/ui/parser/issues/issue-112188.stderr create mode 100644 tests/ui/parser/issues/issue-113342.rs create mode 100644 tests/ui/parser/issues/issue-113342.stderr create mode 100644 tests/ui/parser/issues/issue-17718-parse-const.rs create mode 100644 tests/ui/parser/issues/issue-39616.rs create mode 100644 tests/ui/parser/issues/issue-39616.stderr create mode 100644 tests/ui/parser/issues/issue-49257.rs create mode 100644 tests/ui/parser/issues/issue-49257.stderr create mode 100644 tests/ui/parser/issues/issue-61858.rs create mode 100644 tests/ui/parser/issues/issue-61858.stderr create mode 100644 tests/ui/parser/issues/issue-68091-unicode-ident-after-if.rs create mode 100644 tests/ui/parser/issues/issue-68091-unicode-ident-after-if.stderr create mode 100644 tests/ui/parser/issues/issue-68092-unicode-ident-after-incomplete-expr.rs create mode 100644 tests/ui/parser/issues/issue-68092-unicode-ident-after-incomplete-expr.stderr create mode 100644 tests/ui/parser/issues/issue-68987-unmatch-issue-1.rs create mode 100644 tests/ui/parser/issues/issue-68987-unmatch-issue-1.stderr create mode 100644 tests/ui/parser/issues/issue-68987-unmatch-issue-2.rs create mode 100644 tests/ui/parser/issues/issue-68987-unmatch-issue-2.stderr create mode 100644 tests/ui/parser/issues/issue-68987-unmatch-issue-3.rs create mode 100644 tests/ui/parser/issues/issue-68987-unmatch-issue-3.stderr create mode 100644 tests/ui/parser/issues/issue-68987-unmatch-issue.rs create mode 100644 tests/ui/parser/issues/issue-68987-unmatch-issue.stderr create mode 100644 tests/ui/parser/issues/issue-81804.rs create mode 100644 tests/ui/parser/issues/issue-81804.stderr create mode 100644 tests/ui/parser/issues/issue-81827.rs create mode 100644 tests/ui/parser/issues/issue-81827.stderr create mode 100644 tests/ui/parser/issues/issue-87694-duplicated-pub.rs create mode 100644 tests/ui/parser/issues/issue-87694-duplicated-pub.stderr create mode 100644 tests/ui/parser/issues/issue-87694-misplaced-pub.rs create mode 100644 tests/ui/parser/issues/issue-87694-misplaced-pub.stderr create mode 100644 tests/ui/parser/issues/issue-90728.rs create mode 100644 tests/ui/parser/issues/issue-90728.stderr create mode 100644 tests/ui/parser/issues/issue-91421.rs create mode 100644 tests/ui/parser/issues/issue-91421.stderr create mode 100644 tests/ui/parser/issues/issue-99625-enum-struct-mutually-exclusive.fixed create mode 100644 tests/ui/parser/issues/issue-99625-enum-struct-mutually-exclusive.rs create mode 100644 tests/ui/parser/issues/issue-99625-enum-struct-mutually-exclusive.stderr create mode 100644 tests/ui/parser/issues/issue-99910-const-let-mutually-exclusive.fixed create mode 100644 tests/ui/parser/issues/issue-99910-const-let-mutually-exclusive.rs create mode 100644 tests/ui/parser/issues/issue-99910-const-let-mutually-exclusive.stderr diff --git a/tests/ui/parser/issue-100197-mut-let.fixed b/tests/ui/parser/issue-100197-mut-let.fixed deleted file mode 100644 index 5a895622200..00000000000 --- a/tests/ui/parser/issue-100197-mut-let.fixed +++ /dev/null @@ -1,6 +0,0 @@ -// run-rustfix - -fn main() { - let mut _x = 123; - //~^ ERROR invalid variable declaration -} diff --git a/tests/ui/parser/issue-100197-mut-let.rs b/tests/ui/parser/issue-100197-mut-let.rs deleted file mode 100644 index 71103813a6e..00000000000 --- a/tests/ui/parser/issue-100197-mut-let.rs +++ /dev/null @@ -1,6 +0,0 @@ -// run-rustfix - -fn main() { - mut let _x = 123; - //~^ ERROR invalid variable declaration -} diff --git a/tests/ui/parser/issue-100197-mut-let.stderr b/tests/ui/parser/issue-100197-mut-let.stderr deleted file mode 100644 index 86658e4f39f..00000000000 --- a/tests/ui/parser/issue-100197-mut-let.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: invalid variable declaration - --> $DIR/issue-100197-mut-let.rs:4:5 - | -LL | mut let _x = 123; - | ^^^^^^^ help: switch the order of `mut` and `let`: `let mut` - -error: aborting due to previous error - diff --git a/tests/ui/parser/issue-101477-enum.fixed b/tests/ui/parser/issue-101477-enum.fixed deleted file mode 100644 index 1dfeae22aea..00000000000 --- a/tests/ui/parser/issue-101477-enum.fixed +++ /dev/null @@ -1,10 +0,0 @@ -// run-rustfix - -#[allow(dead_code)] -enum Demo { - A = 1, - B = 2 //~ ERROR unexpected `==` - //~^ expected item, found `==` -} - -fn main() {} diff --git a/tests/ui/parser/issue-101477-enum.rs b/tests/ui/parser/issue-101477-enum.rs deleted file mode 100644 index ea7051d69a4..00000000000 --- a/tests/ui/parser/issue-101477-enum.rs +++ /dev/null @@ -1,10 +0,0 @@ -// run-rustfix - -#[allow(dead_code)] -enum Demo { - A = 1, - B == 2 //~ ERROR unexpected `==` - //~^ expected item, found `==` -} - -fn main() {} diff --git a/tests/ui/parser/issue-101477-enum.stderr b/tests/ui/parser/issue-101477-enum.stderr deleted file mode 100644 index 94130671f1c..00000000000 --- a/tests/ui/parser/issue-101477-enum.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error: unexpected `==` - --> $DIR/issue-101477-enum.rs:6:7 - | -LL | B == 2 - | ^^ help: try using `=` instead - | - = help: enum variants can be `Variant`, `Variant = `, `Variant(Type, ..., TypeN)` or `Variant { fields: Types }` - -error: expected item, found `==` - --> $DIR/issue-101477-enum.rs:6:7 - | -LL | B == 2 - | ^^ expected item - | - = note: for a full list of items that can appear in modules, see - -error: aborting due to 2 previous errors - diff --git a/tests/ui/parser/issue-101477-let.fixed b/tests/ui/parser/issue-101477-let.fixed deleted file mode 100644 index 9989ad81524..00000000000 --- a/tests/ui/parser/issue-101477-let.fixed +++ /dev/null @@ -1,6 +0,0 @@ -// run-rustfix - -fn main() { - let x = 2; //~ ERROR unexpected `==` - println!("x: {}", x) -} diff --git a/tests/ui/parser/issue-101477-let.rs b/tests/ui/parser/issue-101477-let.rs deleted file mode 100644 index 8b0e8bee179..00000000000 --- a/tests/ui/parser/issue-101477-let.rs +++ /dev/null @@ -1,6 +0,0 @@ -// run-rustfix - -fn main() { - let x == 2; //~ ERROR unexpected `==` - println!("x: {}", x) -} diff --git a/tests/ui/parser/issue-101477-let.stderr b/tests/ui/parser/issue-101477-let.stderr deleted file mode 100644 index 1b30d4b1786..00000000000 --- a/tests/ui/parser/issue-101477-let.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: unexpected `==` - --> $DIR/issue-101477-let.rs:4:11 - | -LL | let x == 2; - | ^^ help: try using `=` instead - -error: aborting due to previous error - diff --git a/tests/ui/parser/issue-102806.rs b/tests/ui/parser/issue-102806.rs deleted file mode 100644 index ba297bdc967..00000000000 --- a/tests/ui/parser/issue-102806.rs +++ /dev/null @@ -1,25 +0,0 @@ -#![allow(dead_code)] - -#[derive(Default)] -struct V3 { - x: f32, - y: f32, - z: f32, -} - -fn pz(v: V3) { - let _ = V3 { z: 0.0, ...v}; - //~^ ERROR expected `..` - - let _ = V3 { z: 0.0, ...Default::default() }; - //~^ ERROR expected `..` - - let _ = V3 { z: 0.0, ... }; - //~^ expected identifier - //~| ERROR missing fields `x` and `y` in initializer of `V3` - - let V3 { z: val, ... } = v; - //~^ ERROR expected field pattern -} - -fn main() {} diff --git a/tests/ui/parser/issue-102806.stderr b/tests/ui/parser/issue-102806.stderr deleted file mode 100644 index ba8174a823b..00000000000 --- a/tests/ui/parser/issue-102806.stderr +++ /dev/null @@ -1,50 +0,0 @@ -error: expected `..`, found `...` - --> $DIR/issue-102806.rs:11:26 - | -LL | let _ = V3 { z: 0.0, ...v}; - | ^^^ - | -help: use `..` to fill in the rest of the fields - | -LL | let _ = V3 { z: 0.0, ..v}; - | ~~ - -error: expected `..`, found `...` - --> $DIR/issue-102806.rs:14:26 - | -LL | let _ = V3 { z: 0.0, ...Default::default() }; - | ^^^ - | -help: use `..` to fill in the rest of the fields - | -LL | let _ = V3 { z: 0.0, ..Default::default() }; - | ~~ - -error: expected identifier, found `...` - --> $DIR/issue-102806.rs:17:26 - | -LL | let _ = V3 { z: 0.0, ... }; - | -- ^^^ expected identifier - | | - | while parsing this struct - -error: expected field pattern, found `...` - --> $DIR/issue-102806.rs:21:22 - | -LL | let V3 { z: val, ... } = v; - | ^^^ - | -help: to omit remaining fields, use `..` - | -LL | let V3 { z: val, .. } = v; - | ~~ - -error[E0063]: missing fields `x` and `y` in initializer of `V3` - --> $DIR/issue-102806.rs:17:13 - | -LL | let _ = V3 { z: 0.0, ... }; - | ^^ missing `x` and `y` - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0063`. diff --git a/tests/ui/parser/issue-103143.rs b/tests/ui/parser/issue-103143.rs deleted file mode 100644 index a584274c405..00000000000 --- a/tests/ui/parser/issue-103143.rs +++ /dev/null @@ -1,5 +0,0 @@ -fn main() { - x::<#[a]y::> - //~^ ERROR invalid const generic expression - //~| ERROR cannot find value `x` in this scope -} diff --git a/tests/ui/parser/issue-103143.stderr b/tests/ui/parser/issue-103143.stderr deleted file mode 100644 index 4035c69afa7..00000000000 --- a/tests/ui/parser/issue-103143.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: invalid const generic expression - --> $DIR/issue-103143.rs:2:13 - | -LL | x::<#[a]y::> - | ^^^^^^ - | -help: expressions must be enclosed in braces to be used as const generic arguments - | -LL | x::<#[a]{ y:: }> - | + + - -error[E0425]: cannot find value `x` in this scope - --> $DIR/issue-103143.rs:2:5 - | -LL | x::<#[a]y::> - | ^ not found in this scope - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/parser/issue-103381.fixed b/tests/ui/parser/issue-103381.fixed deleted file mode 100644 index 6a9fb991097..00000000000 --- a/tests/ui/parser/issue-103381.fixed +++ /dev/null @@ -1,59 +0,0 @@ -// run-rustfix - -#![feature(let_chains)] -#![allow(unused_variables)] -#![allow(dead_code)] -#![allow(irrefutable_let_patterns)] - -fn err_some(b: bool, x: Option) { - if b && let Some(x) = x {} - //~^ ERROR unexpected `if` in the condition expression -} - -fn err_none(b: bool, x: Option) { - if b && let None = x {} - //~^ ERROR unexpected `if` in the condition expression -} - -fn err_bool_1() { - if true && true { true } else { false }; - //~^ ERROR unexpected `if` in the condition expression -} - -fn err_bool_2() { - if true && false { true } else { false }; - //~^ ERROR unexpected `if` in the condition expression -} - -fn should_ok_1() { - if true && if let x = 1 { true } else { true } {} -} - -fn should_ok_2() { - if true && if let 1 = 1 { true } else { true } {} -} - -fn should_ok_3() { - if true && if true { true } else { false } {} -} - -fn shoule_match_ok() { - #[cfg(feature = "full")] - { - let a = 1; - let b = 2; - if match a { - 1 if b == 1 => true, - _ => false, - } && if a > 1 { true } else { false } - { - true - } - } -} - -fn should_ok_in_nested() { - if true && if true { true } else { false } { true } else { false }; -} - -fn main() {} diff --git a/tests/ui/parser/issue-103381.rs b/tests/ui/parser/issue-103381.rs deleted file mode 100644 index bf79e10103e..00000000000 --- a/tests/ui/parser/issue-103381.rs +++ /dev/null @@ -1,59 +0,0 @@ -// run-rustfix - -#![feature(let_chains)] -#![allow(unused_variables)] -#![allow(dead_code)] -#![allow(irrefutable_let_patterns)] - -fn err_some(b: bool, x: Option) { - if b && if let Some(x) = x {} - //~^ ERROR unexpected `if` in the condition expression -} - -fn err_none(b: bool, x: Option) { - if b && if let None = x {} - //~^ ERROR unexpected `if` in the condition expression -} - -fn err_bool_1() { - if true && if true { true } else { false }; - //~^ ERROR unexpected `if` in the condition expression -} - -fn err_bool_2() { - if true && if false { true } else { false }; - //~^ ERROR unexpected `if` in the condition expression -} - -fn should_ok_1() { - if true && if let x = 1 { true } else { true } {} -} - -fn should_ok_2() { - if true && if let 1 = 1 { true } else { true } {} -} - -fn should_ok_3() { - if true && if true { true } else { false } {} -} - -fn shoule_match_ok() { - #[cfg(feature = "full")] - { - let a = 1; - let b = 2; - if match a { - 1 if b == 1 => true, - _ => false, - } && if a > 1 { true } else { false } - { - true - } - } -} - -fn should_ok_in_nested() { - if true && if true { true } else { false } { true } else { false }; -} - -fn main() {} diff --git a/tests/ui/parser/issue-103381.stderr b/tests/ui/parser/issue-103381.stderr deleted file mode 100644 index 85fcc18e76b..00000000000 --- a/tests/ui/parser/issue-103381.stderr +++ /dev/null @@ -1,50 +0,0 @@ -error: unexpected `if` in the condition expression - --> $DIR/issue-103381.rs:9:12 - | -LL | if b && if let Some(x) = x {} - | ^^^^ - | -help: remove the `if` - | -LL - if b && if let Some(x) = x {} -LL + if b && let Some(x) = x {} - | - -error: unexpected `if` in the condition expression - --> $DIR/issue-103381.rs:14:12 - | -LL | if b && if let None = x {} - | ^^^^ - | -help: remove the `if` - | -LL - if b && if let None = x {} -LL + if b && let None = x {} - | - -error: unexpected `if` in the condition expression - --> $DIR/issue-103381.rs:19:15 - | -LL | if true && if true { true } else { false }; - | ^^^^ - | -help: remove the `if` - | -LL - if true && if true { true } else { false }; -LL + if true && true { true } else { false }; - | - -error: unexpected `if` in the condition expression - --> $DIR/issue-103381.rs:24:15 - | -LL | if true && if false { true } else { false }; - | ^^^^ - | -help: remove the `if` - | -LL - if true && if false { true } else { false }; -LL + if true && false { true } else { false }; - | - -error: aborting due to 4 previous errors - diff --git a/tests/ui/parser/issue-103425.rs b/tests/ui/parser/issue-103425.rs deleted file mode 100644 index c2f8123ca4e..00000000000 --- a/tests/ui/parser/issue-103425.rs +++ /dev/null @@ -1,15 +0,0 @@ -fn f() -> f32 { - 3 - //~^ ERROR expected `;` - 5.0 -} - -fn k() -> f32 { - 2_u32 - //~^ ERROR expected `;` - 3_i8 - //~^ ERROR expected `;` - 5.0 -} - -fn main() {} diff --git a/tests/ui/parser/issue-103425.stderr b/tests/ui/parser/issue-103425.stderr deleted file mode 100644 index 0efe3e3ca71..00000000000 --- a/tests/ui/parser/issue-103425.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error: expected `;`, found `5.0` - --> $DIR/issue-103425.rs:2:6 - | -LL | 3 - | ^ help: add `;` here -LL | -LL | 5.0 - | --- unexpected token - -error: expected `;`, found `3_i8` - --> $DIR/issue-103425.rs:8:10 - | -LL | 2_u32 - | ^ help: add `;` here -LL | -LL | 3_i8 - | ---- unexpected token - -error: expected `;`, found `5.0` - --> $DIR/issue-103425.rs:10:9 - | -LL | 3_i8 - | ^ help: add `;` here -LL | -LL | 5.0 - | --- unexpected token - -error: aborting due to 3 previous errors - diff --git a/tests/ui/parser/issue-103451.rs b/tests/ui/parser/issue-103451.rs deleted file mode 100644 index be33213f3cb..00000000000 --- a/tests/ui/parser/issue-103451.rs +++ /dev/null @@ -1,4 +0,0 @@ -// error-pattern: this file contains an unclosed delimiter -struct R { } -struct S { - x: [u8; R diff --git a/tests/ui/parser/issue-103451.stderr b/tests/ui/parser/issue-103451.stderr deleted file mode 100644 index 6aacd5012c1..00000000000 --- a/tests/ui/parser/issue-103451.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error: this file contains an unclosed delimiter - --> $DIR/issue-103451.rs:4:15 - | -LL | struct S { - | - unclosed delimiter -LL | x: [u8; R - | - ^ - | | - | unclosed delimiter - -error: aborting due to previous error - diff --git a/tests/ui/parser/issue-103748-ICE-wrong-braces.rs b/tests/ui/parser/issue-103748-ICE-wrong-braces.rs deleted file mode 100644 index 8012cb652bd..00000000000 --- a/tests/ui/parser/issue-103748-ICE-wrong-braces.rs +++ /dev/null @@ -1,8 +0,0 @@ -#![crate_type = "lib"] - -struct Apple((Apple, Option(Banana ? Citron))); -//~^ ERROR invalid `?` in type -//~| ERROR expected one of `)` or `,`, found `Citron` -//~| ERROR cannot find type `Citron` in this scope [E0412] -//~| ERROR parenthesized type parameters may only be used with a `Fn` trait [E0214] -//~| ERROR recursive type `Apple` has infinite size [E0072] diff --git a/tests/ui/parser/issue-103748-ICE-wrong-braces.stderr b/tests/ui/parser/issue-103748-ICE-wrong-braces.stderr deleted file mode 100644 index b0d8b03ae08..00000000000 --- a/tests/ui/parser/issue-103748-ICE-wrong-braces.stderr +++ /dev/null @@ -1,51 +0,0 @@ -error: invalid `?` in type - --> $DIR/issue-103748-ICE-wrong-braces.rs:3:36 - | -LL | struct Apple((Apple, Option(Banana ? Citron))); - | ^ `?` is only allowed on expressions, not types - | -help: if you meant to express that the type might not contain a value, use the `Option` wrapper type - | -LL | struct Apple((Apple, Option(Option Citron))); - | +++++++ ~ - -error: expected one of `)` or `,`, found `Citron` - --> $DIR/issue-103748-ICE-wrong-braces.rs:3:38 - | -LL | struct Apple((Apple, Option(Banana ? Citron))); - | -^^^^^^ expected one of `)` or `,` - | | - | help: missing `,` - -error[E0412]: cannot find type `Citron` in this scope - --> $DIR/issue-103748-ICE-wrong-braces.rs:3:38 - | -LL | struct Apple((Apple, Option(Banana ? Citron))); - | ^^^^^^ not found in this scope - -error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-103748-ICE-wrong-braces.rs:3:22 - | -LL | struct Apple((Apple, Option(Banana ? Citron))); - | ^^^^^^^^^^^^^^^^^^^^^^^ only `Fn` traits may use parentheses - | -help: use angle brackets instead - | -LL | struct Apple((Apple, Option)); - | ~ ~ - -error[E0072]: recursive type `Apple` has infinite size - --> $DIR/issue-103748-ICE-wrong-braces.rs:3:1 - | -LL | struct Apple((Apple, Option(Banana ? Citron))); - | ^^^^^^^^^^^^ ----- recursive without indirection - | -help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle - | -LL | struct Apple((Box, Option(Banana ? Citron))); - | ++++ + - -error: aborting due to 5 previous errors - -Some errors have detailed explanations: E0072, E0214, E0412. -For more information about an error, try `rustc --explain E0072`. diff --git a/tests/ui/parser/issue-104620.rs b/tests/ui/parser/issue-104620.rs deleted file mode 100644 index f49476c4408..00000000000 --- a/tests/ui/parser/issue-104620.rs +++ /dev/null @@ -1,4 +0,0 @@ -#![feature(rustc_attrs)] - -#![rustc_dummy=5z] //~ ERROR unexpected expression: `5z` -fn main() {} diff --git a/tests/ui/parser/issue-104620.stderr b/tests/ui/parser/issue-104620.stderr deleted file mode 100644 index d06a6b2554b..00000000000 --- a/tests/ui/parser/issue-104620.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: unexpected expression: `5z` - --> $DIR/issue-104620.rs:3:16 - | -LL | #![rustc_dummy=5z] - | ^^ - -error: aborting due to previous error - diff --git a/tests/ui/parser/issue-104867-inc-dec-2.rs b/tests/ui/parser/issue-104867-inc-dec-2.rs deleted file mode 100644 index a006421a975..00000000000 --- a/tests/ui/parser/issue-104867-inc-dec-2.rs +++ /dev/null @@ -1,52 +0,0 @@ -fn test1() { - let mut i = 0; - let _ = i + ++i; //~ ERROR Rust has no prefix increment operator -} - -fn test2() { - let mut i = 0; - let _ = ++i + i; //~ ERROR Rust has no prefix increment operator -} - -fn test3() { - let mut i = 0; - let _ = ++i + ++i; //~ ERROR Rust has no prefix increment operator -} - -fn test4() { - let mut i = 0; - let _ = i + i++; //~ ERROR Rust has no postfix increment operator - // won't suggest since we can not handle the precedences -} - -fn test5() { - let mut i = 0; - let _ = i++ + i; //~ ERROR Rust has no postfix increment operator -} - -fn test6() { - let mut i = 0; - let _ = i++ + i++; //~ ERROR Rust has no postfix increment operator -} - -fn test7() { - let mut i = 0; - let _ = ++i + i++; //~ ERROR Rust has no prefix increment operator -} - -fn test8() { - let mut i = 0; - let _ = i++ + ++i; //~ ERROR Rust has no postfix increment operator -} - -fn test9() { - let mut i = 0; - let _ = (1 + 2 + i)++; //~ ERROR Rust has no postfix increment operator -} - -fn test10() { - let mut i = 0; - let _ = (i++ + 1) + 2; //~ ERROR Rust has no postfix increment operator -} - -fn main() { } diff --git a/tests/ui/parser/issue-104867-inc-dec-2.stderr b/tests/ui/parser/issue-104867-inc-dec-2.stderr deleted file mode 100644 index 4e2d0546851..00000000000 --- a/tests/ui/parser/issue-104867-inc-dec-2.stderr +++ /dev/null @@ -1,107 +0,0 @@ -error: Rust has no prefix increment operator - --> $DIR/issue-104867-inc-dec-2.rs:3:17 - | -LL | let _ = i + ++i; - | ^^ not a valid prefix operator - | -help: use `+= 1` instead - | -LL | let _ = i + { i += 1; i }; - | ~ +++++++++ - -error: Rust has no prefix increment operator - --> $DIR/issue-104867-inc-dec-2.rs:8:13 - | -LL | let _ = ++i + i; - | ^^ not a valid prefix operator - | -help: use `+= 1` instead - | -LL | let _ = { i += 1; i } + i; - | ~ +++++++++ - -error: Rust has no prefix increment operator - --> $DIR/issue-104867-inc-dec-2.rs:13:13 - | -LL | let _ = ++i + ++i; - | ^^ not a valid prefix operator - | -help: use `+= 1` instead - | -LL | let _ = { i += 1; i } + ++i; - | ~ +++++++++ - -error: Rust has no postfix increment operator - --> $DIR/issue-104867-inc-dec-2.rs:18:18 - | -LL | let _ = i + i++; - | ^^ not a valid postfix operator - -error: Rust has no postfix increment operator - --> $DIR/issue-104867-inc-dec-2.rs:24:14 - | -LL | let _ = i++ + i; - | ^^ not a valid postfix operator - | -help: use `+= 1` instead - | -LL | let _ = { let tmp = i; i += 1; tmp } + i; - | +++++++++++ ~~~~~~~~~~~~~~~ - -error: Rust has no postfix increment operator - --> $DIR/issue-104867-inc-dec-2.rs:29:14 - | -LL | let _ = i++ + i++; - | ^^ not a valid postfix operator - | -help: use `+= 1` instead - | -LL | let _ = { let tmp = i; i += 1; tmp } + i++; - | +++++++++++ ~~~~~~~~~~~~~~~ - -error: Rust has no prefix increment operator - --> $DIR/issue-104867-inc-dec-2.rs:34:13 - | -LL | let _ = ++i + i++; - | ^^ not a valid prefix operator - | -help: use `+= 1` instead - | -LL | let _ = { i += 1; i } + i++; - | ~ +++++++++ - -error: Rust has no postfix increment operator - --> $DIR/issue-104867-inc-dec-2.rs:39:14 - | -LL | let _ = i++ + ++i; - | ^^ not a valid postfix operator - | -help: use `+= 1` instead - | -LL | let _ = { let tmp = i; i += 1; tmp } + ++i; - | +++++++++++ ~~~~~~~~~~~~~~~ - -error: Rust has no postfix increment operator - --> $DIR/issue-104867-inc-dec-2.rs:44:24 - | -LL | let _ = (1 + 2 + i)++; - | ^^ not a valid postfix operator - | -help: use `+= 1` instead - | -LL | let _ = { let tmp = (1 + 2 + i); (1 + 2 + i) += 1; tmp }; - | +++++++++++ ~~~~~~~~~~~~~~~~~~~~~~~~~ - -error: Rust has no postfix increment operator - --> $DIR/issue-104867-inc-dec-2.rs:49:15 - | -LL | let _ = (i++ + 1) + 2; - | ^^ not a valid postfix operator - | -help: use `+= 1` instead - | -LL | let _ = ({ let tmp = i; i += 1; tmp } + 1) + 2; - | +++++++++++ ~~~~~~~~~~~~~~~ - -error: aborting due to 10 previous errors - diff --git a/tests/ui/parser/issue-104867-inc-dec.rs b/tests/ui/parser/issue-104867-inc-dec.rs deleted file mode 100644 index 760c67b4bed..00000000000 --- a/tests/ui/parser/issue-104867-inc-dec.rs +++ /dev/null @@ -1,45 +0,0 @@ -struct S { - x: i32, -} - -fn test1() { - let mut i = 0; - i++; //~ ERROR Rust has no postfix increment operator -} - -fn test2() { - let s = S { x: 0 }; - s.x++; //~ ERROR Rust has no postfix increment operator -} - -fn test3() { - let mut i = 0; - if i++ == 1 {} //~ ERROR Rust has no postfix increment operator -} - -fn test4() { - let mut i = 0; - ++i; //~ ERROR Rust has no prefix increment operator -} - -fn test5() { - let mut i = 0; - if ++i == 1 { } //~ ERROR Rust has no prefix increment operator -} - -fn test6() { - let mut i = 0; - loop { break; } - i++; //~ ERROR Rust has no postfix increment operator - loop { break; } - ++i; -} - -fn test7() { - let mut i = 0; - loop { break; } - ++i; //~ ERROR Rust has no prefix increment operator -} - - -fn main() {} diff --git a/tests/ui/parser/issue-104867-inc-dec.stderr b/tests/ui/parser/issue-104867-inc-dec.stderr deleted file mode 100644 index 78bfd3e82f0..00000000000 --- a/tests/ui/parser/issue-104867-inc-dec.stderr +++ /dev/null @@ -1,81 +0,0 @@ -error: Rust has no postfix increment operator - --> $DIR/issue-104867-inc-dec.rs:7:6 - | -LL | i++; - | ^^ not a valid postfix operator - | -help: use `+= 1` instead - | -LL | i += 1; - | ~~~~ - -error: Rust has no postfix increment operator - --> $DIR/issue-104867-inc-dec.rs:12:8 - | -LL | s.x++; - | ^^ not a valid postfix operator - | -help: use `+= 1` instead - | -LL | s.x += 1; - | ~~~~ - -error: Rust has no postfix increment operator - --> $DIR/issue-104867-inc-dec.rs:17:9 - | -LL | if i++ == 1 {} - | ^^ not a valid postfix operator - | -help: use `+= 1` instead - | -LL | if { let tmp = i; i += 1; tmp } == 1 {} - | +++++++++++ ~~~~~~~~~~~~~~~ - -error: Rust has no prefix increment operator - --> $DIR/issue-104867-inc-dec.rs:22:5 - | -LL | ++i; - | ^^ not a valid prefix operator - | -help: use `+= 1` instead - | -LL - ++i; -LL + i += 1; - | - -error: Rust has no prefix increment operator - --> $DIR/issue-104867-inc-dec.rs:27:8 - | -LL | if ++i == 1 { } - | ^^ not a valid prefix operator - | -help: use `+= 1` instead - | -LL | if { i += 1; i } == 1 { } - | ~ +++++++++ - -error: Rust has no postfix increment operator - --> $DIR/issue-104867-inc-dec.rs:33:6 - | -LL | i++; - | ^^ not a valid postfix operator - | -help: use `+= 1` instead - | -LL | i += 1; - | ~~~~ - -error: Rust has no prefix increment operator - --> $DIR/issue-104867-inc-dec.rs:41:5 - | -LL | ++i; - | ^^ not a valid prefix operator - | -help: use `+= 1` instead - | -LL - ++i; -LL + i += 1; - | - -error: aborting due to 7 previous errors - diff --git a/tests/ui/parser/issue-105366.fixed b/tests/ui/parser/issue-105366.fixed deleted file mode 100644 index ad26643c327..00000000000 --- a/tests/ui/parser/issue-105366.fixed +++ /dev/null @@ -1,12 +0,0 @@ -// run-rustfix - -struct Foo; - -impl From for Foo { - //~^ ERROR you might have meant to write `impl` instead of `fn` - fn from(_a: i32) -> Self { - Foo - } -} - -fn main() {} diff --git a/tests/ui/parser/issue-105366.rs b/tests/ui/parser/issue-105366.rs deleted file mode 100644 index 311b6a60f1a..00000000000 --- a/tests/ui/parser/issue-105366.rs +++ /dev/null @@ -1,12 +0,0 @@ -// run-rustfix - -struct Foo; - -fn From for Foo { - //~^ ERROR you might have meant to write `impl` instead of `fn` - fn from(_a: i32) -> Self { - Foo - } -} - -fn main() {} diff --git a/tests/ui/parser/issue-105366.stderr b/tests/ui/parser/issue-105366.stderr deleted file mode 100644 index 0a7408e2c17..00000000000 --- a/tests/ui/parser/issue-105366.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error: you might have meant to write `impl` instead of `fn` - --> $DIR/issue-105366.rs:5:1 - | -LL | fn From for Foo { - | ^^ - | -help: replace `fn` with `impl` here - | -LL | impl From for Foo { - | ~~~~ - -error: aborting due to previous error - diff --git a/tests/ui/parser/issue-105634.rs b/tests/ui/parser/issue-105634.rs deleted file mode 100644 index 579aa6e5bfb..00000000000 --- a/tests/ui/parser/issue-105634.rs +++ /dev/null @@ -1,8 +0,0 @@ -// check-pass - -fn main() { - let _a = ..; - let _b = ..=10; - let _c = &..; - let _d = &..=10; -} diff --git a/tests/ui/parser/issue-107705.rs b/tests/ui/parser/issue-107705.rs deleted file mode 100644 index b80984fcdb0..00000000000 --- a/tests/ui/parser/issue-107705.rs +++ /dev/null @@ -1,3 +0,0 @@ -// compile-flags: -C debug-assertions - -fn f() {a(b:&, //~ ERROR this file contains an unclosed delimiter diff --git a/tests/ui/parser/issue-107705.stderr b/tests/ui/parser/issue-107705.stderr deleted file mode 100644 index d2d61346118..00000000000 --- a/tests/ui/parser/issue-107705.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: this file contains an unclosed delimiter - --> $DIR/issue-107705.rs:3:67 - | -LL | fn f() {a(b:&, - | - - unclosed delimiter ^ - | | - | unclosed delimiter - -error: aborting due to previous error - diff --git a/tests/ui/parser/issue-108495-dec.rs b/tests/ui/parser/issue-108495-dec.rs deleted file mode 100644 index e0816f84e5c..00000000000 --- a/tests/ui/parser/issue-108495-dec.rs +++ /dev/null @@ -1,39 +0,0 @@ -fn test0() { - let mut i = 0; - let _ = i + i--; //~ ERROR Rust has no postfix decrement operator - // won't suggest since we can not handle the precedences -} - -fn test1() { - let mut i = 0; - let _ = i-- + i--; //~ ERROR Rust has no postfix decrement operator -} - -fn test2() { - let mut i = 0; - let _ = --i + i--; //~ ERROR Rust has no postfix decrement operator -} - -fn test3() { - let mut i = 0; - let _ = i-- + --i; //~ ERROR Rust has no postfix decrement operator -} - -fn test4() { - let mut i = 0; - let _ = (1 + 2 + i)--; //~ ERROR Rust has no postfix decrement operator -} - -fn test5() { - let mut i = 0; - let _ = (i-- + 1) + 2; //~ ERROR Rust has no postfix decrement operator -} - -fn test6(){ - let i=10; - while i != 0 { - i--; //~ ERROR Rust has no postfix decrement operator - } -} - -fn main() {} diff --git a/tests/ui/parser/issue-108495-dec.stderr b/tests/ui/parser/issue-108495-dec.stderr deleted file mode 100644 index 85b29038f7c..00000000000 --- a/tests/ui/parser/issue-108495-dec.stderr +++ /dev/null @@ -1,69 +0,0 @@ -error: Rust has no postfix decrement operator - --> $DIR/issue-108495-dec.rs:3:18 - | -LL | let _ = i + i--; - | ^^ not a valid postfix operator - -error: Rust has no postfix decrement operator - --> $DIR/issue-108495-dec.rs:9:14 - | -LL | let _ = i-- + i--; - | ^^ not a valid postfix operator - | -help: use `-= 1` instead - | -LL | let _ = { let tmp = i; i -= 1; tmp } + i--; - | +++++++++++ ~~~~~~~~~~~~~~~ - -error: Rust has no postfix decrement operator - --> $DIR/issue-108495-dec.rs:14:20 - | -LL | let _ = --i + i--; - | ^^ not a valid postfix operator - -error: Rust has no postfix decrement operator - --> $DIR/issue-108495-dec.rs:19:14 - | -LL | let _ = i-- + --i; - | ^^ not a valid postfix operator - | -help: use `-= 1` instead - | -LL | let _ = { let tmp = i; i -= 1; tmp } + --i; - | +++++++++++ ~~~~~~~~~~~~~~~ - -error: Rust has no postfix decrement operator - --> $DIR/issue-108495-dec.rs:24:24 - | -LL | let _ = (1 + 2 + i)--; - | ^^ not a valid postfix operator - | -help: use `-= 1` instead - | -LL | let _ = { let tmp = (1 + 2 + i); (1 + 2 + i) -= 1; tmp }; - | +++++++++++ ~~~~~~~~~~~~~~~~~~~~~~~~~ - -error: Rust has no postfix decrement operator - --> $DIR/issue-108495-dec.rs:29:15 - | -LL | let _ = (i-- + 1) + 2; - | ^^ not a valid postfix operator - | -help: use `-= 1` instead - | -LL | let _ = ({ let tmp = i; i -= 1; tmp } + 1) + 2; - | +++++++++++ ~~~~~~~~~~~~~~~ - -error: Rust has no postfix decrement operator - --> $DIR/issue-108495-dec.rs:35:10 - | -LL | i--; - | ^^ not a valid postfix operator - | -help: use `-= 1` instead - | -LL | i -= 1; - | ~~~~ - -error: aborting due to 7 previous errors - diff --git a/tests/ui/parser/issue-112188.fixed b/tests/ui/parser/issue-112188.fixed deleted file mode 100644 index 5e73d8e38de..00000000000 --- a/tests/ui/parser/issue-112188.fixed +++ /dev/null @@ -1,14 +0,0 @@ -// run-rustfix - -#![allow(unused)] - -struct Foo { x: i32 } - -fn main() { - let f = Foo { x: 0 }; - let Foo { .. } = f; - let Foo { .. } = f; //~ ERROR expected `}`, found `,` - let Foo { x, .. } = f; - let Foo { x, .. } = f; //~ ERROR expected `}`, found `,` - let Foo { x, .. } = f; //~ ERROR expected `}`, found `,` -} diff --git a/tests/ui/parser/issue-112188.rs b/tests/ui/parser/issue-112188.rs deleted file mode 100644 index 27ca192e522..00000000000 --- a/tests/ui/parser/issue-112188.rs +++ /dev/null @@ -1,14 +0,0 @@ -// run-rustfix - -#![allow(unused)] - -struct Foo { x: i32 } - -fn main() { - let f = Foo { x: 0 }; - let Foo { .. } = f; - let Foo { .., } = f; //~ ERROR expected `}`, found `,` - let Foo { x, .. } = f; - let Foo { .., x } = f; //~ ERROR expected `}`, found `,` - let Foo { .., x, .. } = f; //~ ERROR expected `}`, found `,` -} diff --git a/tests/ui/parser/issue-112188.stderr b/tests/ui/parser/issue-112188.stderr deleted file mode 100644 index 6d2d8e6a3b0..00000000000 --- a/tests/ui/parser/issue-112188.stderr +++ /dev/null @@ -1,37 +0,0 @@ -error: expected `}`, found `,` - --> $DIR/issue-112188.rs:10:17 - | -LL | let Foo { .., } = f; - | --^ - | | | - | | expected `}` - | | help: remove this comma - | `..` must be at the end and cannot have a trailing comma - -error: expected `}`, found `,` - --> $DIR/issue-112188.rs:12:17 - | -LL | let Foo { .., x } = f; - | --^ - | | | - | | expected `}` - | `..` must be at the end and cannot have a trailing comma - | -help: move the `..` to the end of the field list - | -LL - let Foo { .., x } = f; -LL + let Foo { x, .. } = f; - | - -error: expected `}`, found `,` - --> $DIR/issue-112188.rs:13:17 - | -LL | let Foo { .., x, .. } = f; - | --^- - | | | - | | expected `}` - | `..` must be at the end and cannot have a trailing comma - | help: remove the starting `..` - -error: aborting due to 3 previous errors - diff --git a/tests/ui/parser/issue-113342.rs b/tests/ui/parser/issue-113342.rs deleted file mode 100644 index 18b502736f7..00000000000 --- a/tests/ui/parser/issue-113342.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[link(name = "my_c_library")] -extern "C" { - fn my_c_function(x: i32) -> bool; -} - -#[no_mangle] -extern "C" pub fn id(x: i32) -> i32 { x } //~ ERROR expected `fn`, found keyword `pub` - -fn main() {} diff --git a/tests/ui/parser/issue-113342.stderr b/tests/ui/parser/issue-113342.stderr deleted file mode 100644 index a0c5e665ff8..00000000000 --- a/tests/ui/parser/issue-113342.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: expected `fn`, found keyword `pub` - --> $DIR/issue-113342.rs:7:12 - | -LL | extern "C" pub fn id(x: i32) -> i32 { x } - | -----------^^^ - | | | - | | expected `fn` - | help: visibility `pub` must come before `extern "C"`: `pub extern "C"` - -error: aborting due to previous error - diff --git a/tests/ui/parser/issue-17718-parse-const.rs b/tests/ui/parser/issue-17718-parse-const.rs deleted file mode 100644 index d5a5f445d5b..00000000000 --- a/tests/ui/parser/issue-17718-parse-const.rs +++ /dev/null @@ -1,7 +0,0 @@ -// run-pass - -const FOO: usize = 3; - -fn main() { - assert_eq!(FOO, 3); -} diff --git a/tests/ui/parser/issue-39616.rs b/tests/ui/parser/issue-39616.rs deleted file mode 100644 index 46b5aa334ca..00000000000 --- a/tests/ui/parser/issue-39616.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn foo(a: [0; 1]) {} //~ ERROR expected type, found `0` - -fn main() {} diff --git a/tests/ui/parser/issue-39616.stderr b/tests/ui/parser/issue-39616.stderr deleted file mode 100644 index 393d1f2e2ce..00000000000 --- a/tests/ui/parser/issue-39616.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: expected type, found `0` - --> $DIR/issue-39616.rs:1:12 - | -LL | fn foo(a: [0; 1]) {} - | ^ expected type - -error: aborting due to previous error - diff --git a/tests/ui/parser/issue-49257.rs b/tests/ui/parser/issue-49257.rs deleted file mode 100644 index a7fa19d52fd..00000000000 --- a/tests/ui/parser/issue-49257.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Test for #49257: -// emits good diagnostics for `..` pattern fragments not in the last position. - -#![allow(unused)] - -struct Point { x: u8, y: u8 } - -fn main() { - let p = Point { x: 0, y: 0 }; - let Point { .., y, } = p; //~ ERROR expected `}`, found `,` - let Point { .., y } = p; //~ ERROR expected `}`, found `,` - let Point { .., } = p; //~ ERROR expected `}`, found `,` - let Point { .. } = p; -} diff --git a/tests/ui/parser/issue-49257.stderr b/tests/ui/parser/issue-49257.stderr deleted file mode 100644 index 97e16f88b8d..00000000000 --- a/tests/ui/parser/issue-49257.stderr +++ /dev/null @@ -1,42 +0,0 @@ -error: expected `}`, found `,` - --> $DIR/issue-49257.rs:10:19 - | -LL | let Point { .., y, } = p; - | --^ - | | | - | | expected `}` - | `..` must be at the end and cannot have a trailing comma - | -help: move the `..` to the end of the field list - | -LL - let Point { .., y, } = p; -LL + let Point { y, .. } = p; - | - -error: expected `}`, found `,` - --> $DIR/issue-49257.rs:11:19 - | -LL | let Point { .., y } = p; - | --^ - | | | - | | expected `}` - | `..` must be at the end and cannot have a trailing comma - | -help: move the `..` to the end of the field list - | -LL - let Point { .., y } = p; -LL + let Point { y, .. } = p; - | - -error: expected `}`, found `,` - --> $DIR/issue-49257.rs:12:19 - | -LL | let Point { .., } = p; - | --^ - | | | - | | expected `}` - | | help: remove this comma - | `..` must be at the end and cannot have a trailing comma - -error: aborting due to 3 previous errors - diff --git a/tests/ui/parser/issue-61858.rs b/tests/ui/parser/issue-61858.rs deleted file mode 100644 index 6c3b56586c4..00000000000 --- a/tests/ui/parser/issue-61858.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - (if foobar) //~ ERROR expected `{`, found `)` -} diff --git a/tests/ui/parser/issue-61858.stderr b/tests/ui/parser/issue-61858.stderr deleted file mode 100644 index 03f51c6e3a8..00000000000 --- a/tests/ui/parser/issue-61858.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: expected `{`, found `)` - --> $DIR/issue-61858.rs:2:15 - | -LL | (if foobar) - | ^ expected `{` - | -note: the `if` expression is missing a block after this condition - --> $DIR/issue-61858.rs:2:9 - | -LL | (if foobar) - | ^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/parser/issue-68091-unicode-ident-after-if.rs b/tests/ui/parser/issue-68091-unicode-ident-after-if.rs deleted file mode 100644 index 57d36feb37b..00000000000 --- a/tests/ui/parser/issue-68091-unicode-ident-after-if.rs +++ /dev/null @@ -1,10 +0,0 @@ -macro_rules! x { - ($($c:tt)*) => { - $($c)ö* {} - //~^ ERROR missing condition for `if` expression - }; -} - -fn main() { - x!(if); -} diff --git a/tests/ui/parser/issue-68091-unicode-ident-after-if.stderr b/tests/ui/parser/issue-68091-unicode-ident-after-if.stderr deleted file mode 100644 index 6674b924e9c..00000000000 --- a/tests/ui/parser/issue-68091-unicode-ident-after-if.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: missing condition for `if` expression - --> $DIR/issue-68091-unicode-ident-after-if.rs:3:14 - | -LL | $($c)ö* {} - | ^ - if this block is the condition of the `if` expression, then it must be followed by another block - | | - | expected condition here - -error: aborting due to previous error - diff --git a/tests/ui/parser/issue-68092-unicode-ident-after-incomplete-expr.rs b/tests/ui/parser/issue-68092-unicode-ident-after-incomplete-expr.rs deleted file mode 100644 index 1a90b4724d4..00000000000 --- a/tests/ui/parser/issue-68092-unicode-ident-after-incomplete-expr.rs +++ /dev/null @@ -1,9 +0,0 @@ -macro_rules! x { - ($($c:tt)*) => { - $($c)ö* //~ ERROR macro expansion ends with an incomplete expression: expected expression - }; -} - -fn main() { - x!(!); -} diff --git a/tests/ui/parser/issue-68092-unicode-ident-after-incomplete-expr.stderr b/tests/ui/parser/issue-68092-unicode-ident-after-incomplete-expr.stderr deleted file mode 100644 index 0b9c364f1f1..00000000000 --- a/tests/ui/parser/issue-68092-unicode-ident-after-incomplete-expr.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: macro expansion ends with an incomplete expression: expected expression - --> $DIR/issue-68092-unicode-ident-after-incomplete-expr.rs:3:14 - | -LL | $($c)ö* - | ^ expected expression - -error: aborting due to previous error - diff --git a/tests/ui/parser/issue-68987-unmatch-issue-1.rs b/tests/ui/parser/issue-68987-unmatch-issue-1.rs deleted file mode 100644 index 30e7ef46736..00000000000 --- a/tests/ui/parser/issue-68987-unmatch-issue-1.rs +++ /dev/null @@ -1,12 +0,0 @@ -// This file has unexpected closing delimiter, - -fn func(o: Option) { - match o { - Some(_x) => {} // Extra '}' - let _ = if true {}; - } - None => {} - } -} //~ ERROR unexpected closing delimiter - -fn main() {} diff --git a/tests/ui/parser/issue-68987-unmatch-issue-1.stderr b/tests/ui/parser/issue-68987-unmatch-issue-1.stderr deleted file mode 100644 index 2d873b46193..00000000000 --- a/tests/ui/parser/issue-68987-unmatch-issue-1.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error: unexpected closing delimiter: `}` - --> $DIR/issue-68987-unmatch-issue-1.rs:10:1 - | -LL | match o { - | - this delimiter might not be properly closed... -LL | Some(_x) => {} // Extra '}' - | -- block is empty, you might have not meant to close it -LL | let _ = if true {}; -LL | } - | - ...as it matches this but it has different indentation -... -LL | } - | ^ unexpected closing delimiter - -error: aborting due to previous error - diff --git a/tests/ui/parser/issue-68987-unmatch-issue-2.rs b/tests/ui/parser/issue-68987-unmatch-issue-2.rs deleted file mode 100644 index 89aaa68ba40..00000000000 --- a/tests/ui/parser/issue-68987-unmatch-issue-2.rs +++ /dev/null @@ -1,14 +0,0 @@ -// FIXME: this case need more work to fix -// currently the TokenTree matching ')' with '{', which is not user friendly for diagnostics -async fn obstest() -> Result<> { - let obs_connect = || -> Result<(), MyError) { //~ ERROR mismatched closing delimiter - async { - } - } - - if let Ok(version, scene_list) = obs_connect() { - - } else { - - } -} //~ ERROR unexpected closing delimiter diff --git a/tests/ui/parser/issue-68987-unmatch-issue-2.stderr b/tests/ui/parser/issue-68987-unmatch-issue-2.stderr deleted file mode 100644 index 0ecb748a0a4..00000000000 --- a/tests/ui/parser/issue-68987-unmatch-issue-2.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error: mismatched closing delimiter: `)` - --> $DIR/issue-68987-unmatch-issue-2.rs:3:32 - | -LL | async fn obstest() -> Result<> { - | ^ unclosed delimiter -LL | let obs_connect = || -> Result<(), MyError) { - | ^ mismatched closing delimiter - -error: unexpected closing delimiter: `}` - --> $DIR/issue-68987-unmatch-issue-2.rs:14:1 - | -LL | let obs_connect = || -> Result<(), MyError) { - | - missing open `(` for this delimiter -... -LL | } - | ^ unexpected closing delimiter - -error: aborting due to 2 previous errors - diff --git a/tests/ui/parser/issue-68987-unmatch-issue-3.rs b/tests/ui/parser/issue-68987-unmatch-issue-3.rs deleted file mode 100644 index e98df8d7c3c..00000000000 --- a/tests/ui/parser/issue-68987-unmatch-issue-3.rs +++ /dev/null @@ -1,8 +0,0 @@ -// the `{` is closed with `)`, there is a missing `(` -fn f(i: u32, j: u32) { - let res = String::new(); - let mut cnt = i; - while cnt < j { - write!&mut res, " "); //~ ERROR mismatched closing delimiter - } -} //~ ERROR unexpected closing delimiter diff --git a/tests/ui/parser/issue-68987-unmatch-issue-3.stderr b/tests/ui/parser/issue-68987-unmatch-issue-3.stderr deleted file mode 100644 index dfc4407ed65..00000000000 --- a/tests/ui/parser/issue-68987-unmatch-issue-3.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error: mismatched closing delimiter: `)` - --> $DIR/issue-68987-unmatch-issue-3.rs:5:19 - | -LL | while cnt < j { - | ^ unclosed delimiter -LL | write!&mut res, " "); - | ^ mismatched closing delimiter - -error: unexpected closing delimiter: `}` - --> $DIR/issue-68987-unmatch-issue-3.rs:8:1 - | -LL | write!&mut res, " "); - | - missing open `(` for this delimiter -LL | } -LL | } - | ^ unexpected closing delimiter - -error: aborting due to 2 previous errors - diff --git a/tests/ui/parser/issue-68987-unmatch-issue.rs b/tests/ui/parser/issue-68987-unmatch-issue.rs deleted file mode 100644 index 5a3620bf24b..00000000000 --- a/tests/ui/parser/issue-68987-unmatch-issue.rs +++ /dev/null @@ -1,12 +0,0 @@ -// This file has unexpected closing delimiter, - -fn func(o: Option) { - match o { - Some(_x) => // Missing '{' - let _ = if true {}; - } - None => {} - } -} //~ ERROR unexpected closing delimiter - -fn main() {} diff --git a/tests/ui/parser/issue-68987-unmatch-issue.stderr b/tests/ui/parser/issue-68987-unmatch-issue.stderr deleted file mode 100644 index cabd133242f..00000000000 --- a/tests/ui/parser/issue-68987-unmatch-issue.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error: unexpected closing delimiter: `}` - --> $DIR/issue-68987-unmatch-issue.rs:10:1 - | -LL | match o { - | - this delimiter might not be properly closed... -LL | Some(_x) => // Missing '{' -LL | let _ = if true {}; - | -- block is empty, you might have not meant to close it -LL | } - | - ...as it matches this but it has different indentation -... -LL | } - | ^ unexpected closing delimiter - -error: aborting due to previous error - diff --git a/tests/ui/parser/issue-81804.rs b/tests/ui/parser/issue-81804.rs deleted file mode 100644 index ebc4752a142..00000000000 --- a/tests/ui/parser/issue-81804.rs +++ /dev/null @@ -1,6 +0,0 @@ -// error-pattern: this file contains an unclosed delimiter -// error-pattern: this file contains an unclosed delimiter - -fn main() {} - -fn p([=(} diff --git a/tests/ui/parser/issue-81804.stderr b/tests/ui/parser/issue-81804.stderr deleted file mode 100644 index de3b33ecd95..00000000000 --- a/tests/ui/parser/issue-81804.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error: mismatched closing delimiter: `}` - --> $DIR/issue-81804.rs:6:8 - | -LL | fn p([=(} - | ^^ mismatched closing delimiter - | | - | unclosed delimiter - -error: this file contains an unclosed delimiter - --> $DIR/issue-81804.rs:6:11 - | -LL | fn p([=(} - | -- ^ - | || - | |unclosed delimiter - | unclosed delimiter - -error: aborting due to 2 previous errors - diff --git a/tests/ui/parser/issue-81827.rs b/tests/ui/parser/issue-81827.rs deleted file mode 100644 index 91defd12a57..00000000000 --- a/tests/ui/parser/issue-81827.rs +++ /dev/null @@ -1,10 +0,0 @@ -// error-pattern: this file contains an unclosed delimiter -// error-pattern: mismatched closing delimiter: `]` - -#![crate_name="0"] - - - -fn main() {} - -fn r()->i{0|{#[cfg(r(0{]0 diff --git a/tests/ui/parser/issue-81827.stderr b/tests/ui/parser/issue-81827.stderr deleted file mode 100644 index 63d135f73e6..00000000000 --- a/tests/ui/parser/issue-81827.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error: mismatched closing delimiter: `]` - --> $DIR/issue-81827.rs:10:23 - | -LL | fn r()->i{0|{#[cfg(r(0{]0 - | - ^^ mismatched closing delimiter - | | | - | | unclosed delimiter - | closing delimiter possibly meant for this - -error: this file contains an unclosed delimiter - --> $DIR/issue-81827.rs:10:27 - | -LL | fn r()->i{0|{#[cfg(r(0{]0 - | - - - ^ - | | | | - | | | missing open `[` for this delimiter - | | unclosed delimiter - | unclosed delimiter - -error: aborting due to 2 previous errors - diff --git a/tests/ui/parser/issue-87694-duplicated-pub.rs b/tests/ui/parser/issue-87694-duplicated-pub.rs deleted file mode 100644 index e3ea61dc4ad..00000000000 --- a/tests/ui/parser/issue-87694-duplicated-pub.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub const pub fn test() {} -//~^ ERROR expected one of `async`, `extern`, `fn`, or `unsafe`, found keyword `pub` -//~| NOTE expected one of `async`, `extern`, `fn`, or `unsafe` -//~| HELP there is already a visibility modifier, remove one -//~| NOTE explicit visibility first seen here diff --git a/tests/ui/parser/issue-87694-duplicated-pub.stderr b/tests/ui/parser/issue-87694-duplicated-pub.stderr deleted file mode 100644 index 8d242bc9de5..00000000000 --- a/tests/ui/parser/issue-87694-duplicated-pub.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error: expected one of `async`, `extern`, `fn`, or `unsafe`, found keyword `pub` - --> $DIR/issue-87694-duplicated-pub.rs:1:11 - | -LL | pub const pub fn test() {} - | ^^^ - | | - | expected one of `async`, `extern`, `fn`, or `unsafe` - | help: there is already a visibility modifier, remove one - | -note: explicit visibility first seen here - --> $DIR/issue-87694-duplicated-pub.rs:1:1 - | -LL | pub const pub fn test() {} - | ^^^ - -error: aborting due to previous error - diff --git a/tests/ui/parser/issue-87694-misplaced-pub.rs b/tests/ui/parser/issue-87694-misplaced-pub.rs deleted file mode 100644 index 3f824617cad..00000000000 --- a/tests/ui/parser/issue-87694-misplaced-pub.rs +++ /dev/null @@ -1,5 +0,0 @@ -const pub fn test() {} -//~^ ERROR expected one of `async`, `extern`, `fn`, or `unsafe`, found keyword `pub` -//~| NOTE expected one of `async`, `extern`, `fn`, or `unsafe` -//~| HELP visibility `pub` must come before `const` -//~| SUGGESTION pub const diff --git a/tests/ui/parser/issue-87694-misplaced-pub.stderr b/tests/ui/parser/issue-87694-misplaced-pub.stderr deleted file mode 100644 index 94c6a29efcb..00000000000 --- a/tests/ui/parser/issue-87694-misplaced-pub.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: expected one of `async`, `extern`, `fn`, or `unsafe`, found keyword `pub` - --> $DIR/issue-87694-misplaced-pub.rs:1:7 - | -LL | const pub fn test() {} - | ------^^^ - | | | - | | expected one of `async`, `extern`, `fn`, or `unsafe` - | help: visibility `pub` must come before `const`: `pub const` - -error: aborting due to previous error - diff --git a/tests/ui/parser/issue-90728.rs b/tests/ui/parser/issue-90728.rs deleted file mode 100644 index d6a898361cc..00000000000 --- a/tests/ui/parser/issue-90728.rs +++ /dev/null @@ -1,6 +0,0 @@ -fn main() { - a.5.2E+ - //~^ ERROR: unexpected token: `5.2E+` - //~| ERROR: expected one of `.`, `;`, `?`, `}`, or an operator, found `5.2E+` - //~| ERROR: expected at least one digit in exponent -} diff --git a/tests/ui/parser/issue-90728.stderr b/tests/ui/parser/issue-90728.stderr deleted file mode 100644 index b55c4603066..00000000000 --- a/tests/ui/parser/issue-90728.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: expected at least one digit in exponent - --> $DIR/issue-90728.rs:2:7 - | -LL | a.5.2E+ - | ^^^^^ - -error: unexpected token: `5.2E+` - --> $DIR/issue-90728.rs:2:7 - | -LL | a.5.2E+ - | ^^^^^ - -error: expected one of `.`, `;`, `?`, `}`, or an operator, found `5.2E+` - --> $DIR/issue-90728.rs:2:7 - | -LL | a.5.2E+ - | ^^^^^ expected one of `.`, `;`, `?`, `}`, or an operator - -error: aborting due to 3 previous errors - diff --git a/tests/ui/parser/issue-91421.rs b/tests/ui/parser/issue-91421.rs deleted file mode 100644 index 8bba27f3724..00000000000 --- a/tests/ui/parser/issue-91421.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Regression test for issue #91421. - -fn main() { - let value = if true && { - //~^ ERROR: this `if` expression is missing a block after the condition - //~| HELP: this binary operation is possibly unfinished - 3 - } else { 4 }; -} diff --git a/tests/ui/parser/issue-91421.stderr b/tests/ui/parser/issue-91421.stderr deleted file mode 100644 index 2d9652051dd..00000000000 --- a/tests/ui/parser/issue-91421.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: this `if` expression is missing a block after the condition - --> $DIR/issue-91421.rs:4:17 - | -LL | let value = if true && { - | ^^ - | -help: this binary operation is possibly unfinished - --> $DIR/issue-91421.rs:4:20 - | -LL | let value = if true && { - | ^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/parser/issue-99625-enum-struct-mutually-exclusive.fixed b/tests/ui/parser/issue-99625-enum-struct-mutually-exclusive.fixed deleted file mode 100644 index 4b4a416b1ac..00000000000 --- a/tests/ui/parser/issue-99625-enum-struct-mutually-exclusive.fixed +++ /dev/null @@ -1,13 +0,0 @@ -// run-rustfix - -pub enum Range { - //~^ ERROR `enum` and `struct` are mutually exclusive - Valid { - begin: u32, - len: u32, - }, - Out, -} - -fn main() { -} diff --git a/tests/ui/parser/issue-99625-enum-struct-mutually-exclusive.rs b/tests/ui/parser/issue-99625-enum-struct-mutually-exclusive.rs deleted file mode 100644 index 9cc88664129..00000000000 --- a/tests/ui/parser/issue-99625-enum-struct-mutually-exclusive.rs +++ /dev/null @@ -1,13 +0,0 @@ -// run-rustfix - -pub enum struct Range { - //~^ ERROR `enum` and `struct` are mutually exclusive - Valid { - begin: u32, - len: u32, - }, - Out, -} - -fn main() { -} diff --git a/tests/ui/parser/issue-99625-enum-struct-mutually-exclusive.stderr b/tests/ui/parser/issue-99625-enum-struct-mutually-exclusive.stderr deleted file mode 100644 index edc640bf5ec..00000000000 --- a/tests/ui/parser/issue-99625-enum-struct-mutually-exclusive.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: `enum` and `struct` are mutually exclusive - --> $DIR/issue-99625-enum-struct-mutually-exclusive.rs:3:5 - | -LL | pub enum struct Range { - | ^^^^^^^^^^^ help: replace `enum struct` with: `enum` - -error: aborting due to previous error - diff --git a/tests/ui/parser/issue-99910-const-let-mutually-exclusive.fixed b/tests/ui/parser/issue-99910-const-let-mutually-exclusive.fixed deleted file mode 100644 index 64ab6f62b77..00000000000 --- a/tests/ui/parser/issue-99910-const-let-mutually-exclusive.fixed +++ /dev/null @@ -1,8 +0,0 @@ -// run-rustfix - -fn main() { - const _FOO: i32 = 123; - //~^ ERROR const` and `let` are mutually exclusive - const _BAR: i32 = 123; - //~^ ERROR `const` and `let` are mutually exclusive -} diff --git a/tests/ui/parser/issue-99910-const-let-mutually-exclusive.rs b/tests/ui/parser/issue-99910-const-let-mutually-exclusive.rs deleted file mode 100644 index 50520971ffb..00000000000 --- a/tests/ui/parser/issue-99910-const-let-mutually-exclusive.rs +++ /dev/null @@ -1,8 +0,0 @@ -// run-rustfix - -fn main() { - const let _FOO: i32 = 123; - //~^ ERROR const` and `let` are mutually exclusive - let const _BAR: i32 = 123; - //~^ ERROR `const` and `let` are mutually exclusive -} diff --git a/tests/ui/parser/issue-99910-const-let-mutually-exclusive.stderr b/tests/ui/parser/issue-99910-const-let-mutually-exclusive.stderr deleted file mode 100644 index 72377fc379c..00000000000 --- a/tests/ui/parser/issue-99910-const-let-mutually-exclusive.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: `const` and `let` are mutually exclusive - --> $DIR/issue-99910-const-let-mutually-exclusive.rs:4:5 - | -LL | const let _FOO: i32 = 123; - | ^^^^^^^^^ help: remove `let`: `const` - -error: `const` and `let` are mutually exclusive - --> $DIR/issue-99910-const-let-mutually-exclusive.rs:6:5 - | -LL | let const _BAR: i32 = 123; - | ^^^^^^^^^ help: remove `let`: `const` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/parser/issues/issue-100197-mut-let.fixed b/tests/ui/parser/issues/issue-100197-mut-let.fixed new file mode 100644 index 00000000000..5a895622200 --- /dev/null +++ b/tests/ui/parser/issues/issue-100197-mut-let.fixed @@ -0,0 +1,6 @@ +// run-rustfix + +fn main() { + let mut _x = 123; + //~^ ERROR invalid variable declaration +} diff --git a/tests/ui/parser/issues/issue-100197-mut-let.rs b/tests/ui/parser/issues/issue-100197-mut-let.rs new file mode 100644 index 00000000000..71103813a6e --- /dev/null +++ b/tests/ui/parser/issues/issue-100197-mut-let.rs @@ -0,0 +1,6 @@ +// run-rustfix + +fn main() { + mut let _x = 123; + //~^ ERROR invalid variable declaration +} diff --git a/tests/ui/parser/issues/issue-100197-mut-let.stderr b/tests/ui/parser/issues/issue-100197-mut-let.stderr new file mode 100644 index 00000000000..86658e4f39f --- /dev/null +++ b/tests/ui/parser/issues/issue-100197-mut-let.stderr @@ -0,0 +1,8 @@ +error: invalid variable declaration + --> $DIR/issue-100197-mut-let.rs:4:5 + | +LL | mut let _x = 123; + | ^^^^^^^ help: switch the order of `mut` and `let`: `let mut` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-101477-enum.fixed b/tests/ui/parser/issues/issue-101477-enum.fixed new file mode 100644 index 00000000000..1dfeae22aea --- /dev/null +++ b/tests/ui/parser/issues/issue-101477-enum.fixed @@ -0,0 +1,10 @@ +// run-rustfix + +#[allow(dead_code)] +enum Demo { + A = 1, + B = 2 //~ ERROR unexpected `==` + //~^ expected item, found `==` +} + +fn main() {} diff --git a/tests/ui/parser/issues/issue-101477-enum.rs b/tests/ui/parser/issues/issue-101477-enum.rs new file mode 100644 index 00000000000..ea7051d69a4 --- /dev/null +++ b/tests/ui/parser/issues/issue-101477-enum.rs @@ -0,0 +1,10 @@ +// run-rustfix + +#[allow(dead_code)] +enum Demo { + A = 1, + B == 2 //~ ERROR unexpected `==` + //~^ expected item, found `==` +} + +fn main() {} diff --git a/tests/ui/parser/issues/issue-101477-enum.stderr b/tests/ui/parser/issues/issue-101477-enum.stderr new file mode 100644 index 00000000000..94130671f1c --- /dev/null +++ b/tests/ui/parser/issues/issue-101477-enum.stderr @@ -0,0 +1,18 @@ +error: unexpected `==` + --> $DIR/issue-101477-enum.rs:6:7 + | +LL | B == 2 + | ^^ help: try using `=` instead + | + = help: enum variants can be `Variant`, `Variant = `, `Variant(Type, ..., TypeN)` or `Variant { fields: Types }` + +error: expected item, found `==` + --> $DIR/issue-101477-enum.rs:6:7 + | +LL | B == 2 + | ^^ expected item + | + = note: for a full list of items that can appear in modules, see + +error: aborting due to 2 previous errors + diff --git a/tests/ui/parser/issues/issue-101477-let.fixed b/tests/ui/parser/issues/issue-101477-let.fixed new file mode 100644 index 00000000000..9989ad81524 --- /dev/null +++ b/tests/ui/parser/issues/issue-101477-let.fixed @@ -0,0 +1,6 @@ +// run-rustfix + +fn main() { + let x = 2; //~ ERROR unexpected `==` + println!("x: {}", x) +} diff --git a/tests/ui/parser/issues/issue-101477-let.rs b/tests/ui/parser/issues/issue-101477-let.rs new file mode 100644 index 00000000000..8b0e8bee179 --- /dev/null +++ b/tests/ui/parser/issues/issue-101477-let.rs @@ -0,0 +1,6 @@ +// run-rustfix + +fn main() { + let x == 2; //~ ERROR unexpected `==` + println!("x: {}", x) +} diff --git a/tests/ui/parser/issues/issue-101477-let.stderr b/tests/ui/parser/issues/issue-101477-let.stderr new file mode 100644 index 00000000000..1b30d4b1786 --- /dev/null +++ b/tests/ui/parser/issues/issue-101477-let.stderr @@ -0,0 +1,8 @@ +error: unexpected `==` + --> $DIR/issue-101477-let.rs:4:11 + | +LL | let x == 2; + | ^^ help: try using `=` instead + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-102806.rs b/tests/ui/parser/issues/issue-102806.rs new file mode 100644 index 00000000000..ba297bdc967 --- /dev/null +++ b/tests/ui/parser/issues/issue-102806.rs @@ -0,0 +1,25 @@ +#![allow(dead_code)] + +#[derive(Default)] +struct V3 { + x: f32, + y: f32, + z: f32, +} + +fn pz(v: V3) { + let _ = V3 { z: 0.0, ...v}; + //~^ ERROR expected `..` + + let _ = V3 { z: 0.0, ...Default::default() }; + //~^ ERROR expected `..` + + let _ = V3 { z: 0.0, ... }; + //~^ expected identifier + //~| ERROR missing fields `x` and `y` in initializer of `V3` + + let V3 { z: val, ... } = v; + //~^ ERROR expected field pattern +} + +fn main() {} diff --git a/tests/ui/parser/issues/issue-102806.stderr b/tests/ui/parser/issues/issue-102806.stderr new file mode 100644 index 00000000000..ba8174a823b --- /dev/null +++ b/tests/ui/parser/issues/issue-102806.stderr @@ -0,0 +1,50 @@ +error: expected `..`, found `...` + --> $DIR/issue-102806.rs:11:26 + | +LL | let _ = V3 { z: 0.0, ...v}; + | ^^^ + | +help: use `..` to fill in the rest of the fields + | +LL | let _ = V3 { z: 0.0, ..v}; + | ~~ + +error: expected `..`, found `...` + --> $DIR/issue-102806.rs:14:26 + | +LL | let _ = V3 { z: 0.0, ...Default::default() }; + | ^^^ + | +help: use `..` to fill in the rest of the fields + | +LL | let _ = V3 { z: 0.0, ..Default::default() }; + | ~~ + +error: expected identifier, found `...` + --> $DIR/issue-102806.rs:17:26 + | +LL | let _ = V3 { z: 0.0, ... }; + | -- ^^^ expected identifier + | | + | while parsing this struct + +error: expected field pattern, found `...` + --> $DIR/issue-102806.rs:21:22 + | +LL | let V3 { z: val, ... } = v; + | ^^^ + | +help: to omit remaining fields, use `..` + | +LL | let V3 { z: val, .. } = v; + | ~~ + +error[E0063]: missing fields `x` and `y` in initializer of `V3` + --> $DIR/issue-102806.rs:17:13 + | +LL | let _ = V3 { z: 0.0, ... }; + | ^^ missing `x` and `y` + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0063`. diff --git a/tests/ui/parser/issues/issue-103143.rs b/tests/ui/parser/issues/issue-103143.rs new file mode 100644 index 00000000000..a584274c405 --- /dev/null +++ b/tests/ui/parser/issues/issue-103143.rs @@ -0,0 +1,5 @@ +fn main() { + x::<#[a]y::> + //~^ ERROR invalid const generic expression + //~| ERROR cannot find value `x` in this scope +} diff --git a/tests/ui/parser/issues/issue-103143.stderr b/tests/ui/parser/issues/issue-103143.stderr new file mode 100644 index 00000000000..4035c69afa7 --- /dev/null +++ b/tests/ui/parser/issues/issue-103143.stderr @@ -0,0 +1,20 @@ +error: invalid const generic expression + --> $DIR/issue-103143.rs:2:13 + | +LL | x::<#[a]y::> + | ^^^^^^ + | +help: expressions must be enclosed in braces to be used as const generic arguments + | +LL | x::<#[a]{ y:: }> + | + + + +error[E0425]: cannot find value `x` in this scope + --> $DIR/issue-103143.rs:2:5 + | +LL | x::<#[a]y::> + | ^ not found in this scope + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/parser/issues/issue-103381.fixed b/tests/ui/parser/issues/issue-103381.fixed new file mode 100644 index 00000000000..6a9fb991097 --- /dev/null +++ b/tests/ui/parser/issues/issue-103381.fixed @@ -0,0 +1,59 @@ +// run-rustfix + +#![feature(let_chains)] +#![allow(unused_variables)] +#![allow(dead_code)] +#![allow(irrefutable_let_patterns)] + +fn err_some(b: bool, x: Option) { + if b && let Some(x) = x {} + //~^ ERROR unexpected `if` in the condition expression +} + +fn err_none(b: bool, x: Option) { + if b && let None = x {} + //~^ ERROR unexpected `if` in the condition expression +} + +fn err_bool_1() { + if true && true { true } else { false }; + //~^ ERROR unexpected `if` in the condition expression +} + +fn err_bool_2() { + if true && false { true } else { false }; + //~^ ERROR unexpected `if` in the condition expression +} + +fn should_ok_1() { + if true && if let x = 1 { true } else { true } {} +} + +fn should_ok_2() { + if true && if let 1 = 1 { true } else { true } {} +} + +fn should_ok_3() { + if true && if true { true } else { false } {} +} + +fn shoule_match_ok() { + #[cfg(feature = "full")] + { + let a = 1; + let b = 2; + if match a { + 1 if b == 1 => true, + _ => false, + } && if a > 1 { true } else { false } + { + true + } + } +} + +fn should_ok_in_nested() { + if true && if true { true } else { false } { true } else { false }; +} + +fn main() {} diff --git a/tests/ui/parser/issues/issue-103381.rs b/tests/ui/parser/issues/issue-103381.rs new file mode 100644 index 00000000000..bf79e10103e --- /dev/null +++ b/tests/ui/parser/issues/issue-103381.rs @@ -0,0 +1,59 @@ +// run-rustfix + +#![feature(let_chains)] +#![allow(unused_variables)] +#![allow(dead_code)] +#![allow(irrefutable_let_patterns)] + +fn err_some(b: bool, x: Option) { + if b && if let Some(x) = x {} + //~^ ERROR unexpected `if` in the condition expression +} + +fn err_none(b: bool, x: Option) { + if b && if let None = x {} + //~^ ERROR unexpected `if` in the condition expression +} + +fn err_bool_1() { + if true && if true { true } else { false }; + //~^ ERROR unexpected `if` in the condition expression +} + +fn err_bool_2() { + if true && if false { true } else { false }; + //~^ ERROR unexpected `if` in the condition expression +} + +fn should_ok_1() { + if true && if let x = 1 { true } else { true } {} +} + +fn should_ok_2() { + if true && if let 1 = 1 { true } else { true } {} +} + +fn should_ok_3() { + if true && if true { true } else { false } {} +} + +fn shoule_match_ok() { + #[cfg(feature = "full")] + { + let a = 1; + let b = 2; + if match a { + 1 if b == 1 => true, + _ => false, + } && if a > 1 { true } else { false } + { + true + } + } +} + +fn should_ok_in_nested() { + if true && if true { true } else { false } { true } else { false }; +} + +fn main() {} diff --git a/tests/ui/parser/issues/issue-103381.stderr b/tests/ui/parser/issues/issue-103381.stderr new file mode 100644 index 00000000000..85fcc18e76b --- /dev/null +++ b/tests/ui/parser/issues/issue-103381.stderr @@ -0,0 +1,50 @@ +error: unexpected `if` in the condition expression + --> $DIR/issue-103381.rs:9:12 + | +LL | if b && if let Some(x) = x {} + | ^^^^ + | +help: remove the `if` + | +LL - if b && if let Some(x) = x {} +LL + if b && let Some(x) = x {} + | + +error: unexpected `if` in the condition expression + --> $DIR/issue-103381.rs:14:12 + | +LL | if b && if let None = x {} + | ^^^^ + | +help: remove the `if` + | +LL - if b && if let None = x {} +LL + if b && let None = x {} + | + +error: unexpected `if` in the condition expression + --> $DIR/issue-103381.rs:19:15 + | +LL | if true && if true { true } else { false }; + | ^^^^ + | +help: remove the `if` + | +LL - if true && if true { true } else { false }; +LL + if true && true { true } else { false }; + | + +error: unexpected `if` in the condition expression + --> $DIR/issue-103381.rs:24:15 + | +LL | if true && if false { true } else { false }; + | ^^^^ + | +help: remove the `if` + | +LL - if true && if false { true } else { false }; +LL + if true && false { true } else { false }; + | + +error: aborting due to 4 previous errors + diff --git a/tests/ui/parser/issues/issue-103425.rs b/tests/ui/parser/issues/issue-103425.rs new file mode 100644 index 00000000000..c2f8123ca4e --- /dev/null +++ b/tests/ui/parser/issues/issue-103425.rs @@ -0,0 +1,15 @@ +fn f() -> f32 { + 3 + //~^ ERROR expected `;` + 5.0 +} + +fn k() -> f32 { + 2_u32 + //~^ ERROR expected `;` + 3_i8 + //~^ ERROR expected `;` + 5.0 +} + +fn main() {} diff --git a/tests/ui/parser/issues/issue-103425.stderr b/tests/ui/parser/issues/issue-103425.stderr new file mode 100644 index 00000000000..0efe3e3ca71 --- /dev/null +++ b/tests/ui/parser/issues/issue-103425.stderr @@ -0,0 +1,29 @@ +error: expected `;`, found `5.0` + --> $DIR/issue-103425.rs:2:6 + | +LL | 3 + | ^ help: add `;` here +LL | +LL | 5.0 + | --- unexpected token + +error: expected `;`, found `3_i8` + --> $DIR/issue-103425.rs:8:10 + | +LL | 2_u32 + | ^ help: add `;` here +LL | +LL | 3_i8 + | ---- unexpected token + +error: expected `;`, found `5.0` + --> $DIR/issue-103425.rs:10:9 + | +LL | 3_i8 + | ^ help: add `;` here +LL | +LL | 5.0 + | --- unexpected token + +error: aborting due to 3 previous errors + diff --git a/tests/ui/parser/issues/issue-103451.rs b/tests/ui/parser/issues/issue-103451.rs new file mode 100644 index 00000000000..be33213f3cb --- /dev/null +++ b/tests/ui/parser/issues/issue-103451.rs @@ -0,0 +1,4 @@ +// error-pattern: this file contains an unclosed delimiter +struct R { } +struct S { + x: [u8; R diff --git a/tests/ui/parser/issues/issue-103451.stderr b/tests/ui/parser/issues/issue-103451.stderr new file mode 100644 index 00000000000..6aacd5012c1 --- /dev/null +++ b/tests/ui/parser/issues/issue-103451.stderr @@ -0,0 +1,12 @@ +error: this file contains an unclosed delimiter + --> $DIR/issue-103451.rs:4:15 + | +LL | struct S { + | - unclosed delimiter +LL | x: [u8; R + | - ^ + | | + | unclosed delimiter + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-103748-ICE-wrong-braces.rs b/tests/ui/parser/issues/issue-103748-ICE-wrong-braces.rs new file mode 100644 index 00000000000..8012cb652bd --- /dev/null +++ b/tests/ui/parser/issues/issue-103748-ICE-wrong-braces.rs @@ -0,0 +1,8 @@ +#![crate_type = "lib"] + +struct Apple((Apple, Option(Banana ? Citron))); +//~^ ERROR invalid `?` in type +//~| ERROR expected one of `)` or `,`, found `Citron` +//~| ERROR cannot find type `Citron` in this scope [E0412] +//~| ERROR parenthesized type parameters may only be used with a `Fn` trait [E0214] +//~| ERROR recursive type `Apple` has infinite size [E0072] diff --git a/tests/ui/parser/issues/issue-103748-ICE-wrong-braces.stderr b/tests/ui/parser/issues/issue-103748-ICE-wrong-braces.stderr new file mode 100644 index 00000000000..b0d8b03ae08 --- /dev/null +++ b/tests/ui/parser/issues/issue-103748-ICE-wrong-braces.stderr @@ -0,0 +1,51 @@ +error: invalid `?` in type + --> $DIR/issue-103748-ICE-wrong-braces.rs:3:36 + | +LL | struct Apple((Apple, Option(Banana ? Citron))); + | ^ `?` is only allowed on expressions, not types + | +help: if you meant to express that the type might not contain a value, use the `Option` wrapper type + | +LL | struct Apple((Apple, Option(Option Citron))); + | +++++++ ~ + +error: expected one of `)` or `,`, found `Citron` + --> $DIR/issue-103748-ICE-wrong-braces.rs:3:38 + | +LL | struct Apple((Apple, Option(Banana ? Citron))); + | -^^^^^^ expected one of `)` or `,` + | | + | help: missing `,` + +error[E0412]: cannot find type `Citron` in this scope + --> $DIR/issue-103748-ICE-wrong-braces.rs:3:38 + | +LL | struct Apple((Apple, Option(Banana ? Citron))); + | ^^^^^^ not found in this scope + +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait + --> $DIR/issue-103748-ICE-wrong-braces.rs:3:22 + | +LL | struct Apple((Apple, Option(Banana ? Citron))); + | ^^^^^^^^^^^^^^^^^^^^^^^ only `Fn` traits may use parentheses + | +help: use angle brackets instead + | +LL | struct Apple((Apple, Option)); + | ~ ~ + +error[E0072]: recursive type `Apple` has infinite size + --> $DIR/issue-103748-ICE-wrong-braces.rs:3:1 + | +LL | struct Apple((Apple, Option(Banana ? Citron))); + | ^^^^^^^^^^^^ ----- recursive without indirection + | +help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle + | +LL | struct Apple((Box, Option(Banana ? Citron))); + | ++++ + + +error: aborting due to 5 previous errors + +Some errors have detailed explanations: E0072, E0214, E0412. +For more information about an error, try `rustc --explain E0072`. diff --git a/tests/ui/parser/issues/issue-104620.rs b/tests/ui/parser/issues/issue-104620.rs new file mode 100644 index 00000000000..f49476c4408 --- /dev/null +++ b/tests/ui/parser/issues/issue-104620.rs @@ -0,0 +1,4 @@ +#![feature(rustc_attrs)] + +#![rustc_dummy=5z] //~ ERROR unexpected expression: `5z` +fn main() {} diff --git a/tests/ui/parser/issues/issue-104620.stderr b/tests/ui/parser/issues/issue-104620.stderr new file mode 100644 index 00000000000..d06a6b2554b --- /dev/null +++ b/tests/ui/parser/issues/issue-104620.stderr @@ -0,0 +1,8 @@ +error: unexpected expression: `5z` + --> $DIR/issue-104620.rs:3:16 + | +LL | #![rustc_dummy=5z] + | ^^ + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-104867-inc-dec-2.rs b/tests/ui/parser/issues/issue-104867-inc-dec-2.rs new file mode 100644 index 00000000000..a006421a975 --- /dev/null +++ b/tests/ui/parser/issues/issue-104867-inc-dec-2.rs @@ -0,0 +1,52 @@ +fn test1() { + let mut i = 0; + let _ = i + ++i; //~ ERROR Rust has no prefix increment operator +} + +fn test2() { + let mut i = 0; + let _ = ++i + i; //~ ERROR Rust has no prefix increment operator +} + +fn test3() { + let mut i = 0; + let _ = ++i + ++i; //~ ERROR Rust has no prefix increment operator +} + +fn test4() { + let mut i = 0; + let _ = i + i++; //~ ERROR Rust has no postfix increment operator + // won't suggest since we can not handle the precedences +} + +fn test5() { + let mut i = 0; + let _ = i++ + i; //~ ERROR Rust has no postfix increment operator +} + +fn test6() { + let mut i = 0; + let _ = i++ + i++; //~ ERROR Rust has no postfix increment operator +} + +fn test7() { + let mut i = 0; + let _ = ++i + i++; //~ ERROR Rust has no prefix increment operator +} + +fn test8() { + let mut i = 0; + let _ = i++ + ++i; //~ ERROR Rust has no postfix increment operator +} + +fn test9() { + let mut i = 0; + let _ = (1 + 2 + i)++; //~ ERROR Rust has no postfix increment operator +} + +fn test10() { + let mut i = 0; + let _ = (i++ + 1) + 2; //~ ERROR Rust has no postfix increment operator +} + +fn main() { } diff --git a/tests/ui/parser/issues/issue-104867-inc-dec-2.stderr b/tests/ui/parser/issues/issue-104867-inc-dec-2.stderr new file mode 100644 index 00000000000..4e2d0546851 --- /dev/null +++ b/tests/ui/parser/issues/issue-104867-inc-dec-2.stderr @@ -0,0 +1,107 @@ +error: Rust has no prefix increment operator + --> $DIR/issue-104867-inc-dec-2.rs:3:17 + | +LL | let _ = i + ++i; + | ^^ not a valid prefix operator + | +help: use `+= 1` instead + | +LL | let _ = i + { i += 1; i }; + | ~ +++++++++ + +error: Rust has no prefix increment operator + --> $DIR/issue-104867-inc-dec-2.rs:8:13 + | +LL | let _ = ++i + i; + | ^^ not a valid prefix operator + | +help: use `+= 1` instead + | +LL | let _ = { i += 1; i } + i; + | ~ +++++++++ + +error: Rust has no prefix increment operator + --> $DIR/issue-104867-inc-dec-2.rs:13:13 + | +LL | let _ = ++i + ++i; + | ^^ not a valid prefix operator + | +help: use `+= 1` instead + | +LL | let _ = { i += 1; i } + ++i; + | ~ +++++++++ + +error: Rust has no postfix increment operator + --> $DIR/issue-104867-inc-dec-2.rs:18:18 + | +LL | let _ = i + i++; + | ^^ not a valid postfix operator + +error: Rust has no postfix increment operator + --> $DIR/issue-104867-inc-dec-2.rs:24:14 + | +LL | let _ = i++ + i; + | ^^ not a valid postfix operator + | +help: use `+= 1` instead + | +LL | let _ = { let tmp = i; i += 1; tmp } + i; + | +++++++++++ ~~~~~~~~~~~~~~~ + +error: Rust has no postfix increment operator + --> $DIR/issue-104867-inc-dec-2.rs:29:14 + | +LL | let _ = i++ + i++; + | ^^ not a valid postfix operator + | +help: use `+= 1` instead + | +LL | let _ = { let tmp = i; i += 1; tmp } + i++; + | +++++++++++ ~~~~~~~~~~~~~~~ + +error: Rust has no prefix increment operator + --> $DIR/issue-104867-inc-dec-2.rs:34:13 + | +LL | let _ = ++i + i++; + | ^^ not a valid prefix operator + | +help: use `+= 1` instead + | +LL | let _ = { i += 1; i } + i++; + | ~ +++++++++ + +error: Rust has no postfix increment operator + --> $DIR/issue-104867-inc-dec-2.rs:39:14 + | +LL | let _ = i++ + ++i; + | ^^ not a valid postfix operator + | +help: use `+= 1` instead + | +LL | let _ = { let tmp = i; i += 1; tmp } + ++i; + | +++++++++++ ~~~~~~~~~~~~~~~ + +error: Rust has no postfix increment operator + --> $DIR/issue-104867-inc-dec-2.rs:44:24 + | +LL | let _ = (1 + 2 + i)++; + | ^^ not a valid postfix operator + | +help: use `+= 1` instead + | +LL | let _ = { let tmp = (1 + 2 + i); (1 + 2 + i) += 1; tmp }; + | +++++++++++ ~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: Rust has no postfix increment operator + --> $DIR/issue-104867-inc-dec-2.rs:49:15 + | +LL | let _ = (i++ + 1) + 2; + | ^^ not a valid postfix operator + | +help: use `+= 1` instead + | +LL | let _ = ({ let tmp = i; i += 1; tmp } + 1) + 2; + | +++++++++++ ~~~~~~~~~~~~~~~ + +error: aborting due to 10 previous errors + diff --git a/tests/ui/parser/issues/issue-104867-inc-dec.rs b/tests/ui/parser/issues/issue-104867-inc-dec.rs new file mode 100644 index 00000000000..760c67b4bed --- /dev/null +++ b/tests/ui/parser/issues/issue-104867-inc-dec.rs @@ -0,0 +1,45 @@ +struct S { + x: i32, +} + +fn test1() { + let mut i = 0; + i++; //~ ERROR Rust has no postfix increment operator +} + +fn test2() { + let s = S { x: 0 }; + s.x++; //~ ERROR Rust has no postfix increment operator +} + +fn test3() { + let mut i = 0; + if i++ == 1 {} //~ ERROR Rust has no postfix increment operator +} + +fn test4() { + let mut i = 0; + ++i; //~ ERROR Rust has no prefix increment operator +} + +fn test5() { + let mut i = 0; + if ++i == 1 { } //~ ERROR Rust has no prefix increment operator +} + +fn test6() { + let mut i = 0; + loop { break; } + i++; //~ ERROR Rust has no postfix increment operator + loop { break; } + ++i; +} + +fn test7() { + let mut i = 0; + loop { break; } + ++i; //~ ERROR Rust has no prefix increment operator +} + + +fn main() {} diff --git a/tests/ui/parser/issues/issue-104867-inc-dec.stderr b/tests/ui/parser/issues/issue-104867-inc-dec.stderr new file mode 100644 index 00000000000..78bfd3e82f0 --- /dev/null +++ b/tests/ui/parser/issues/issue-104867-inc-dec.stderr @@ -0,0 +1,81 @@ +error: Rust has no postfix increment operator + --> $DIR/issue-104867-inc-dec.rs:7:6 + | +LL | i++; + | ^^ not a valid postfix operator + | +help: use `+= 1` instead + | +LL | i += 1; + | ~~~~ + +error: Rust has no postfix increment operator + --> $DIR/issue-104867-inc-dec.rs:12:8 + | +LL | s.x++; + | ^^ not a valid postfix operator + | +help: use `+= 1` instead + | +LL | s.x += 1; + | ~~~~ + +error: Rust has no postfix increment operator + --> $DIR/issue-104867-inc-dec.rs:17:9 + | +LL | if i++ == 1 {} + | ^^ not a valid postfix operator + | +help: use `+= 1` instead + | +LL | if { let tmp = i; i += 1; tmp } == 1 {} + | +++++++++++ ~~~~~~~~~~~~~~~ + +error: Rust has no prefix increment operator + --> $DIR/issue-104867-inc-dec.rs:22:5 + | +LL | ++i; + | ^^ not a valid prefix operator + | +help: use `+= 1` instead + | +LL - ++i; +LL + i += 1; + | + +error: Rust has no prefix increment operator + --> $DIR/issue-104867-inc-dec.rs:27:8 + | +LL | if ++i == 1 { } + | ^^ not a valid prefix operator + | +help: use `+= 1` instead + | +LL | if { i += 1; i } == 1 { } + | ~ +++++++++ + +error: Rust has no postfix increment operator + --> $DIR/issue-104867-inc-dec.rs:33:6 + | +LL | i++; + | ^^ not a valid postfix operator + | +help: use `+= 1` instead + | +LL | i += 1; + | ~~~~ + +error: Rust has no prefix increment operator + --> $DIR/issue-104867-inc-dec.rs:41:5 + | +LL | ++i; + | ^^ not a valid prefix operator + | +help: use `+= 1` instead + | +LL - ++i; +LL + i += 1; + | + +error: aborting due to 7 previous errors + diff --git a/tests/ui/parser/issues/issue-105366.fixed b/tests/ui/parser/issues/issue-105366.fixed new file mode 100644 index 00000000000..ad26643c327 --- /dev/null +++ b/tests/ui/parser/issues/issue-105366.fixed @@ -0,0 +1,12 @@ +// run-rustfix + +struct Foo; + +impl From for Foo { + //~^ ERROR you might have meant to write `impl` instead of `fn` + fn from(_a: i32) -> Self { + Foo + } +} + +fn main() {} diff --git a/tests/ui/parser/issues/issue-105366.rs b/tests/ui/parser/issues/issue-105366.rs new file mode 100644 index 00000000000..311b6a60f1a --- /dev/null +++ b/tests/ui/parser/issues/issue-105366.rs @@ -0,0 +1,12 @@ +// run-rustfix + +struct Foo; + +fn From for Foo { + //~^ ERROR you might have meant to write `impl` instead of `fn` + fn from(_a: i32) -> Self { + Foo + } +} + +fn main() {} diff --git a/tests/ui/parser/issues/issue-105366.stderr b/tests/ui/parser/issues/issue-105366.stderr new file mode 100644 index 00000000000..0a7408e2c17 --- /dev/null +++ b/tests/ui/parser/issues/issue-105366.stderr @@ -0,0 +1,13 @@ +error: you might have meant to write `impl` instead of `fn` + --> $DIR/issue-105366.rs:5:1 + | +LL | fn From for Foo { + | ^^ + | +help: replace `fn` with `impl` here + | +LL | impl From for Foo { + | ~~~~ + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-105634.rs b/tests/ui/parser/issues/issue-105634.rs new file mode 100644 index 00000000000..579aa6e5bfb --- /dev/null +++ b/tests/ui/parser/issues/issue-105634.rs @@ -0,0 +1,8 @@ +// check-pass + +fn main() { + let _a = ..; + let _b = ..=10; + let _c = &..; + let _d = &..=10; +} diff --git a/tests/ui/parser/issues/issue-107705.rs b/tests/ui/parser/issues/issue-107705.rs new file mode 100644 index 00000000000..b80984fcdb0 --- /dev/null +++ b/tests/ui/parser/issues/issue-107705.rs @@ -0,0 +1,3 @@ +// compile-flags: -C debug-assertions + +fn f() {a(b:&, //~ ERROR this file contains an unclosed delimiter diff --git a/tests/ui/parser/issues/issue-107705.stderr b/tests/ui/parser/issues/issue-107705.stderr new file mode 100644 index 00000000000..d2d61346118 --- /dev/null +++ b/tests/ui/parser/issues/issue-107705.stderr @@ -0,0 +1,10 @@ +error: this file contains an unclosed delimiter + --> $DIR/issue-107705.rs:3:67 + | +LL | fn f() {a(b:&, + | - - unclosed delimiter ^ + | | + | unclosed delimiter + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-108495-dec.rs b/tests/ui/parser/issues/issue-108495-dec.rs new file mode 100644 index 00000000000..e0816f84e5c --- /dev/null +++ b/tests/ui/parser/issues/issue-108495-dec.rs @@ -0,0 +1,39 @@ +fn test0() { + let mut i = 0; + let _ = i + i--; //~ ERROR Rust has no postfix decrement operator + // won't suggest since we can not handle the precedences +} + +fn test1() { + let mut i = 0; + let _ = i-- + i--; //~ ERROR Rust has no postfix decrement operator +} + +fn test2() { + let mut i = 0; + let _ = --i + i--; //~ ERROR Rust has no postfix decrement operator +} + +fn test3() { + let mut i = 0; + let _ = i-- + --i; //~ ERROR Rust has no postfix decrement operator +} + +fn test4() { + let mut i = 0; + let _ = (1 + 2 + i)--; //~ ERROR Rust has no postfix decrement operator +} + +fn test5() { + let mut i = 0; + let _ = (i-- + 1) + 2; //~ ERROR Rust has no postfix decrement operator +} + +fn test6(){ + let i=10; + while i != 0 { + i--; //~ ERROR Rust has no postfix decrement operator + } +} + +fn main() {} diff --git a/tests/ui/parser/issues/issue-108495-dec.stderr b/tests/ui/parser/issues/issue-108495-dec.stderr new file mode 100644 index 00000000000..85b29038f7c --- /dev/null +++ b/tests/ui/parser/issues/issue-108495-dec.stderr @@ -0,0 +1,69 @@ +error: Rust has no postfix decrement operator + --> $DIR/issue-108495-dec.rs:3:18 + | +LL | let _ = i + i--; + | ^^ not a valid postfix operator + +error: Rust has no postfix decrement operator + --> $DIR/issue-108495-dec.rs:9:14 + | +LL | let _ = i-- + i--; + | ^^ not a valid postfix operator + | +help: use `-= 1` instead + | +LL | let _ = { let tmp = i; i -= 1; tmp } + i--; + | +++++++++++ ~~~~~~~~~~~~~~~ + +error: Rust has no postfix decrement operator + --> $DIR/issue-108495-dec.rs:14:20 + | +LL | let _ = --i + i--; + | ^^ not a valid postfix operator + +error: Rust has no postfix decrement operator + --> $DIR/issue-108495-dec.rs:19:14 + | +LL | let _ = i-- + --i; + | ^^ not a valid postfix operator + | +help: use `-= 1` instead + | +LL | let _ = { let tmp = i; i -= 1; tmp } + --i; + | +++++++++++ ~~~~~~~~~~~~~~~ + +error: Rust has no postfix decrement operator + --> $DIR/issue-108495-dec.rs:24:24 + | +LL | let _ = (1 + 2 + i)--; + | ^^ not a valid postfix operator + | +help: use `-= 1` instead + | +LL | let _ = { let tmp = (1 + 2 + i); (1 + 2 + i) -= 1; tmp }; + | +++++++++++ ~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: Rust has no postfix decrement operator + --> $DIR/issue-108495-dec.rs:29:15 + | +LL | let _ = (i-- + 1) + 2; + | ^^ not a valid postfix operator + | +help: use `-= 1` instead + | +LL | let _ = ({ let tmp = i; i -= 1; tmp } + 1) + 2; + | +++++++++++ ~~~~~~~~~~~~~~~ + +error: Rust has no postfix decrement operator + --> $DIR/issue-108495-dec.rs:35:10 + | +LL | i--; + | ^^ not a valid postfix operator + | +help: use `-= 1` instead + | +LL | i -= 1; + | ~~~~ + +error: aborting due to 7 previous errors + diff --git a/tests/ui/parser/issues/issue-112188.fixed b/tests/ui/parser/issues/issue-112188.fixed new file mode 100644 index 00000000000..5e73d8e38de --- /dev/null +++ b/tests/ui/parser/issues/issue-112188.fixed @@ -0,0 +1,14 @@ +// run-rustfix + +#![allow(unused)] + +struct Foo { x: i32 } + +fn main() { + let f = Foo { x: 0 }; + let Foo { .. } = f; + let Foo { .. } = f; //~ ERROR expected `}`, found `,` + let Foo { x, .. } = f; + let Foo { x, .. } = f; //~ ERROR expected `}`, found `,` + let Foo { x, .. } = f; //~ ERROR expected `}`, found `,` +} diff --git a/tests/ui/parser/issues/issue-112188.rs b/tests/ui/parser/issues/issue-112188.rs new file mode 100644 index 00000000000..27ca192e522 --- /dev/null +++ b/tests/ui/parser/issues/issue-112188.rs @@ -0,0 +1,14 @@ +// run-rustfix + +#![allow(unused)] + +struct Foo { x: i32 } + +fn main() { + let f = Foo { x: 0 }; + let Foo { .. } = f; + let Foo { .., } = f; //~ ERROR expected `}`, found `,` + let Foo { x, .. } = f; + let Foo { .., x } = f; //~ ERROR expected `}`, found `,` + let Foo { .., x, .. } = f; //~ ERROR expected `}`, found `,` +} diff --git a/tests/ui/parser/issues/issue-112188.stderr b/tests/ui/parser/issues/issue-112188.stderr new file mode 100644 index 00000000000..6d2d8e6a3b0 --- /dev/null +++ b/tests/ui/parser/issues/issue-112188.stderr @@ -0,0 +1,37 @@ +error: expected `}`, found `,` + --> $DIR/issue-112188.rs:10:17 + | +LL | let Foo { .., } = f; + | --^ + | | | + | | expected `}` + | | help: remove this comma + | `..` must be at the end and cannot have a trailing comma + +error: expected `}`, found `,` + --> $DIR/issue-112188.rs:12:17 + | +LL | let Foo { .., x } = f; + | --^ + | | | + | | expected `}` + | `..` must be at the end and cannot have a trailing comma + | +help: move the `..` to the end of the field list + | +LL - let Foo { .., x } = f; +LL + let Foo { x, .. } = f; + | + +error: expected `}`, found `,` + --> $DIR/issue-112188.rs:13:17 + | +LL | let Foo { .., x, .. } = f; + | --^- + | | | + | | expected `}` + | `..` must be at the end and cannot have a trailing comma + | help: remove the starting `..` + +error: aborting due to 3 previous errors + diff --git a/tests/ui/parser/issues/issue-113342.rs b/tests/ui/parser/issues/issue-113342.rs new file mode 100644 index 00000000000..18b502736f7 --- /dev/null +++ b/tests/ui/parser/issues/issue-113342.rs @@ -0,0 +1,9 @@ +#[link(name = "my_c_library")] +extern "C" { + fn my_c_function(x: i32) -> bool; +} + +#[no_mangle] +extern "C" pub fn id(x: i32) -> i32 { x } //~ ERROR expected `fn`, found keyword `pub` + +fn main() {} diff --git a/tests/ui/parser/issues/issue-113342.stderr b/tests/ui/parser/issues/issue-113342.stderr new file mode 100644 index 00000000000..a0c5e665ff8 --- /dev/null +++ b/tests/ui/parser/issues/issue-113342.stderr @@ -0,0 +1,11 @@ +error: expected `fn`, found keyword `pub` + --> $DIR/issue-113342.rs:7:12 + | +LL | extern "C" pub fn id(x: i32) -> i32 { x } + | -----------^^^ + | | | + | | expected `fn` + | help: visibility `pub` must come before `extern "C"`: `pub extern "C"` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-17718-parse-const.rs b/tests/ui/parser/issues/issue-17718-parse-const.rs new file mode 100644 index 00000000000..d5a5f445d5b --- /dev/null +++ b/tests/ui/parser/issues/issue-17718-parse-const.rs @@ -0,0 +1,7 @@ +// run-pass + +const FOO: usize = 3; + +fn main() { + assert_eq!(FOO, 3); +} diff --git a/tests/ui/parser/issues/issue-39616.rs b/tests/ui/parser/issues/issue-39616.rs new file mode 100644 index 00000000000..46b5aa334ca --- /dev/null +++ b/tests/ui/parser/issues/issue-39616.rs @@ -0,0 +1,3 @@ +fn foo(a: [0; 1]) {} //~ ERROR expected type, found `0` + +fn main() {} diff --git a/tests/ui/parser/issues/issue-39616.stderr b/tests/ui/parser/issues/issue-39616.stderr new file mode 100644 index 00000000000..393d1f2e2ce --- /dev/null +++ b/tests/ui/parser/issues/issue-39616.stderr @@ -0,0 +1,8 @@ +error: expected type, found `0` + --> $DIR/issue-39616.rs:1:12 + | +LL | fn foo(a: [0; 1]) {} + | ^ expected type + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-49257.rs b/tests/ui/parser/issues/issue-49257.rs new file mode 100644 index 00000000000..a7fa19d52fd --- /dev/null +++ b/tests/ui/parser/issues/issue-49257.rs @@ -0,0 +1,14 @@ +// Test for #49257: +// emits good diagnostics for `..` pattern fragments not in the last position. + +#![allow(unused)] + +struct Point { x: u8, y: u8 } + +fn main() { + let p = Point { x: 0, y: 0 }; + let Point { .., y, } = p; //~ ERROR expected `}`, found `,` + let Point { .., y } = p; //~ ERROR expected `}`, found `,` + let Point { .., } = p; //~ ERROR expected `}`, found `,` + let Point { .. } = p; +} diff --git a/tests/ui/parser/issues/issue-49257.stderr b/tests/ui/parser/issues/issue-49257.stderr new file mode 100644 index 00000000000..97e16f88b8d --- /dev/null +++ b/tests/ui/parser/issues/issue-49257.stderr @@ -0,0 +1,42 @@ +error: expected `}`, found `,` + --> $DIR/issue-49257.rs:10:19 + | +LL | let Point { .., y, } = p; + | --^ + | | | + | | expected `}` + | `..` must be at the end and cannot have a trailing comma + | +help: move the `..` to the end of the field list + | +LL - let Point { .., y, } = p; +LL + let Point { y, .. } = p; + | + +error: expected `}`, found `,` + --> $DIR/issue-49257.rs:11:19 + | +LL | let Point { .., y } = p; + | --^ + | | | + | | expected `}` + | `..` must be at the end and cannot have a trailing comma + | +help: move the `..` to the end of the field list + | +LL - let Point { .., y } = p; +LL + let Point { y, .. } = p; + | + +error: expected `}`, found `,` + --> $DIR/issue-49257.rs:12:19 + | +LL | let Point { .., } = p; + | --^ + | | | + | | expected `}` + | | help: remove this comma + | `..` must be at the end and cannot have a trailing comma + +error: aborting due to 3 previous errors + diff --git a/tests/ui/parser/issues/issue-61858.rs b/tests/ui/parser/issues/issue-61858.rs new file mode 100644 index 00000000000..6c3b56586c4 --- /dev/null +++ b/tests/ui/parser/issues/issue-61858.rs @@ -0,0 +1,3 @@ +fn main() { + (if foobar) //~ ERROR expected `{`, found `)` +} diff --git a/tests/ui/parser/issues/issue-61858.stderr b/tests/ui/parser/issues/issue-61858.stderr new file mode 100644 index 00000000000..03f51c6e3a8 --- /dev/null +++ b/tests/ui/parser/issues/issue-61858.stderr @@ -0,0 +1,14 @@ +error: expected `{`, found `)` + --> $DIR/issue-61858.rs:2:15 + | +LL | (if foobar) + | ^ expected `{` + | +note: the `if` expression is missing a block after this condition + --> $DIR/issue-61858.rs:2:9 + | +LL | (if foobar) + | ^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-68091-unicode-ident-after-if.rs b/tests/ui/parser/issues/issue-68091-unicode-ident-after-if.rs new file mode 100644 index 00000000000..57d36feb37b --- /dev/null +++ b/tests/ui/parser/issues/issue-68091-unicode-ident-after-if.rs @@ -0,0 +1,10 @@ +macro_rules! x { + ($($c:tt)*) => { + $($c)ö* {} + //~^ ERROR missing condition for `if` expression + }; +} + +fn main() { + x!(if); +} diff --git a/tests/ui/parser/issues/issue-68091-unicode-ident-after-if.stderr b/tests/ui/parser/issues/issue-68091-unicode-ident-after-if.stderr new file mode 100644 index 00000000000..6674b924e9c --- /dev/null +++ b/tests/ui/parser/issues/issue-68091-unicode-ident-after-if.stderr @@ -0,0 +1,10 @@ +error: missing condition for `if` expression + --> $DIR/issue-68091-unicode-ident-after-if.rs:3:14 + | +LL | $($c)ö* {} + | ^ - if this block is the condition of the `if` expression, then it must be followed by another block + | | + | expected condition here + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-68092-unicode-ident-after-incomplete-expr.rs b/tests/ui/parser/issues/issue-68092-unicode-ident-after-incomplete-expr.rs new file mode 100644 index 00000000000..1a90b4724d4 --- /dev/null +++ b/tests/ui/parser/issues/issue-68092-unicode-ident-after-incomplete-expr.rs @@ -0,0 +1,9 @@ +macro_rules! x { + ($($c:tt)*) => { + $($c)ö* //~ ERROR macro expansion ends with an incomplete expression: expected expression + }; +} + +fn main() { + x!(!); +} diff --git a/tests/ui/parser/issues/issue-68092-unicode-ident-after-incomplete-expr.stderr b/tests/ui/parser/issues/issue-68092-unicode-ident-after-incomplete-expr.stderr new file mode 100644 index 00000000000..0b9c364f1f1 --- /dev/null +++ b/tests/ui/parser/issues/issue-68092-unicode-ident-after-incomplete-expr.stderr @@ -0,0 +1,8 @@ +error: macro expansion ends with an incomplete expression: expected expression + --> $DIR/issue-68092-unicode-ident-after-incomplete-expr.rs:3:14 + | +LL | $($c)ö* + | ^ expected expression + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-68987-unmatch-issue-1.rs b/tests/ui/parser/issues/issue-68987-unmatch-issue-1.rs new file mode 100644 index 00000000000..30e7ef46736 --- /dev/null +++ b/tests/ui/parser/issues/issue-68987-unmatch-issue-1.rs @@ -0,0 +1,12 @@ +// This file has unexpected closing delimiter, + +fn func(o: Option) { + match o { + Some(_x) => {} // Extra '}' + let _ = if true {}; + } + None => {} + } +} //~ ERROR unexpected closing delimiter + +fn main() {} diff --git a/tests/ui/parser/issues/issue-68987-unmatch-issue-1.stderr b/tests/ui/parser/issues/issue-68987-unmatch-issue-1.stderr new file mode 100644 index 00000000000..2d873b46193 --- /dev/null +++ b/tests/ui/parser/issues/issue-68987-unmatch-issue-1.stderr @@ -0,0 +1,16 @@ +error: unexpected closing delimiter: `}` + --> $DIR/issue-68987-unmatch-issue-1.rs:10:1 + | +LL | match o { + | - this delimiter might not be properly closed... +LL | Some(_x) => {} // Extra '}' + | -- block is empty, you might have not meant to close it +LL | let _ = if true {}; +LL | } + | - ...as it matches this but it has different indentation +... +LL | } + | ^ unexpected closing delimiter + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-68987-unmatch-issue-2.rs b/tests/ui/parser/issues/issue-68987-unmatch-issue-2.rs new file mode 100644 index 00000000000..89aaa68ba40 --- /dev/null +++ b/tests/ui/parser/issues/issue-68987-unmatch-issue-2.rs @@ -0,0 +1,14 @@ +// FIXME: this case need more work to fix +// currently the TokenTree matching ')' with '{', which is not user friendly for diagnostics +async fn obstest() -> Result<> { + let obs_connect = || -> Result<(), MyError) { //~ ERROR mismatched closing delimiter + async { + } + } + + if let Ok(version, scene_list) = obs_connect() { + + } else { + + } +} //~ ERROR unexpected closing delimiter diff --git a/tests/ui/parser/issues/issue-68987-unmatch-issue-2.stderr b/tests/ui/parser/issues/issue-68987-unmatch-issue-2.stderr new file mode 100644 index 00000000000..0ecb748a0a4 --- /dev/null +++ b/tests/ui/parser/issues/issue-68987-unmatch-issue-2.stderr @@ -0,0 +1,19 @@ +error: mismatched closing delimiter: `)` + --> $DIR/issue-68987-unmatch-issue-2.rs:3:32 + | +LL | async fn obstest() -> Result<> { + | ^ unclosed delimiter +LL | let obs_connect = || -> Result<(), MyError) { + | ^ mismatched closing delimiter + +error: unexpected closing delimiter: `}` + --> $DIR/issue-68987-unmatch-issue-2.rs:14:1 + | +LL | let obs_connect = || -> Result<(), MyError) { + | - missing open `(` for this delimiter +... +LL | } + | ^ unexpected closing delimiter + +error: aborting due to 2 previous errors + diff --git a/tests/ui/parser/issues/issue-68987-unmatch-issue-3.rs b/tests/ui/parser/issues/issue-68987-unmatch-issue-3.rs new file mode 100644 index 00000000000..e98df8d7c3c --- /dev/null +++ b/tests/ui/parser/issues/issue-68987-unmatch-issue-3.rs @@ -0,0 +1,8 @@ +// the `{` is closed with `)`, there is a missing `(` +fn f(i: u32, j: u32) { + let res = String::new(); + let mut cnt = i; + while cnt < j { + write!&mut res, " "); //~ ERROR mismatched closing delimiter + } +} //~ ERROR unexpected closing delimiter diff --git a/tests/ui/parser/issues/issue-68987-unmatch-issue-3.stderr b/tests/ui/parser/issues/issue-68987-unmatch-issue-3.stderr new file mode 100644 index 00000000000..dfc4407ed65 --- /dev/null +++ b/tests/ui/parser/issues/issue-68987-unmatch-issue-3.stderr @@ -0,0 +1,19 @@ +error: mismatched closing delimiter: `)` + --> $DIR/issue-68987-unmatch-issue-3.rs:5:19 + | +LL | while cnt < j { + | ^ unclosed delimiter +LL | write!&mut res, " "); + | ^ mismatched closing delimiter + +error: unexpected closing delimiter: `}` + --> $DIR/issue-68987-unmatch-issue-3.rs:8:1 + | +LL | write!&mut res, " "); + | - missing open `(` for this delimiter +LL | } +LL | } + | ^ unexpected closing delimiter + +error: aborting due to 2 previous errors + diff --git a/tests/ui/parser/issues/issue-68987-unmatch-issue.rs b/tests/ui/parser/issues/issue-68987-unmatch-issue.rs new file mode 100644 index 00000000000..5a3620bf24b --- /dev/null +++ b/tests/ui/parser/issues/issue-68987-unmatch-issue.rs @@ -0,0 +1,12 @@ +// This file has unexpected closing delimiter, + +fn func(o: Option) { + match o { + Some(_x) => // Missing '{' + let _ = if true {}; + } + None => {} + } +} //~ ERROR unexpected closing delimiter + +fn main() {} diff --git a/tests/ui/parser/issues/issue-68987-unmatch-issue.stderr b/tests/ui/parser/issues/issue-68987-unmatch-issue.stderr new file mode 100644 index 00000000000..cabd133242f --- /dev/null +++ b/tests/ui/parser/issues/issue-68987-unmatch-issue.stderr @@ -0,0 +1,16 @@ +error: unexpected closing delimiter: `}` + --> $DIR/issue-68987-unmatch-issue.rs:10:1 + | +LL | match o { + | - this delimiter might not be properly closed... +LL | Some(_x) => // Missing '{' +LL | let _ = if true {}; + | -- block is empty, you might have not meant to close it +LL | } + | - ...as it matches this but it has different indentation +... +LL | } + | ^ unexpected closing delimiter + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-81804.rs b/tests/ui/parser/issues/issue-81804.rs new file mode 100644 index 00000000000..ebc4752a142 --- /dev/null +++ b/tests/ui/parser/issues/issue-81804.rs @@ -0,0 +1,6 @@ +// error-pattern: this file contains an unclosed delimiter +// error-pattern: this file contains an unclosed delimiter + +fn main() {} + +fn p([=(} diff --git a/tests/ui/parser/issues/issue-81804.stderr b/tests/ui/parser/issues/issue-81804.stderr new file mode 100644 index 00000000000..de3b33ecd95 --- /dev/null +++ b/tests/ui/parser/issues/issue-81804.stderr @@ -0,0 +1,19 @@ +error: mismatched closing delimiter: `}` + --> $DIR/issue-81804.rs:6:8 + | +LL | fn p([=(} + | ^^ mismatched closing delimiter + | | + | unclosed delimiter + +error: this file contains an unclosed delimiter + --> $DIR/issue-81804.rs:6:11 + | +LL | fn p([=(} + | -- ^ + | || + | |unclosed delimiter + | unclosed delimiter + +error: aborting due to 2 previous errors + diff --git a/tests/ui/parser/issues/issue-81827.rs b/tests/ui/parser/issues/issue-81827.rs new file mode 100644 index 00000000000..91defd12a57 --- /dev/null +++ b/tests/ui/parser/issues/issue-81827.rs @@ -0,0 +1,10 @@ +// error-pattern: this file contains an unclosed delimiter +// error-pattern: mismatched closing delimiter: `]` + +#![crate_name="0"] + + + +fn main() {} + +fn r()->i{0|{#[cfg(r(0{]0 diff --git a/tests/ui/parser/issues/issue-81827.stderr b/tests/ui/parser/issues/issue-81827.stderr new file mode 100644 index 00000000000..63d135f73e6 --- /dev/null +++ b/tests/ui/parser/issues/issue-81827.stderr @@ -0,0 +1,21 @@ +error: mismatched closing delimiter: `]` + --> $DIR/issue-81827.rs:10:23 + | +LL | fn r()->i{0|{#[cfg(r(0{]0 + | - ^^ mismatched closing delimiter + | | | + | | unclosed delimiter + | closing delimiter possibly meant for this + +error: this file contains an unclosed delimiter + --> $DIR/issue-81827.rs:10:27 + | +LL | fn r()->i{0|{#[cfg(r(0{]0 + | - - - ^ + | | | | + | | | missing open `[` for this delimiter + | | unclosed delimiter + | unclosed delimiter + +error: aborting due to 2 previous errors + diff --git a/tests/ui/parser/issues/issue-87694-duplicated-pub.rs b/tests/ui/parser/issues/issue-87694-duplicated-pub.rs new file mode 100644 index 00000000000..e3ea61dc4ad --- /dev/null +++ b/tests/ui/parser/issues/issue-87694-duplicated-pub.rs @@ -0,0 +1,5 @@ +pub const pub fn test() {} +//~^ ERROR expected one of `async`, `extern`, `fn`, or `unsafe`, found keyword `pub` +//~| NOTE expected one of `async`, `extern`, `fn`, or `unsafe` +//~| HELP there is already a visibility modifier, remove one +//~| NOTE explicit visibility first seen here diff --git a/tests/ui/parser/issues/issue-87694-duplicated-pub.stderr b/tests/ui/parser/issues/issue-87694-duplicated-pub.stderr new file mode 100644 index 00000000000..8d242bc9de5 --- /dev/null +++ b/tests/ui/parser/issues/issue-87694-duplicated-pub.stderr @@ -0,0 +1,17 @@ +error: expected one of `async`, `extern`, `fn`, or `unsafe`, found keyword `pub` + --> $DIR/issue-87694-duplicated-pub.rs:1:11 + | +LL | pub const pub fn test() {} + | ^^^ + | | + | expected one of `async`, `extern`, `fn`, or `unsafe` + | help: there is already a visibility modifier, remove one + | +note: explicit visibility first seen here + --> $DIR/issue-87694-duplicated-pub.rs:1:1 + | +LL | pub const pub fn test() {} + | ^^^ + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-87694-misplaced-pub.rs b/tests/ui/parser/issues/issue-87694-misplaced-pub.rs new file mode 100644 index 00000000000..3f824617cad --- /dev/null +++ b/tests/ui/parser/issues/issue-87694-misplaced-pub.rs @@ -0,0 +1,5 @@ +const pub fn test() {} +//~^ ERROR expected one of `async`, `extern`, `fn`, or `unsafe`, found keyword `pub` +//~| NOTE expected one of `async`, `extern`, `fn`, or `unsafe` +//~| HELP visibility `pub` must come before `const` +//~| SUGGESTION pub const diff --git a/tests/ui/parser/issues/issue-87694-misplaced-pub.stderr b/tests/ui/parser/issues/issue-87694-misplaced-pub.stderr new file mode 100644 index 00000000000..94c6a29efcb --- /dev/null +++ b/tests/ui/parser/issues/issue-87694-misplaced-pub.stderr @@ -0,0 +1,11 @@ +error: expected one of `async`, `extern`, `fn`, or `unsafe`, found keyword `pub` + --> $DIR/issue-87694-misplaced-pub.rs:1:7 + | +LL | const pub fn test() {} + | ------^^^ + | | | + | | expected one of `async`, `extern`, `fn`, or `unsafe` + | help: visibility `pub` must come before `const`: `pub const` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-90728.rs b/tests/ui/parser/issues/issue-90728.rs new file mode 100644 index 00000000000..d6a898361cc --- /dev/null +++ b/tests/ui/parser/issues/issue-90728.rs @@ -0,0 +1,6 @@ +fn main() { + a.5.2E+ + //~^ ERROR: unexpected token: `5.2E+` + //~| ERROR: expected one of `.`, `;`, `?`, `}`, or an operator, found `5.2E+` + //~| ERROR: expected at least one digit in exponent +} diff --git a/tests/ui/parser/issues/issue-90728.stderr b/tests/ui/parser/issues/issue-90728.stderr new file mode 100644 index 00000000000..b55c4603066 --- /dev/null +++ b/tests/ui/parser/issues/issue-90728.stderr @@ -0,0 +1,20 @@ +error: expected at least one digit in exponent + --> $DIR/issue-90728.rs:2:7 + | +LL | a.5.2E+ + | ^^^^^ + +error: unexpected token: `5.2E+` + --> $DIR/issue-90728.rs:2:7 + | +LL | a.5.2E+ + | ^^^^^ + +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `5.2E+` + --> $DIR/issue-90728.rs:2:7 + | +LL | a.5.2E+ + | ^^^^^ expected one of `.`, `;`, `?`, `}`, or an operator + +error: aborting due to 3 previous errors + diff --git a/tests/ui/parser/issues/issue-91421.rs b/tests/ui/parser/issues/issue-91421.rs new file mode 100644 index 00000000000..8bba27f3724 --- /dev/null +++ b/tests/ui/parser/issues/issue-91421.rs @@ -0,0 +1,9 @@ +// Regression test for issue #91421. + +fn main() { + let value = if true && { + //~^ ERROR: this `if` expression is missing a block after the condition + //~| HELP: this binary operation is possibly unfinished + 3 + } else { 4 }; +} diff --git a/tests/ui/parser/issues/issue-91421.stderr b/tests/ui/parser/issues/issue-91421.stderr new file mode 100644 index 00000000000..2d9652051dd --- /dev/null +++ b/tests/ui/parser/issues/issue-91421.stderr @@ -0,0 +1,14 @@ +error: this `if` expression is missing a block after the condition + --> $DIR/issue-91421.rs:4:17 + | +LL | let value = if true && { + | ^^ + | +help: this binary operation is possibly unfinished + --> $DIR/issue-91421.rs:4:20 + | +LL | let value = if true && { + | ^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-99625-enum-struct-mutually-exclusive.fixed b/tests/ui/parser/issues/issue-99625-enum-struct-mutually-exclusive.fixed new file mode 100644 index 00000000000..4b4a416b1ac --- /dev/null +++ b/tests/ui/parser/issues/issue-99625-enum-struct-mutually-exclusive.fixed @@ -0,0 +1,13 @@ +// run-rustfix + +pub enum Range { + //~^ ERROR `enum` and `struct` are mutually exclusive + Valid { + begin: u32, + len: u32, + }, + Out, +} + +fn main() { +} diff --git a/tests/ui/parser/issues/issue-99625-enum-struct-mutually-exclusive.rs b/tests/ui/parser/issues/issue-99625-enum-struct-mutually-exclusive.rs new file mode 100644 index 00000000000..9cc88664129 --- /dev/null +++ b/tests/ui/parser/issues/issue-99625-enum-struct-mutually-exclusive.rs @@ -0,0 +1,13 @@ +// run-rustfix + +pub enum struct Range { + //~^ ERROR `enum` and `struct` are mutually exclusive + Valid { + begin: u32, + len: u32, + }, + Out, +} + +fn main() { +} diff --git a/tests/ui/parser/issues/issue-99625-enum-struct-mutually-exclusive.stderr b/tests/ui/parser/issues/issue-99625-enum-struct-mutually-exclusive.stderr new file mode 100644 index 00000000000..edc640bf5ec --- /dev/null +++ b/tests/ui/parser/issues/issue-99625-enum-struct-mutually-exclusive.stderr @@ -0,0 +1,8 @@ +error: `enum` and `struct` are mutually exclusive + --> $DIR/issue-99625-enum-struct-mutually-exclusive.rs:3:5 + | +LL | pub enum struct Range { + | ^^^^^^^^^^^ help: replace `enum struct` with: `enum` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-99910-const-let-mutually-exclusive.fixed b/tests/ui/parser/issues/issue-99910-const-let-mutually-exclusive.fixed new file mode 100644 index 00000000000..64ab6f62b77 --- /dev/null +++ b/tests/ui/parser/issues/issue-99910-const-let-mutually-exclusive.fixed @@ -0,0 +1,8 @@ +// run-rustfix + +fn main() { + const _FOO: i32 = 123; + //~^ ERROR const` and `let` are mutually exclusive + const _BAR: i32 = 123; + //~^ ERROR `const` and `let` are mutually exclusive +} diff --git a/tests/ui/parser/issues/issue-99910-const-let-mutually-exclusive.rs b/tests/ui/parser/issues/issue-99910-const-let-mutually-exclusive.rs new file mode 100644 index 00000000000..50520971ffb --- /dev/null +++ b/tests/ui/parser/issues/issue-99910-const-let-mutually-exclusive.rs @@ -0,0 +1,8 @@ +// run-rustfix + +fn main() { + const let _FOO: i32 = 123; + //~^ ERROR const` and `let` are mutually exclusive + let const _BAR: i32 = 123; + //~^ ERROR `const` and `let` are mutually exclusive +} diff --git a/tests/ui/parser/issues/issue-99910-const-let-mutually-exclusive.stderr b/tests/ui/parser/issues/issue-99910-const-let-mutually-exclusive.stderr new file mode 100644 index 00000000000..72377fc379c --- /dev/null +++ b/tests/ui/parser/issues/issue-99910-const-let-mutually-exclusive.stderr @@ -0,0 +1,14 @@ +error: `const` and `let` are mutually exclusive + --> $DIR/issue-99910-const-let-mutually-exclusive.rs:4:5 + | +LL | const let _FOO: i32 = 123; + | ^^^^^^^^^ help: remove `let`: `const` + +error: `const` and `let` are mutually exclusive + --> $DIR/issue-99910-const-let-mutually-exclusive.rs:6:5 + | +LL | let const _BAR: i32 = 123; + | ^^^^^^^^^ help: remove `let`: `const` + +error: aborting due to 2 previous errors + -- cgit 1.4.1-3-g733a5 From 2dec1bc685c58747c81391b1c5a53ba91400c50d Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Tue, 24 Oct 2023 22:22:52 +0000 Subject: Avoid unbounded O(n^2) when parsing nested type args When encountering code like `f:: { /// appropriately. /// /// See the comments in the `parse_path_segment` function for more details. - unmatched_angle_bracket_count: u32, - max_angle_bracket_count: u32, + unmatched_angle_bracket_count: u16, + max_angle_bracket_count: u16, + angle_bracket_nesting: u16, last_unexpected_token_span: Option, /// If present, this `Parser` is not parsing Rust code but rather a macro call. @@ -394,6 +395,7 @@ impl<'a> Parser<'a> { break_last_token: false, unmatched_angle_bracket_count: 0, max_angle_bracket_count: 0, + angle_bracket_nesting: 0, last_unexpected_token_span: None, subparser_name, capture_state: CaptureState { diff --git a/compiler/rustc_parse/src/parser/path.rs b/compiler/rustc_parse/src/parser/path.rs index 2fcb9a78cfd..4969e672a72 100644 --- a/compiler/rustc_parse/src/parser/path.rs +++ b/compiler/rustc_parse/src/parser/path.rs @@ -487,10 +487,24 @@ impl<'a> Parser<'a> { // Take a snapshot before attempting to parse - we can restore this later. let snapshot = is_first_invocation.then(|| self.clone()); + self.angle_bracket_nesting += 1; debug!("parse_generic_args_with_leading_angle_bracket_recovery: (snapshotting)"); match self.parse_angle_args(ty_generics) { - Ok(args) => Ok(args), + Ok(args) => { + self.angle_bracket_nesting -= 1; + Ok(args) + } + Err(mut e) if self.angle_bracket_nesting > 10 => { + self.angle_bracket_nesting -= 1; + // When encountering severely malformed code where there are several levels of + // nested unclosed angle args (`f:: 0 => { + self.angle_bracket_nesting -= 1; + // Swap `self` with our backup of the parser state before attempting to parse // generic arguments. let snapshot = mem::replace(self, snapshot.unwrap()); @@ -520,8 +534,8 @@ impl<'a> Parser<'a> { // Make a span over ${unmatched angle bracket count} characters. // This is safe because `all_angle_brackets` ensures that there are only `<`s, // i.e. no multibyte characters, in this range. - let span = - lo.with_hi(lo.lo() + BytePos(snapshot.unmatched_angle_bracket_count)); + let span = lo + .with_hi(lo.lo() + BytePos(snapshot.unmatched_angle_bracket_count.into())); self.sess.emit_err(errors::UnmatchedAngle { span, plural: snapshot.unmatched_angle_bracket_count > 1, @@ -531,7 +545,10 @@ impl<'a> Parser<'a> { self.parse_angle_args(ty_generics) } } - Err(e) => Err(e), + Err(e) => { + self.angle_bracket_nesting -= 1; + Err(e) + } } } diff --git a/tests/ui/parser/deep-unmatched-angle-brackets.rs b/tests/ui/parser/deep-unmatched-angle-brackets.rs new file mode 100644 index 00000000000..f8d490e1c5e --- /dev/null +++ b/tests/ui/parser/deep-unmatched-angle-brackets.rs @@ -0,0 +1,17 @@ +trait Mul { + type Output; +} +trait Matrix: Mul<::Row, Output = ()> { + type Row; + type Transpose: Matrix; +} +fn is_mul>() {} +fn f() { + is_mul::(); + //~^ ERROR expected one of `!`, `+`, `,`, `::`, or `>`, found `(` +} +fn main() {} diff --git a/tests/ui/parser/deep-unmatched-angle-brackets.stderr b/tests/ui/parser/deep-unmatched-angle-brackets.stderr new file mode 100644 index 00000000000..1f285037482 --- /dev/null +++ b/tests/ui/parser/deep-unmatched-angle-brackets.stderr @@ -0,0 +1,13 @@ +error: expected one of `!`, `+`, `,`, `::`, or `>`, found `(` + --> $DIR/deep-unmatched-angle-brackets.rs:14:63 + | +LL | (); + | ^ expected one of `!`, `+`, `,`, `::`, or `>` + | +help: you might have meant to end the type parameters here + | +LL | >(); + | + + +error: aborting due to previous error + -- cgit 1.4.1-3-g733a5 From e4c41b07f0b7fd15e19818b3349bb4bf726342d2 Mon Sep 17 00:00:00 2001 From: Kirby Linvill Date: Mon, 23 Oct 2023 18:07:07 +0100 Subject: Add arg_count field to Body in Stable MIR This field allows SMIR consumers to identify which locals correspond to argument locals. It simply exposes the arg_count field from the MIR representation. --- compiler/rustc_smir/src/rustc_smir/mod.rs | 1 + compiler/stable_mir/src/mir/body.rs | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/compiler/rustc_smir/src/rustc_smir/mod.rs b/compiler/rustc_smir/src/rustc_smir/mod.rs index e772ae942fa..86f3c7c2e3f 100644 --- a/compiler/rustc_smir/src/rustc_smir/mod.rs +++ b/compiler/rustc_smir/src/rustc_smir/mod.rs @@ -308,6 +308,7 @@ impl<'tcx> Stable<'tcx> for mir::Body<'tcx> { span: decl.source_info.span.stable(tables), }) .collect(), + arg_count: self.arg_count, } } } diff --git a/compiler/stable_mir/src/mir/body.rs b/compiler/stable_mir/src/mir/body.rs index fc617513aee..34dff7a6214 100644 --- a/compiler/stable_mir/src/mir/body.rs +++ b/compiler/stable_mir/src/mir/body.rs @@ -2,10 +2,20 @@ use crate::ty::{AdtDef, ClosureDef, Const, CoroutineDef, GenericArgs, Movability use crate::Opaque; use crate::{ty::Ty, Span}; +/// The SMIR representation of a single function. #[derive(Clone, Debug)] pub struct Body { pub blocks: Vec, + + /// Declarations of locals. + /// + /// The first local is the return value pointer, followed by `arg_count` + /// locals for the function arguments, followed by any user-declared + /// variables and temporaries. pub locals: LocalDecls, + + /// The number of arguments this function takes. + pub arg_count: usize, } type LocalDecls = Vec; -- cgit 1.4.1-3-g733a5 From 93d1b3e92a1cd19e1609a4755a68b62e8f528707 Mon Sep 17 00:00:00 2001 From: Kirby Linvill Date: Wed, 25 Oct 2023 10:21:47 +0100 Subject: Replace arg_count in public API with return/arg getters This commit hides the arg_count field in Body and instead exposes more stable and user-friendly methods to get the return and argument locals. As a result, Body instances must now be constructed using the `new` function. --- compiler/rustc_smir/src/rustc_smir/mod.rs | 12 ++++------ compiler/stable_mir/src/mir/body.rs | 38 ++++++++++++++++++++++++++----- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/compiler/rustc_smir/src/rustc_smir/mod.rs b/compiler/rustc_smir/src/rustc_smir/mod.rs index 86f3c7c2e3f..1eb8b0ca406 100644 --- a/compiler/rustc_smir/src/rustc_smir/mod.rs +++ b/compiler/rustc_smir/src/rustc_smir/mod.rs @@ -287,9 +287,8 @@ impl<'tcx> Stable<'tcx> for mir::Body<'tcx> { type T = stable_mir::mir::Body; fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T { - stable_mir::mir::Body { - blocks: self - .basic_blocks + stable_mir::mir::Body::new( + self.basic_blocks .iter() .map(|block| stable_mir::mir::BasicBlock { terminator: block.terminator().stable(tables), @@ -300,16 +299,15 @@ impl<'tcx> Stable<'tcx> for mir::Body<'tcx> { .collect(), }) .collect(), - locals: self - .local_decls + self.local_decls .iter() .map(|decl| stable_mir::mir::LocalDecl { ty: decl.ty.stable(tables), span: decl.source_info.span.stable(tables), }) .collect(), - arg_count: self.arg_count, - } + self.arg_count, + ) } } diff --git a/compiler/stable_mir/src/mir/body.rs b/compiler/stable_mir/src/mir/body.rs index 34dff7a6214..8cdc9614db6 100644 --- a/compiler/stable_mir/src/mir/body.rs +++ b/compiler/stable_mir/src/mir/body.rs @@ -8,14 +8,40 @@ pub struct Body { pub blocks: Vec, /// Declarations of locals. - /// - /// The first local is the return value pointer, followed by `arg_count` - /// locals for the function arguments, followed by any user-declared - /// variables and temporaries. + // + // The first local is the return value pointer, followed by `arg_count` + // locals for the function arguments, followed by any user-declared + // variables and temporaries. pub locals: LocalDecls, - /// The number of arguments this function takes. - pub arg_count: usize, + // The number of arguments this function takes. + arg_count: usize, +} + +impl Body { + /// Constructs a `Body`. + /// + /// A constructor is required to build a `Body` from outside the crate + /// because the `arg_count` field is private. + pub fn new(blocks: Vec, locals: LocalDecls, arg_count: usize) -> Self { + // If locals doesn't contain enough entries, it can lead to panics in + // `ret_local` and `arg_locals`. + assert!( + locals.len() >= arg_count + 1, + "A Body must contain at least a local for the return value and each of the function's arguments" + ); + Self { blocks, locals, arg_count } + } + + /// Gets the function's return local. + pub fn ret_local(&self) -> &LocalDecl { + &self.locals[0] + } + + /// Gets the locals in `self` that correspond to the function's arguments. + pub fn arg_locals(&self) -> &[LocalDecl] { + &self.locals[1..self.arg_count + 1] + } } type LocalDecls = Vec; -- cgit 1.4.1-3-g733a5 From f4d80a5f09afcbe0bd80147a0685be1dfaf81acd Mon Sep 17 00:00:00 2001 From: Kirby Linvill Date: Wed, 25 Oct 2023 16:51:18 +0100 Subject: Add public API to retrieve internal locals --- compiler/stable_mir/src/mir/body.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/compiler/stable_mir/src/mir/body.rs b/compiler/stable_mir/src/mir/body.rs index 8cdc9614db6..f76ad87584f 100644 --- a/compiler/stable_mir/src/mir/body.rs +++ b/compiler/stable_mir/src/mir/body.rs @@ -33,15 +33,21 @@ impl Body { Self { blocks, locals, arg_count } } - /// Gets the function's return local. + /// Return local that holds this function's return value. pub fn ret_local(&self) -> &LocalDecl { &self.locals[0] } - /// Gets the locals in `self` that correspond to the function's arguments. + /// Locals in `self` that correspond to this function's arguments. pub fn arg_locals(&self) -> &[LocalDecl] { &self.locals[1..self.arg_count + 1] } + + /// Internal locals for this function. These are the locals that are + /// neither the return local nor the argument locals. + pub fn internal_locals(&self) -> &[LocalDecl] { + &self.locals[self.arg_count + 1..] + } } type LocalDecls = Vec; -- cgit 1.4.1-3-g733a5 From 372c5335327f330858b03889a46614d2a248d325 Mon Sep 17 00:00:00 2001 From: Kirby Linvill Date: Wed, 25 Oct 2023 21:28:18 +0100 Subject: Make locals field private --- compiler/stable_mir/src/mir/body.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/stable_mir/src/mir/body.rs b/compiler/stable_mir/src/mir/body.rs index f76ad87584f..dc472b3786c 100644 --- a/compiler/stable_mir/src/mir/body.rs +++ b/compiler/stable_mir/src/mir/body.rs @@ -7,12 +7,12 @@ use crate::{ty::Ty, Span}; pub struct Body { pub blocks: Vec, - /// Declarations of locals. + // Declarations of locals within the function. // // The first local is the return value pointer, followed by `arg_count` // locals for the function arguments, followed by any user-declared // variables and temporaries. - pub locals: LocalDecls, + locals: LocalDecls, // The number of arguments this function takes. arg_count: usize, @@ -22,12 +22,12 @@ impl Body { /// Constructs a `Body`. /// /// A constructor is required to build a `Body` from outside the crate - /// because the `arg_count` field is private. + /// because the `arg_count` and `locals` fields are private. pub fn new(blocks: Vec, locals: LocalDecls, arg_count: usize) -> Self { // If locals doesn't contain enough entries, it can lead to panics in - // `ret_local` and `arg_locals`. + // `ret_local`, `arg_locals`, and `internal_locals`. assert!( - locals.len() >= arg_count + 1, + locals.len() > arg_count, "A Body must contain at least a local for the return value and each of the function's arguments" ); Self { blocks, locals, arg_count } -- cgit 1.4.1-3-g733a5 From 39b293fb5a68081e7c050ed2805c8e3404c9763a Mon Sep 17 00:00:00 2001 From: Kirby Linvill Date: Wed, 25 Oct 2023 22:09:12 +0100 Subject: Add a public API to get all body locals This is particularly helpful for the ui tests, but also could be helpful for Stable MIR users who just want all the locals without needing to concatenate responses --- compiler/stable_mir/src/mir/body.rs | 8 ++++++++ tests/ui-fulldeps/stable-mir/check_instance.rs | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/compiler/stable_mir/src/mir/body.rs b/compiler/stable_mir/src/mir/body.rs index dc472b3786c..97dd649bf64 100644 --- a/compiler/stable_mir/src/mir/body.rs +++ b/compiler/stable_mir/src/mir/body.rs @@ -48,6 +48,14 @@ impl Body { pub fn internal_locals(&self) -> &[LocalDecl] { &self.locals[self.arg_count + 1..] } + + /// Convenience function to get all the locals in this function. + /// + /// Locals are typically accessed via the more specific methods `ret_local`, + /// `arg_locals`, and `internal_locals`. + pub fn locals(&self) -> &[LocalDecl] { + &self.locals + } } type LocalDecls = Vec; diff --git a/tests/ui-fulldeps/stable-mir/check_instance.rs b/tests/ui-fulldeps/stable-mir/check_instance.rs index ee82bc77aed..29d88b31e77 100644 --- a/tests/ui-fulldeps/stable-mir/check_instance.rs +++ b/tests/ui-fulldeps/stable-mir/check_instance.rs @@ -59,7 +59,7 @@ fn test_body(body: mir::Body) { for term in body.blocks.iter().map(|bb| &bb.terminator) { match &term.kind { Call { func, .. } => { - let TyKind::RigidTy(ty) = func.ty(&body.locals).kind() else { unreachable!() }; + let TyKind::RigidTy(ty) = func.ty(&body.locals()).kind() else { unreachable!() }; let RigidTy::FnDef(def, args) = ty else { unreachable!() }; let result = Instance::resolve(def, &args); assert!(result.is_ok()); -- cgit 1.4.1-3-g733a5 From 72e8690c0495d9ba48e27e66f824c6bdcdb1664c Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 24 Oct 2023 16:19:28 +1100 Subject: Remove unused `never_type` feature. --- compiler/rustc_incremental/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/compiler/rustc_incremental/src/lib.rs b/compiler/rustc_incremental/src/lib.rs index bdae07a3946..1e8bb2c4045 100644 --- a/compiler/rustc_incremental/src/lib.rs +++ b/compiler/rustc_incremental/src/lib.rs @@ -5,7 +5,6 @@ #![cfg_attr(not(bootstrap), doc(rust_logo))] #![cfg_attr(not(bootstrap), feature(rustdoc_internals))] #![cfg_attr(not(bootstrap), allow(internal_features))] -#![feature(never_type)] #![recursion_limit = "256"] #![deny(rustc::untranslatable_diagnostic)] #![deny(rustc::diagnostic_outside_of_impl)] -- cgit 1.4.1-3-g733a5 From ca29c272e7ab8535e1870a967a6d990c85227585 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 24 Oct 2023 16:34:03 +1100 Subject: Reduce exposure of three functions used only within `rustc_incremental`. --- compiler/rustc_incremental/src/lib.rs | 3 --- compiler/rustc_incremental/src/persist/fs.rs | 4 ++-- compiler/rustc_incremental/src/persist/mod.rs | 3 --- compiler/rustc_incremental/src/persist/work_product.rs | 2 +- 4 files changed, 3 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_incremental/src/lib.rs b/compiler/rustc_incremental/src/lib.rs index 1e8bb2c4045..e1c5e6e8d36 100644 --- a/compiler/rustc_incremental/src/lib.rs +++ b/compiler/rustc_incremental/src/lib.rs @@ -20,13 +20,10 @@ mod persist; use assert_dep_graph::assert_dep_graph; pub use persist::copy_cgu_workproduct_to_incr_comp_cache_dir; -pub use persist::delete_workproduct_files; pub use persist::finalize_session_directory; -pub use persist::garbage_collect_session_directories; pub use persist::in_incr_comp_dir; pub use persist::in_incr_comp_dir_sess; pub use persist::load_query_result_cache; -pub use persist::prepare_session_directory; pub use persist::save_dep_graph; pub use persist::save_work_product_index; pub use persist::setup_dep_graph; diff --git a/compiler/rustc_incremental/src/persist/fs.rs b/compiler/rustc_incremental/src/persist/fs.rs index db8ea2bfe48..ecae79cbd21 100644 --- a/compiler/rustc_incremental/src/persist/fs.rs +++ b/compiler/rustc_incremental/src/persist/fs.rs @@ -202,7 +202,7 @@ pub fn in_incr_comp_dir(incr_comp_session_dir: &Path, file_name: &str) -> PathBu /// The garbage collection will take care of it. /// /// [`rustc_interface::queries::dep_graph`]: ../../rustc_interface/struct.Queries.html#structfield.dep_graph -pub fn prepare_session_directory( +pub(crate) fn prepare_session_directory( sess: &Session, crate_name: Symbol, stable_crate_id: StableCrateId, @@ -621,7 +621,7 @@ fn is_old_enough_to_be_collected(timestamp: SystemTime) -> bool { } /// Runs garbage collection for the current session. -pub fn garbage_collect_session_directories(sess: &Session) -> io::Result<()> { +pub(crate) fn garbage_collect_session_directories(sess: &Session) -> io::Result<()> { debug!("garbage_collect_session_directories() - begin"); let session_directory = sess.incr_comp_session_dir(); diff --git a/compiler/rustc_incremental/src/persist/mod.rs b/compiler/rustc_incremental/src/persist/mod.rs index fdecaca5a2d..94c05f4a2c8 100644 --- a/compiler/rustc_incremental/src/persist/mod.rs +++ b/compiler/rustc_incremental/src/persist/mod.rs @@ -11,14 +11,11 @@ mod save; mod work_product; pub use fs::finalize_session_directory; -pub use fs::garbage_collect_session_directories; pub use fs::in_incr_comp_dir; pub use fs::in_incr_comp_dir_sess; -pub use fs::prepare_session_directory; pub use load::load_query_result_cache; pub use load::setup_dep_graph; pub use load::LoadResult; pub use save::save_dep_graph; pub use save::save_work_product_index; pub use work_product::copy_cgu_workproduct_to_incr_comp_cache_dir; -pub use work_product::delete_workproduct_files; diff --git a/compiler/rustc_incremental/src/persist/work_product.rs b/compiler/rustc_incremental/src/persist/work_product.rs index bce5ca1e16b..6be35a4a8dc 100644 --- a/compiler/rustc_incremental/src/persist/work_product.rs +++ b/compiler/rustc_incremental/src/persist/work_product.rs @@ -45,7 +45,7 @@ pub fn copy_cgu_workproduct_to_incr_comp_cache_dir( } /// Removes files for a given work product. -pub fn delete_workproduct_files(sess: &Session, work_product: &WorkProduct) { +pub(crate) fn delete_workproduct_files(sess: &Session, work_product: &WorkProduct) { for (_, path) in work_product.saved_files.items().into_sorted_stable_ord() { let path = in_incr_comp_dir_sess(sess, path); if let Err(err) = std_fs::remove_file(&path) { -- cgit 1.4.1-3-g733a5 From 8da1b3315343bb9b77c17e6f8533fbc59af67315 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 24 Oct 2023 16:37:30 +1100 Subject: Move a `use` to a more sensible spot. I.e. in the source file where it's used. --- compiler/rustc_incremental/src/lib.rs | 1 - compiler/rustc_incremental/src/persist/save.rs | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_incremental/src/lib.rs b/compiler/rustc_incremental/src/lib.rs index e1c5e6e8d36..dde138973b9 100644 --- a/compiler/rustc_incremental/src/lib.rs +++ b/compiler/rustc_incremental/src/lib.rs @@ -18,7 +18,6 @@ mod assert_dep_graph; mod errors; mod persist; -use assert_dep_graph::assert_dep_graph; pub use persist::copy_cgu_workproduct_to_incr_comp_cache_dir; pub use persist::finalize_session_directory; pub use persist::in_incr_comp_dir; diff --git a/compiler/rustc_incremental/src/persist/save.rs b/compiler/rustc_incremental/src/persist/save.rs index 210da751d95..fa21320be26 100644 --- a/compiler/rustc_incremental/src/persist/save.rs +++ b/compiler/rustc_incremental/src/persist/save.rs @@ -1,3 +1,4 @@ +use crate::assert_dep_graph::assert_dep_graph; use crate::errors; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::sync::join; @@ -39,7 +40,7 @@ pub fn save_dep_graph(tcx: TyCtxt<'_>) { let dep_graph_path = dep_graph_path(sess); let staging_dep_graph_path = staging_dep_graph_path(sess); - sess.time("assert_dep_graph", || crate::assert_dep_graph(tcx)); + sess.time("assert_dep_graph", || assert_dep_graph(tcx)); sess.time("check_dirty_clean", || dirty_clean::check_dirty_clean_annotations(tcx)); if sess.opts.unstable_opts.incremental_info { -- cgit 1.4.1-3-g733a5 From 3cf2a7441fcefa659f332b67413cc79ee5a8ac1d Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 26 Oct 2023 08:39:49 +1100 Subject: Tiny comment fixes. --- compiler/rustc_incremental/src/persist/fs.rs | 2 +- compiler/rustc_incremental/src/persist/load.rs | 2 +- compiler/rustc_incremental/src/persist/work_product.rs | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_incremental/src/persist/fs.rs b/compiler/rustc_incremental/src/persist/fs.rs index ecae79cbd21..6d565b6d3e4 100644 --- a/compiler/rustc_incremental/src/persist/fs.rs +++ b/compiler/rustc_incremental/src/persist/fs.rs @@ -53,7 +53,7 @@ //! ## Synchronization //! //! There is some synchronization needed in order for the compiler to be able to -//! determine whether a given private session directory is not in used any more. +//! determine whether a given private session directory is not in use any more. //! This is done by creating a lock file for each session directory and //! locking it while the directory is still being used. Since file locks have //! operating system support, we can rely on the lock being released if the diff --git a/compiler/rustc_incremental/src/persist/load.rs b/compiler/rustc_incremental/src/persist/load.rs index 2310d0b12ef..cbd55fe4205 100644 --- a/compiler/rustc_incremental/src/persist/load.rs +++ b/compiler/rustc_incremental/src/persist/load.rs @@ -1,4 +1,4 @@ -//! Code to save/load the dep-graph from files. +//! Code to load the dep-graph from files. use crate::errors; use rustc_data_structures::memmap::Mmap; diff --git a/compiler/rustc_incremental/src/persist/work_product.rs b/compiler/rustc_incremental/src/persist/work_product.rs index 6be35a4a8dc..fb96bed5a71 100644 --- a/compiler/rustc_incremental/src/persist/work_product.rs +++ b/compiler/rustc_incremental/src/persist/work_product.rs @@ -11,7 +11,8 @@ use rustc_session::Session; use std::fs as std_fs; use std::path::Path; -/// Copies a CGU work product to the incremental compilation directory, so next compilation can find and reuse it. +/// Copies a CGU work product to the incremental compilation directory, so next compilation can +/// find and reuse it. pub fn copy_cgu_workproduct_to_incr_comp_cache_dir( sess: &Session, cgu_name: &str, -- cgit 1.4.1-3-g733a5 From e0c990e32c1fd061e7889703a2c0f6499e7c477d Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 26 Oct 2023 08:46:03 +1100 Subject: Reduce some function exposure. --- compiler/rustc_incremental/src/persist/fs.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_incremental/src/persist/fs.rs b/compiler/rustc_incremental/src/persist/fs.rs index 6d565b6d3e4..f56fb0d0534 100644 --- a/compiler/rustc_incremental/src/persist/fs.rs +++ b/compiler/rustc_incremental/src/persist/fs.rs @@ -136,26 +136,29 @@ const QUERY_CACHE_FILENAME: &str = "query-cache.bin"; const INT_ENCODE_BASE: usize = base_n::CASE_INSENSITIVE; /// Returns the path to a session's dependency graph. -pub fn dep_graph_path(sess: &Session) -> PathBuf { +pub(crate) fn dep_graph_path(sess: &Session) -> PathBuf { in_incr_comp_dir_sess(sess, DEP_GRAPH_FILENAME) } + /// Returns the path to a session's staging dependency graph. /// /// On the difference between dep-graph and staging dep-graph, /// see `build_dep_graph`. -pub fn staging_dep_graph_path(sess: &Session) -> PathBuf { +pub(crate) fn staging_dep_graph_path(sess: &Session) -> PathBuf { in_incr_comp_dir_sess(sess, STAGING_DEP_GRAPH_FILENAME) } -pub fn work_products_path(sess: &Session) -> PathBuf { + +pub(crate) fn work_products_path(sess: &Session) -> PathBuf { in_incr_comp_dir_sess(sess, WORK_PRODUCTS_FILENAME) } + /// Returns the path to a session's query cache. pub fn query_cache_path(sess: &Session) -> PathBuf { in_incr_comp_dir_sess(sess, QUERY_CACHE_FILENAME) } /// Locks a given session directory. -pub fn lock_file_path(session_dir: &Path) -> PathBuf { +fn lock_file_path(session_dir: &Path) -> PathBuf { let crate_dir = session_dir.parent().unwrap(); let directory_name = session_dir.file_name().unwrap().to_string_lossy(); @@ -373,7 +376,7 @@ pub fn finalize_session_directory(sess: &Session, svh: Option) { let _ = garbage_collect_session_directories(sess); } -pub fn delete_all_session_dir_contents(sess: &Session) -> io::Result<()> { +pub(crate) fn delete_all_session_dir_contents(sess: &Session) -> io::Result<()> { let sess_dir_iterator = sess.incr_comp_session_dir().read_dir()?; for entry in sess_dir_iterator { let entry = entry?; -- cgit 1.4.1-3-g733a5 From fe4dfb814b68bb03468736c5c0632f6495ea855e Mon Sep 17 00:00:00 2001 From: Kirby Linvill Date: Thu, 26 Oct 2023 00:18:42 +0100 Subject: Rename internal_locals to inner_locals The word internal has connotations about information that's not exposed. It's more accurate to say that the remaining locals apply only to the inner part of the function, so I'm renaming them to inner locals. --- compiler/stable_mir/src/mir/body.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/stable_mir/src/mir/body.rs b/compiler/stable_mir/src/mir/body.rs index 97dd649bf64..75c988056b4 100644 --- a/compiler/stable_mir/src/mir/body.rs +++ b/compiler/stable_mir/src/mir/body.rs @@ -25,7 +25,7 @@ impl Body { /// because the `arg_count` and `locals` fields are private. pub fn new(blocks: Vec, locals: LocalDecls, arg_count: usize) -> Self { // If locals doesn't contain enough entries, it can lead to panics in - // `ret_local`, `arg_locals`, and `internal_locals`. + // `ret_local`, `arg_locals`, and `inner_locals`. assert!( locals.len() > arg_count, "A Body must contain at least a local for the return value and each of the function's arguments" @@ -43,16 +43,16 @@ impl Body { &self.locals[1..self.arg_count + 1] } - /// Internal locals for this function. These are the locals that are + /// Inner locals for this function. These are the locals that are /// neither the return local nor the argument locals. - pub fn internal_locals(&self) -> &[LocalDecl] { + pub fn inner_locals(&self) -> &[LocalDecl] { &self.locals[self.arg_count + 1..] } /// Convenience function to get all the locals in this function. /// /// Locals are typically accessed via the more specific methods `ret_local`, - /// `arg_locals`, and `internal_locals`. + /// `arg_locals`, and `inner_locals`. pub fn locals(&self) -> &[LocalDecl] { &self.locals } -- cgit 1.4.1-3-g733a5 From 4b23bd47348a6325ee332e48b9d16e1b65d1c500 Mon Sep 17 00:00:00 2001 From: Kirby Linvill Date: Thu, 26 Oct 2023 00:21:28 +0100 Subject: Update Place and Operand to take slices The latest locals() method in stable MIR returns slices instead of vecs. This commit also includes fixes to the existing tests that previously referenced the private locals field. --- compiler/stable_mir/src/mir/body.rs | 4 ++-- tests/ui-fulldeps/stable-mir/check_instance.rs | 2 +- tests/ui-fulldeps/stable-mir/crate-info.rs | 22 +++++++++++----------- tests/ui-fulldeps/stable-mir/smir_internal.rs | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/compiler/stable_mir/src/mir/body.rs b/compiler/stable_mir/src/mir/body.rs index 75c988056b4..8081def1479 100644 --- a/compiler/stable_mir/src/mir/body.rs +++ b/compiler/stable_mir/src/mir/body.rs @@ -517,7 +517,7 @@ pub enum NullOp { } impl Operand { - pub fn ty(&self, locals: &LocalDecls) -> Ty { + pub fn ty(&self, locals: &[LocalDecl]) -> Ty { match self { Operand::Copy(place) | Operand::Move(place) => place.ty(locals), Operand::Constant(c) => c.ty(), @@ -532,7 +532,7 @@ impl Constant { } impl Place { - pub fn ty(&self, locals: &LocalDecls) -> Ty { + pub fn ty(&self, locals: &[LocalDecl]) -> Ty { let _start_ty = locals[self.local].ty; todo!("Implement projection") } diff --git a/tests/ui-fulldeps/stable-mir/check_instance.rs b/tests/ui-fulldeps/stable-mir/check_instance.rs index 29d88b31e77..a340877752d 100644 --- a/tests/ui-fulldeps/stable-mir/check_instance.rs +++ b/tests/ui-fulldeps/stable-mir/check_instance.rs @@ -59,7 +59,7 @@ fn test_body(body: mir::Body) { for term in body.blocks.iter().map(|bb| &bb.terminator) { match &term.kind { Call { func, .. } => { - let TyKind::RigidTy(ty) = func.ty(&body.locals()).kind() else { unreachable!() }; + let TyKind::RigidTy(ty) = func.ty(body.locals()).kind() else { unreachable!() }; let RigidTy::FnDef(def, args) = ty else { unreachable!() }; let result = Instance::resolve(def, &args); assert!(result.is_ok()); diff --git a/tests/ui-fulldeps/stable-mir/crate-info.rs b/tests/ui-fulldeps/stable-mir/crate-info.rs index 60c6053d295..33673cd131f 100644 --- a/tests/ui-fulldeps/stable-mir/crate-info.rs +++ b/tests/ui-fulldeps/stable-mir/crate-info.rs @@ -47,7 +47,7 @@ fn test_stable_mir(_tcx: TyCtxt<'_>) -> ControlFlow<()> { let bar = get_item(&items, (DefKind::Fn, "bar")).unwrap(); let body = bar.body(); - assert_eq!(body.locals.len(), 2); + assert_eq!(body.locals().len(), 2); assert_eq!(body.blocks.len(), 1); let block = &body.blocks[0]; assert_eq!(block.statements.len(), 1); @@ -62,7 +62,7 @@ fn test_stable_mir(_tcx: TyCtxt<'_>) -> ControlFlow<()> { let foo_bar = get_item(&items, (DefKind::Fn, "foo_bar")).unwrap(); let body = foo_bar.body(); - assert_eq!(body.locals.len(), 5); + assert_eq!(body.locals().len(), 5); assert_eq!(body.blocks.len(), 4); let block = &body.blocks[0]; match &block.terminator.kind { @@ -72,29 +72,29 @@ fn test_stable_mir(_tcx: TyCtxt<'_>) -> ControlFlow<()> { let types = get_item(&items, (DefKind::Fn, "types")).unwrap(); let body = types.body(); - assert_eq!(body.locals.len(), 6); + assert_eq!(body.locals().len(), 6); assert_matches!( - body.locals[0].ty.kind(), + body.locals()[0].ty.kind(), stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Bool) ); assert_matches!( - body.locals[1].ty.kind(), + body.locals()[1].ty.kind(), stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Bool) ); assert_matches!( - body.locals[2].ty.kind(), + body.locals()[2].ty.kind(), stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Char) ); assert_matches!( - body.locals[3].ty.kind(), + body.locals()[3].ty.kind(), stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Int(stable_mir::ty::IntTy::I32)) ); assert_matches!( - body.locals[4].ty.kind(), + body.locals()[4].ty.kind(), stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Uint(stable_mir::ty::UintTy::U64)) ); assert_matches!( - body.locals[5].ty.kind(), + body.locals()[5].ty.kind(), stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Float( stable_mir::ty::FloatTy::F64 )) @@ -123,10 +123,10 @@ fn test_stable_mir(_tcx: TyCtxt<'_>) -> ControlFlow<()> { for block in instance.body().blocks { match &block.terminator.kind { stable_mir::mir::TerminatorKind::Call { func, .. } => { - let TyKind::RigidTy(ty) = func.ty(&body.locals).kind() else { unreachable!() }; + let TyKind::RigidTy(ty) = func.ty(&body.locals()).kind() else { unreachable!() }; let RigidTy::FnDef(def, args) = ty else { unreachable!() }; let next_func = Instance::resolve(def, &args).unwrap(); - match next_func.body().locals[1].ty.kind() { + match next_func.body().locals()[1].ty.kind() { TyKind::RigidTy(RigidTy::Uint(_)) | TyKind::RigidTy(RigidTy::Tuple(_)) => {} other => panic!("{other:?}"), } diff --git a/tests/ui-fulldeps/stable-mir/smir_internal.rs b/tests/ui-fulldeps/stable-mir/smir_internal.rs index 5ad05559cb4..b0596b18823 100644 --- a/tests/ui-fulldeps/stable-mir/smir_internal.rs +++ b/tests/ui-fulldeps/stable-mir/smir_internal.rs @@ -29,7 +29,7 @@ const CRATE_NAME: &str = "input"; fn test_translation(_tcx: TyCtxt<'_>) -> ControlFlow<()> { let main_fn = stable_mir::entry_fn().unwrap(); let body = main_fn.body(); - let orig_ty = body.locals[0].ty; + let orig_ty = body.locals()[0].ty; let rustc_ty = rustc_internal::internal(&orig_ty); assert!(rustc_ty.is_unit()); ControlFlow::Continue(()) -- cgit 1.4.1-3-g733a5 From bac7d5b52cc60754e0555f96c3501e1531bbf6fe Mon Sep 17 00:00:00 2001 From: Kirby Linvill Date: Thu, 26 Oct 2023 00:22:56 +0100 Subject: Add test for smir locals --- tests/ui-fulldeps/stable-mir/crate-info.rs | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/ui-fulldeps/stable-mir/crate-info.rs b/tests/ui-fulldeps/stable-mir/crate-info.rs index 33673cd131f..ed6b786f5e1 100644 --- a/tests/ui-fulldeps/stable-mir/crate-info.rs +++ b/tests/ui-fulldeps/stable-mir/crate-info.rs @@ -140,6 +140,29 @@ fn test_stable_mir(_tcx: TyCtxt<'_>) -> ControlFlow<()> { // Ensure we don't panic trying to get the body of a constant. foo_const.body(); + let locals_fn = get_item(&items, (DefKind::Fn, "locals")).unwrap(); + let body = locals_fn.body(); + assert_eq!(body.locals().len(), 4); + assert_matches!( + body.ret_local().ty.kind(), + stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Char) + ); + assert_eq!(body.arg_locals().len(), 2); + assert_matches!( + body.arg_locals()[0].ty.kind(), + stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Int(stable_mir::ty::IntTy::I32)) + ); + assert_matches!( + body.arg_locals()[1].ty.kind(), + stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Uint(stable_mir::ty::UintTy::U64)) + ); + assert_eq!(body.inner_locals().len(), 1); + // If conditions have an extra inner local to hold their results + assert_matches!( + body.inner_locals()[0].ty.kind(), + stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Bool) + ); + ControlFlow::Continue(()) } @@ -211,6 +234,14 @@ fn generate_input(path: &str) -> std::io::Result<()> { pub fn assert(x: i32) -> i32 {{ x + 1 + }} + + pub fn locals(a: i32, _: u64) -> char {{ + if a > 5 {{ + 'a' + }} else {{ + 'b' + }} }}"# )?; Ok(()) -- cgit 1.4.1-3-g733a5 From 9f5fc0283cedc2cbae3727764b451098a7e98071 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Wed, 25 Oct 2023 14:36:13 +1100 Subject: The value of `-Cinstrument-coverage=` doesn't need to be `Option` Not using this flag is identical to passing `-Cinstrument-coverage=off`, so there's no need to distinguish between `None` and `Some(Off)`. --- compiler/rustc_interface/src/tests.rs | 2 +- compiler/rustc_session/src/config.rs | 12 +++++------- compiler/rustc_session/src/options.rs | 18 +++++++++--------- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index 657bce7384b..d625a6b1a2c 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -612,7 +612,7 @@ fn test_codegen_options_tracking_hash() { tracked!(force_frame_pointers, Some(false)); tracked!(force_unwind_tables, Some(true)); tracked!(inline_threshold, Some(0xf007ba11)); - tracked!(instrument_coverage, Some(InstrumentCoverage::All)); + tracked!(instrument_coverage, InstrumentCoverage::All); tracked!(link_dead_code, Some(true)); tracked!(linker_plugin_lto, LinkerPluginLto::LinkerPluginAuto); tracked!(llvm_args, vec![String::from("1"), String::from("2")]); diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 78e410488c3..7aced414ed6 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -2743,13 +2743,11 @@ pub fn build_session_options( // This is what prevents them from being used on stable compilers. match cg.instrument_coverage { // Stable values: - Some(InstrumentCoverage::All | InstrumentCoverage::Off) | None => {} + InstrumentCoverage::All | InstrumentCoverage::Off => {} // Unstable values: - Some( - InstrumentCoverage::Branch - | InstrumentCoverage::ExceptUnusedFunctions - | InstrumentCoverage::ExceptUnusedGenerics, - ) => { + InstrumentCoverage::Branch + | InstrumentCoverage::ExceptUnusedFunctions + | InstrumentCoverage::ExceptUnusedGenerics => { if !unstable_opts.unstable_options { handler.early_error( "`-C instrument-coverage=branch` and `-C instrument-coverage=except-*` \ @@ -2759,7 +2757,7 @@ pub fn build_session_options( } } - if cg.instrument_coverage.is_some() && cg.instrument_coverage != Some(InstrumentCoverage::Off) { + if cg.instrument_coverage != InstrumentCoverage::Off { if cg.profile_generate.enabled() || cg.profile_use.is_some() { handler.early_error( "option `-C instrument-coverage` is not compatible with either `-C profile-use` \ diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 35c167837e5..fd473acbd3c 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -294,7 +294,7 @@ impl CodegenOptions { // JUSTIFICATION: defn of the suggested wrapper fn #[allow(rustc::bad_opt_access)] pub fn instrument_coverage(&self) -> InstrumentCoverage { - self.instrument_coverage.unwrap_or(InstrumentCoverage::Off) + self.instrument_coverage } } @@ -913,23 +913,23 @@ mod parse { } pub(crate) fn parse_instrument_coverage( - slot: &mut Option, + slot: &mut InstrumentCoverage, v: Option<&str>, ) -> bool { if v.is_some() { - let mut bool_arg = None; - if parse_opt_bool(&mut bool_arg, v) { - *slot = bool_arg.unwrap().then_some(InstrumentCoverage::All); + let mut bool_arg = false; + if parse_bool(&mut bool_arg, v) { + *slot = if bool_arg { InstrumentCoverage::All } else { InstrumentCoverage::Off }; return true; } } let Some(v) = v else { - *slot = Some(InstrumentCoverage::All); + *slot = InstrumentCoverage::All; return true; }; - *slot = Some(match v { + *slot = match v { "all" => InstrumentCoverage::All, "branch" => InstrumentCoverage::Branch, "except-unused-generics" | "except_unused_generics" => { @@ -940,7 +940,7 @@ mod parse { } "off" | "no" | "n" | "false" | "0" => InstrumentCoverage::Off, _ => return false, - }); + }; true } @@ -1352,7 +1352,7 @@ options! { inline_threshold: Option = (None, parse_opt_number, [TRACKED], "set the threshold for inlining a function"), #[rustc_lint_opt_deny_field_access("use `Session::instrument_coverage` instead of this field")] - instrument_coverage: Option = (None, parse_instrument_coverage, [TRACKED], + instrument_coverage: InstrumentCoverage = (InstrumentCoverage::Off, parse_instrument_coverage, [TRACKED], "instrument the generated code to support LLVM source-based code coverage \ reports (note, the compiler build config must include `profiler = true`); \ implies `-C symbol-mangling-version=v0`. Optional values are: -- cgit 1.4.1-3-g733a5 From ab7f64c788d627d9fbe4119ad5e6f58eeb4da48c Mon Sep 17 00:00:00 2001 From: Takayuki Maeda Date: Thu, 26 Oct 2023 11:52:45 +0900 Subject: Revert "Remove TaKO8Ki from reviewers" This reverts commit 8e06b25e3900b8b14d9043ff6d2b846199672b2b. --- triagebot.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/triagebot.toml b/triagebot.toml index e3c4233c843..7cac74c2c4f 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -625,6 +625,7 @@ compiler-team = [ compiler-team-contributors = [ "@compiler-errors", "@jackh726", + "@TaKO8Ki", "@WaffleLapkin", "@b-naber", ] @@ -671,6 +672,7 @@ diagnostics = [ "@compiler-errors", "@davidtwco", "@oli-obk", + "@TaKO8Ki", ] parser = [ "@compiler-errors", -- cgit 1.4.1-3-g733a5 From d55487d7e9834c8fe01350b5b4fa402423c855d5 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Thu, 26 Oct 2023 12:32:47 +0200 Subject: Use two slice expressions to save on an offset repetition --- compiler/stable_mir/src/mir/body.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/stable_mir/src/mir/body.rs b/compiler/stable_mir/src/mir/body.rs index 8081def1479..d86d56b3dc7 100644 --- a/compiler/stable_mir/src/mir/body.rs +++ b/compiler/stable_mir/src/mir/body.rs @@ -40,7 +40,7 @@ impl Body { /// Locals in `self` that correspond to this function's arguments. pub fn arg_locals(&self) -> &[LocalDecl] { - &self.locals[1..self.arg_count + 1] + &self.locals[1..][..self.arg_count] } /// Inner locals for this function. These are the locals that are -- cgit 1.4.1-3-g733a5 From d572729d59a2812229f39c217246def5f77bd420 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Thu, 26 Oct 2023 11:13:32 +0000 Subject: Quietly fail if an error has already occurred --- .../src/type_check/free_region_relations.rs | 5 ++- tests/ui/lifetimes/issue-76168-hr-outlives-3.rs | 19 ++++++++ .../ui/lifetimes/issue-76168-hr-outlives-3.stderr | 51 ++++++++++++++++++++++ 3 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 tests/ui/lifetimes/issue-76168-hr-outlives-3.rs create mode 100644 tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr diff --git a/compiler/rustc_borrowck/src/type_check/free_region_relations.rs b/compiler/rustc_borrowck/src/type_check/free_region_relations.rs index f22851d76b3..c84256f8ff3 100644 --- a/compiler/rustc_borrowck/src/type_check/free_region_relations.rs +++ b/compiler/rustc_borrowck/src/type_check/free_region_relations.rs @@ -8,7 +8,7 @@ use rustc_infer::infer::InferCtxt; use rustc_middle::mir::ConstraintCategory; use rustc_middle::traits::query::OutlivesBound; use rustc_middle::ty::{self, RegionVid, Ty}; -use rustc_span::{Span, DUMMY_SP}; +use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP}; use rustc_trait_selection::traits::query::type_op::{self, TypeOp}; use std::rc::Rc; use type_op::TypeOpOutput; @@ -318,7 +318,8 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> { .param_env .and(type_op::implied_outlives_bounds::ImpliedOutlivesBounds { ty }) .fully_perform(self.infcx, DUMMY_SP) - .unwrap_or_else(|_| bug!("failed to compute implied bounds {:?}", ty)); + .map_err(|_: ErrorGuaranteed| debug!("failed to compute implied bounds {:?}", ty)) + .ok()?; debug!(?bounds, ?constraints); self.add_outlives_bounds(bounds); constraints diff --git a/tests/ui/lifetimes/issue-76168-hr-outlives-3.rs b/tests/ui/lifetimes/issue-76168-hr-outlives-3.rs new file mode 100644 index 00000000000..081e962028c --- /dev/null +++ b/tests/ui/lifetimes/issue-76168-hr-outlives-3.rs @@ -0,0 +1,19 @@ +// edition:2018 + +#![feature(unboxed_closures)] +use std::future::Future; + +async fn wrapper(f: F) +//~^ ERROR: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32` +//~| ERROR: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32` +//~| ERROR: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32` +where + F:, + for<'a> >::Output: Future + 'a, +{ + //~^ ERROR: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32` + let mut i = 41; + &mut i; +} + +fn main() {} diff --git a/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr b/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr new file mode 100644 index 00000000000..9d8c15d4a6a --- /dev/null +++ b/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr @@ -0,0 +1,51 @@ +error[E0277]: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32` + --> $DIR/issue-76168-hr-outlives-3.rs:6:1 + | +LL | / async fn wrapper(f: F) +LL | | +LL | | +LL | | +LL | | where +LL | | F:, +LL | | for<'a> >::Output: Future + 'a, + | |______________________________________________________________________________^ expected an `FnOnce<(&'a mut i32,)>` closure, found `i32` + | + = help: the trait `for<'a> FnOnce<(&'a mut i32,)>` is not implemented for `i32` + +error[E0277]: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32` + --> $DIR/issue-76168-hr-outlives-3.rs:6:10 + | +LL | async fn wrapper(f: F) + | ^^^^^^^ expected an `FnOnce<(&'a mut i32,)>` closure, found `i32` + | + = help: the trait `for<'a> FnOnce<(&'a mut i32,)>` is not implemented for `i32` + +error[E0277]: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32` + --> $DIR/issue-76168-hr-outlives-3.rs:13:1 + | +LL | / { +LL | | +LL | | let mut i = 41; +LL | | &mut i; +LL | | } + | |_^ expected an `FnOnce<(&'a mut i32,)>` closure, found `i32` + | + = help: the trait `for<'a> FnOnce<(&'a mut i32,)>` is not implemented for `i32` + +error[E0277]: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32` + --> $DIR/issue-76168-hr-outlives-3.rs:6:1 + | +LL | / async fn wrapper(f: F) +LL | | +LL | | +LL | | +LL | | where +LL | | F:, +LL | | for<'a> >::Output: Future + 'a, + | |______________________________________________________________________________^ expected an `FnOnce<(&'a mut i32,)>` closure, found `i32` + | + = help: the trait `for<'a> FnOnce<(&'a mut i32,)>` is not implemented for `i32` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0277`. -- cgit 1.4.1-3-g733a5 From b1b1458233a7464383367e406115caa80c87cb2d Mon Sep 17 00:00:00 2001 From: León Orell Valerian Liehr Date: Thu, 26 Oct 2023 15:18:50 +0200 Subject: Replace type flag HAS_TY_GENERATOR with HAS_TY_COROUTINE --- compiler/rustc_middle/src/ty/flags.rs | 2 +- compiler/rustc_middle/src/ty/visit.rs | 2 +- compiler/rustc_type_ir/src/flags.rs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_middle/src/ty/flags.rs b/compiler/rustc_middle/src/ty/flags.rs index d75315b7ac9..a348e9f608a 100644 --- a/compiler/rustc_middle/src/ty/flags.rs +++ b/compiler/rustc_middle/src/ty/flags.rs @@ -134,7 +134,7 @@ impl FlagComputation { if should_remove_further_specializable { self.flags -= TypeFlags::STILL_FURTHER_SPECIALIZABLE; } - self.add_flags(TypeFlags::HAS_TY_GENERATOR); + self.add_flags(TypeFlags::HAS_TY_COROUTINE); } &ty::Closure(_, args) => { diff --git a/compiler/rustc_middle/src/ty/visit.rs b/compiler/rustc_middle/src/ty/visit.rs index 15de9948644..ab0999b3f19 100644 --- a/compiler/rustc_middle/src/ty/visit.rs +++ b/compiler/rustc_middle/src/ty/visit.rs @@ -48,7 +48,7 @@ pub trait TypeVisitableExt<'tcx>: TypeVisitable> { self.has_type_flags(TypeFlags::HAS_TY_OPAQUE) } fn has_coroutines(&self) -> bool { - self.has_type_flags(TypeFlags::HAS_TY_GENERATOR) + self.has_type_flags(TypeFlags::HAS_TY_COROUTINE) } fn references_error(&self) -> bool { self.has_type_flags(TypeFlags::HAS_ERROR) diff --git a/compiler/rustc_type_ir/src/flags.rs b/compiler/rustc_type_ir/src/flags.rs index 2acb903c217..d5cadd4e83a 100644 --- a/compiler/rustc_type_ir/src/flags.rs +++ b/compiler/rustc_type_ir/src/flags.rs @@ -113,7 +113,7 @@ bitflags! { /// Does this value have `InferConst::Fresh`? const HAS_CT_FRESH = 1 << 22; - /// Does this have `Generator` or `GeneratorWitness`? - const HAS_TY_GENERATOR = 1 << 23; + /// Does this have `Coroutine` or `CoroutineWitness`? + const HAS_TY_COROUTINE = 1 << 23; } } -- cgit 1.4.1-3-g733a5