From dc9732620d21835176638ef7c443e04c708dcfdc Mon Sep 17 00:00:00 2001 From: Coca162 Date: Mon, 27 Feb 2023 13:51:10 +0000 Subject: [PATCH 01/14] Update docs to show [expr; N] can repeat const expr --- library/core/src/primitive_docs.rs | 6 ++++-- library/std/src/primitive_docs.rs | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/library/core/src/primitive_docs.rs b/library/core/src/primitive_docs.rs index d6e9da187e80a..f04963f06afbe 100644 --- a/library/core/src/primitive_docs.rs +++ b/library/core/src/primitive_docs.rs @@ -587,8 +587,10 @@ mod prim_pointer {} /// There are two syntactic forms for creating an array: /// /// * A list with each element, i.e., `[x, y, z]`. -/// * A repeat expression `[x; N]`, which produces an array with `N` copies of `x`. -/// The type of `x` must be [`Copy`]. +/// * A repeat expression `[expr; N]` where `N` is how many times to repeat `expr` in the array. `expr` must either be: +/// +/// * A value of type `Copy` +/// * A `const` value /// /// Note that `[expr; 0]` is allowed, and produces an empty array. /// This will still evaluate `expr`, however, and immediately drop the resulting value, so diff --git a/library/std/src/primitive_docs.rs b/library/std/src/primitive_docs.rs index d6e9da187e80a..f04963f06afbe 100644 --- a/library/std/src/primitive_docs.rs +++ b/library/std/src/primitive_docs.rs @@ -587,8 +587,10 @@ mod prim_pointer {} /// There are two syntactic forms for creating an array: /// /// * A list with each element, i.e., `[x, y, z]`. -/// * A repeat expression `[x; N]`, which produces an array with `N` copies of `x`. -/// The type of `x` must be [`Copy`]. +/// * A repeat expression `[expr; N]` where `N` is how many times to repeat `expr` in the array. `expr` must either be: +/// +/// * A value of type `Copy` +/// * A `const` value /// /// Note that `[expr; 0]` is allowed, and produces an empty array. /// This will still evaluate `expr`, however, and immediately drop the resulting value, so From 22b65fc27594d5f95195ea098bfb0a60d21225d2 Mon Sep 17 00:00:00 2001 From: Coca162 Date: Mon, 27 Feb 2023 15:16:39 +0000 Subject: [PATCH 02/14] Clarify that Copy is a trait in array docs --- library/core/src/primitive_docs.rs | 2 +- library/std/src/primitive_docs.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/core/src/primitive_docs.rs b/library/core/src/primitive_docs.rs index f04963f06afbe..6f78811a186c7 100644 --- a/library/core/src/primitive_docs.rs +++ b/library/core/src/primitive_docs.rs @@ -589,7 +589,7 @@ mod prim_pointer {} /// * A list with each element, i.e., `[x, y, z]`. /// * A repeat expression `[expr; N]` where `N` is how many times to repeat `expr` in the array. `expr` must either be: /// -/// * A value of type `Copy` +/// * A value of a type implementing the [`Copy`] trait /// * A `const` value /// /// Note that `[expr; 0]` is allowed, and produces an empty array. diff --git a/library/std/src/primitive_docs.rs b/library/std/src/primitive_docs.rs index f04963f06afbe..6f78811a186c7 100644 --- a/library/std/src/primitive_docs.rs +++ b/library/std/src/primitive_docs.rs @@ -589,7 +589,7 @@ mod prim_pointer {} /// * A list with each element, i.e., `[x, y, z]`. /// * A repeat expression `[expr; N]` where `N` is how many times to repeat `expr` in the array. `expr` must either be: /// -/// * A value of type `Copy` +/// * A value of a type implementing the [`Copy`] trait /// * A `const` value /// /// Note that `[expr; 0]` is allowed, and produces an empty array. From 48af38fa0c292369f7ce992afe832bb8f023a1f8 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Mon, 27 Feb 2023 10:53:13 -0500 Subject: [PATCH 03/14] Bump rust-installer This brings in rust-lang/rust-installer#123, which enables a larger compression window (8 -> 64MB) amongst other changes to the xz compression settings. The net effect should be smaller compressed tarballs which will decrease bandwidth usage for static.rust-lang.org, download times, and decompression time. This comes at the cost of higher baseline requirements for running rustup to use these files, which we believe should be largely acceptable (running rustc is likely to use at least this much memory) but if we get specific reports we may explore options to decrease impact (e.g., using the gzip tarballs automatically in rustup). --- src/tools/rust-installer | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/rust-installer b/src/tools/rust-installer index 9981e4d1ea6ac..31b4e313213df 160000 --- a/src/tools/rust-installer +++ b/src/tools/rust-installer @@ -1 +1 @@ -Subproject commit 9981e4d1ea6ac0992ff21be5514d4230dc77548b +Subproject commit 31b4e313213dfaf62b2dd13a4da8176990929526 From 8732fcd0c9ced1a8205f7fb10f49f013bf4a2c1f Mon Sep 17 00:00:00 2001 From: rustbot <47979223+rustbot@users.noreply.github.com> Date: Mon, 27 Feb 2023 12:00:26 -0500 Subject: [PATCH 04/14] Update books --- src/doc/book | 2 +- src/doc/reference | 2 +- src/doc/rust-by-example | 2 +- src/doc/rustc-dev-guide | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/doc/book b/src/doc/book index d94e03a18a259..21a2ed14f4480 160000 --- a/src/doc/book +++ b/src/doc/book @@ -1 +1 @@ -Subproject commit d94e03a18a2590ed3f1c67b859cb11528d2a2d5c +Subproject commit 21a2ed14f4480dab62438dcc1130291bebc65379 diff --git a/src/doc/reference b/src/doc/reference index e5adb99c04817..a9afb04b47a84 160000 --- a/src/doc/reference +++ b/src/doc/reference @@ -1 +1 @@ -Subproject commit e5adb99c04817b7fbe08f4ffce5b36702667345f +Subproject commit a9afb04b47a84a6753e4dc657348c324c876102c diff --git a/src/doc/rust-by-example b/src/doc/rust-by-example index efe23c4fe12e0..af0998b747383 160000 --- a/src/doc/rust-by-example +++ b/src/doc/rust-by-example @@ -1 +1 @@ -Subproject commit efe23c4fe12e06351b8dc8c3d18312c761455109 +Subproject commit af0998b7473839ca75563ba3d3e7fd0160bef235 diff --git a/src/doc/rustc-dev-guide b/src/doc/rustc-dev-guide index 41a96ab971cb4..b06dab8408339 160000 --- a/src/doc/rustc-dev-guide +++ b/src/doc/rustc-dev-guide @@ -1 +1 @@ -Subproject commit 41a96ab971cb45e2a184df20619ad1829765c990 +Subproject commit b06dab84083390e0ee1e998f466545a8a1a76a9f From f83ce99c326ae13eabd5b4f6bd5459a5a764c13b Mon Sep 17 00:00:00 2001 From: clubby789 Date: Tue, 28 Feb 2023 01:21:15 +0000 Subject: [PATCH 05/14] Remove the `capture_disjoint_fields` feature --- compiler/rustc_feature/src/active.rs | 2 -- compiler/rustc_feature/src/removed.rs | 2 ++ compiler/rustc_hir_typeck/src/upvar.rs | 15 ++++++--------- .../rustc_mir_build/src/build/expr/as_place.rs | 11 +++++------ tests/debuginfo/captured-fields-1.rs | 3 +-- tests/debuginfo/captured-fields-2.rs | 8 ++------ .../closures/2229_closure_analysis/issue_88118.rs | 5 +---- 7 files changed, 17 insertions(+), 29 deletions(-) diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs index 6d8f7e4a0f681..d38350f10ae91 100644 --- a/compiler/rustc_feature/src/active.rs +++ b/compiler/rustc_feature/src/active.rs @@ -317,8 +317,6 @@ declare_features! ( (active, c_unwind, "1.52.0", Some(74990), None), /// Allows using C-variadics. (active, c_variadic, "1.34.0", Some(44930), None), - /// Allows capturing disjoint fields in a closure/generator (RFC 2229). - (incomplete, capture_disjoint_fields, "1.49.0", Some(53488), None), /// Allows the use of `#[cfg(sanitize = "option")]`; set when -Zsanitizer is used. (active, cfg_sanitize, "1.41.0", Some(39699), None), /// Allows `cfg(target_abi = "...")`. diff --git a/compiler/rustc_feature/src/removed.rs b/compiler/rustc_feature/src/removed.rs index 79a12801de29d..04d4f6cb14e4c 100644 --- a/compiler/rustc_feature/src/removed.rs +++ b/compiler/rustc_feature/src/removed.rs @@ -52,6 +52,8 @@ declare_features! ( (removed, allow_fail, "1.19.0", Some(46488), None, Some("removed due to no clear use cases")), (removed, await_macro, "1.38.0", Some(50547), None, Some("subsumed by `.await` syntax")), + /// Allows capturing disjoint fields in a closure/generator (RFC 2229). + (removed, capture_disjoint_fields, "1.49.0", Some(53488), None, Some("stabilized in Rust 2021")), /// Allows comparing raw pointers during const eval. (removed, const_compare_raw_pointers, "1.46.0", Some(53020), None, Some("cannot be allowed in const eval in any meaningful way")), diff --git a/compiler/rustc_hir_typeck/src/upvar.rs b/compiler/rustc_hir_typeck/src/upvar.rs index e94915c754e8f..00cc4c3befc67 100644 --- a/compiler/rustc_hir_typeck/src/upvar.rs +++ b/compiler/rustc_hir_typeck/src/upvar.rs @@ -231,7 +231,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // We now fake capture information for all variables that are mentioned within the closure // We do this after handling migrations so that min_captures computes before - if !enable_precise_capture(self.tcx, span) { + if !enable_precise_capture(span) { let mut capture_information: InferredCaptureInformation<'tcx> = Default::default(); if let Some(upvars) = self.tcx.upvars_mentioned(closure_def_id) { @@ -265,7 +265,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // If we have an origin, store it. if let Some(origin) = origin { - let origin = if enable_precise_capture(self.tcx, span) { + let origin = if enable_precise_capture(span) { (origin.0, origin.1) } else { (origin.0, Place { projections: vec![], ..origin.1 }) @@ -1240,8 +1240,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// /// This will make more sense with an example: /// - /// ```rust - /// #![feature(capture_disjoint_fields)] + /// ```rust,edition2021 /// /// struct FancyInteger(i32); // This implements Drop /// @@ -2247,12 +2246,10 @@ fn truncate_capture_for_optimization( (place, curr_mode) } -/// Precise capture is enabled if the feature gate `capture_disjoint_fields` is enabled or if -/// user is using Rust Edition 2021 or higher. -/// +/// Precise capture is enabled if user is using Rust Edition 2021 or higher. /// `span` is the span of the closure. -fn enable_precise_capture(tcx: TyCtxt<'_>, span: Span) -> bool { +fn enable_precise_capture(span: Span) -> bool { // We use span here to ensure that if the closure was generated by a macro with a different // edition. - tcx.features().capture_disjoint_fields || span.rust_2021() + span.rust_2021() } diff --git a/compiler/rustc_mir_build/src/build/expr/as_place.rs b/compiler/rustc_mir_build/src/build/expr/as_place.rs index eb20b2308c0bd..33200b80a572d 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_place.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_place.rs @@ -11,7 +11,7 @@ use rustc_middle::mir::AssertKind::BoundsCheck; use rustc_middle::mir::*; use rustc_middle::thir::*; use rustc_middle::ty::AdtDef; -use rustc_middle::ty::{self, CanonicalUserTypeAnnotation, Ty, TyCtxt, Variance}; +use rustc_middle::ty::{self, CanonicalUserTypeAnnotation, Ty, Variance}; use rustc_span::Span; use rustc_target::abi::VariantIdx; @@ -183,7 +183,7 @@ fn to_upvars_resolved_place_builder<'tcx>( &projection, ) else { let closure_span = cx.tcx.def_span(closure_def_id); - if !enable_precise_capture(cx.tcx, closure_span) { + if !enable_precise_capture(closure_span) { bug!( "No associated capture found for {:?}[{:#?}] even though \ capture_disjoint_fields isn't enabled", @@ -745,8 +745,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } -/// Precise capture is enabled if the feature gate `capture_disjoint_fields` is enabled or if -/// user is using Rust Edition 2021 or higher. -fn enable_precise_capture(tcx: TyCtxt<'_>, closure_span: Span) -> bool { - tcx.features().capture_disjoint_fields || closure_span.rust_2021() +/// Precise capture is enabled if user is using Rust Edition 2021 or higher. +fn enable_precise_capture(closure_span: Span) -> bool { + closure_span.rust_2021() } diff --git a/tests/debuginfo/captured-fields-1.rs b/tests/debuginfo/captured-fields-1.rs index afbf942d40471..b71734c2354df 100644 --- a/tests/debuginfo/captured-fields-1.rs +++ b/tests/debuginfo/captured-fields-1.rs @@ -1,5 +1,5 @@ // compile-flags:-g - +// edition:2021 // === GDB TESTS =================================================================================== // gdb-command:run @@ -44,7 +44,6 @@ // lldbg-check:(captured_fields_1::main::{closure_env#5}) $5 = { my_var = { my_field1 = 11 my_field2 = 22 } } // lldb-command:continue -#![feature(capture_disjoint_fields)] #![allow(unused)] struct MyStruct { diff --git a/tests/debuginfo/captured-fields-2.rs b/tests/debuginfo/captured-fields-2.rs index c872354a92489..8d463fb245162 100644 --- a/tests/debuginfo/captured-fields-2.rs +++ b/tests/debuginfo/captured-fields-2.rs @@ -1,5 +1,5 @@ // compile-flags:-g - +// edition:2021 // === GDB TESTS =================================================================================== // gdb-command:run @@ -20,7 +20,6 @@ // lldbg-check:(unsigned int) $1 = 22 // lldb-command:continue -#![feature(capture_disjoint_fields)] #![allow(unused)] struct MyStruct { @@ -29,10 +28,7 @@ struct MyStruct { } fn main() { - let mut my_var = MyStruct { - my_field1: 11, - my_field2: 22, - }; + let mut my_var = MyStruct { my_field1: 11, my_field2: 22 }; let my_ref = &mut my_var; let test = || { diff --git a/tests/ui/closures/2229_closure_analysis/issue_88118.rs b/tests/ui/closures/2229_closure_analysis/issue_88118.rs index 453b7e04a369b..bfb487649a3ce 100644 --- a/tests/ui/closures/2229_closure_analysis/issue_88118.rs +++ b/tests/ui/closures/2229_closure_analysis/issue_88118.rs @@ -1,10 +1,7 @@ // Regression test for #88118. Used to ICE. -// +// edition:2021 // check-pass -#![allow(incomplete_features)] -#![feature(capture_disjoint_fields)] - fn foo(handler: impl FnOnce() -> MsU + Clone + 'static) { Box::new(move |value| { (|_| handler.clone()())(value); From ecac8fd5afbb4ca8a98f8b0d3b547608e04cfc44 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Tue, 28 Feb 2023 02:03:26 +0000 Subject: [PATCH 06/14] Descriptive error when users try to combine RPITIT/AFIT with specialization --- .../rustc_hir_analysis/src/check/check.rs | 40 +++++++++++++++++-- compiler/rustc_metadata/src/rmeta/encoder.rs | 30 +------------- compiler/rustc_middle/src/ty/mod.rs | 28 +++++++++++++ .../src/traits/project.rs | 24 ++--------- ...project-to-specializable-projection.stderr | 15 ++----- .../in-trait/specialization-broken.rs | 1 + .../in-trait/specialization-broken.stderr | 10 ++++- 7 files changed, 83 insertions(+), 65 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index 4ea471f8f0553..848828175e2d8 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -792,8 +792,10 @@ fn check_impl_items_against_trait<'tcx>( trait_def.must_implement_one_of.as_deref(); for &trait_item_id in tcx.associated_item_def_ids(impl_trait_ref.def_id) { - let is_implemented = ancestors - .leaf_def(tcx, trait_item_id) + let leaf_def = ancestors.leaf_def(tcx, trait_item_id); + + let is_implemented = leaf_def + .as_ref() .map_or(false, |node_item| node_item.item.defaultness(tcx).has_value()); if !is_implemented && tcx.impl_defaultness(impl_id).is_final() { @@ -801,8 +803,8 @@ fn check_impl_items_against_trait<'tcx>( } // true if this item is specifically implemented in this impl - let is_implemented_here = ancestors - .leaf_def(tcx, trait_item_id) + let is_implemented_here = leaf_def + .as_ref() .map_or(false, |node_item| !node_item.defining_node.is_from_trait()); if !is_implemented_here { @@ -831,6 +833,36 @@ fn check_impl_items_against_trait<'tcx>( } } } + + if let Some(leaf_def) = &leaf_def + && !leaf_def.is_final() + && let def_id = leaf_def.item.def_id + && tcx.impl_method_has_trait_impl_trait_tys(def_id) + { + let def_kind = tcx.def_kind(def_id); + let descr = tcx.def_kind_descr(def_kind, def_id); + let (msg, feature) = if tcx.asyncness(def_id).is_async() { + ( + format!("async {descr} in trait cannot be specialized"), + sym::async_fn_in_trait, + ) + } else { + ( + format!( + "{descr} with return-position `impl Trait` in trait cannot be specialized" + ), + sym::return_position_impl_trait_in_trait, + ) + }; + tcx.sess + .struct_span_err(tcx.def_span(def_id), msg) + .note(format!( + "specialization behaves in inconsistent and \ + surprising ways with `#![feature({feature})]`, \ + and for now is disallowed" + )) + .emit(); + } } if !missing_items.is_empty() { diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index f0dafe73c004e..27490a09a3646 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -1101,34 +1101,6 @@ fn should_encode_const(def_kind: DefKind) -> bool { } } -fn should_encode_trait_impl_trait_tys(tcx: TyCtxt<'_>, def_id: DefId) -> bool { - if tcx.def_kind(def_id) != DefKind::AssocFn { - return false; - } - - let Some(item) = tcx.opt_associated_item(def_id) else { return false; }; - if item.container != ty::AssocItemContainer::ImplContainer { - return false; - } - - let Some(trait_item_def_id) = item.trait_item_def_id else { return false; }; - - // FIXME(RPITIT): This does a somewhat manual walk through the signature - // of the trait fn to look for any RPITITs, but that's kinda doing a lot - // of work. We can probably remove this when we refactor RPITITs to be - // associated types. - tcx.fn_sig(trait_item_def_id).subst_identity().skip_binder().output().walk().any(|arg| { - if let ty::GenericArgKind::Type(ty) = arg.unpack() - && let ty::Alias(ty::Projection, data) = ty.kind() - && tcx.def_kind(data.def_id) == DefKind::ImplTraitPlaceholder - { - true - } else { - false - } - }) -} - // Return `false` to avoid encoding impl trait in trait, while we don't use the query. fn should_encode_fn_impl_trait_in_trait<'tcx>(_tcx: TyCtxt<'tcx>, _def_id: DefId) -> bool { false @@ -1211,7 +1183,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { if let DefKind::Enum | DefKind::Struct | DefKind::Union = def_kind { self.encode_info_for_adt(def_id); } - if should_encode_trait_impl_trait_tys(tcx, def_id) + if tcx.impl_method_has_trait_impl_trait_tys(def_id) && let Ok(table) = self.tcx.collect_return_position_impl_trait_in_trait_tys(def_id) { record!(self.tables.trait_impl_trait_tys[def_id] <- table); diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index fc5757564a74b..5084bc9cec6c6 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -2541,6 +2541,34 @@ impl<'tcx> TyCtxt<'tcx> { } def_id } + + pub fn impl_method_has_trait_impl_trait_tys(self, def_id: DefId) -> bool { + if self.def_kind(def_id) != DefKind::AssocFn { + return false; + } + + let Some(item) = self.opt_associated_item(def_id) else { return false; }; + if item.container != ty::AssocItemContainer::ImplContainer { + return false; + } + + let Some(trait_item_def_id) = item.trait_item_def_id else { return false; }; + + // FIXME(RPITIT): This does a somewhat manual walk through the signature + // of the trait fn to look for any RPITITs, but that's kinda doing a lot + // of work. We can probably remove this when we refactor RPITITs to be + // associated types. + self.fn_sig(trait_item_def_id).subst_identity().skip_binder().output().walk().any(|arg| { + if let ty::GenericArgKind::Type(ty) = arg.unpack() + && let ty::Alias(ty::Projection, data) = ty.kind() + && self.def_kind(data.def_id) == DefKind::ImplTraitPlaceholder + { + true + } else { + false + } + }) + } } /// Yields the parent function's `LocalDefId` if `def_id` is an `impl Trait` definition. diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index d542240be9b24..013db2edb398d 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -1307,25 +1307,8 @@ fn assemble_candidate_for_impl_trait_in_trait<'cx, 'tcx>( let _ = selcx.infcx.commit_if_ok(|_| { match selcx.select(&obligation.with(tcx, trait_predicate)) { Ok(Some(super::ImplSource::UserDefined(data))) => { - let Ok(leaf_def) = specialization_graph::assoc_def(tcx, data.impl_def_id, trait_fn_def_id) else { - return Err(()); - }; - // Only reveal a specializable default if we're past type-checking - // and the obligation is monomorphic, otherwise passes such as - // transmute checking and polymorphic MIR optimizations could - // get a result which isn't correct for all monomorphizations. - if leaf_def.is_final() - || (obligation.param_env.reveal() == Reveal::All - && !selcx - .infcx - .resolve_vars_if_possible(obligation.predicate.trait_ref(tcx)) - .still_further_specializable()) - { - candidate_set.push_candidate(ProjectionCandidate::ImplTraitInTrait(data)); - Ok(()) - } else { - Err(()) - } + candidate_set.push_candidate(ProjectionCandidate::ImplTraitInTrait(data)); + Ok(()) } Ok(None) => { candidate_set.mark_ambiguous(); @@ -2216,7 +2199,8 @@ fn confirm_impl_trait_in_trait_candidate<'tcx>( Ok(assoc_ty) => assoc_ty, Err(guar) => return Progress::error(tcx, guar), }; - if !leaf_def.item.defaultness(tcx).has_value() { + // We don't support specialization for RPITITs anyways... yet. + if !leaf_def.is_final() { return Progress { term: tcx.ty_error_misc().into(), obligations }; } diff --git a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr index 371122ea71ec0..f71fd9980a261 100644 --- a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr +++ b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr @@ -7,20 +7,13 @@ LL | #![feature(async_fn_in_trait)] = note: see issue #91611 for more information = note: `#[warn(incomplete_features)]` on by default -error[E0053]: method `foo` has an incompatible type for trait - --> $DIR/dont-project-to-specializable-projection.rs:14:35 +error: async associated function in trait cannot be specialized + --> $DIR/dont-project-to-specializable-projection.rs:14:5 | LL | default async fn foo(_: T) -> &'static str { - | ^^^^^^^^^^^^ expected associated type, found future + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -note: type in trait - --> $DIR/dont-project-to-specializable-projection.rs:10:27 - | -LL | async fn foo(_: T) -> &'static str; - | ^^^^^^^^^^^^ - = note: expected signature `fn(_) -> impl Future` - found signature `fn(_) -> impl Future` + = note: specialization behaves in inconsistent and surprising ways with `#![feature(async_fn_in_trait)]`, and for now is disallowed error: aborting due to previous error; 1 warning emitted -For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/impl-trait/in-trait/specialization-broken.rs b/tests/ui/impl-trait/in-trait/specialization-broken.rs index 9d27d3710a601..2fcffdf3f9a29 100644 --- a/tests/ui/impl-trait/in-trait/specialization-broken.rs +++ b/tests/ui/impl-trait/in-trait/specialization-broken.rs @@ -15,6 +15,7 @@ where { fn bar(&self) -> U { //~^ ERROR method `bar` has an incompatible type for trait + //~| ERROR method with return-position `impl Trait` in trait cannot be specialized *self } } diff --git a/tests/ui/impl-trait/in-trait/specialization-broken.stderr b/tests/ui/impl-trait/in-trait/specialization-broken.stderr index 37cfd74498d81..dc621d6b8a848 100644 --- a/tests/ui/impl-trait/in-trait/specialization-broken.stderr +++ b/tests/ui/impl-trait/in-trait/specialization-broken.stderr @@ -18,6 +18,14 @@ LL | fn bar(&self) -> impl Sized; = note: expected signature `fn(&U) -> impl Sized` found signature `fn(&U) -> U` -error: aborting due to previous error +error: method with return-position `impl Trait` in trait cannot be specialized + --> $DIR/specialization-broken.rs:16:5 + | +LL | fn bar(&self) -> U { + | ^^^^^^^^^^^^^^^^^^ + | + = note: specialization behaves in inconsistent and surprising ways with `#![feature(return_position_impl_trait_in_trait)]`, and for now is disallowed + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0053`. From f851a8aefa5fd61405e8f82989995dce12d93bfc Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Tue, 28 Feb 2023 06:26:48 +0000 Subject: [PATCH 07/14] Only look for param in generics if it actually comes from generics --- compiler/rustc_ast_lowering/src/item.rs | 15 +++- compiler/rustc_ast_lowering/src/lib.rs | 39 ++++++--- compiler/rustc_hir/src/hir.rs | 15 ++++ .../src/collect/resolve_bound_vars.rs | 81 ++++++++++--------- .../object-lifetime-default-for-late.rs | 7 ++ .../object-lifetime-default-for-late.stderr | 11 +++ 6 files changed, 119 insertions(+), 49 deletions(-) create mode 100644 tests/ui/traits/non_lifetime_binders/object-lifetime-default-for-late.rs create mode 100644 tests/ui/traits/non_lifetime_binders/object-lifetime-default-for-late.stderr diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index 7325bce605592..41295f2b7b661 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -1339,13 +1339,19 @@ impl<'hir> LoweringContext<'_, 'hir> { .map(|predicate| self.lower_where_predicate(predicate)), ); - let mut params: SmallVec<[hir::GenericParam<'hir>; 4]> = - self.lower_generic_params_mut(&generics.params).collect(); + let mut params: SmallVec<[hir::GenericParam<'hir>; 4]> = self + .lower_generic_params_mut(&generics.params, hir::GenericParamSource::Generics) + .collect(); // Introduce extra lifetimes if late resolution tells us to. let extra_lifetimes = self.resolver.take_extra_lifetime_params(parent_node_id); params.extend(extra_lifetimes.into_iter().filter_map(|(ident, node_id, res)| { - self.lifetime_res_to_generic_param(ident, node_id, res) + self.lifetime_res_to_generic_param( + ident, + node_id, + res, + hir::GenericParamSource::Generics, + ) })); let has_where_clause_predicates = !generics.where_clause.predicates.is_empty(); @@ -1449,7 +1455,8 @@ impl<'hir> LoweringContext<'_, 'hir> { span, }) => hir::WherePredicate::BoundPredicate(hir::WhereBoundPredicate { hir_id: self.next_id(), - bound_generic_params: self.lower_generic_params(bound_generic_params), + bound_generic_params: self + .lower_generic_params(bound_generic_params, hir::GenericParamSource::Binder), bounded_ty: self .lower_ty(bounded_ty, &ImplTraitContext::Disallowed(ImplTraitPosition::Bound)), bounds: self.arena.alloc_from_iter(bounds.iter().map(|bound| { diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 5d78d914b6d7f..5352a56b16588 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -804,6 +804,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { ident: Ident, node_id: NodeId, res: LifetimeRes, + source: hir::GenericParamSource, ) -> Option> { let (name, kind) = match res { LifetimeRes::Param { .. } => { @@ -837,6 +838,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { pure_wrt_drop: false, kind: hir::GenericParamKind::Lifetime { kind }, colon_span: None, + source, }) } @@ -852,11 +854,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { binder: NodeId, generic_params: &[GenericParam], ) -> &'hir [hir::GenericParam<'hir>] { - let mut generic_params: Vec<_> = self.lower_generic_params_mut(generic_params).collect(); + let mut generic_params: Vec<_> = self + .lower_generic_params_mut(generic_params, hir::GenericParamSource::Binder) + .collect(); let extra_lifetimes = self.resolver.take_extra_lifetime_params(binder); debug!(?extra_lifetimes); generic_params.extend(extra_lifetimes.into_iter().filter_map(|(ident, node_id, res)| { - self.lifetime_res_to_generic_param(ident, node_id, res) + self.lifetime_res_to_generic_param(ident, node_id, res, hir::GenericParamSource::Binder) })); let generic_params = self.arena.alloc_from_iter(generic_params); debug!(?generic_params); @@ -1375,8 +1379,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { span, ); let ident = Ident::from_str_and_span(&pprust::ty_to_string(t), span); - let (param, bounds, path) = - self.lower_generic_and_bounds(*def_node_id, span, ident, bounds); + let (param, bounds, path) = self.lower_universal_param_and_bounds( + *def_node_id, + span, + ident, + bounds, + ); self.impl_trait_defs.push(param); if let Some(bounds) = bounds { self.impl_trait_bounds.push(bounds); @@ -1530,6 +1538,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { pure_wrt_drop: false, kind: hir::GenericParamKind::Lifetime { kind }, colon_span: None, + source: hir::GenericParamSource::Generics, } }, )); @@ -1987,6 +1996,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { pure_wrt_drop: false, kind: hir::GenericParamKind::Lifetime { kind }, colon_span: None, + source: hir::GenericParamSource::Generics, } }, )); @@ -2152,16 +2162,25 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { fn lower_generic_params_mut<'s>( &'s mut self, params: &'s [GenericParam], + source: hir::GenericParamSource, ) -> impl Iterator> + Captures<'a> + Captures<'s> { - params.iter().map(move |param| self.lower_generic_param(param)) + params.iter().map(move |param| self.lower_generic_param(param, source)) } - fn lower_generic_params(&mut self, params: &[GenericParam]) -> &'hir [hir::GenericParam<'hir>] { - self.arena.alloc_from_iter(self.lower_generic_params_mut(params)) + fn lower_generic_params( + &mut self, + params: &[GenericParam], + source: hir::GenericParamSource, + ) -> &'hir [hir::GenericParam<'hir>] { + self.arena.alloc_from_iter(self.lower_generic_params_mut(params, source)) } #[instrument(level = "trace", skip(self))] - fn lower_generic_param(&mut self, param: &GenericParam) -> hir::GenericParam<'hir> { + fn lower_generic_param( + &mut self, + param: &GenericParam, + source: hir::GenericParamSource, + ) -> hir::GenericParam<'hir> { let (name, kind) = self.lower_generic_param_kind(param); let hir_id = self.lower_node_id(param.id); @@ -2174,6 +2193,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { pure_wrt_drop: self.tcx.sess.contains_name(¶m.attrs, sym::may_dangle), kind, colon_span: param.colon_span.map(|s| self.lower_span(s)), + source, } } @@ -2266,7 +2286,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { } #[instrument(level = "debug", skip(self), ret)] - fn lower_generic_and_bounds( + fn lower_universal_param_and_bounds( &mut self, node_id: NodeId, span: Span, @@ -2286,6 +2306,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { span, kind: hir::GenericParamKind::Type { default: None, synthetic: true }, colon_span: None, + source: hir::GenericParamSource::Generics, }; let preds = self.lower_generic_bound_predicate( diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 72e9f7c13437e..19d3d41c9841c 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -498,6 +498,7 @@ pub struct GenericParam<'hir> { pub pure_wrt_drop: bool, pub kind: GenericParamKind<'hir>, pub colon_span: Option, + pub source: GenericParamSource, } impl<'hir> GenericParam<'hir> { @@ -516,6 +517,20 @@ impl<'hir> GenericParam<'hir> { } } +/// Records where the generic parameter originated from. +/// +/// This can either be from an item's generics, in which case it's typically +/// early-bound (but can be a late-bound lifetime in functions, for example), +/// or from a `for<...>` binder, in which case it's late-bound (and notably, +/// does not show up in the parent item's generics). +#[derive(Debug, HashStable_Generic, PartialEq, Eq, Copy, Clone)] +pub enum GenericParamSource { + // Early or late-bound parameters defined on an item + Generics, + // Late-bound parameters defined via a `for<...>` + Binder, +} + #[derive(Default)] pub struct GenericParamCount { pub lifetimes: usize, diff --git a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs index 6c00b8ff7bdee..b14e65183aa3d 100644 --- a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs +++ b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs @@ -1034,45 +1034,53 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> { fn object_lifetime_default(tcx: TyCtxt<'_>, param_def_id: DefId) -> ObjectLifetimeDefault { debug_assert_eq!(tcx.def_kind(param_def_id), DefKind::TyParam); let param_def_id = param_def_id.expect_local(); - let parent_def_id = tcx.local_parent(param_def_id); - let generics = tcx.hir().get_generics(parent_def_id).unwrap(); - let param_hir_id = tcx.local_def_id_to_hir_id(param_def_id); - let param = generics.params.iter().find(|p| p.hir_id == param_hir_id).unwrap(); - - // Scan the bounds and where-clauses on parameters to extract bounds - // of the form `T:'a` so as to determine the `ObjectLifetimeDefault` - // for each type parameter. - match param.kind { - GenericParamKind::Type { .. } => { - let mut set = Set1::Empty; - - // Look for `type: ...` where clauses. - for bound in generics.bounds_for_param(param_def_id) { - // Ignore `for<'a> type: ...` as they can change what - // lifetimes mean (although we could "just" handle it). - if !bound.bound_generic_params.is_empty() { - continue; - } + let hir::Node::GenericParam(param) = tcx.hir().get_by_def_id(param_def_id) else { + bug!("expected GenericParam for object_lifetime_default"); + }; + match param.source { + hir::GenericParamSource::Generics => { + let parent_def_id = tcx.local_parent(param_def_id); + let generics = tcx.hir().get_generics(parent_def_id).unwrap(); + let param_hir_id = tcx.local_def_id_to_hir_id(param_def_id); + let param = generics.params.iter().find(|p| p.hir_id == param_hir_id).unwrap(); + + // Scan the bounds and where-clauses on parameters to extract bounds + // of the form `T:'a` so as to determine the `ObjectLifetimeDefault` + // for each type parameter. + match param.kind { + GenericParamKind::Type { .. } => { + let mut set = Set1::Empty; + + // Look for `type: ...` where clauses. + for bound in generics.bounds_for_param(param_def_id) { + // Ignore `for<'a> type: ...` as they can change what + // lifetimes mean (although we could "just" handle it). + if !bound.bound_generic_params.is_empty() { + continue; + } - for bound in bound.bounds { - if let hir::GenericBound::Outlives(lifetime) = bound { - set.insert(lifetime.res); + for bound in bound.bounds { + if let hir::GenericBound::Outlives(lifetime) = bound { + set.insert(lifetime.res); + } + } } - } - } - match set { - Set1::Empty => ObjectLifetimeDefault::Empty, - Set1::One(hir::LifetimeName::Static) => ObjectLifetimeDefault::Static, - Set1::One(hir::LifetimeName::Param(param_def_id)) => { - ObjectLifetimeDefault::Param(param_def_id.to_def_id()) + match set { + Set1::Empty => ObjectLifetimeDefault::Empty, + Set1::One(hir::LifetimeName::Static) => ObjectLifetimeDefault::Static, + Set1::One(hir::LifetimeName::Param(param_def_id)) => { + ObjectLifetimeDefault::Param(param_def_id.to_def_id()) + } + _ => ObjectLifetimeDefault::Ambiguous, + } + } + _ => { + bug!("object_lifetime_default_raw must only be called on a type parameter") } - _ => ObjectLifetimeDefault::Ambiguous, } } - _ => { - bug!("object_lifetime_default_raw must only be called on a type parameter") - } + hir::GenericParamSource::Binder => ObjectLifetimeDefault::Empty, } } @@ -1392,9 +1400,10 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> { return; } - self.tcx - .sess - .delay_span_bug(self.tcx.hir().span(hir_id), "could not resolve {param_def_id:?}"); + self.tcx.sess.delay_span_bug( + self.tcx.hir().span(hir_id), + format!("could not resolve {param_def_id:?}"), + ); } #[instrument(level = "debug", skip(self))] diff --git a/tests/ui/traits/non_lifetime_binders/object-lifetime-default-for-late.rs b/tests/ui/traits/non_lifetime_binders/object-lifetime-default-for-late.rs new file mode 100644 index 0000000000000..9830241c3770c --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/object-lifetime-default-for-late.rs @@ -0,0 +1,7 @@ +// check-pass +// compile-flags: --crate-type=lib + +#![feature(non_lifetime_binders)] +//~^ WARN the feature `non_lifetime_binders` is incomplete + +pub fn f() where for (T, U): Copy {} diff --git a/tests/ui/traits/non_lifetime_binders/object-lifetime-default-for-late.stderr b/tests/ui/traits/non_lifetime_binders/object-lifetime-default-for-late.stderr new file mode 100644 index 0000000000000..667575b72d4cb --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/object-lifetime-default-for-late.stderr @@ -0,0 +1,11 @@ +warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/object-lifetime-default-for-late.rs:4:12 + | +LL | #![feature(non_lifetime_binders)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #108185 for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + From 10b08e3c9c935da0295fc57ac7dbad99778068e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Wed, 8 Feb 2023 19:53:48 +0100 Subject: [PATCH 08/14] Fix a race in the query system --- compiler/rustc_query_system/src/query/plumbing.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_query_system/src/query/plumbing.rs b/compiler/rustc_query_system/src/query/plumbing.rs index 586bd38fbb80b..5f003fa70e133 100644 --- a/compiler/rustc_query_system/src/query/plumbing.rs +++ b/compiler/rustc_query_system/src/query/plumbing.rs @@ -25,7 +25,6 @@ use std::collections::hash_map::Entry; use std::fmt::Debug; use std::hash::Hash; use std::mem; -use std::ptr; use thin_vec::ThinVec; use super::QueryConfig; @@ -250,13 +249,16 @@ where where C: QueryCache, { - // We can move out of `self` here because we `mem::forget` it below - let key = unsafe { ptr::read(&self.key) }; + let key = self.key; let state = self.state; // Forget ourself so our destructor won't poison the query mem::forget(self); + // Mark as complete before we remove the job from the active state + // so no other thread can re-execute this query. + cache.complete(key, result, dep_node_index); + let job = { #[cfg(parallel_compiler)] let mut lock = state.active.get_shard_by_value(&key).lock(); @@ -267,7 +269,6 @@ where QueryResult::Poisoned => panic!(), } }; - cache.complete(key, result, dep_node_index); job.signal_complete(); } From f01d0c02e7fccc866c3adb7b95e96ec9b4974a37 Mon Sep 17 00:00:00 2001 From: yukang Date: Tue, 28 Feb 2023 07:55:19 +0000 Subject: [PATCH 09/14] Exit when there are unmatched delims to avoid noisy diagnostics --- compiler/rustc_parse/src/lib.rs | 13 +- src/librustdoc/doctest.rs | 14 +-- tests/ui/lint/issue-104897.rs | 1 - tests/ui/lint/issue-104897.stderr | 19 +-- .../lint/unused_parens_multibyte_recovery.rs | 1 - .../unused_parens_multibyte_recovery.stderr | 19 +-- tests/ui/macros/issue-102878.rs | 4 - tests/ui/macros/issue-102878.stderr | 51 +------- tests/ui/parser/deli-ident-issue-1.rs | 2 - tests/ui/parser/deli-ident-issue-1.stderr | 24 +--- tests/ui/parser/deli-ident-issue-2.stderr | 16 +-- .../do-not-suggest-semicolon-before-array.rs | 2 +- ...-not-suggest-semicolon-before-array.stderr | 4 +- tests/ui/parser/issue-103451.rs | 1 - tests/ui/parser/issue-103451.stderr | 16 +-- .../parser/issue-68987-unmatch-issue-2.stderr | 16 +-- .../parser/issue-68987-unmatch-issue-3.stderr | 16 +-- tests/ui/parser/issue-81804.rs | 3 - tests/ui/parser/issue-81804.stderr | 27 ++--- tests/ui/parser/issue-81827.rs | 1 - tests/ui/parser/issue-81827.stderr | 14 +-- tests/ui/parser/issues/issue-10636-2.rs | 4 +- tests/ui/parser/issues/issue-10636-2.stderr | 19 ++- ...ssue-58094-missing-right-square-bracket.rs | 3 +- ...-58094-missing-right-square-bracket.stderr | 10 +- tests/ui/parser/issues/issue-58856-1.rs | 5 +- tests/ui/parser/issues/issue-58856-1.stderr | 29 +---- tests/ui/parser/issues/issue-58856-2.rs | 5 +- tests/ui/parser/issues/issue-58856-2.stderr | 33 +---- tests/ui/parser/issues/issue-60075.rs | 5 +- tests/ui/parser/issues/issue-60075.stderr | 20 +--- tests/ui/parser/issues/issue-62524.rs | 2 +- tests/ui/parser/issues/issue-62524.stderr | 25 +--- tests/ui/parser/issues/issue-62546.rs | 4 +- tests/ui/parser/issues/issue-62546.stderr | 15 +-- tests/ui/parser/issues/issue-62554.rs | 1 - tests/ui/parser/issues/issue-62554.stderr | 28 +---- tests/ui/parser/issues/issue-62881.rs | 5 +- tests/ui/parser/issues/issue-62881.stderr | 24 +--- tests/ui/parser/issues/issue-62894.rs | 1 - tests/ui/parser/issues/issue-62894.stderr | 20 +--- tests/ui/parser/issues/issue-62895.rs | 14 +-- tests/ui/parser/issues/issue-62895.stderr | 51 ++------ tests/ui/parser/issues/issue-62973.rs | 2 +- tests/ui/parser/issues/issue-62973.stderr | 45 +------ tests/ui/parser/issues/issue-63116.rs | 2 +- tests/ui/parser/issues/issue-63116.stderr | 8 +- tests/ui/parser/issues/issue-63135.rs | 4 +- tests/ui/parser/issues/issue-63135.stderr | 30 +---- .../issue-66357-unexpected-unreachable.rs | 4 +- .../issue-66357-unexpected-unreachable.stderr | 17 +-- ...377-invalid-syntax-in-enum-discriminant.rs | 14 +-- ...invalid-syntax-in-enum-discriminant.stderr | 113 +++--------------- tests/ui/parser/issues/issue-68629.rs | Bin 336 -> 129 bytes tests/ui/parser/issues/issue-68629.stderr | Bin 1637 -> 1155 bytes tests/ui/parser/issues/issue-84104.rs | 1 - tests/ui/parser/issues/issue-84104.stderr | 10 +- tests/ui/parser/issues/issue-84148-2.rs | 1 - tests/ui/parser/issues/issue-84148-2.stderr | 21 +--- tests/ui/parser/issues/issue-88770.rs | 3 - tests/ui/parser/issues/issue-88770.stderr | 30 +---- .../macro-mismatched-delim-paren-brace.stderr | 18 +-- tests/ui/parser/mbe_missing_right_paren.rs | 2 +- .../ui/parser/mbe_missing_right_paren.stderr | 23 +--- .../missing-close-brace-in-impl-trait.rs | 6 +- .../missing-close-brace-in-impl-trait.stderr | 25 +--- .../missing-close-brace-in-struct.rs | 2 +- .../missing-close-brace-in-struct.stderr | 11 +- .../missing-close-brace-in-trait.rs | 3 +- .../missing-close-brace-in-trait.stderr | 20 +--- tests/ui/parser/missing_right_paren.rs | 3 +- tests/ui/parser/missing_right_paren.stderr | 18 +-- tests/ui/parser/parser-recovery-1.rs | 3 - tests/ui/parser/parser-recovery-1.stderr | 25 +--- tests/ui/parser/parser-recovery-2.rs | 5 +- tests/ui/parser/parser-recovery-2.stderr | 21 +--- tests/ui/parser/unclosed-delimiter-in-dep.rs | 1 - .../parser/unclosed-delimiter-in-dep.stderr | 14 +-- tests/ui/parser/use-unclosed-brace.rs | 2 - tests/ui/parser/use-unclosed-brace.stderr | 20 +--- tests/ui/resolve/token-error-correct-2.rs | 1 - tests/ui/resolve/token-error-correct-2.stderr | 10 +- tests/ui/resolve/token-error-correct-3.rs | 5 +- tests/ui/resolve/token-error-correct-3.stderr | 26 ++-- tests/ui/resolve/token-error-correct-4.fixed | 10 -- tests/ui/resolve/token-error-correct-4.rs | 5 +- tests/ui/resolve/token-error-correct-4.stderr | 18 ++- tests/ui/resolve/token-error-correct.rs | 1 - tests/ui/resolve/token-error-correct.stderr | 10 +- ...021-incompatible-closure-captures-93117.rs | 12 +- ...incompatible-closure-captures-93117.stderr | 93 +------------- tests/ui/suggestions/constrain-suggest-ice.rs | 10 +- .../suggestions/constrain-suggest-ice.stderr | 61 +--------- tests/ui/type/issue-91268.rs | 4 - tests/ui/type/issue-91268.stderr | 47 +------- tests/ui/typeck/issue-91334.rs | 3 - tests/ui/typeck/issue-91334.stderr | 29 +---- tests/ui/typeck/issue-92481.rs | 9 +- tests/ui/typeck/issue-92481.stderr | 61 +--------- 99 files changed, 252 insertions(+), 1277 deletions(-) delete mode 100644 tests/ui/resolve/token-error-correct-4.fixed diff --git a/compiler/rustc_parse/src/lib.rs b/compiler/rustc_parse/src/lib.rs index 6f37e9758fcbb..28a771ac9486c 100644 --- a/compiler/rustc_parse/src/lib.rs +++ b/compiler/rustc_parse/src/lib.rs @@ -204,16 +204,23 @@ pub fn maybe_file_to_stream( lexer::parse_token_trees(sess, src.as_str(), source_file.start_pos, override_span); match token_trees { - Ok(stream) => Ok((stream, unmatched_braces)), - Err(err) => { + Ok(stream) if unmatched_braces.is_empty() => Ok((stream, unmatched_braces)), + _ => { + // Return error if there are unmatched delimiters or unclosng delimiters. + // We emit delimiter mismatch errors first, then emit the unclosing delimiter mismatch + // because the delimiter mismatch is more likely to be the root cause of the + let mut buffer = Vec::with_capacity(1); - err.buffer(&mut buffer); // Not using `emit_unclosed_delims` to use `db.buffer` for unmatched in unmatched_braces { if let Some(err) = make_unclosed_delims_error(unmatched, &sess) { err.buffer(&mut buffer); } } + if let Err(err) = token_trees { + // Add unclosing delimiter error + err.buffer(&mut buffer); + } Err(buffer) } } diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index 8a73d25d3f000..9cf84acc79f8d 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -769,8 +769,8 @@ fn check_if_attr_is_complete(source: &str, edition: Edition) -> bool { match maybe_new_parser_from_source_str(&sess, filename, source.to_owned()) { Ok(p) => p, Err(_) => { - debug!("Cannot build a parser to check mod attr so skipping..."); - return true; + // If there is an unclosed delimiter, an error will be returned by the tokentrees. + return false; } }; // If a parsing error happened, it's very likely that the attribute is incomplete. @@ -778,15 +778,7 @@ fn check_if_attr_is_complete(source: &str, edition: Edition) -> bool { e.cancel(); return false; } - // We now check if there is an unclosed delimiter for the attribute. To do so, we look at - // the `unclosed_delims` and see if the opening square bracket was closed. - parser - .unclosed_delims() - .get(0) - .map(|unclosed| { - unclosed.unclosed_span.map(|s| s.lo()).unwrap_or(BytePos(0)) != BytePos(2) - }) - .unwrap_or(true) + true }) }) .unwrap_or(false) diff --git a/tests/ui/lint/issue-104897.rs b/tests/ui/lint/issue-104897.rs index 5fbc658f1557c..2d298aff9db89 100644 --- a/tests/ui/lint/issue-104897.rs +++ b/tests/ui/lint/issue-104897.rs @@ -1,6 +1,5 @@ // error-pattern: this file contains an unclosed delimiter // error-pattern: this file contains an unclosed delimiter // error-pattern: this file contains an unclosed delimiter -// error-pattern: format argument must be a string literal fn f(){(print!(á diff --git a/tests/ui/lint/issue-104897.stderr b/tests/ui/lint/issue-104897.stderr index 817a93c2f3bb2..83fafb2b083c9 100644 --- a/tests/ui/lint/issue-104897.stderr +++ b/tests/ui/lint/issue-104897.stderr @@ -1,5 +1,5 @@ error: this file contains an unclosed delimiter - --> $DIR/issue-104897.rs:6:18 + --> $DIR/issue-104897.rs:5:18 | LL | fn f(){(print!(á | -- - ^ @@ -9,7 +9,7 @@ LL | fn f(){(print!(á | unclosed delimiter error: this file contains an unclosed delimiter - --> $DIR/issue-104897.rs:6:18 + --> $DIR/issue-104897.rs:5:18 | LL | fn f(){(print!(á | -- - ^ @@ -19,7 +19,7 @@ LL | fn f(){(print!(á | unclosed delimiter error: this file contains an unclosed delimiter - --> $DIR/issue-104897.rs:6:18 + --> $DIR/issue-104897.rs:5:18 | LL | fn f(){(print!(á | -- - ^ @@ -28,16 +28,5 @@ LL | fn f(){(print!(á | |unclosed delimiter | unclosed delimiter -error: format argument must be a string literal - --> $DIR/issue-104897.rs:6:16 - | -LL | fn f(){(print!(á - | ^ - | -help: you might be missing a string literal to format with - | -LL | fn f(){(print!("{}", á - | +++++ - -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/lint/unused_parens_multibyte_recovery.rs b/tests/ui/lint/unused_parens_multibyte_recovery.rs index 8fcfae22a3d33..bc03faf3fce6c 100644 --- a/tests/ui/lint/unused_parens_multibyte_recovery.rs +++ b/tests/ui/lint/unused_parens_multibyte_recovery.rs @@ -3,7 +3,6 @@ // error-pattern: this file contains an unclosed delimiter // error-pattern: this file contains an unclosed delimiter // error-pattern: this file contains an unclosed delimiter -// error-pattern: format argument must be a string literal // // Verify that unused parens lint does not try to create a span // which points in the middle of a multibyte character. diff --git a/tests/ui/lint/unused_parens_multibyte_recovery.stderr b/tests/ui/lint/unused_parens_multibyte_recovery.stderr index a0302b17e255d..b61f074b9b212 100644 --- a/tests/ui/lint/unused_parens_multibyte_recovery.stderr +++ b/tests/ui/lint/unused_parens_multibyte_recovery.stderr @@ -1,5 +1,5 @@ error: this file contains an unclosed delimiter - --> $DIR/unused_parens_multibyte_recovery.rs:11:17 + --> $DIR/unused_parens_multibyte_recovery.rs:10:17 | LL | fn f(){(print!(á | -- - ^ @@ -9,7 +9,7 @@ LL | fn f(){(print!(á | unclosed delimiter error: this file contains an unclosed delimiter - --> $DIR/unused_parens_multibyte_recovery.rs:11:17 + --> $DIR/unused_parens_multibyte_recovery.rs:10:17 | LL | fn f(){(print!(á | -- - ^ @@ -19,7 +19,7 @@ LL | fn f(){(print!(á | unclosed delimiter error: this file contains an unclosed delimiter - --> $DIR/unused_parens_multibyte_recovery.rs:11:17 + --> $DIR/unused_parens_multibyte_recovery.rs:10:17 | LL | fn f(){(print!(á | -- - ^ @@ -28,16 +28,5 @@ LL | fn f(){(print!(á | |unclosed delimiter | unclosed delimiter -error: format argument must be a string literal - --> $DIR/unused_parens_multibyte_recovery.rs:11:16 - | -LL | fn f(){(print!(á - | ^ - | -help: you might be missing a string literal to format with - | -LL | fn f(){(print!("{}", á - | +++++ - -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/macros/issue-102878.rs b/tests/ui/macros/issue-102878.rs index aac5891939e0c..bdd9c2569545a 100644 --- a/tests/ui/macros/issue-102878.rs +++ b/tests/ui/macros/issue-102878.rs @@ -1,9 +1,5 @@ macro_rules!test{($l:expr,$_:r)=>({const:y y)} //~^ ERROR mismatched closing delimiter: `)` -//~| ERROR invalid fragment specifier `r` -//~| ERROR expected identifier, found keyword `const` -//~| ERROR expected identifier, found keyword `const` -//~| ERROR expected identifier, found `:` fn s(){test!(1,i)} diff --git a/tests/ui/macros/issue-102878.stderr b/tests/ui/macros/issue-102878.stderr index e0b8855a38d05..034e3731b87fa 100644 --- a/tests/ui/macros/issue-102878.stderr +++ b/tests/ui/macros/issue-102878.stderr @@ -7,54 +7,5 @@ LL | macro_rules!test{($l:expr,$_:r)=>({const:y y)} | |unclosed delimiter | closing delimiter possibly meant for this -error: invalid fragment specifier `r` - --> $DIR/issue-102878.rs:1:27 - | -LL | macro_rules!test{($l:expr,$_:r)=>({const:y y)} - | ^^^^ - | - = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis` - -error: expected identifier, found keyword `const` - --> $DIR/issue-102878.rs:1:36 - | -LL | macro_rules!test{($l:expr,$_:r)=>({const:y y)} - | ^^^^^ expected identifier, found keyword -... -LL | fn s(){test!(1,i)} - | ---------- in this macro invocation - | - = note: this error originates in the macro `test` (in Nightly builds, run with -Z macro-backtrace for more info) -help: escape `const` to use it as an identifier - | -LL | macro_rules!test{($l:expr,$_:r)=>({r#const:y y)} - | ++ - -error: expected identifier, found keyword `const` - --> $DIR/issue-102878.rs:1:36 - | -LL | macro_rules!test{($l:expr,$_:r)=>({const:y y)} - | ^^^^^ expected identifier, found keyword -... -LL | fn s(){test!(1,i)} - | ---------- in this macro invocation - | - = note: this error originates in the macro `test` (in Nightly builds, run with -Z macro-backtrace for more info) -help: escape `const` to use it as an identifier - | -LL | macro_rules!test{($l:expr,$_:r)=>({r#const:y y)} - | ++ - -error: expected identifier, found `:` - --> $DIR/issue-102878.rs:1:41 - | -LL | macro_rules!test{($l:expr,$_:r)=>({const:y y)} - | ^ expected identifier -... -LL | fn s(){test!(1,i)} - | ---------- in this macro invocation - | - = note: this error originates in the macro `test` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to 5 previous errors +error: aborting due to previous error diff --git a/tests/ui/parser/deli-ident-issue-1.rs b/tests/ui/parser/deli-ident-issue-1.rs index 54485262a0cc8..224ee6c09e0c2 100644 --- a/tests/ui/parser/deli-ident-issue-1.rs +++ b/tests/ui/parser/deli-ident-issue-1.rs @@ -15,8 +15,6 @@ impl dyn Demo { if let Some(b) = val && let Some(c) = num { && b == c { - //~^ ERROR expected struct - //~| ERROR mismatched types } } } diff --git a/tests/ui/parser/deli-ident-issue-1.stderr b/tests/ui/parser/deli-ident-issue-1.stderr index 1119edb199f05..eb5073e14cfd9 100644 --- a/tests/ui/parser/deli-ident-issue-1.stderr +++ b/tests/ui/parser/deli-ident-issue-1.stderr @@ -1,5 +1,5 @@ error: this file contains an unclosed delimiter - --> $DIR/deli-ident-issue-1.rs:24:66 + --> $DIR/deli-ident-issue-1.rs:22:66 | LL | impl dyn Demo { | - unclosed delimiter @@ -13,25 +13,5 @@ LL | } LL | fn main() { } | ^ -error[E0574]: expected struct, variant or union type, found local variable `c` - --> $DIR/deli-ident-issue-1.rs:17:17 - | -LL | && b == c { - | ^ not a struct, variant or union type - -error[E0308]: mismatched types - --> $DIR/deli-ident-issue-1.rs:17:9 - | -LL | fn check(&self, val: Option, num: Option) { - | - expected `()` because of default return type -... -LL | / && b == c { -LL | | -LL | | -LL | | } - | |_________^ expected `()`, found `bool` - -error: aborting due to 3 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0308, E0574. -For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/parser/deli-ident-issue-2.stderr b/tests/ui/parser/deli-ident-issue-2.stderr index c8f59c9d32b5f..e0188cdfb4af8 100644 --- a/tests/ui/parser/deli-ident-issue-2.stderr +++ b/tests/ui/parser/deli-ident-issue-2.stderr @@ -1,3 +1,11 @@ +error: mismatched closing delimiter: `]` + --> $DIR/deli-ident-issue-2.rs:2:14 + | +LL | if 1 < 2 { + | ^ unclosed delimiter +LL | let _a = vec!]; + | ^ mismatched closing delimiter + error: unexpected closing delimiter: `}` --> $DIR/deli-ident-issue-2.rs:5:1 | @@ -7,13 +15,5 @@ LL | } LL | } | ^ unexpected closing delimiter -error: mismatched closing delimiter: `]` - --> $DIR/deli-ident-issue-2.rs:2:14 - | -LL | if 1 < 2 { - | ^ unclosed delimiter -LL | let _a = vec!]; - | ^ mismatched closing delimiter - error: aborting due to 2 previous errors diff --git a/tests/ui/parser/do-not-suggest-semicolon-before-array.rs b/tests/ui/parser/do-not-suggest-semicolon-before-array.rs index 7ebf3f6b0d899..7eff7f431be7e 100644 --- a/tests/ui/parser/do-not-suggest-semicolon-before-array.rs +++ b/tests/ui/parser/do-not-suggest-semicolon-before-array.rs @@ -2,7 +2,7 @@ fn foo() {} fn bar() -> [u8; 2] { foo() - [1, 3) //~ ERROR expected one of `.`, `?`, `]`, or an operator, found `,` + [1, 3) //~ ERROR mismatched closing delimiter } fn main() {} diff --git a/tests/ui/parser/do-not-suggest-semicolon-before-array.stderr b/tests/ui/parser/do-not-suggest-semicolon-before-array.stderr index a9dd526321f5c..7b43c77005ed4 100644 --- a/tests/ui/parser/do-not-suggest-semicolon-before-array.stderr +++ b/tests/ui/parser/do-not-suggest-semicolon-before-array.stderr @@ -1,8 +1,8 @@ -error: expected one of `.`, `?`, `]`, or an operator, found `,` +error: mismatched closing delimiter: `)` --> $DIR/do-not-suggest-semicolon-before-array.rs:5:5 | LL | [1, 3) - | ^ ^ help: `]` may belong here + | ^ ^ mismatched closing delimiter | | | unclosed delimiter diff --git a/tests/ui/parser/issue-103451.rs b/tests/ui/parser/issue-103451.rs index 1fdb001488155..be33213f3cbce 100644 --- a/tests/ui/parser/issue-103451.rs +++ b/tests/ui/parser/issue-103451.rs @@ -1,5 +1,4 @@ // error-pattern: this file contains an unclosed delimiter -// error-pattern: expected value, found struct `R` struct R { } struct S { x: [u8; R diff --git a/tests/ui/parser/issue-103451.stderr b/tests/ui/parser/issue-103451.stderr index eb3c92fb43d9b..e9a984261ca26 100644 --- a/tests/ui/parser/issue-103451.stderr +++ b/tests/ui/parser/issue-103451.stderr @@ -1,5 +1,5 @@ error: this file contains an unclosed delimiter - --> $DIR/issue-103451.rs:5:15 + --> $DIR/issue-103451.rs:4:15 | LL | struct S { | - unclosed delimiter @@ -9,7 +9,7 @@ LL | x: [u8; R | unclosed delimiter error: this file contains an unclosed delimiter - --> $DIR/issue-103451.rs:5:15 + --> $DIR/issue-103451.rs:4:15 | LL | struct S { | - unclosed delimiter @@ -18,15 +18,5 @@ LL | x: [u8; R | | | unclosed delimiter -error[E0423]: expected value, found struct `R` - --> $DIR/issue-103451.rs:5:13 - | -LL | struct R { } - | ------------ `R` defined here -LL | struct S { -LL | x: [u8; R - | ^ help: use struct literal syntax instead: `R {}` - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0423`. diff --git a/tests/ui/parser/issue-68987-unmatch-issue-2.stderr b/tests/ui/parser/issue-68987-unmatch-issue-2.stderr index 2c08d41a15f1b..0ecb748a0a4ce 100644 --- a/tests/ui/parser/issue-68987-unmatch-issue-2.stderr +++ b/tests/ui/parser/issue-68987-unmatch-issue-2.stderr @@ -1,3 +1,11 @@ +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 | @@ -7,13 +15,5 @@ LL | let obs_connect = || -> Result<(), MyError) { LL | } | ^ unexpected closing delimiter -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: aborting due to 2 previous errors diff --git a/tests/ui/parser/issue-68987-unmatch-issue-3.stderr b/tests/ui/parser/issue-68987-unmatch-issue-3.stderr index a3fc46a1e883c..dfc4407ed6565 100644 --- a/tests/ui/parser/issue-68987-unmatch-issue-3.stderr +++ b/tests/ui/parser/issue-68987-unmatch-issue-3.stderr @@ -1,3 +1,11 @@ +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 | @@ -7,13 +15,5 @@ LL | } LL | } | ^ unexpected closing delimiter -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: aborting due to 2 previous errors diff --git a/tests/ui/parser/issue-81804.rs b/tests/ui/parser/issue-81804.rs index 803bde11e20d1..ebc4752a14291 100644 --- a/tests/ui/parser/issue-81804.rs +++ b/tests/ui/parser/issue-81804.rs @@ -1,8 +1,5 @@ // error-pattern: this file contains an unclosed delimiter // error-pattern: this file contains an unclosed delimiter -// error-pattern: expected pattern, found `=` -// error-pattern: expected one of `)`, `,`, `->`, `where`, or `{`, found `]` -// error-pattern: expected item, found `]` fn main() {} diff --git a/tests/ui/parser/issue-81804.stderr b/tests/ui/parser/issue-81804.stderr index 19c4422c6221c..77e1a8bb2f35a 100644 --- a/tests/ui/parser/issue-81804.stderr +++ b/tests/ui/parser/issue-81804.stderr @@ -1,5 +1,5 @@ error: this file contains an unclosed delimiter - --> $DIR/issue-81804.rs:9:11 + --> $DIR/issue-81804.rs:6:11 | LL | fn p([=(} | -- ^ @@ -8,7 +8,7 @@ LL | fn p([=(} | unclosed delimiter error: this file contains an unclosed delimiter - --> $DIR/issue-81804.rs:9:11 + --> $DIR/issue-81804.rs:6:11 | LL | fn p([=(} | -- ^ @@ -16,26 +16,13 @@ LL | fn p([=(} | |unclosed delimiter | unclosed delimiter -error: expected pattern, found `=` - --> $DIR/issue-81804.rs:9:7 +error: mismatched closing delimiter: `}` + --> $DIR/issue-81804.rs:6:8 | LL | fn p([=(} - | ^ expected pattern - -error: expected one of `)`, `,`, `->`, `where`, or `{`, found `]` - --> $DIR/issue-81804.rs:9:8 - | -LL | fn p([=(} - | ^ -^ - | | | - | | help: `)` may belong here + | ^^ mismatched closing delimiter + | | | unclosed delimiter -error: expected item, found `]` - --> $DIR/issue-81804.rs:9:11 - | -LL | fn p([=(} - | ^ expected item - -error: aborting due to 5 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/parser/issue-81827.rs b/tests/ui/parser/issue-81827.rs index 7ec5815941323..91defd12a5783 100644 --- a/tests/ui/parser/issue-81827.rs +++ b/tests/ui/parser/issue-81827.rs @@ -1,6 +1,5 @@ // error-pattern: this file contains an unclosed delimiter // error-pattern: mismatched closing delimiter: `]` -// error-pattern: expected one of `)` or `,`, found `{` #![crate_name="0"] diff --git a/tests/ui/parser/issue-81827.stderr b/tests/ui/parser/issue-81827.stderr index 867244b72e849..c14bb9f42319a 100644 --- a/tests/ui/parser/issue-81827.stderr +++ b/tests/ui/parser/issue-81827.stderr @@ -1,5 +1,5 @@ error: this file contains an unclosed delimiter - --> $DIR/issue-81827.rs:11:27 + --> $DIR/issue-81827.rs:10:27 | LL | fn r()->i{0|{#[cfg(r(0{]0 | - - - ^ @@ -9,7 +9,7 @@ LL | fn r()->i{0|{#[cfg(r(0{]0 | unclosed delimiter error: this file contains an unclosed delimiter - --> $DIR/issue-81827.rs:11:27 + --> $DIR/issue-81827.rs:10:27 | LL | fn r()->i{0|{#[cfg(r(0{]0 | - - - ^ @@ -19,7 +19,7 @@ LL | fn r()->i{0|{#[cfg(r(0{]0 | unclosed delimiter error: mismatched closing delimiter: `]` - --> $DIR/issue-81827.rs:11:23 + --> $DIR/issue-81827.rs:10:23 | LL | fn r()->i{0|{#[cfg(r(0{]0 | - ^^ mismatched closing delimiter @@ -27,11 +27,5 @@ LL | fn r()->i{0|{#[cfg(r(0{]0 | | unclosed delimiter | closing delimiter possibly meant for this -error: expected one of `)` or `,`, found `{` - --> $DIR/issue-81827.rs:11:23 - | -LL | fn r()->i{0|{#[cfg(r(0{]0 - | ^ expected one of `)` or `,` - -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/parser/issues/issue-10636-2.rs b/tests/ui/parser/issues/issue-10636-2.rs index 6fb63639d5f60..80d8ef65a6952 100644 --- a/tests/ui/parser/issues/issue-10636-2.rs +++ b/tests/ui/parser/issues/issue-10636-2.rs @@ -1,11 +1,11 @@ +// error-pattern: mismatched closing delimiter: `}` // FIXME(31528) we emit a bunch of silly errors here due to continuing past the // first one. This would be easy-ish to address by better recovery in tokenisation. pub fn trace_option(option: Option) { option.map(|some| 42; - //~^ ERROR: expected one of + } -//~^ ERROR: expected expression, found `)` fn main() {} diff --git a/tests/ui/parser/issues/issue-10636-2.stderr b/tests/ui/parser/issues/issue-10636-2.stderr index d4f2da9e3ab6f..4cd4be1803e12 100644 --- a/tests/ui/parser/issues/issue-10636-2.stderr +++ b/tests/ui/parser/issues/issue-10636-2.stderr @@ -1,16 +1,13 @@ -error: expected one of `)`, `,`, `.`, `?`, or an operator, found `;` - --> $DIR/issue-10636-2.rs:5:15 +error: mismatched closing delimiter: `}` + --> $DIR/issue-10636-2.rs:6:15 | +LL | pub fn trace_option(option: Option) { + | - closing delimiter possibly meant for this LL | option.map(|some| 42; - | ^ ^ help: `)` may belong here - | | - | unclosed delimiter - -error: expected expression, found `)` - --> $DIR/issue-10636-2.rs:8:1 - | + | ^ unclosed delimiter +... LL | } - | ^ expected expression + | ^ mismatched closing delimiter -error: aborting due to 2 previous errors +error: aborting due to previous error diff --git a/tests/ui/parser/issues/issue-58094-missing-right-square-bracket.rs b/tests/ui/parser/issues/issue-58094-missing-right-square-bracket.rs index 25699f9fe111e..a596a9f2de3a2 100644 --- a/tests/ui/parser/issues/issue-58094-missing-right-square-bracket.rs +++ b/tests/ui/parser/issues/issue-58094-missing-right-square-bracket.rs @@ -1,4 +1,5 @@ // Fixed in #66054. // ignore-tidy-trailing-newlines -// error-pattern: aborting due to 2 previous errors +// error-pattern: this file contains an unclosed delimiter +// error-pattern: aborting due to previous error #[Ѕ \ No newline at end of file diff --git a/tests/ui/parser/issues/issue-58094-missing-right-square-bracket.stderr b/tests/ui/parser/issues/issue-58094-missing-right-square-bracket.stderr index 8a44ee761ed67..c79e8b4fb7082 100644 --- a/tests/ui/parser/issues/issue-58094-missing-right-square-bracket.stderr +++ b/tests/ui/parser/issues/issue-58094-missing-right-square-bracket.stderr @@ -1,16 +1,10 @@ error: this file contains an unclosed delimiter - --> $DIR/issue-58094-missing-right-square-bracket.rs:4:4 + --> $DIR/issue-58094-missing-right-square-bracket.rs:5:4 | LL | #[Ѕ | - ^ | | | unclosed delimiter -error: expected item after attributes - --> $DIR/issue-58094-missing-right-square-bracket.rs:4:1 - | -LL | #[Ѕ - | ^^^ - -error: aborting due to 2 previous errors +error: aborting due to previous error diff --git a/tests/ui/parser/issues/issue-58856-1.rs b/tests/ui/parser/issues/issue-58856-1.rs index ea80eb8714f96..799243d545ade 100644 --- a/tests/ui/parser/issues/issue-58856-1.rs +++ b/tests/ui/parser/issues/issue-58856-1.rs @@ -1,8 +1,5 @@ impl A { - //~^ ERROR cannot find type `A` in this scope fn b(self> - //~^ ERROR expected one of `)`, `,`, or `:`, found `>` - //~| ERROR expected one of `->`, `where`, or `{`, found `>` -} +} //~ ERROR mismatched closing delimiter fn main() {} diff --git a/tests/ui/parser/issues/issue-58856-1.stderr b/tests/ui/parser/issues/issue-58856-1.stderr index 96151f3fe07fd..77ad8acbd43b5 100644 --- a/tests/ui/parser/issues/issue-58856-1.stderr +++ b/tests/ui/parser/issues/issue-58856-1.stderr @@ -1,29 +1,12 @@ -error: expected one of `)`, `,`, or `:`, found `>` - --> $DIR/issue-58856-1.rs:3:9 - | -LL | fn b(self> - | ^ ^ help: `)` may belong here - | | - | unclosed delimiter - -error: expected one of `->`, `where`, or `{`, found `>` - --> $DIR/issue-58856-1.rs:3:14 +error: mismatched closing delimiter: `}` + --> $DIR/issue-58856-1.rs:2:9 | LL | impl A { - | - while parsing this item list starting here -LL | + | - closing delimiter possibly meant for this LL | fn b(self> - | ^ expected one of `->`, `where`, or `{` -... + | ^ unclosed delimiter LL | } - | - the item list ends here - -error[E0412]: cannot find type `A` in this scope - --> $DIR/issue-58856-1.rs:1:6 - | -LL | impl A { - | ^ not found in this scope + | ^ mismatched closing delimiter -error: aborting due to 3 previous errors +error: aborting due to previous error -For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/parser/issues/issue-58856-2.rs b/tests/ui/parser/issues/issue-58856-2.rs index 9356d57b0e5f4..5edd72639058d 100644 --- a/tests/ui/parser/issues/issue-58856-2.rs +++ b/tests/ui/parser/issues/issue-58856-2.rs @@ -4,11 +4,8 @@ trait Howness {} impl Howness for () { fn how_are_you(&self -> Empty { - //~^ ERROR expected one of `)` or `,`, found `->` - //~| ERROR method `how_are_you` is not a member of trait `Howness` Empty } -} -//~^ ERROR non-item in item list +} //~ ERROR mismatched closing delimiter fn main() {} diff --git a/tests/ui/parser/issues/issue-58856-2.stderr b/tests/ui/parser/issues/issue-58856-2.stderr index 627dd389059cd..5fcf5bcc17e83 100644 --- a/tests/ui/parser/issues/issue-58856-2.stderr +++ b/tests/ui/parser/issues/issue-58856-2.stderr @@ -1,34 +1,13 @@ -error: expected one of `)` or `,`, found `->` +error: mismatched closing delimiter: `}` --> $DIR/issue-58856-2.rs:6:19 | -LL | fn how_are_you(&self -> Empty { - | ^ -^^ - | | | - | | help: `)` may belong here - | unclosed delimiter - -error: non-item in item list - --> $DIR/issue-58856-2.rs:11:1 - | LL | impl Howness for () { - | - item list starts here + | - closing delimiter possibly meant for this +LL | fn how_are_you(&self -> Empty { + | ^ unclosed delimiter ... LL | } - | ^ - | | - | non-item starts here - | item list ends here - -error[E0407]: method `how_are_you` is not a member of trait `Howness` - --> $DIR/issue-58856-2.rs:6:5 - | -LL | / fn how_are_you(&self -> Empty { -LL | | -LL | | -LL | | Empty -LL | | } - | |_____^ not a member of trait `Howness` + | ^ mismatched closing delimiter -error: aborting due to 3 previous errors +error: aborting due to previous error -For more information about this error, try `rustc --explain E0407`. diff --git a/tests/ui/parser/issues/issue-60075.rs b/tests/ui/parser/issues/issue-60075.rs index e89d78ee8a6a2..3c36e4d3ea7da 100644 --- a/tests/ui/parser/issues/issue-60075.rs +++ b/tests/ui/parser/issues/issue-60075.rs @@ -3,9 +3,6 @@ fn main() {} trait T { fn qux() -> Option { let _ = if true { - }); -//~^ ERROR non-item in item list -//~| ERROR mismatched closing delimiter: `)` -//~| ERROR expected one of `.`, `;` + }); //~ ERROR mismatched closing delimiter Some(4) } diff --git a/tests/ui/parser/issues/issue-60075.stderr b/tests/ui/parser/issues/issue-60075.stderr index 210ef700cd4bc..cd8f1231fad0a 100644 --- a/tests/ui/parser/issues/issue-60075.stderr +++ b/tests/ui/parser/issues/issue-60075.stderr @@ -1,21 +1,3 @@ -error: expected one of `.`, `;`, `?`, `else`, or an operator, found `}` - --> $DIR/issue-60075.rs:6:10 - | -LL | }); - | ^ expected one of `.`, `;`, `?`, `else`, or an operator - -error: non-item in item list - --> $DIR/issue-60075.rs:6:11 - | -LL | trait T { - | - item list starts here -... -LL | }); - | ^ non-item starts here -... -LL | } - | - item list ends here - error: mismatched closing delimiter: `)` --> $DIR/issue-60075.rs:4:31 | @@ -25,5 +7,5 @@ LL | let _ = if true { LL | }); | ^ mismatched closing delimiter -error: aborting due to 3 previous errors +error: aborting due to previous error diff --git a/tests/ui/parser/issues/issue-62524.rs b/tests/ui/parser/issues/issue-62524.rs index 5259dfe2e656c..fa7c626f5cc12 100644 --- a/tests/ui/parser/issues/issue-62524.rs +++ b/tests/ui/parser/issues/issue-62524.rs @@ -1,5 +1,5 @@ // ignore-tidy-trailing-newlines -// error-pattern: aborting due to 3 previous errors +// error-pattern: aborting due to previous error #![allow(uncommon_codepoints)] y![ diff --git a/tests/ui/parser/issues/issue-62524.stderr b/tests/ui/parser/issues/issue-62524.stderr index 55eed0402a4c6..0cbaacd4c64be 100644 --- a/tests/ui/parser/issues/issue-62524.stderr +++ b/tests/ui/parser/issues/issue-62524.stderr @@ -6,28 +6,5 @@ LL | y![ LL | Ϥ, | ^ -error: macros that expand to items must be delimited with braces or followed by a semicolon - --> $DIR/issue-62524.rs:5:3 - | -LL | y![ - | ___^ -LL | | Ϥ, - | |__^ - | -help: change the delimiters to curly braces - | -LL | y! { /* items */ } - | ~~~~~~~~~~~~~~~ -help: add a semicolon - | -LL | Ϥ,; - | + - -error: cannot find macro `y` in this scope - --> $DIR/issue-62524.rs:5:1 - | -LL | y![ - | ^ - -error: aborting due to 3 previous errors +error: aborting due to previous error diff --git a/tests/ui/parser/issues/issue-62546.rs b/tests/ui/parser/issues/issue-62546.rs index f06b6505859cf..bb30d68eabd71 100644 --- a/tests/ui/parser/issues/issue-62546.rs +++ b/tests/ui/parser/issues/issue-62546.rs @@ -1,3 +1 @@ -pub t(# -//~^ ERROR missing `fn` or `struct` for function or struct definition -//~ ERROR this file contains an unclosed delimiter +pub t(# //~ ERROR this file contains an unclosed delimiter diff --git a/tests/ui/parser/issues/issue-62546.stderr b/tests/ui/parser/issues/issue-62546.stderr index 32c61391e1682..80c1c71689d15 100644 --- a/tests/ui/parser/issues/issue-62546.stderr +++ b/tests/ui/parser/issues/issue-62546.stderr @@ -1,17 +1,8 @@ error: this file contains an unclosed delimiter - --> $DIR/issue-62546.rs:3:52 + --> $DIR/issue-62546.rs:1:60 | LL | pub t(# - | - unclosed delimiter -LL | -LL | - | ^ + | - unclosed delimiter ^ -error: missing `fn` or `struct` for function or struct definition - --> $DIR/issue-62546.rs:1:4 - | -LL | pub t(# - | ---^- help: if you meant to call a macro, try: `t!` - -error: aborting due to 2 previous errors +error: aborting due to previous error diff --git a/tests/ui/parser/issues/issue-62554.rs b/tests/ui/parser/issues/issue-62554.rs index cfd02183cb4a8..4b463a17333a1 100644 --- a/tests/ui/parser/issues/issue-62554.rs +++ b/tests/ui/parser/issues/issue-62554.rs @@ -1,5 +1,4 @@ // error-pattern:this file contains an unclosed delimiter -// error-pattern:xpected `{`, found `macro_rules` fn main() {} diff --git a/tests/ui/parser/issues/issue-62554.stderr b/tests/ui/parser/issues/issue-62554.stderr index 9e62572e388fd..9cb0c5a351157 100644 --- a/tests/ui/parser/issues/issue-62554.stderr +++ b/tests/ui/parser/issues/issue-62554.stderr @@ -1,5 +1,5 @@ error: this file contains an unclosed delimiter - --> $DIR/issue-62554.rs:6:89 + --> $DIR/issue-62554.rs:5:89 | LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 { | - - - - - ^ @@ -10,7 +10,7 @@ LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s | unclosed delimiter unclosed delimiter error: this file contains an unclosed delimiter - --> $DIR/issue-62554.rs:6:89 + --> $DIR/issue-62554.rs:5:89 | LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 { | - - - - - ^ @@ -21,7 +21,7 @@ LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s | unclosed delimiter unclosed delimiter error: this file contains an unclosed delimiter - --> $DIR/issue-62554.rs:6:89 + --> $DIR/issue-62554.rs:5:89 | LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 { | - - - - - ^ @@ -32,7 +32,7 @@ LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s | unclosed delimiter unclosed delimiter error: this file contains an unclosed delimiter - --> $DIR/issue-62554.rs:6:89 + --> $DIR/issue-62554.rs:5:89 | LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 { | - - - - - ^ @@ -43,7 +43,7 @@ LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s | unclosed delimiter unclosed delimiter error: this file contains an unclosed delimiter - --> $DIR/issue-62554.rs:6:89 + --> $DIR/issue-62554.rs:5:89 | LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 { | - - - - - ^ @@ -53,21 +53,5 @@ LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s | | | unclosed delimiter | unclosed delimiter unclosed delimiter -error: expected `{`, found `macro_rules` - --> $DIR/issue-62554.rs:6:23 - | -LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 { - | ^^^^^^^^^^^ expected `{` - | -note: the `if` expression is missing a block after this condition - --> $DIR/issue-62554.rs:6:20 - | -LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 { - | ^^ -help: try placing this code inside a block - | -LL | fn foo(u: u8) { if u8 { macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 { } - | + + - -error: aborting due to 6 previous errors +error: aborting due to 5 previous errors diff --git a/tests/ui/parser/issues/issue-62881.rs b/tests/ui/parser/issues/issue-62881.rs index b9204595fb971..cc80d449930ee 100644 --- a/tests/ui/parser/issues/issue-62881.rs +++ b/tests/ui/parser/issues/issue-62881.rs @@ -1,6 +1,3 @@ fn main() {} -fn f() -> isize { fn f() -> isize {} pub f< -//~^ ERROR missing `fn` or `struct` for function or struct definition -//~| ERROR mismatched types -//~ ERROR this file contains an unclosed delimiter +fn f() -> isize { fn f() -> isize {} pub f< //~ ERROR this file contains an unclosed delimiter diff --git a/tests/ui/parser/issues/issue-62881.stderr b/tests/ui/parser/issues/issue-62881.stderr index 87be69baadda5..e57cbd1810a47 100644 --- a/tests/ui/parser/issues/issue-62881.stderr +++ b/tests/ui/parser/issues/issue-62881.stderr @@ -1,26 +1,8 @@ error: this file contains an unclosed delimiter - --> $DIR/issue-62881.rs:6:52 + --> $DIR/issue-62881.rs:3:96 | LL | fn f() -> isize { fn f() -> isize {} pub f< - | - unclosed delimiter -... -LL | - | ^ + | - unclosed delimiter ^ -error: missing `fn` or `struct` for function or struct definition - --> $DIR/issue-62881.rs:3:41 - | -LL | fn f() -> isize { fn f() -> isize {} pub f< - | ^ - -error[E0308]: mismatched types - --> $DIR/issue-62881.rs:3:29 - | -LL | fn f() -> isize { fn f() -> isize {} pub f< - | - ^^^^^ expected `isize`, found `()` - | | - | implicitly returns `()` as its body has no tail or `return` expression - -error: aborting due to 3 previous errors +error: aborting due to previous error -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/parser/issues/issue-62894.rs b/tests/ui/parser/issues/issue-62894.rs index b9c0bf834ddb2..4dfa406ea2d82 100644 --- a/tests/ui/parser/issues/issue-62894.rs +++ b/tests/ui/parser/issues/issue-62894.rs @@ -1,6 +1,5 @@ // Regression test for #62894, shouldn't crash. // error-pattern: this file contains an unclosed delimiter -// error-pattern: expected one of `(`, `[`, or `{`, found keyword `fn` fn f() { assert_eq!(f(), (), assert_eq!(assert_eq! diff --git a/tests/ui/parser/issues/issue-62894.stderr b/tests/ui/parser/issues/issue-62894.stderr index 07a203bf416ea..1b056c8a1598d 100644 --- a/tests/ui/parser/issues/issue-62894.stderr +++ b/tests/ui/parser/issues/issue-62894.stderr @@ -1,5 +1,5 @@ error: this file contains an unclosed delimiter - --> $DIR/issue-62894.rs:7:14 + --> $DIR/issue-62894.rs:6:14 | LL | fn f() { assert_eq!(f(), (), assert_eq!(assert_eq! | - - - unclosed delimiter @@ -11,7 +11,7 @@ LL | fn main() {} | ^ error: this file contains an unclosed delimiter - --> $DIR/issue-62894.rs:7:14 + --> $DIR/issue-62894.rs:6:14 | LL | fn f() { assert_eq!(f(), (), assert_eq!(assert_eq! | - - - unclosed delimiter @@ -23,7 +23,7 @@ LL | fn main() {} | ^ error: this file contains an unclosed delimiter - --> $DIR/issue-62894.rs:7:14 + --> $DIR/issue-62894.rs:6:14 | LL | fn f() { assert_eq!(f(), (), assert_eq!(assert_eq! | - - - unclosed delimiter @@ -34,17 +34,5 @@ LL | LL | fn main() {} | ^ -error: expected one of `(`, `[`, or `{`, found keyword `fn` - --> $DIR/issue-62894.rs:7:1 - | -LL | fn f() { assert_eq!(f(), (), assert_eq!(assert_eq! - | - expected one of `(`, `[`, or `{` -LL | -LL | fn main() {} - | ^^ unexpected token - --> $SRC_DIR/core/src/macros/mod.rs:LL:COL - | - = note: while parsing argument for this `expr` macro fragment - -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/parser/issues/issue-62895.rs b/tests/ui/parser/issues/issue-62895.rs index 53f17405d79f4..33511dee93e8f 100644 --- a/tests/ui/parser/issues/issue-62895.rs +++ b/tests/ui/parser/issues/issue-62895.rs @@ -1,11 +1,11 @@ fn main() {} -fn v() -> isize { //~ ERROR mismatched types -mod _ { //~ ERROR expected identifier -pub fn g() -> isizee { //~ ERROR cannot find type `isizee` in this scope -mod _ { //~ ERROR expected identifier -pub g() -> is //~ ERROR missing `fn` for function definition -(), w20); +fn v() -> isize { +mod _ { +pub fn g() -> isizee { +mod _ { +pub g() -> is +(), w20); //~ ERROR mismatched closing delimiter } -(), w20); //~ ERROR expected item, found `;` +(), w20); //~ ERROR mismatched closing delimiter } diff --git a/tests/ui/parser/issues/issue-62895.stderr b/tests/ui/parser/issues/issue-62895.stderr index 2e7e500f47880..0ad9ac63ebd45 100644 --- a/tests/ui/parser/issues/issue-62895.stderr +++ b/tests/ui/parser/issues/issue-62895.stderr @@ -1,47 +1,20 @@ -error: expected identifier, found reserved identifier `_` - --> $DIR/issue-62895.rs:4:5 +error: mismatched closing delimiter: `)` + --> $DIR/issue-62895.rs:6:7 | LL | mod _ { - | ^ expected identifier, found reserved identifier - -error: expected identifier, found reserved identifier `_` - --> $DIR/issue-62895.rs:6:5 - | -LL | mod _ { - | ^ expected identifier, found reserved identifier - -error: missing `fn` for function definition - --> $DIR/issue-62895.rs:7:4 - | + | ^ unclosed delimiter LL | pub g() -> is - | ^^^^ - | -help: add `fn` here to parse `g` as a public function - | -LL | pub fn g() -> is - | ++ - -error: expected item, found `;` - --> $DIR/issue-62895.rs:10:9 - | LL | (), w20); - | ^ help: remove this semicolon - -error[E0412]: cannot find type `isizee` in this scope - --> $DIR/issue-62895.rs:5:15 - | -LL | pub fn g() -> isizee { - | ^^^^^^ help: a builtin type with a similar name exists: `isize` + | ^ mismatched closing delimiter -error[E0308]: mismatched types - --> $DIR/issue-62895.rs:3:11 +error: mismatched closing delimiter: `)` + --> $DIR/issue-62895.rs:4:7 | -LL | fn v() -> isize { - | - ^^^^^ expected `isize`, found `()` - | | - | implicitly returns `()` as its body has no tail or `return` expression +LL | mod _ { + | ^ unclosed delimiter +... +LL | (), w20); + | ^ mismatched closing delimiter -error: aborting due to 6 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0308, E0412. -For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/parser/issues/issue-62973.rs b/tests/ui/parser/issues/issue-62973.rs index 1c5d0c6f8ab46..e8314a88a2b15 100644 --- a/tests/ui/parser/issues/issue-62973.rs +++ b/tests/ui/parser/issues/issue-62973.rs @@ -1,5 +1,5 @@ // ignore-tidy-trailing-newlines -// error-pattern: aborting due to 7 previous errors +// error-pattern: aborting due to 4 previous errors fn main() {} diff --git a/tests/ui/parser/issues/issue-62973.stderr b/tests/ui/parser/issues/issue-62973.stderr index 3cb6d75a6754b..1296063c05a56 100644 --- a/tests/ui/parser/issues/issue-62973.stderr +++ b/tests/ui/parser/issues/issue-62973.stderr @@ -24,49 +24,6 @@ LL | LL | | ^ -error: expected one of `,`, `:`, or `}`, found `{` - --> $DIR/issue-62973.rs:6:8 - | -LL | fn p() { match s { v, E { [) {) } - | ^ - ^ expected one of `,`, `:`, or `}` - | | | - | | while parsing this struct - | unclosed delimiter - | -help: `}` may belong here - | -LL | fn p() { match s { v, E} { [) {) } - | + -help: try naming a field - | -LL | fn p() { match s { v, E: E { [) {) } - | ++ - -error: struct literals are not allowed here - --> $DIR/issue-62973.rs:6:16 - | -LL | fn p() { match s { v, E { [) {) } - | ________________^ -LL | | -LL | | - | |_^ - | -help: surround the struct literal with parentheses - | -LL ~ fn p() { match (s { v, E { [) {) } -LL | -LL ~ ) - | - -error: expected one of `.`, `?`, `{`, or an operator, found `}` - --> $DIR/issue-62973.rs:8:2 - | -LL | fn p() { match s { v, E { [) {) } - | ----- while parsing this `match` expression -LL | -LL | - | ^ expected one of `.`, `?`, `{`, or an operator - error: mismatched closing delimiter: `)` --> $DIR/issue-62973.rs:6:27 | @@ -83,5 +40,5 @@ LL | fn p() { match s { v, E { [) {) } | | | unclosed delimiter -error: aborting due to 7 previous errors +error: aborting due to 4 previous errors diff --git a/tests/ui/parser/issues/issue-63116.rs b/tests/ui/parser/issues/issue-63116.rs index 430bc1d716c91..6b9d9cdbeb1fb 100644 --- a/tests/ui/parser/issues/issue-63116.rs +++ b/tests/ui/parser/issues/issue-63116.rs @@ -1,3 +1,3 @@ // fixed by #66361 -// error-pattern: aborting due to 3 previous errors +// error-pattern: aborting due to 2 previous errors impl W $DIR/issue-63116.rs:3:12 - | -LL | impl W $DIR/issue-63116.rs:3:14 | @@ -21,5 +15,5 @@ LL | impl W $DIR/issue-63135.rs:3:8 - | -LL | fn i(n{...,f # - | ^^^ - | -help: to omit remaining fields, use `..` - | -LL | fn i(n{..,f # - | ~~ - -error: expected `}`, found `,` - --> $DIR/issue-63135.rs:3:11 - | -LL | fn i(n{...,f # - | ---^ - | | | - | | expected `}` - | `..` must be at the end and cannot have a trailing comma - -error: expected one of `!` or `[`, found `}` - --> $DIR/issue-63135.rs:3:16 - | -LL | fn i(n{...,f # - | - ^ expected one of `!` or `[` - | | - | while parsing the fields for this pattern - -error: aborting due to 5 previous errors +error: aborting due to 2 previous errors diff --git a/tests/ui/parser/issues/issue-66357-unexpected-unreachable.rs b/tests/ui/parser/issues/issue-66357-unexpected-unreachable.rs index aed428bfc2a79..69a2dfe6cbd15 100644 --- a/tests/ui/parser/issues/issue-66357-unexpected-unreachable.rs +++ b/tests/ui/parser/issues/issue-66357-unexpected-unreachable.rs @@ -9,6 +9,4 @@ // // ended up bubbling up `Ok(true)` to `unexpected` which then used `unreachable!()`. -fn f() { |[](* } -//~^ ERROR expected one of `,` or `:`, found `(` -//~| ERROR expected one of `&`, `(`, `)`, `-`, `...`, `..=`, `..`, `[`, `_`, `box`, `mut`, `ref`, `|`, identifier, or path, found `*` +fn f() { |[](* } //~ ERROR mismatched closing delimiter diff --git a/tests/ui/parser/issues/issue-66357-unexpected-unreachable.stderr b/tests/ui/parser/issues/issue-66357-unexpected-unreachable.stderr index 6cbab855c7636..079fff37ea4f8 100644 --- a/tests/ui/parser/issues/issue-66357-unexpected-unreachable.stderr +++ b/tests/ui/parser/issues/issue-66357-unexpected-unreachable.stderr @@ -1,16 +1,11 @@ -error: expected one of `,` or `:`, found `(` +error: mismatched closing delimiter: `}` --> $DIR/issue-66357-unexpected-unreachable.rs:12:13 | LL | fn f() { |[](* } - | ^ expected one of `,` or `:` + | - ^ ^ mismatched closing delimiter + | | | + | | unclosed delimiter + | closing delimiter possibly meant for this -error: expected one of `&`, `(`, `)`, `-`, `...`, `..=`, `..`, `[`, `_`, `box`, `mut`, `ref`, `|`, identifier, or path, found `*` - --> $DIR/issue-66357-unexpected-unreachable.rs:12:13 - | -LL | fn f() { |[](* } - | ^^ help: `)` may belong here - | | - | unclosed delimiter - -error: aborting due to 2 previous errors +error: aborting due to previous error diff --git a/tests/ui/parser/issues/issue-67377-invalid-syntax-in-enum-discriminant.rs b/tests/ui/parser/issues/issue-67377-invalid-syntax-in-enum-discriminant.rs index 87222ef4b5924..e712160fcf84d 100644 --- a/tests/ui/parser/issues/issue-67377-invalid-syntax-in-enum-discriminant.rs +++ b/tests/ui/parser/issues/issue-67377-invalid-syntax-in-enum-discriminant.rs @@ -4,9 +4,6 @@ mod a { enum Bug { V = [PhantomData; { [ () ].len() ].len() as isize, //~^ ERROR mismatched closing delimiter: `]` - //~| ERROR mismatched closing delimiter: `]` - //~| ERROR mismatched closing delimiter: `]` - //~| ERROR mismatched closing delimiter: `]` } } @@ -14,10 +11,6 @@ mod b { enum Bug { V = [Vec::new; { [].len() ].len() as isize, //~^ ERROR mismatched closing delimiter: `]` - //~| ERROR mismatched closing delimiter: `]` - //~| ERROR mismatched closing delimiter: `]` - //~| ERROR mismatched closing delimiter: `]` - //~| ERROR type annotations needed } } @@ -25,11 +18,6 @@ mod c { enum Bug { V = [Vec::new; { [0].len() ].len() as isize, //~^ ERROR mismatched closing delimiter: `]` - //~| ERROR mismatched closing delimiter: `]` - //~| ERROR mismatched closing delimiter: `]` - //~| ERROR mismatched closing delimiter: `]` - //~| ERROR type annotations needed - } } -fn main() {} +fn main() {} //~ ERROR this file contains an unclosed delimiter diff --git a/tests/ui/parser/issues/issue-67377-invalid-syntax-in-enum-discriminant.stderr b/tests/ui/parser/issues/issue-67377-invalid-syntax-in-enum-discriminant.stderr index a00f37ed6069c..dc6af1ed5687e 100644 --- a/tests/ui/parser/issues/issue-67377-invalid-syntax-in-enum-discriminant.stderr +++ b/tests/ui/parser/issues/issue-67377-invalid-syntax-in-enum-discriminant.stderr @@ -1,83 +1,20 @@ -error: mismatched closing delimiter: `]` - --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:5:27 - | -LL | V = [PhantomData; { [ () ].len() ].len() as isize, - | - ^ ^ mismatched closing delimiter - | | | - | | unclosed delimiter - | closing delimiter possibly meant for this - -error: mismatched closing delimiter: `]` - --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:15:24 - | -LL | V = [Vec::new; { [].len() ].len() as isize, - | - ^ ^ mismatched closing delimiter - | | | - | | unclosed delimiter - | closing delimiter possibly meant for this - -error: mismatched closing delimiter: `]` - --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:26:24 - | -LL | V = [Vec::new; { [0].len() ].len() as isize, - | - ^ ^ mismatched closing delimiter - | | | - | | unclosed delimiter - | closing delimiter possibly meant for this - -error: mismatched closing delimiter: `]` - --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:5:27 - | -LL | V = [PhantomData; { [ () ].len() ].len() as isize, - | - ^ ^ mismatched closing delimiter - | | | - | | unclosed delimiter - | closing delimiter possibly meant for this - -error: mismatched closing delimiter: `]` - --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:15:24 - | -LL | V = [Vec::new; { [].len() ].len() as isize, - | - ^ ^ mismatched closing delimiter - | | | - | | unclosed delimiter - | closing delimiter possibly meant for this - -error: mismatched closing delimiter: `]` - --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:26:24 - | -LL | V = [Vec::new; { [0].len() ].len() as isize, - | - ^ ^ mismatched closing delimiter - | | | - | | unclosed delimiter - | closing delimiter possibly meant for this - -error: mismatched closing delimiter: `]` - --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:5:27 +error: this file contains an unclosed delimiter + --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:23:65 | LL | V = [PhantomData; { [ () ].len() ].len() as isize, - | - ^ ^ mismatched closing delimiter - | | | - | | unclosed delimiter - | closing delimiter possibly meant for this - -error: mismatched closing delimiter: `]` - --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:15:24 - | + | - missing open `[` for this delimiter +... LL | V = [Vec::new; { [].len() ].len() as isize, - | - ^ ^ mismatched closing delimiter - | | | - | | unclosed delimiter - | closing delimiter possibly meant for this - -error: mismatched closing delimiter: `]` - --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:26:24 - | + | - missing open `[` for this delimiter +... +LL | mod c { + | - unclosed delimiter +LL | enum Bug { LL | V = [Vec::new; { [0].len() ].len() as isize, - | - ^ ^ mismatched closing delimiter - | | | - | | unclosed delimiter - | closing delimiter possibly meant for this + | - missing open `[` for this delimiter +... +LL | fn main() {} + | ^ error: mismatched closing delimiter: `]` --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:5:27 @@ -89,7 +26,7 @@ LL | V = [PhantomData; { [ () ].len() ].len() as isize, | closing delimiter possibly meant for this error: mismatched closing delimiter: `]` - --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:15:24 + --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:12:24 | LL | V = [Vec::new; { [].len() ].len() as isize, | - ^ ^ mismatched closing delimiter @@ -98,7 +35,7 @@ LL | V = [Vec::new; { [].len() ].len() as isize, | closing delimiter possibly meant for this error: mismatched closing delimiter: `]` - --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:26:24 + --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:19:24 | LL | V = [Vec::new; { [0].len() ].len() as isize, | - ^ ^ mismatched closing delimiter @@ -106,23 +43,5 @@ LL | V = [Vec::new; { [0].len() ].len() as isize, | | unclosed delimiter | closing delimiter possibly meant for this -error[E0282]: type annotations needed - --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:15:26 - | -LL | V = [Vec::new; { [].len() ].len() as isize, - | ^^ cannot infer type for type parameter `T` - -error[E0282]: type annotations needed - --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:26:14 - | -LL | V = [Vec::new; { [0].len() ].len() as isize, - | ^^^^^^^^ cannot infer type of the type parameter `T` declared on the struct `Vec` - | -help: consider specifying the generic argument - | -LL | V = [Vec::::new; { [0].len() ].len() as isize, - | +++++ - -error: aborting due to 14 previous errors +error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/parser/issues/issue-68629.rs b/tests/ui/parser/issues/issue-68629.rs index 672a31f12c838bf7b2e54e6012354acea5852515..af89bb58699b51d2a72be405dd52999cdce599c7 100644 GIT binary patch delta 37 rcmcb>)W|qdF-4Y3M!uw&K{2{IlZ$~tK_M+qq3G`J{6sq-nac$L$J`6+ literal 336 zcmZvXJx;_x424tY3`jf<5T&Q!A~frragxy{c4RwRRveA9a2G5JXwult``*tuqRpbl zL$vxB!lSPu$kJhQv{p5;*gu@UEo0$&d6g{(4@^O@Nuvon2T0rJf!Gcq?$Ze;d@ xbMzGAxVTb_it>xB6cUs2i%K%{(iKulQx!_`70eV0ic-rm^Gk~rz$%KlxB#trAi@9u literal 1637 zcmds1&2G~`7|hwvfW#niDumD?f@?%i2nnetL{Fg7&H8h^s=c4JyC#W}@?ty-@6yk9 z;`A>8i31XQuq@j<-kJGk$T@ZiYI|vUX5oW!0h}T5CD{aD>*b-oih$wp1W(_8{4_G& z*EAf*kk#DyjsYYo`gBDafO&eSl^gl(9Jb{9zb_tmc$b1e%BEA}h@+(m@{Bx+pMNgl3zW z<|4AzwZkkY3x(8V89B0{12A?9<57D`|3t#Q6pwE?G#CJxh5PlB)rnlojZ^=gXsfd2 zKnZlNoD$g_R8^639&APRk{$JWgj^JAeAqbPp{yvb3l`asQejFX5JGU*@QO6!efG=7 zhXG~OH+r>q5B#;w!w$8Z&HdVj%4=86PhS2*J2)jclTX5UV&ny?E^VWqWb!-!Ei`fj-P JXv^P6(KUdF_ay)T diff --git a/tests/ui/parser/issues/issue-84104.rs b/tests/ui/parser/issues/issue-84104.rs index 998949b94a4ba..962eb69bd83f1 100644 --- a/tests/ui/parser/issues/issue-84104.rs +++ b/tests/ui/parser/issues/issue-84104.rs @@ -1,3 +1,2 @@ // error-pattern: this file contains an unclosed delimiter -// error-pattern: expected one of #[i=i::<ښܖ< diff --git a/tests/ui/parser/issues/issue-84104.stderr b/tests/ui/parser/issues/issue-84104.stderr index aff31f2c97149..7ad59f8450efa 100644 --- a/tests/ui/parser/issues/issue-84104.stderr +++ b/tests/ui/parser/issues/issue-84104.stderr @@ -1,16 +1,10 @@ error: this file contains an unclosed delimiter - --> $DIR/issue-84104.rs:3:13 + --> $DIR/issue-84104.rs:2:13 | LL | #[i=i::<ښܖ< | - ^ | | | unclosed delimiter -error: expected one of `>`, a const expression, lifetime, or type, found `]` - --> $DIR/issue-84104.rs:3:13 - | -LL | #[i=i::<ښܖ< - | ^ expected one of `>`, a const expression, lifetime, or type - -error: aborting due to 2 previous errors +error: aborting due to previous error diff --git a/tests/ui/parser/issues/issue-84148-2.rs b/tests/ui/parser/issues/issue-84148-2.rs index 2f6a7facfb271..e677abde5f632 100644 --- a/tests/ui/parser/issues/issue-84148-2.rs +++ b/tests/ui/parser/issues/issue-84148-2.rs @@ -1,3 +1,2 @@ // error-pattern: this file contains an unclosed delimiter -// error-pattern: invalid `?` in type fn f(t:for<>t? diff --git a/tests/ui/parser/issues/issue-84148-2.stderr b/tests/ui/parser/issues/issue-84148-2.stderr index 71d543f9b7344..20761180e77c4 100644 --- a/tests/ui/parser/issues/issue-84148-2.stderr +++ b/tests/ui/parser/issues/issue-84148-2.stderr @@ -1,27 +1,10 @@ error: this file contains an unclosed delimiter - --> $DIR/issue-84148-2.rs:3:16 + --> $DIR/issue-84148-2.rs:2:16 | LL | fn f(t:for<>t? | - ^ | | | unclosed delimiter -error: invalid `?` in type - --> $DIR/issue-84148-2.rs:3:14 - | -LL | fn f(t:for<>t? - | ^ `?` 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 | fn f(t:Optiont> - | +++++++ ~ - -error: expected one of `->`, `where`, or `{`, found `` - --> $DIR/issue-84148-2.rs:3:16 - | -LL | fn f(t:for<>t? - | ^ expected one of `->`, `where`, or `{` - -error: aborting due to 3 previous errors +error: aborting due to previous error diff --git a/tests/ui/parser/issues/issue-88770.rs b/tests/ui/parser/issues/issue-88770.rs index bb69951c7b4ea..9341415b2d9d6 100644 --- a/tests/ui/parser/issues/issue-88770.rs +++ b/tests/ui/parser/issues/issue-88770.rs @@ -1,9 +1,6 @@ // Regression test for the ICE described in #88770. // error-pattern:this file contains an unclosed delimiter -// error-pattern:expected one of -// error-pattern:missing `in` in `for` loop -// error-pattern:expected one of `!`, `)`, `,`, `.`, `::`, `;`, `?`, `{`, or an operator, found `e` fn m(){print!("",(c for&g u diff --git a/tests/ui/parser/issues/issue-88770.stderr b/tests/ui/parser/issues/issue-88770.stderr index 4e3a21613ec78..3fec25cdf4c58 100644 --- a/tests/ui/parser/issues/issue-88770.stderr +++ b/tests/ui/parser/issues/issue-88770.stderr @@ -1,5 +1,5 @@ error: this file contains an unclosed delimiter - --> $DIR/issue-88770.rs:11:3 + --> $DIR/issue-88770.rs:8:3 | LL | fn m(){print!("",(c for&g | - - - unclosed delimiter @@ -11,7 +11,7 @@ LL | e | ^ error: this file contains an unclosed delimiter - --> $DIR/issue-88770.rs:11:3 + --> $DIR/issue-88770.rs:8:3 | LL | fn m(){print!("",(c for&g | - - - unclosed delimiter @@ -23,7 +23,7 @@ LL | e | ^ error: this file contains an unclosed delimiter - --> $DIR/issue-88770.rs:11:3 + --> $DIR/issue-88770.rs:8:3 | LL | fn m(){print!("",(c for&g | - - - unclosed delimiter @@ -34,27 +34,5 @@ LL | fn m(){print!("",(c for&g LL | e | ^ -error: missing `in` in `for` loop - --> $DIR/issue-88770.rs:8:26 - | -LL | fn m(){print!("",(c for&g - | __________________________^ -LL | | u - | |_ help: try adding `in` here - -error: expected one of `!`, `)`, `,`, `.`, `::`, `?`, `{`, or an operator, found keyword `for` - --> $DIR/issue-88770.rs:8:21 - | -LL | fn m(){print!("",(c for&g - | ^^^ expected one of 8 possible tokens - -error: expected one of `!`, `)`, `,`, `.`, `::`, `;`, `?`, `{`, or an operator, found `e` - --> $DIR/issue-88770.rs:11:1 - | -LL | e - | - expected one of 9 possible tokens -LL | e - | ^ unexpected token - -error: aborting due to 6 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/parser/macro-mismatched-delim-paren-brace.stderr b/tests/ui/parser/macro-mismatched-delim-paren-brace.stderr index 689ce1eb6b704..34217e21ae95e 100644 --- a/tests/ui/parser/macro-mismatched-delim-paren-brace.stderr +++ b/tests/ui/parser/macro-mismatched-delim-paren-brace.stderr @@ -1,3 +1,12 @@ +error: mismatched closing delimiter: `}` + --> $DIR/macro-mismatched-delim-paren-brace.rs:2:10 + | +LL | foo! ( + | ^ unclosed delimiter +LL | bar, "baz", 1, 2.0 +LL | } + | ^ mismatched closing delimiter + error: unexpected closing delimiter: `}` --> $DIR/macro-mismatched-delim-paren-brace.rs:5:1 | @@ -9,14 +18,5 @@ LL | } LL | } | ^ unexpected closing delimiter -error: mismatched closing delimiter: `}` - --> $DIR/macro-mismatched-delim-paren-brace.rs:2:10 - | -LL | foo! ( - | ^ unclosed delimiter -LL | bar, "baz", 1, 2.0 -LL | } - | ^ mismatched closing delimiter - error: aborting due to 2 previous errors diff --git a/tests/ui/parser/mbe_missing_right_paren.rs b/tests/ui/parser/mbe_missing_right_paren.rs index 689176b3eb75b..9a92e67da4db2 100644 --- a/tests/ui/parser/mbe_missing_right_paren.rs +++ b/tests/ui/parser/mbe_missing_right_paren.rs @@ -1,3 +1,3 @@ // ignore-tidy-trailing-newlines -// error-pattern: aborting due to 3 previous errors +// error-pattern: this file contains an unclosed delimiter macro_rules! abc(ؼ \ No newline at end of file diff --git a/tests/ui/parser/mbe_missing_right_paren.stderr b/tests/ui/parser/mbe_missing_right_paren.stderr index ccaf77d3995e0..d2af94683eff4 100644 --- a/tests/ui/parser/mbe_missing_right_paren.stderr +++ b/tests/ui/parser/mbe_missing_right_paren.stderr @@ -6,26 +6,5 @@ LL | macro_rules! abc(ؼ | | | unclosed delimiter -error: macros that expand to items must be delimited with braces or followed by a semicolon - --> $DIR/mbe_missing_right_paren.rs:3:17 - | -LL | macro_rules! abc(ؼ - | ^^ - | -help: change the delimiters to curly braces - | -LL | macro_rules! abc { /* items */ } - | ~~~~~~~~~~~~~~~ -help: add a semicolon - | -LL | macro_rules! abc(ؼ; - | + - -error: unexpected end of macro invocation - --> $DIR/mbe_missing_right_paren.rs:3:19 - | -LL | macro_rules! abc(ؼ - | ^ missing tokens in macro arguments - -error: aborting due to 3 previous errors +error: aborting due to previous error diff --git a/tests/ui/parser/mismatched-braces/missing-close-brace-in-impl-trait.rs b/tests/ui/parser/mismatched-braces/missing-close-brace-in-impl-trait.rs index 8f46970b1af4d..79de98d8b8cd3 100644 --- a/tests/ui/parser/mismatched-braces/missing-close-brace-in-impl-trait.rs +++ b/tests/ui/parser/mismatched-braces/missing-close-brace-in-impl-trait.rs @@ -1,13 +1,13 @@ fn main() {} -impl T for () { //~ ERROR cannot find trait `T` in this scope +impl T for () { fn foo(&self) {} -trait T { //~ ERROR trait is not supported in `trait`s or `impl`s +trait T { fn foo(&self); } -pub(crate) struct Bar(); //~ ERROR struct is not supported in `trait`s or `impl`s +pub(crate) struct Bar(); //~ ERROR this file contains an unclosed delimiter diff --git a/tests/ui/parser/mismatched-braces/missing-close-brace-in-impl-trait.stderr b/tests/ui/parser/mismatched-braces/missing-close-brace-in-impl-trait.stderr index cc7cc0c55d5ff..d91a7f0542d38 100644 --- a/tests/ui/parser/mismatched-braces/missing-close-brace-in-impl-trait.stderr +++ b/tests/ui/parser/mismatched-braces/missing-close-brace-in-impl-trait.stderr @@ -7,28 +7,5 @@ LL | impl T for () { LL | | ^ -error: trait is not supported in `trait`s or `impl`s - --> $DIR/missing-close-brace-in-impl-trait.rs:7:1 - | -LL | trait T { - | ^^^^^^^ - | - = help: consider moving the trait out to a nearby module scope - -error: struct is not supported in `trait`s or `impl`s - --> $DIR/missing-close-brace-in-impl-trait.rs:11:1 - | -LL | pub(crate) struct Bar(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: consider moving the struct out to a nearby module scope - -error[E0405]: cannot find trait `T` in this scope - --> $DIR/missing-close-brace-in-impl-trait.rs:3:6 - | -LL | impl T for () { - | ^ not found in this scope - -error: aborting due to 4 previous errors +error: aborting due to previous error -For more information about this error, try `rustc --explain E0405`. diff --git a/tests/ui/parser/mismatched-braces/missing-close-brace-in-struct.rs b/tests/ui/parser/mismatched-braces/missing-close-brace-in-struct.rs index 090a17b413dda..88bc72576877e 100644 --- a/tests/ui/parser/mismatched-braces/missing-close-brace-in-struct.rs +++ b/tests/ui/parser/mismatched-braces/missing-close-brace-in-struct.rs @@ -1,7 +1,7 @@ pub(crate) struct Bar { foo: T, -trait T { //~ ERROR expected identifier, found keyword `trait` +trait T { fn foo(&self); } diff --git a/tests/ui/parser/mismatched-braces/missing-close-brace-in-struct.stderr b/tests/ui/parser/mismatched-braces/missing-close-brace-in-struct.stderr index ad1e90e43ec4e..d01d9ed60e411 100644 --- a/tests/ui/parser/mismatched-braces/missing-close-brace-in-struct.stderr +++ b/tests/ui/parser/mismatched-braces/missing-close-brace-in-struct.stderr @@ -7,14 +7,5 @@ LL | pub(crate) struct Bar { LL | fn main() {} | ^ -error: expected identifier, found keyword `trait` - --> $DIR/missing-close-brace-in-struct.rs:4:1 - | -LL | pub(crate) struct Bar { - | --- while parsing this struct -... -LL | trait T { - | ^^^^^ expected identifier, found keyword - -error: aborting due to 2 previous errors +error: aborting due to previous error diff --git a/tests/ui/parser/mismatched-braces/missing-close-brace-in-trait.rs b/tests/ui/parser/mismatched-braces/missing-close-brace-in-trait.rs index b6932deb5c0a6..a05d6aa8edc12 100644 --- a/tests/ui/parser/mismatched-braces/missing-close-brace-in-trait.rs +++ b/tests/ui/parser/mismatched-braces/missing-close-brace-in-trait.rs @@ -2,10 +2,9 @@ trait T { fn foo(&self); pub(crate) struct Bar(); -//~^ ERROR struct is not supported in `trait`s or `impl`s impl T for Bar { -//~^ ERROR implementation is not supported in `trait`s or `impl`s + fn foo(&self) {} } diff --git a/tests/ui/parser/mismatched-braces/missing-close-brace-in-trait.stderr b/tests/ui/parser/mismatched-braces/missing-close-brace-in-trait.stderr index 7c6254356e077..7418dd64c9e91 100644 --- a/tests/ui/parser/mismatched-braces/missing-close-brace-in-trait.stderr +++ b/tests/ui/parser/mismatched-braces/missing-close-brace-in-trait.stderr @@ -1,5 +1,5 @@ error: this file contains an unclosed delimiter - --> $DIR/missing-close-brace-in-trait.rs:12:65 + --> $DIR/missing-close-brace-in-trait.rs:11:65 | LL | trait T { | - unclosed delimiter @@ -7,21 +7,5 @@ LL | trait T { LL | fn main() {} | ^ -error: struct is not supported in `trait`s or `impl`s - --> $DIR/missing-close-brace-in-trait.rs:4:1 - | -LL | pub(crate) struct Bar(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: consider moving the struct out to a nearby module scope - -error: implementation is not supported in `trait`s or `impl`s - --> $DIR/missing-close-brace-in-trait.rs:7:1 - | -LL | impl T for Bar { - | ^^^^^^^^^^^^^^^^^^^^^ - | - = help: consider moving the implementation out to a nearby module scope - -error: aborting due to 3 previous errors +error: aborting due to previous error diff --git a/tests/ui/parser/missing_right_paren.rs b/tests/ui/parser/missing_right_paren.rs index 810dee9571d81..c5c56ac4cd4c1 100644 --- a/tests/ui/parser/missing_right_paren.rs +++ b/tests/ui/parser/missing_right_paren.rs @@ -1,3 +1,4 @@ // ignore-tidy-trailing-newlines -// error-pattern: aborting due to 4 previous errors +// error-pattern: this file contains an unclosed delimiter +// error-pattern: aborting due to 2 previous errors fn main((ؼ \ No newline at end of file diff --git a/tests/ui/parser/missing_right_paren.stderr b/tests/ui/parser/missing_right_paren.stderr index 3fe0d0f4273de..dfdc6a831e04f 100644 --- a/tests/ui/parser/missing_right_paren.stderr +++ b/tests/ui/parser/missing_right_paren.stderr @@ -1,5 +1,5 @@ error: this file contains an unclosed delimiter - --> $DIR/missing_right_paren.rs:3:11 + --> $DIR/missing_right_paren.rs:4:11 | LL | fn main((ؼ | -- ^ @@ -8,7 +8,7 @@ LL | fn main((ؼ | unclosed delimiter error: this file contains an unclosed delimiter - --> $DIR/missing_right_paren.rs:3:11 + --> $DIR/missing_right_paren.rs:4:11 | LL | fn main((ؼ | -- ^ @@ -16,17 +16,5 @@ LL | fn main((ؼ | |unclosed delimiter | unclosed delimiter -error: expected one of `:` or `|`, found `)` - --> $DIR/missing_right_paren.rs:3:11 - | -LL | fn main((ؼ - | ^ expected one of `:` or `|` - -error: expected one of `->`, `where`, or `{`, found `` - --> $DIR/missing_right_paren.rs:3:11 - | -LL | fn main((ؼ - | ^ expected one of `->`, `where`, or `{` - -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors diff --git a/tests/ui/parser/parser-recovery-1.rs b/tests/ui/parser/parser-recovery-1.rs index 7e26b4f2b6a22..5f729665cb8be 100644 --- a/tests/ui/parser/parser-recovery-1.rs +++ b/tests/ui/parser/parser-recovery-1.rs @@ -3,11 +3,8 @@ trait Foo { fn bar() { let x = foo(); - //~^ ERROR cannot find function `foo` in this scope } fn main() { let x = y.; - //~^ ERROR unexpected token - //~| ERROR cannot find value `y` in this scope } //~ ERROR this file contains an unclosed delimiter diff --git a/tests/ui/parser/parser-recovery-1.stderr b/tests/ui/parser/parser-recovery-1.stderr index 0cb771ea39c6d..7045b6f5b7869 100644 --- a/tests/ui/parser/parser-recovery-1.stderr +++ b/tests/ui/parser/parser-recovery-1.stderr @@ -1,35 +1,16 @@ error: this file contains an unclosed delimiter - --> $DIR/parser-recovery-1.rs:13:54 + --> $DIR/parser-recovery-1.rs:10:54 | LL | trait Foo { | - unclosed delimiter LL | fn bar() { | - this delimiter might not be properly closed... -... +LL | let x = foo(); LL | } | - ...as it matches this but it has different indentation ... LL | } | ^ -error: unexpected token: `;` - --> $DIR/parser-recovery-1.rs:10:15 - | -LL | let x = y.; - | ^ - -error[E0425]: cannot find value `y` in this scope - --> $DIR/parser-recovery-1.rs:10:13 - | -LL | let x = y.; - | ^ not found in this scope - -error[E0425]: cannot find function `foo` in this scope - --> $DIR/parser-recovery-1.rs:5:17 - | -LL | let x = foo(); - | ^^^ not found in this scope - -error: aborting due to 4 previous errors +error: aborting due to previous error -For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/parser/parser-recovery-2.rs b/tests/ui/parser/parser-recovery-2.rs index 48b22afffe7f0..203d8aac66c59 100644 --- a/tests/ui/parser/parser-recovery-2.rs +++ b/tests/ui/parser/parser-recovery-2.rs @@ -2,11 +2,10 @@ trait Foo { fn bar() { - let x = foo(); //~ ERROR cannot find function `foo` in this scope + let x = foo(); ) //~ ERROR mismatched closing delimiter: `)` } fn main() { - let x = y.; //~ ERROR unexpected token - //~^ ERROR cannot find value `y` in this scope + let x = y.; } diff --git a/tests/ui/parser/parser-recovery-2.stderr b/tests/ui/parser/parser-recovery-2.stderr index 8829cf4c1e160..f396e5fde5bad 100644 --- a/tests/ui/parser/parser-recovery-2.stderr +++ b/tests/ui/parser/parser-recovery-2.stderr @@ -1,9 +1,3 @@ -error: unexpected token: `;` - --> $DIR/parser-recovery-2.rs:10:15 - | -LL | let x = y.; - | ^ - error: mismatched closing delimiter: `)` --> $DIR/parser-recovery-2.rs:4:14 | @@ -13,18 +7,5 @@ LL | let x = foo(); LL | ) | ^ mismatched closing delimiter -error[E0425]: cannot find value `y` in this scope - --> $DIR/parser-recovery-2.rs:10:13 - | -LL | let x = y.; - | ^ not found in this scope - -error[E0425]: cannot find function `foo` in this scope - --> $DIR/parser-recovery-2.rs:5:17 - | -LL | let x = foo(); - | ^^^ not found in this scope - -error: aborting due to 4 previous errors +error: aborting due to previous error -For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/parser/unclosed-delimiter-in-dep.rs b/tests/ui/parser/unclosed-delimiter-in-dep.rs index 6db1b66e9f785..4de83ee640a73 100644 --- a/tests/ui/parser/unclosed-delimiter-in-dep.rs +++ b/tests/ui/parser/unclosed-delimiter-in-dep.rs @@ -2,5 +2,4 @@ mod unclosed_delim_mod; fn main() { let _: usize = unclosed_delim_mod::new(); - //~^ ERROR mismatched types } diff --git a/tests/ui/parser/unclosed-delimiter-in-dep.stderr b/tests/ui/parser/unclosed-delimiter-in-dep.stderr index d1725c60dbbea..a46d020b9672e 100644 --- a/tests/ui/parser/unclosed-delimiter-in-dep.stderr +++ b/tests/ui/parser/unclosed-delimiter-in-dep.stderr @@ -9,17 +9,5 @@ LL | } LL | } | ^ mismatched closing delimiter -error[E0308]: mismatched types - --> $DIR/unclosed-delimiter-in-dep.rs:4:20 - | -LL | let _: usize = unclosed_delim_mod::new(); - | ----- ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `Result` - | | - | expected due to this - | - = note: expected type `usize` - found enum `Result` - -error: aborting due to 2 previous errors +error: aborting due to previous error -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/parser/use-unclosed-brace.rs b/tests/ui/parser/use-unclosed-brace.rs index 41742f37f3c50..fcfe95b26f96b 100644 --- a/tests/ui/parser/use-unclosed-brace.rs +++ b/tests/ui/parser/use-unclosed-brace.rs @@ -1,6 +1,4 @@ -// error-pattern: expected one of `,`, `::`, `as`, or `}`, found `;` // error-pattern: this file contains an unclosed delimiter -// error-pattern: expected item, found `}` use foo::{bar, baz; use std::fmt::Display; diff --git a/tests/ui/parser/use-unclosed-brace.stderr b/tests/ui/parser/use-unclosed-brace.stderr index 438fe9c47eac1..ad5bb2de1b256 100644 --- a/tests/ui/parser/use-unclosed-brace.stderr +++ b/tests/ui/parser/use-unclosed-brace.stderr @@ -1,5 +1,5 @@ error: this file contains an unclosed delimiter - --> $DIR/use-unclosed-brace.rs:12:14 + --> $DIR/use-unclosed-brace.rs:10:14 | LL | use foo::{bar, baz; | - unclosed delimiter @@ -7,21 +7,5 @@ LL | use foo::{bar, baz; LL | fn main() {} | ^ -error: expected one of `,`, `::`, `as`, or `}`, found `;` - --> $DIR/use-unclosed-brace.rs:4:10 - | -LL | use foo::{bar, baz; - | ^ ^ - | | | - | | expected one of `,`, `::`, `as`, or `}` - | | help: `}` may belong here - | unclosed delimiter - -error: expected item, found `}` - --> $DIR/use-unclosed-brace.rs:12:14 - | -LL | fn main() {} - | ^ expected item - -error: aborting due to 3 previous errors +error: aborting due to previous error diff --git a/tests/ui/resolve/token-error-correct-2.rs b/tests/ui/resolve/token-error-correct-2.rs index f7c7d908c784f..a38755dae0858 100644 --- a/tests/ui/resolve/token-error-correct-2.rs +++ b/tests/ui/resolve/token-error-correct-2.rs @@ -2,6 +2,5 @@ fn main() { if foo { - //~^ ERROR: cannot find value `foo` ) //~ ERROR: mismatched closing delimiter: `)` } diff --git a/tests/ui/resolve/token-error-correct-2.stderr b/tests/ui/resolve/token-error-correct-2.stderr index cca9f2dc88ca0..be5fb18a5d88a 100644 --- a/tests/ui/resolve/token-error-correct-2.stderr +++ b/tests/ui/resolve/token-error-correct-2.stderr @@ -3,16 +3,8 @@ error: mismatched closing delimiter: `)` | LL | if foo { | ^ unclosed delimiter -LL | LL | ) | ^ mismatched closing delimiter -error[E0425]: cannot find value `foo` in this scope - --> $DIR/token-error-correct-2.rs:4:8 - | -LL | if foo { - | ^^^ not found in this scope - -error: aborting due to 2 previous errors +error: aborting due to previous error -For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/resolve/token-error-correct-3.rs b/tests/ui/resolve/token-error-correct-3.rs index 52934085fa142..2793f1b90ff05 100644 --- a/tests/ui/resolve/token-error-correct-3.rs +++ b/tests/ui/resolve/token-error-correct-3.rs @@ -9,12 +9,9 @@ pub mod raw { callback: F) -> io::Result { if !is_directory(path.as_ref()) { - //~^ ERROR cannot find function `is_directory` callback(path.as_ref(); - //~^ ERROR expected one of fs::create_dir_all(path.as_ref()).map(|()| true) - } else { - //~^ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `)` + } else { //~ ERROR mismatched closing delimiter Ok(false); } diff --git a/tests/ui/resolve/token-error-correct-3.stderr b/tests/ui/resolve/token-error-correct-3.stderr index 77c87c78466b1..79d1d4883a13f 100644 --- a/tests/ui/resolve/token-error-correct-3.stderr +++ b/tests/ui/resolve/token-error-correct-3.stderr @@ -1,25 +1,13 @@ -error: expected one of `)`, `,`, `.`, `?`, or an operator, found `;` - --> $DIR/token-error-correct-3.rs:13:21 +error: mismatched closing delimiter: `}` + --> $DIR/token-error-correct-3.rs:12:21 | +LL | if !is_directory(path.as_ref()) { + | - closing delimiter possibly meant for this LL | callback(path.as_ref(); - | ^ ^ help: `)` may belong here - | | - | unclosed delimiter - -error: expected one of `.`, `;`, `?`, `}`, or an operator, found `)` - --> $DIR/token-error-correct-3.rs:16:9 - | + | ^ unclosed delimiter LL | fs::create_dir_all(path.as_ref()).map(|()| true) - | - expected one of `.`, `;`, `?`, `}`, or an operator LL | } else { - | ^ unexpected token - -error[E0425]: cannot find function `is_directory` in this scope - --> $DIR/token-error-correct-3.rs:11:13 - | -LL | if !is_directory(path.as_ref()) { - | ^^^^^^^^^^^^ not found in this scope + | ^ mismatched closing delimiter -error: aborting due to 3 previous errors +error: aborting due to previous error -For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/resolve/token-error-correct-4.fixed b/tests/ui/resolve/token-error-correct-4.fixed deleted file mode 100644 index 064b9e74e24fd..0000000000000 --- a/tests/ui/resolve/token-error-correct-4.fixed +++ /dev/null @@ -1,10 +0,0 @@ -// run-rustfix -// Test that we do some basic error correction in the tokeniser and apply suggestions. - -fn setsuna(_: ()) {} - -fn kazusa() {} - -fn main() { - setsuna(kazusa()); //~ ERROR: expected one of -} //~ ERROR: expected expression diff --git a/tests/ui/resolve/token-error-correct-4.rs b/tests/ui/resolve/token-error-correct-4.rs index 5e31d71e7bf46..49fad4bd97fa1 100644 --- a/tests/ui/resolve/token-error-correct-4.rs +++ b/tests/ui/resolve/token-error-correct-4.rs @@ -1,4 +1,3 @@ -// run-rustfix // Test that we do some basic error correction in the tokeniser and apply suggestions. fn setsuna(_: ()) {} @@ -6,5 +5,5 @@ fn setsuna(_: ()) {} fn kazusa() {} fn main() { - setsuna(kazusa(); //~ ERROR: expected one of -} //~ ERROR: expected expression + setsuna(kazusa(); +} //~ ERROR mismatched closing delimiter diff --git a/tests/ui/resolve/token-error-correct-4.stderr b/tests/ui/resolve/token-error-correct-4.stderr index 81e5a13369159..3ec97171fd327 100644 --- a/tests/ui/resolve/token-error-correct-4.stderr +++ b/tests/ui/resolve/token-error-correct-4.stderr @@ -1,16 +1,12 @@ -error: expected one of `)`, `,`, `.`, `?`, or an operator, found `;` - --> $DIR/token-error-correct-4.rs:9:12 +error: mismatched closing delimiter: `}` + --> $DIR/token-error-correct-4.rs:8:12 | +LL | fn main() { + | - closing delimiter possibly meant for this LL | setsuna(kazusa(); - | ^ ^ help: `)` may belong here - | | - | unclosed delimiter - -error: expected expression, found `)` - --> $DIR/token-error-correct-4.rs:10:1 - | + | ^ unclosed delimiter LL | } - | ^ expected expression + | ^ mismatched closing delimiter -error: aborting due to 2 previous errors +error: aborting due to previous error diff --git a/tests/ui/resolve/token-error-correct.rs b/tests/ui/resolve/token-error-correct.rs index 4f74df0bf1f39..84ee90e36856c 100644 --- a/tests/ui/resolve/token-error-correct.rs +++ b/tests/ui/resolve/token-error-correct.rs @@ -2,7 +2,6 @@ fn main() { foo(bar(; - //~^ ERROR cannot find function `bar` in this scope } //~^ ERROR: mismatched closing delimiter: `}` diff --git a/tests/ui/resolve/token-error-correct.stderr b/tests/ui/resolve/token-error-correct.stderr index ca0c4c18ad4ba..35b2d0b323bca 100644 --- a/tests/ui/resolve/token-error-correct.stderr +++ b/tests/ui/resolve/token-error-correct.stderr @@ -5,16 +5,8 @@ LL | fn main() { | - closing delimiter possibly meant for this LL | foo(bar(; | ^ unclosed delimiter -LL | LL | } | ^ mismatched closing delimiter -error[E0425]: cannot find function `bar` in this scope - --> $DIR/token-error-correct.rs:4:9 - | -LL | foo(bar(; - | ^^^ not found in this scope - -error: aborting due to 2 previous errors +error: aborting due to previous error -For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.rs b/tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.rs index 4559da91e47a8..f20024e759aa3 100644 --- a/tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.rs +++ b/tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.rs @@ -3,16 +3,10 @@ pub struct A {} impl A { - async fn create(path: impl AsRef) { //~ ERROR `async fn` is not permitted in Rust 2015 - //~^ WARN changes to closure capture in Rust 2021 will affect drop order [rust_2021_incompatible_closure_captures] + async fn create(path: impl AsRef) { ; - crate(move || {} ).await //~ ERROR expected function, found module `crate` + crate(move || {} ).await } } -trait C{async fn new(val: T) {} //~ ERROR `async fn` is not permitted in Rust 2015 -//~^ ERROR functions in traits cannot be declared `async` -//~| ERROR cannot find type `T` in this scope -//~| WARN changes to closure capture in Rust 2021 will affect drop order [rust_2021_incompatible_closure_captures] - -//~ ERROR this file contains an unclosed delimiter +trait C{async fn new(val: T) {} //~ ERROR this file contains an unclosed delimiter diff --git a/tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.stderr b/tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.stderr index df1cafdb7d3cc..1ec8ca4275b37 100644 --- a/tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.stderr +++ b/tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.stderr @@ -1,95 +1,8 @@ error: this file contains an unclosed delimiter - --> $DIR/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.rs:18:53 + --> $DIR/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.rs:12:85 | LL | trait C{async fn new(val: T) {} - | - unclosed delimiter -... -LL | - | ^ + | - unclosed delimiter ^ -error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.rs:6:5 - | -LL | async fn create(path: impl AsRef) { - | ^^^^^ to use `async fn`, switch to Rust 2018 or later - | - = help: pass `--edition 2021` to `rustc` - = note: for more on editions, read https://doc.rust-lang.org/edition-guide - -error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.rs:13:9 - | -LL | trait C{async fn new(val: T) {} - | ^^^^^ to use `async fn`, switch to Rust 2018 or later - | - = help: pass `--edition 2021` to `rustc` - = note: for more on editions, read https://doc.rust-lang.org/edition-guide - -error[E0412]: cannot find type `T` in this scope - --> $DIR/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.rs:13:27 - | -LL | pub struct A {} - | ------------ similarly named struct `A` defined here -... -LL | trait C{async fn new(val: T) {} - | ^ help: a struct with a similar name exists: `A` - -error[E0706]: functions in traits cannot be declared `async` - --> $DIR/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.rs:13:9 - | -LL | trait C{async fn new(val: T) {} - | -----^^^^^^^^^^^^^^^ - | | - | `async` because of this - | - = note: `async` trait functions are not currently supported - = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait - = note: see issue #91611 for more information - = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable - -error[E0423]: expected function, found module `crate` - --> $DIR/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.rs:9:5 - | -LL | crate(move || {} ).await - | ^^^^^ not a function - -warning: changes to closure capture in Rust 2021 will affect drop order - --> $DIR/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.rs:6:57 - | -LL | async fn create(path: impl AsRef) { - | _____________________----_____________________________-__^ - | | | | - | | | in Rust 2018, `path` is dropped here along with the closure, but in Rust 2021 `path` is not part of the closure - | | in Rust 2018, this causes the closure to capture `path`, but in Rust 2021, it has no effect -LL | | -LL | | ; -LL | | crate(move || {} ).await -LL | | } - | |_____^ - | - = note: for more information, see - = note: requested on the command line with `-W rust-2021-incompatible-closure-captures` -help: add a dummy let to cause `path` to be fully captured - | -LL | async fn create(path: impl AsRef) { let _ = &path; - | ++++++++++++++ - -warning: changes to closure capture in Rust 2021 will affect drop order - --> $DIR/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.rs:13:30 - | -LL | trait C{async fn new(val: T) {} - | --- - ^^ - | | | - | | in Rust 2018, `val` is dropped here along with the closure, but in Rust 2021 `val` is not part of the closure - | in Rust 2018, this causes the closure to capture `val`, but in Rust 2021, it has no effect - | - = note: for more information, see -help: add a dummy let to cause `val` to be fully captured - | -LL | trait C{async fn new(val: T) { let _ = &val;} - | +++++++++++++ - -error: aborting due to 6 previous errors; 2 warnings emitted +error: aborting due to previous error -Some errors have detailed explanations: E0412, E0423, E0670, E0706. -For more information about an error, try `rustc --explain E0412`. diff --git a/tests/ui/suggestions/constrain-suggest-ice.rs b/tests/ui/suggestions/constrain-suggest-ice.rs index 69b874bed1b90..d6e5263ffe0a8 100644 --- a/tests/ui/suggestions/constrain-suggest-ice.rs +++ b/tests/ui/suggestions/constrain-suggest-ice.rs @@ -1,11 +1,9 @@ -struct Bug{ //~ ERROR parameter `S` is never used [E0392] +struct Bug{ A: [(); { - let x: [u8; Self::W] = [0; Self::W]; //~ ERROR generic `Self` types are currently not permitted in anonymous constants - //~^ ERROR generic `Self` types are currently not permitted in anonymous constants - //~^^ ERROR the size for values of type `S` cannot be known at compilation time [E0277] - F //~ ERROR cannot find value `F` in this scope [E0425] + let x: [u8; Self::W] = [0; Self::W]; + F } -} //~ ERROR mismatched closing delimiter: `}` +} //~^ ERROR mismatched closing delimiter: `}` fn main() {} diff --git a/tests/ui/suggestions/constrain-suggest-ice.stderr b/tests/ui/suggestions/constrain-suggest-ice.stderr index 2af7c2f697148..9b92091de9f54 100644 --- a/tests/ui/suggestions/constrain-suggest-ice.stderr +++ b/tests/ui/suggestions/constrain-suggest-ice.stderr @@ -9,64 +9,5 @@ LL | A: [(); { LL | } | ^ mismatched closing delimiter -error: mismatched closing delimiter: `}` - --> $DIR/constrain-suggest-ice.rs:2:8 - | -LL | struct Bug{ - | - closing delimiter possibly meant for this -LL | A: [(); { - | ^ unclosed delimiter -... -LL | } - | ^ mismatched closing delimiter - -error[E0425]: cannot find value `F` in this scope - --> $DIR/constrain-suggest-ice.rs:6:9 - | -LL | F - | ^ help: a local variable with a similar name exists: `x` - -error: generic `Self` types are currently not permitted in anonymous constants - --> $DIR/constrain-suggest-ice.rs:3:21 - | -LL | let x: [u8; Self::W] = [0; Self::W]; - | ^^^^ - -error: generic `Self` types are currently not permitted in anonymous constants - --> $DIR/constrain-suggest-ice.rs:3:36 - | -LL | let x: [u8; Self::W] = [0; Self::W]; - | ^^^^ - -error[E0277]: the size for values of type `S` cannot be known at compilation time - --> $DIR/constrain-suggest-ice.rs:3:36 - | -LL | struct Bug{ - | - this type parameter needs to be `std::marker::Sized` -LL | A: [(); { -LL | let x: [u8; Self::W] = [0; Self::W]; - | ^^^^^^^ doesn't have a size known at compile-time - | -note: required by a bound in `Bug` - --> $DIR/constrain-suggest-ice.rs:1:12 - | -LL | struct Bug{ - | ^ required by this bound in `Bug` -help: consider relaxing the implicit `Sized` restriction - | -LL | struct Bug{ - | ++++++++ - -error[E0392]: parameter `S` is never used - --> $DIR/constrain-suggest-ice.rs:1:12 - | -LL | struct Bug{ - | ^ unused parameter - | - = help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData` - = help: if you intended `S` to be a const parameter, use `const S: usize` instead - -error: aborting due to 7 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0277, E0392, E0425. -For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/type/issue-91268.rs b/tests/ui/type/issue-91268.rs index f1e16bc7bd3c1..274ea839e8bdd 100644 --- a/tests/ui/type/issue-91268.rs +++ b/tests/ui/type/issue-91268.rs @@ -1,8 +1,4 @@ // error-pattern: this file contains an unclosed delimiter -// error-pattern: cannot find type `ţ` in this scope -// error-pattern: parenthesized type parameters may only be used with a `Fn` trait -// error-pattern: type arguments are not allowed on builtin type `u8` -// error-pattern: mismatched types // ignore-tidy-trailing-newlines // `ţ` must be the last character in this file, it cannot be followed by a newline fn main() { diff --git a/tests/ui/type/issue-91268.stderr b/tests/ui/type/issue-91268.stderr index 6c9ee9945844d..c14959ae5e5ac 100644 --- a/tests/ui/type/issue-91268.stderr +++ b/tests/ui/type/issue-91268.stderr @@ -1,5 +1,5 @@ error: this file contains an unclosed delimiter - --> $DIR/issue-91268.rs:9:12 + --> $DIR/issue-91268.rs:5:12 | LL | fn main() { | - unclosed delimiter @@ -9,7 +9,7 @@ LL | 0: u8(ţ | unclosed delimiter error: this file contains an unclosed delimiter - --> $DIR/issue-91268.rs:9:12 + --> $DIR/issue-91268.rs:5:12 | LL | fn main() { | - unclosed delimiter @@ -18,46 +18,5 @@ LL | 0: u8(ţ | | | unclosed delimiter -error[E0412]: cannot find type `ţ` in this scope - --> $DIR/issue-91268.rs:9:11 - | -LL | 0: u8(ţ - | ^ expecting a type here because of type ascription - -error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-91268.rs:9:8 - | -LL | 0: u8(ţ - | ^^^^ only `Fn` traits may use parentheses - | -help: use angle brackets instead - | -LL | 0: u8<ţ> - | ~ + - -error[E0109]: type arguments are not allowed on builtin type `u8` - --> $DIR/issue-91268.rs:9:11 - | -LL | 0: u8(ţ - | -- ^ type argument not allowed - | | - | not allowed on builtin type `u8` - | -help: primitive type `u8` doesn't have generic parameters - | -LL - 0: u8(ţ -LL + 0: u8 - | - -error[E0308]: mismatched types - --> $DIR/issue-91268.rs:9:5 - | -LL | fn main() { - | - expected `()` because of default return type -LL | 0: u8(ţ - | ^^^^^^^ expected `()`, found `u8` - -error: aborting due to 6 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0109, E0214, E0308, E0412. -For more information about an error, try `rustc --explain E0109`. diff --git a/tests/ui/typeck/issue-91334.rs b/tests/ui/typeck/issue-91334.rs index bf9a5a62620d9..29204276bb3a5 100644 --- a/tests/ui/typeck/issue-91334.rs +++ b/tests/ui/typeck/issue-91334.rs @@ -1,9 +1,6 @@ // Regression test for the ICE described in issue #91334. // error-pattern: this file contains an unclosed delimiter -// error-pattern: expected one of -// error-pattern: mismatched closing delimiter -// error-pattern: mismatched types #![feature(generators)] diff --git a/tests/ui/typeck/issue-91334.stderr b/tests/ui/typeck/issue-91334.stderr index 78f392c9a8acc..638222abfac82 100644 --- a/tests/ui/typeck/issue-91334.stderr +++ b/tests/ui/typeck/issue-91334.stderr @@ -1,5 +1,5 @@ error: this file contains an unclosed delimiter - --> $DIR/issue-91334.rs:10:23 + --> $DIR/issue-91334.rs:7:23 | LL | fn f(){||yield(((){), | - - - ^ @@ -9,7 +9,7 @@ LL | fn f(){||yield(((){), | unclosed delimiter error: this file contains an unclosed delimiter - --> $DIR/issue-91334.rs:10:23 + --> $DIR/issue-91334.rs:7:23 | LL | fn f(){||yield(((){), | - - - ^ @@ -18,17 +18,8 @@ LL | fn f(){||yield(((){), | | unclosed delimiter | unclosed delimiter -error: expected one of `)`, `,`, `.`, `?`, or an operator, found `{` - --> $DIR/issue-91334.rs:10:19 - | -LL | fn f(){||yield(((){), - | ^ - | | - | expected one of `)`, `,`, `.`, `?`, or an operator - | help: missing `,` - error: mismatched closing delimiter: `)` - --> $DIR/issue-91334.rs:10:19 + --> $DIR/issue-91334.rs:7:19 | LL | fn f(){||yield(((){), | - ^^ mismatched closing delimiter @@ -36,17 +27,5 @@ LL | fn f(){||yield(((){), | | unclosed delimiter | closing delimiter possibly meant for this -error[E0308]: mismatched types - --> $DIR/issue-91334.rs:10:8 - | -LL | fn f(){||yield(((){), - | -^^^^^^^^^^^^^^^ expected `()`, found generator - | | - | help: a return type might be missing here: `-> _` - | - = note: expected unit type `()` - found generator `[generator@$DIR/issue-91334.rs:10:8: 10:10]` - -error: aborting due to 5 previous errors +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/typeck/issue-92481.rs b/tests/ui/typeck/issue-92481.rs index 0a6b1843d996c..f752400bbcbb6 100644 --- a/tests/ui/typeck/issue-92481.rs +++ b/tests/ui/typeck/issue-92481.rs @@ -2,13 +2,8 @@ #![crate_type="lib"] -fn r({) { - Ok { //~ ERROR mismatched types [E0308] +fn r({) { //~ ERROR mismatched closing delimiter + Ok { d..||_=m } } -//~^^^^^ ERROR expected parameter name, found `{` -//~| ERROR expected one of `,`, `:`, or `}`, found `..` -//~^^^^^ ERROR cannot find value `d` in this scope [E0425] -//~| ERROR cannot find value `m` in this scope [E0425] -//~| ERROR variant `Result<_, _>::Ok` has no field named `d` [E0559] diff --git a/tests/ui/typeck/issue-92481.stderr b/tests/ui/typeck/issue-92481.stderr index c3acbd2c067c5..d87d3277d563a 100644 --- a/tests/ui/typeck/issue-92481.stderr +++ b/tests/ui/typeck/issue-92481.stderr @@ -1,60 +1,11 @@ -error: expected parameter name, found `{` +error: mismatched closing delimiter: `)` --> $DIR/issue-92481.rs:5:6 | LL | fn r({) { - | ^ expected parameter name + | -^^ mismatched closing delimiter + | || + | |unclosed delimiter + | closing delimiter possibly meant for this -error: expected one of `,`, `:`, or `}`, found `..` - --> $DIR/issue-92481.rs:5:6 - | -LL | fn r({) { - | ^ unclosed delimiter -LL | Ok { -LL | d..||_=m - | -^ - | | - | help: `}` may belong here - -error[E0425]: cannot find value `d` in this scope - --> $DIR/issue-92481.rs:7:9 - | -LL | d..||_=m - | ^ not found in this scope - -error[E0425]: cannot find value `m` in this scope - --> $DIR/issue-92481.rs:7:16 - | -LL | d..||_=m - | ^ not found in this scope - -error[E0559]: variant `Result<_, _>::Ok` has no field named `d` - --> $DIR/issue-92481.rs:7:9 - | -LL | d..||_=m - | ^ field does not exist - --> $SRC_DIR/core/src/result.rs:LL:COL - | - = note: `Result<_, _>::Ok` defined here - | -help: `Result<_, _>::Ok` is a tuple variant, use the appropriate syntax - | -LL | Result<_, _>::Ok(/* fields */) - | - -error[E0308]: mismatched types - --> $DIR/issue-92481.rs:6:5 - | -LL | fn r({) { - | - help: a return type might be missing here: `-> _` -LL | / Ok { -LL | | d..||_=m -LL | | } - | |_____^ expected `()`, found `Result<_, _>` - | - = note: expected unit type `()` - found enum `Result<_, _>` - -error: aborting due to 6 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0308, E0425, E0559. -For more information about an error, try `rustc --explain E0308`. From 65ad5f8de72c6994b6d2059bf5622af48de3afe4 Mon Sep 17 00:00:00 2001 From: yukang Date: Tue, 28 Feb 2023 07:56:34 +0000 Subject: [PATCH 10/14] remove duplicated diagnostic for unclosed delimiter --- compiler/rustc_parse/src/lexer/tokentrees.rs | 17 ++++--- tests/ui/lint/issue-104897.stderr | 22 +-------- .../unused_parens_multibyte_recovery.stderr | 22 +-------- ...07423-unused-delim-only-one-no-pair.stderr | 22 +-------- tests/ui/parser/issue-103451.stderr | 12 +---- tests/ui/parser/issue-81804.stderr | 21 +++----- tests/ui/parser/issue-81827.stderr | 24 +++------ tests/ui/parser/issues/issue-62554.stderr | 46 +----------------- tests/ui/parser/issues/issue-62894.stderr | 26 +--------- tests/ui/parser/issues/issue-62973.rs | 2 +- tests/ui/parser/issues/issue-62973.stderr | 41 ++++++---------- tests/ui/parser/issues/issue-63116.stderr | 16 +++--- tests/ui/parser/issues/issue-63135.rs | 2 +- tests/ui/parser/issues/issue-63135.stderr | 11 +---- ...invalid-syntax-in-enum-discriminant.stderr | 36 +++++++------- tests/ui/parser/issues/issue-68629.stderr | Bin 1155 -> 944 bytes tests/ui/parser/issues/issue-88770.stderr | 26 +--------- tests/ui/parser/missing_right_paren.rs | 2 +- tests/ui/parser/missing_right_paren.stderr | 11 +---- tests/ui/type/issue-91268.stderr | 12 +---- tests/ui/typeck/issue-91334.stderr | 24 +++------ 21 files changed, 82 insertions(+), 313 deletions(-) diff --git a/compiler/rustc_parse/src/lexer/tokentrees.rs b/compiler/rustc_parse/src/lexer/tokentrees.rs index 0de8f79112c65..fc57b1b6ae9b8 100644 --- a/compiler/rustc_parse/src/lexer/tokentrees.rs +++ b/compiler/rustc_parse/src/lexer/tokentrees.rs @@ -34,7 +34,7 @@ impl<'a> TokenTreesReader<'a> { let mut buf = Vec::new(); loop { match self.token.kind { - token::OpenDelim(delim) => buf.push(self.parse_token_tree_open_delim(delim)), + token::OpenDelim(delim) => buf.push(self.parse_token_tree_open_delim(delim)?), token::CloseDelim(delim) => { return if is_delimited { Ok(TokenStream::new(buf)) @@ -43,10 +43,11 @@ impl<'a> TokenTreesReader<'a> { }; } token::Eof => { - if is_delimited { - self.eof_err().emit(); - } - return Ok(TokenStream::new(buf)); + return if is_delimited { + Err(self.eof_err()) + } else { + Ok(TokenStream::new(buf)) + }; } _ => { // Get the next normal token. This might require getting multiple adjacent @@ -98,7 +99,7 @@ impl<'a> TokenTreesReader<'a> { err } - fn parse_token_tree_open_delim(&mut self, open_delim: Delimiter) -> TokenTree { + fn parse_token_tree_open_delim(&mut self, open_delim: Delimiter) -> PResult<'a, TokenTree> { // The span for beginning of the delimited section let pre_span = self.token.span; @@ -107,7 +108,7 @@ impl<'a> TokenTreesReader<'a> { // Parse the token trees within the delimiters. // We stop at any delimiter so we can try to recover if the user // uses an incorrect delimiter. - let tts = self.parse_token_trees(/* is_delimited */ true).unwrap(); + let tts = self.parse_token_trees(/* is_delimited */ true)?; // Expand to cover the entire delimited token tree let delim_span = DelimSpan::from_pair(pre_span, self.token.span); @@ -190,7 +191,7 @@ impl<'a> TokenTreesReader<'a> { _ => unreachable!(), } - TokenTree::Delimited(delim_span, open_delim, tts) + Ok(TokenTree::Delimited(delim_span, open_delim, tts)) } fn close_delim_err(&mut self, delim: Delimiter) -> PErr<'a> { diff --git a/tests/ui/lint/issue-104897.stderr b/tests/ui/lint/issue-104897.stderr index 83fafb2b083c9..728d51f34a49a 100644 --- a/tests/ui/lint/issue-104897.stderr +++ b/tests/ui/lint/issue-104897.stderr @@ -8,25 +8,5 @@ LL | fn f(){(print!(á | |unclosed delimiter | unclosed delimiter -error: this file contains an unclosed delimiter - --> $DIR/issue-104897.rs:5:18 - | -LL | fn f(){(print!(á - | -- - ^ - | || | - | || unclosed delimiter - | |unclosed delimiter - | unclosed delimiter - -error: this file contains an unclosed delimiter - --> $DIR/issue-104897.rs:5:18 - | -LL | fn f(){(print!(á - | -- - ^ - | || | - | || unclosed delimiter - | |unclosed delimiter - | unclosed delimiter - -error: aborting due to 3 previous errors +error: aborting due to previous error diff --git a/tests/ui/lint/unused_parens_multibyte_recovery.stderr b/tests/ui/lint/unused_parens_multibyte_recovery.stderr index b61f074b9b212..adbf27fcca2f4 100644 --- a/tests/ui/lint/unused_parens_multibyte_recovery.stderr +++ b/tests/ui/lint/unused_parens_multibyte_recovery.stderr @@ -8,25 +8,5 @@ LL | fn f(){(print!(á | |unclosed delimiter | unclosed delimiter -error: this file contains an unclosed delimiter - --> $DIR/unused_parens_multibyte_recovery.rs:10:17 - | -LL | fn f(){(print!(á - | -- - ^ - | || | - | || unclosed delimiter - | |unclosed delimiter - | unclosed delimiter - -error: this file contains an unclosed delimiter - --> $DIR/unused_parens_multibyte_recovery.rs:10:17 - | -LL | fn f(){(print!(á - | -- - ^ - | || | - | || unclosed delimiter - | |unclosed delimiter - | unclosed delimiter - -error: aborting due to 3 previous errors +error: aborting due to previous error diff --git a/tests/ui/malformed/issue-107423-unused-delim-only-one-no-pair.stderr b/tests/ui/malformed/issue-107423-unused-delim-only-one-no-pair.stderr index 0479035171e89..89e0d982eafdc 100644 --- a/tests/ui/malformed/issue-107423-unused-delim-only-one-no-pair.stderr +++ b/tests/ui/malformed/issue-107423-unused-delim-only-one-no-pair.stderr @@ -8,25 +8,5 @@ LL | fn a(){{{ | |unclosed delimiter | unclosed delimiter -error: this file contains an unclosed delimiter - --> $DIR/issue-107423-unused-delim-only-one-no-pair.rs:7:11 - | -LL | fn a(){{{ - | --- ^ - | ||| - | ||unclosed delimiter - | |unclosed delimiter - | unclosed delimiter - -error: this file contains an unclosed delimiter - --> $DIR/issue-107423-unused-delim-only-one-no-pair.rs:7:11 - | -LL | fn a(){{{ - | --- ^ - | ||| - | ||unclosed delimiter - | |unclosed delimiter - | unclosed delimiter - -error: aborting due to 3 previous errors +error: aborting due to previous error diff --git a/tests/ui/parser/issue-103451.stderr b/tests/ui/parser/issue-103451.stderr index e9a984261ca26..6aacd5012c14f 100644 --- a/tests/ui/parser/issue-103451.stderr +++ b/tests/ui/parser/issue-103451.stderr @@ -8,15 +8,5 @@ LL | x: [u8; R | | | unclosed delimiter -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 2 previous errors +error: aborting due to previous error diff --git a/tests/ui/parser/issue-81804.stderr b/tests/ui/parser/issue-81804.stderr index 77e1a8bb2f35a..de3b33ecd95c6 100644 --- a/tests/ui/parser/issue-81804.stderr +++ b/tests/ui/parser/issue-81804.stderr @@ -1,11 +1,10 @@ -error: this file contains an unclosed delimiter - --> $DIR/issue-81804.rs:6:11 +error: mismatched closing delimiter: `}` + --> $DIR/issue-81804.rs:6:8 | LL | fn p([=(} - | -- ^ - | || - | |unclosed delimiter - | unclosed delimiter + | ^^ mismatched closing delimiter + | | + | unclosed delimiter error: this file contains an unclosed delimiter --> $DIR/issue-81804.rs:6:11 @@ -16,13 +15,5 @@ LL | fn p([=(} | |unclosed delimiter | unclosed delimiter -error: mismatched closing delimiter: `}` - --> $DIR/issue-81804.rs:6:8 - | -LL | fn p([=(} - | ^^ mismatched closing delimiter - | | - | unclosed delimiter - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors diff --git a/tests/ui/parser/issue-81827.stderr b/tests/ui/parser/issue-81827.stderr index c14bb9f42319a..63d135f73e69f 100644 --- a/tests/ui/parser/issue-81827.stderr +++ b/tests/ui/parser/issue-81827.stderr @@ -1,12 +1,11 @@ -error: this file contains an unclosed delimiter - --> $DIR/issue-81827.rs:10:27 +error: mismatched closing delimiter: `]` + --> $DIR/issue-81827.rs:10:23 | LL | fn r()->i{0|{#[cfg(r(0{]0 - | - - - ^ - | | | | - | | | missing open `[` for this delimiter - | | unclosed delimiter - | unclosed delimiter + | - ^^ mismatched closing delimiter + | | | + | | unclosed delimiter + | closing delimiter possibly meant for this error: this file contains an unclosed delimiter --> $DIR/issue-81827.rs:10:27 @@ -18,14 +17,5 @@ LL | fn r()->i{0|{#[cfg(r(0{]0 | | unclosed delimiter | unclosed delimiter -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: aborting due to 3 previous errors +error: aborting due to 2 previous errors diff --git a/tests/ui/parser/issues/issue-62554.stderr b/tests/ui/parser/issues/issue-62554.stderr index 9cb0c5a351157..4637c795ae5ec 100644 --- a/tests/ui/parser/issues/issue-62554.stderr +++ b/tests/ui/parser/issues/issue-62554.stderr @@ -9,49 +9,5 @@ LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s | | | unclosed delimiter | unclosed delimiter unclosed delimiter -error: this file contains an unclosed delimiter - --> $DIR/issue-62554.rs:5:89 - | -LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 { - | - - - - - ^ - | | | | | | - | | | | | unclosed delimiter - | | | | unclosed delimiter - | | | unclosed delimiter - | unclosed delimiter unclosed delimiter - -error: this file contains an unclosed delimiter - --> $DIR/issue-62554.rs:5:89 - | -LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 { - | - - - - - ^ - | | | | | | - | | | | | unclosed delimiter - | | | | unclosed delimiter - | | | unclosed delimiter - | unclosed delimiter unclosed delimiter - -error: this file contains an unclosed delimiter - --> $DIR/issue-62554.rs:5:89 - | -LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 { - | - - - - - ^ - | | | | | | - | | | | | unclosed delimiter - | | | | unclosed delimiter - | | | unclosed delimiter - | unclosed delimiter unclosed delimiter - -error: this file contains an unclosed delimiter - --> $DIR/issue-62554.rs:5:89 - | -LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 { - | - - - - - ^ - | | | | | | - | | | | | unclosed delimiter - | | | | unclosed delimiter - | | | unclosed delimiter - | unclosed delimiter unclosed delimiter - -error: aborting due to 5 previous errors +error: aborting due to previous error diff --git a/tests/ui/parser/issues/issue-62894.stderr b/tests/ui/parser/issues/issue-62894.stderr index 1b056c8a1598d..700479076dfe8 100644 --- a/tests/ui/parser/issues/issue-62894.stderr +++ b/tests/ui/parser/issues/issue-62894.stderr @@ -10,29 +10,5 @@ LL | LL | fn main() {} | ^ -error: this file contains an unclosed delimiter - --> $DIR/issue-62894.rs:6:14 - | -LL | fn f() { assert_eq!(f(), (), assert_eq!(assert_eq! - | - - - unclosed delimiter - | | | - | | unclosed delimiter - | unclosed delimiter -LL | -LL | fn main() {} - | ^ - -error: this file contains an unclosed delimiter - --> $DIR/issue-62894.rs:6:14 - | -LL | fn f() { assert_eq!(f(), (), assert_eq!(assert_eq! - | - - - unclosed delimiter - | | | - | | unclosed delimiter - | unclosed delimiter -LL | -LL | fn main() {} - | ^ - -error: aborting due to 3 previous errors +error: aborting due to previous error diff --git a/tests/ui/parser/issues/issue-62973.rs b/tests/ui/parser/issues/issue-62973.rs index e8314a88a2b15..22d7545770223 100644 --- a/tests/ui/parser/issues/issue-62973.rs +++ b/tests/ui/parser/issues/issue-62973.rs @@ -1,5 +1,5 @@ // ignore-tidy-trailing-newlines -// error-pattern: aborting due to 4 previous errors +// error-pattern: aborting due to 3 previous errors fn main() {} diff --git a/tests/ui/parser/issues/issue-62973.stderr b/tests/ui/parser/issues/issue-62973.stderr index 1296063c05a56..14411a8cb7849 100644 --- a/tests/ui/parser/issues/issue-62973.stderr +++ b/tests/ui/parser/issues/issue-62973.stderr @@ -1,29 +1,3 @@ -error: this file contains an unclosed delimiter - --> $DIR/issue-62973.rs:8:2 - | -LL | fn p() { match s { v, E { [) {) } - | - - - - missing open `(` for this delimiter - | | | | - | | | missing open `(` for this delimiter - | | unclosed delimiter - | unclosed delimiter -LL | -LL | - | ^ - -error: this file contains an unclosed delimiter - --> $DIR/issue-62973.rs:8:2 - | -LL | fn p() { match s { v, E { [) {) } - | - - - - missing open `(` for this delimiter - | | | | - | | | missing open `(` for this delimiter - | | unclosed delimiter - | unclosed delimiter -LL | -LL | - | ^ - error: mismatched closing delimiter: `)` --> $DIR/issue-62973.rs:6:27 | @@ -40,5 +14,18 @@ LL | fn p() { match s { v, E { [) {) } | | | unclosed delimiter -error: aborting due to 4 previous errors +error: this file contains an unclosed delimiter + --> $DIR/issue-62973.rs:8:2 + | +LL | fn p() { match s { v, E { [) {) } + | - - - - missing open `(` for this delimiter + | | | | + | | | missing open `(` for this delimiter + | | unclosed delimiter + | unclosed delimiter +LL | +LL | + | ^ + +error: aborting due to 3 previous errors diff --git a/tests/ui/parser/issues/issue-63116.stderr b/tests/ui/parser/issues/issue-63116.stderr index d88cf62ec84f2..27c94f337bdb8 100644 --- a/tests/ui/parser/issues/issue-63116.stderr +++ b/tests/ui/parser/issues/issue-63116.stderr @@ -1,3 +1,11 @@ +error: mismatched closing delimiter: `]` + --> $DIR/issue-63116.rs:3:14 + | +LL | impl W $DIR/issue-63116.rs:3:18 | @@ -7,13 +15,5 @@ LL | impl W $DIR/issue-63116.rs:3:14 - | -LL | impl W $DIR/issue-63135.rs:3:16 - | -LL | fn i(n{...,f # - | - - ^ - | | | - | | unclosed delimiter - | unclosed delimiter - -error: aborting due to 2 previous errors +error: aborting due to previous error diff --git a/tests/ui/parser/issues/issue-67377-invalid-syntax-in-enum-discriminant.stderr b/tests/ui/parser/issues/issue-67377-invalid-syntax-in-enum-discriminant.stderr index dc6af1ed5687e..9f631edf680c8 100644 --- a/tests/ui/parser/issues/issue-67377-invalid-syntax-in-enum-discriminant.stderr +++ b/tests/ui/parser/issues/issue-67377-invalid-syntax-in-enum-discriminant.stderr @@ -1,21 +1,3 @@ -error: this file contains an unclosed delimiter - --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:23:65 - | -LL | V = [PhantomData; { [ () ].len() ].len() as isize, - | - missing open `[` for this delimiter -... -LL | V = [Vec::new; { [].len() ].len() as isize, - | - missing open `[` for this delimiter -... -LL | mod c { - | - unclosed delimiter -LL | enum Bug { -LL | V = [Vec::new; { [0].len() ].len() as isize, - | - missing open `[` for this delimiter -... -LL | fn main() {} - | ^ - error: mismatched closing delimiter: `]` --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:5:27 | @@ -43,5 +25,23 @@ LL | V = [Vec::new; { [0].len() ].len() as isize, | | unclosed delimiter | closing delimiter possibly meant for this +error: this file contains an unclosed delimiter + --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:23:65 + | +LL | V = [PhantomData; { [ () ].len() ].len() as isize, + | - missing open `[` for this delimiter +... +LL | V = [Vec::new; { [].len() ].len() as isize, + | - missing open `[` for this delimiter +... +LL | mod c { + | - unclosed delimiter +LL | enum Bug { +LL | V = [Vec::new; { [0].len() ].len() as isize, + | - missing open `[` for this delimiter +... +LL | fn main() {} + | ^ + error: aborting due to 4 previous errors diff --git a/tests/ui/parser/issues/issue-68629.stderr b/tests/ui/parser/issues/issue-68629.stderr index 09905edfbebc06c08d96ff962b0045f83aa3cffa..2562baa1c49c3034012d9721c128aecc4303dc02 100644 GIT binary patch delta 31 mcmZqX+`zt}mw9pmi-54HLP1e#S!RA|u|jH5QGQV|7Z(7f9|}PL delta 31 mcmdnM-psk7mwECorpLl&3I#=}WtsV<#R{oKMfpX=TwDOY!3%8w diff --git a/tests/ui/parser/issues/issue-88770.stderr b/tests/ui/parser/issues/issue-88770.stderr index 3fec25cdf4c58..836f44953d4a8 100644 --- a/tests/ui/parser/issues/issue-88770.stderr +++ b/tests/ui/parser/issues/issue-88770.stderr @@ -10,29 +10,5 @@ LL | fn m(){print!("",(c for&g LL | e | ^ -error: this file contains an unclosed delimiter - --> $DIR/issue-88770.rs:8:3 - | -LL | fn m(){print!("",(c for&g - | - - - unclosed delimiter - | | | - | | unclosed delimiter - | unclosed delimiter -... -LL | e - | ^ - -error: this file contains an unclosed delimiter - --> $DIR/issue-88770.rs:8:3 - | -LL | fn m(){print!("",(c for&g - | - - - unclosed delimiter - | | | - | | unclosed delimiter - | unclosed delimiter -... -LL | e - | ^ - -error: aborting due to 3 previous errors +error: aborting due to previous error diff --git a/tests/ui/parser/missing_right_paren.rs b/tests/ui/parser/missing_right_paren.rs index c5c56ac4cd4c1..e240f8c6739ee 100644 --- a/tests/ui/parser/missing_right_paren.rs +++ b/tests/ui/parser/missing_right_paren.rs @@ -1,4 +1,4 @@ // ignore-tidy-trailing-newlines // error-pattern: this file contains an unclosed delimiter -// error-pattern: aborting due to 2 previous errors +// error-pattern: aborting due to previous error fn main((ؼ \ No newline at end of file diff --git a/tests/ui/parser/missing_right_paren.stderr b/tests/ui/parser/missing_right_paren.stderr index dfdc6a831e04f..994ce4d8541c0 100644 --- a/tests/ui/parser/missing_right_paren.stderr +++ b/tests/ui/parser/missing_right_paren.stderr @@ -7,14 +7,5 @@ LL | fn main((ؼ | |unclosed delimiter | unclosed delimiter -error: this file contains an unclosed delimiter - --> $DIR/missing_right_paren.rs:4:11 - | -LL | fn main((ؼ - | -- ^ - | || - | |unclosed delimiter - | unclosed delimiter - -error: aborting due to 2 previous errors +error: aborting due to previous error diff --git a/tests/ui/type/issue-91268.stderr b/tests/ui/type/issue-91268.stderr index c14959ae5e5ac..a3619d863e259 100644 --- a/tests/ui/type/issue-91268.stderr +++ b/tests/ui/type/issue-91268.stderr @@ -8,15 +8,5 @@ LL | 0: u8(ţ | | | unclosed delimiter -error: this file contains an unclosed delimiter - --> $DIR/issue-91268.rs:5:12 - | -LL | fn main() { - | - unclosed delimiter -LL | 0: u8(ţ - | - ^ - | | - | unclosed delimiter - -error: aborting due to 2 previous errors +error: aborting due to previous error diff --git a/tests/ui/typeck/issue-91334.stderr b/tests/ui/typeck/issue-91334.stderr index 638222abfac82..7cb30eea530c6 100644 --- a/tests/ui/typeck/issue-91334.stderr +++ b/tests/ui/typeck/issue-91334.stderr @@ -1,12 +1,11 @@ -error: this file contains an unclosed delimiter - --> $DIR/issue-91334.rs:7:23 +error: mismatched closing delimiter: `)` + --> $DIR/issue-91334.rs:7:19 | LL | fn f(){||yield(((){), - | - - - ^ - | | | | - | | | missing open `(` for this delimiter - | | unclosed delimiter - | unclosed delimiter + | - ^^ mismatched closing delimiter + | | | + | | unclosed delimiter + | closing delimiter possibly meant for this error: this file contains an unclosed delimiter --> $DIR/issue-91334.rs:7:23 @@ -18,14 +17,5 @@ LL | fn f(){||yield(((){), | | unclosed delimiter | unclosed delimiter -error: mismatched closing delimiter: `)` - --> $DIR/issue-91334.rs:7:19 - | -LL | fn f(){||yield(((){), - | - ^^ mismatched closing delimiter - | | | - | | unclosed delimiter - | closing delimiter possibly meant for this - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors From 9ce7472db46f62bbc328dbe9e627d4a85a11913c Mon Sep 17 00:00:00 2001 From: yukang Date: Tue, 21 Feb 2023 14:51:19 +0000 Subject: [PATCH 11/14] rename unmatched_braces to unmatched_delims --- compiler/rustc_parse/src/lexer/diagnostics.rs | 10 +++++----- compiler/rustc_parse/src/lexer/mod.rs | 4 ++-- compiler/rustc_parse/src/lexer/tokentrees.rs | 11 ++++++----- compiler/rustc_parse/src/lib.rs | 10 +++++----- compiler/rustc_parse/src/parser/diagnostics.rs | 8 ++++---- compiler/rustc_parse/src/parser/mod.rs | 10 +++++----- 6 files changed, 27 insertions(+), 26 deletions(-) diff --git a/compiler/rustc_parse/src/lexer/diagnostics.rs b/compiler/rustc_parse/src/lexer/diagnostics.rs index 386bf026bb4af..27f4428d306cd 100644 --- a/compiler/rustc_parse/src/lexer/diagnostics.rs +++ b/compiler/rustc_parse/src/lexer/diagnostics.rs @@ -1,4 +1,4 @@ -use super::UnmatchedBrace; +use super::UnmatchedDelim; use rustc_ast::token::Delimiter; use rustc_errors::Diagnostic; use rustc_span::source_map::SourceMap; @@ -8,7 +8,7 @@ use rustc_span::Span; pub struct TokenTreeDiagInfo { /// Stack of open delimiters and their spans. Used for error message. pub open_braces: Vec<(Delimiter, Span)>, - pub unmatched_braces: Vec, + pub unmatched_delims: Vec, /// Used only for error recovery when arriving to EOF with mismatched braces. pub last_unclosed_found_span: Option, @@ -32,10 +32,10 @@ pub fn same_identation_level(sm: &SourceMap, open_sp: Span, close_sp: Span) -> b // it's more friendly compared to report `unmatched error` in later phase pub fn report_missing_open_delim( err: &mut Diagnostic, - unmatched_braces: &[UnmatchedBrace], + unmatched_delims: &[UnmatchedDelim], ) -> bool { let mut reported_missing_open = false; - for unmatch_brace in unmatched_braces.iter() { + for unmatch_brace in unmatched_delims.iter() { if let Some(delim) = unmatch_brace.found_delim && matches!(delim, Delimiter::Parenthesis | Delimiter::Bracket) { @@ -60,7 +60,7 @@ pub fn report_suspicious_mismatch_block( sm: &SourceMap, delim: Delimiter, ) { - if report_missing_open_delim(err, &diag_info.unmatched_braces) { + if report_missing_open_delim(err, &diag_info.unmatched_delims) { return; } diff --git a/compiler/rustc_parse/src/lexer/mod.rs b/compiler/rustc_parse/src/lexer/mod.rs index 37449aaabed8b..db1bea1992315 100644 --- a/compiler/rustc_parse/src/lexer/mod.rs +++ b/compiler/rustc_parse/src/lexer/mod.rs @@ -31,7 +31,7 @@ use unescape_error_reporting::{emit_unescape_error, escaped_char}; rustc_data_structures::static_assert_size!(rustc_lexer::Token, 12); #[derive(Clone, Debug)] -pub struct UnmatchedBrace { +pub struct UnmatchedDelim { pub expected_delim: Delimiter, pub found_delim: Option, pub found_span: Span, @@ -44,7 +44,7 @@ pub(crate) fn parse_token_trees<'a>( mut src: &'a str, mut start_pos: BytePos, override_span: Option, -) -> (PResult<'a, TokenStream>, Vec) { +) -> (PResult<'a, TokenStream>, Vec) { // Skip `#!`, if present. if let Some(shebang_len) = rustc_lexer::strip_shebang(src) { src = &src[shebang_len..]; diff --git a/compiler/rustc_parse/src/lexer/tokentrees.rs b/compiler/rustc_parse/src/lexer/tokentrees.rs index fc57b1b6ae9b8..5abd62bc2a448 100644 --- a/compiler/rustc_parse/src/lexer/tokentrees.rs +++ b/compiler/rustc_parse/src/lexer/tokentrees.rs @@ -1,7 +1,7 @@ use super::diagnostics::report_suspicious_mismatch_block; use super::diagnostics::same_identation_level; use super::diagnostics::TokenTreeDiagInfo; -use super::{StringReader, UnmatchedBrace}; +use super::{StringReader, UnmatchedDelim}; use rustc_ast::token::{self, Delimiter, Token}; use rustc_ast::tokenstream::{DelimSpan, Spacing, TokenStream, TokenTree}; use rustc_ast_pretty::pprust::token_to_string; @@ -18,14 +18,14 @@ pub(super) struct TokenTreesReader<'a> { impl<'a> TokenTreesReader<'a> { pub(super) fn parse_all_token_trees( string_reader: StringReader<'a>, - ) -> (PResult<'a, TokenStream>, Vec) { + ) -> (PResult<'a, TokenStream>, Vec) { let mut tt_reader = TokenTreesReader { string_reader, token: Token::dummy(), diag_info: TokenTreeDiagInfo::default(), }; let res = tt_reader.parse_token_trees(/* is_delimited */ false); - (res, tt_reader.diag_info.unmatched_braces) + (res, tt_reader.diag_info.unmatched_delims) } // Parse a stream of tokens into a list of `TokenTree`s. @@ -79,7 +79,7 @@ impl<'a> TokenTreesReader<'a> { let mut err = self.string_reader.sess.span_diagnostic.struct_span_err(self.token.span, msg); for &(_, sp) in &self.diag_info.open_braces { err.span_label(sp, "unclosed delimiter"); - self.diag_info.unmatched_braces.push(UnmatchedBrace { + self.diag_info.unmatched_delims.push(UnmatchedDelim { expected_delim: Delimiter::Brace, found_delim: None, found_span: self.token.span, @@ -161,7 +161,8 @@ impl<'a> TokenTreesReader<'a> { } } let (tok, _) = self.diag_info.open_braces.pop().unwrap(); - self.diag_info.unmatched_braces.push(UnmatchedBrace { + debug!("anan now: open {:#?} close {:#?}", open_delim, close_delim); + self.diag_info.unmatched_delims.push(UnmatchedDelim { expected_delim: tok, found_delim: Some(close_delim), found_span: self.token.span, diff --git a/compiler/rustc_parse/src/lib.rs b/compiler/rustc_parse/src/lib.rs index 28a771ac9486c..b6e54b53e2614 100644 --- a/compiler/rustc_parse/src/lib.rs +++ b/compiler/rustc_parse/src/lib.rs @@ -182,7 +182,7 @@ pub fn source_file_to_stream( sess: &ParseSess, source_file: Lrc, override_span: Option, -) -> (TokenStream, Vec) { +) -> (TokenStream, Vec) { panictry_buffer!(&sess.span_diagnostic, maybe_file_to_stream(sess, source_file, override_span)) } @@ -192,7 +192,7 @@ pub fn maybe_file_to_stream( sess: &ParseSess, source_file: Lrc, override_span: Option, -) -> Result<(TokenStream, Vec), Vec> { +) -> Result<(TokenStream, Vec), Vec> { let src = source_file.src.as_ref().unwrap_or_else(|| { sess.span_diagnostic.bug(&format!( "cannot lex `source_file` without source: {}", @@ -200,11 +200,11 @@ pub fn maybe_file_to_stream( )); }); - let (token_trees, unmatched_braces) = + let (token_trees, unmatched_delims) = lexer::parse_token_trees(sess, src.as_str(), source_file.start_pos, override_span); match token_trees { - Ok(stream) if unmatched_braces.is_empty() => Ok((stream, unmatched_braces)), + Ok(stream) if unmatched_delims.is_empty() => Ok((stream, unmatched_delims)), _ => { // Return error if there are unmatched delimiters or unclosng delimiters. // We emit delimiter mismatch errors first, then emit the unclosing delimiter mismatch @@ -212,7 +212,7 @@ pub fn maybe_file_to_stream( let mut buffer = Vec::with_capacity(1); // Not using `emit_unclosed_delims` to use `db.buffer` - for unmatched in unmatched_braces { + for unmatched in unmatched_delims { if let Some(err) = make_unclosed_delims_error(unmatched, &sess) { err.buffer(&mut buffer); } diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index d235b8a8176a8..d0cf42b931b8c 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -19,9 +19,9 @@ use crate::errors::{ }; use crate::fluent_generated as fluent; -use crate::lexer::UnmatchedBrace; -use crate::parser; use rustc_ast as ast; +use crate::parser; +use crate::lexer::UnmatchedDelim; use rustc_ast::ptr::P; use rustc_ast::token::{self, Delimiter, Lit, LitKind, TokenKind}; use rustc_ast::util::parser::AssocOp; @@ -222,7 +222,7 @@ impl MultiSugg { /// is dropped. pub struct SnapshotParser<'a> { parser: Parser<'a>, - unclosed_delims: Vec, + unclosed_delims: Vec, } impl<'a> Deref for SnapshotParser<'a> { @@ -264,7 +264,7 @@ impl<'a> Parser<'a> { self.unclosed_delims.extend(snapshot.unclosed_delims); } - pub fn unclosed_delims(&self) -> &[UnmatchedBrace] { + pub fn unclosed_delims(&self) -> &[UnmatchedDelim] { &self.unclosed_delims } diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index fda9151478f68..b1b79fe4e054b 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -10,7 +10,7 @@ mod path; mod stmt; mod ty; -use crate::lexer::UnmatchedBrace; +use crate::lexer::UnmatchedDelim; pub use attr_wrapper::AttrWrapper; pub use diagnostics::AttemptLocalParseRecovery; pub(crate) use item::FnParseMode; @@ -149,7 +149,7 @@ pub struct Parser<'a> { /// A list of all unclosed delimiters found by the lexer. If an entry is used for error recovery /// it gets removed from here. Every entry left at the end gets emitted as an independent /// error. - pub(super) unclosed_delims: Vec, + pub(super) unclosed_delims: Vec, last_unexpected_token_span: Option, /// Span pointing at the `:` for the last type ascription the parser has seen, and whether it /// looked like it could have been a mistyped path or literal `Option:Some(42)`). @@ -1521,11 +1521,11 @@ impl<'a> Parser<'a> { } pub(crate) fn make_unclosed_delims_error( - unmatched: UnmatchedBrace, + unmatched: UnmatchedDelim, sess: &ParseSess, ) -> Option> { // `None` here means an `Eof` was found. We already emit those errors elsewhere, we add them to - // `unmatched_braces` only for error recovery in the `Parser`. + // `unmatched_delims` only for error recovery in the `Parser`. let found_delim = unmatched.found_delim?; let mut spans = vec![unmatched.found_span]; if let Some(sp) = unmatched.unclosed_span { @@ -1542,7 +1542,7 @@ pub(crate) fn make_unclosed_delims_error( Some(err) } -pub fn emit_unclosed_delims(unclosed_delims: &mut Vec, sess: &ParseSess) { +pub fn emit_unclosed_delims(unclosed_delims: &mut Vec, sess: &ParseSess) { *sess.reached_eof.borrow_mut() |= unclosed_delims.iter().any(|unmatched_delim| unmatched_delim.found_delim.is_none()); for unmatched in unclosed_delims.drain(..) { From 88de2e111504439f76315548dd3e442999b46e95 Mon Sep 17 00:00:00 2001 From: yukang Date: Wed, 22 Feb 2023 06:09:57 +0000 Subject: [PATCH 12/14] no need to return unmatched_delims from tokentrees --- compiler/rustc_expand/src/tests.rs | 1 - compiler/rustc_parse/src/lib.rs | 16 ++++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/compiler/rustc_expand/src/tests.rs b/compiler/rustc_expand/src/tests.rs index 14918d3c190a5..480d95b77e901 100644 --- a/compiler/rustc_expand/src/tests.rs +++ b/compiler/rustc_expand/src/tests.rs @@ -43,7 +43,6 @@ pub(crate) fn string_to_stream(source_str: String) -> TokenStream { ps.source_map().new_source_file(PathBuf::from("bogofile").into(), source_str), None, ) - .0 } /// Parses a string, returns a crate. diff --git a/compiler/rustc_parse/src/lib.rs b/compiler/rustc_parse/src/lib.rs index b6e54b53e2614..eede099101083 100644 --- a/compiler/rustc_parse/src/lib.rs +++ b/compiler/rustc_parse/src/lib.rs @@ -30,7 +30,7 @@ pub const MACRO_ARGUMENTS: Option<&str> = Some("macro arguments"); #[macro_use] pub mod parser; -use parser::{emit_unclosed_delims, make_unclosed_delims_error, Parser}; +use parser::{make_unclosed_delims_error, Parser}; pub mod lexer; pub mod validate_attr; @@ -96,10 +96,7 @@ pub fn parse_stream_from_source_str( sess: &ParseSess, override_span: Option, ) -> TokenStream { - let (stream, mut errors) = - source_file_to_stream(sess, sess.source_map().new_source_file(name, source), override_span); - emit_unclosed_delims(&mut errors, &sess); - stream + source_file_to_stream(sess, sess.source_map().new_source_file(name, source), override_span) } /// Creates a new parser from a source string. @@ -135,9 +132,8 @@ fn maybe_source_file_to_parser( source_file: Lrc, ) -> Result, Vec> { let end_pos = source_file.end_pos; - let (stream, unclosed_delims) = maybe_file_to_stream(sess, source_file, None)?; + let stream = maybe_file_to_stream(sess, source_file, None)?; let mut parser = stream_to_parser(sess, stream, None); - parser.unclosed_delims = unclosed_delims; if parser.token == token::Eof { parser.token.span = Span::new(end_pos, end_pos, parser.token.span.ctxt(), None); } @@ -182,7 +178,7 @@ pub fn source_file_to_stream( sess: &ParseSess, source_file: Lrc, override_span: Option, -) -> (TokenStream, Vec) { +) -> TokenStream { panictry_buffer!(&sess.span_diagnostic, maybe_file_to_stream(sess, source_file, override_span)) } @@ -192,7 +188,7 @@ pub fn maybe_file_to_stream( sess: &ParseSess, source_file: Lrc, override_span: Option, -) -> Result<(TokenStream, Vec), Vec> { +) -> Result> { let src = source_file.src.as_ref().unwrap_or_else(|| { sess.span_diagnostic.bug(&format!( "cannot lex `source_file` without source: {}", @@ -204,7 +200,7 @@ pub fn maybe_file_to_stream( lexer::parse_token_trees(sess, src.as_str(), source_file.start_pos, override_span); match token_trees { - Ok(stream) if unmatched_delims.is_empty() => Ok((stream, unmatched_delims)), + Ok(stream) if unmatched_delims.is_empty() => Ok(stream), _ => { // Return error if there are unmatched delimiters or unclosng delimiters. // We emit delimiter mismatch errors first, then emit the unclosing delimiter mismatch From f808877bbf8643cb9ea54a59cb5a61a631f545dd Mon Sep 17 00:00:00 2001 From: yukang Date: Wed, 22 Feb 2023 10:30:35 +0000 Subject: [PATCH 13/14] refactor parse_token_trees to not return unmatched_delims --- compiler/rustc_parse/src/lexer/mod.rs | 29 +++++++++++++++++-- compiler/rustc_parse/src/lexer/tokentrees.rs | 1 - compiler/rustc_parse/src/lib.rs | 25 +--------------- .../rustc_parse/src/parser/diagnostics.rs | 4 +-- 4 files changed, 29 insertions(+), 30 deletions(-) diff --git a/compiler/rustc_parse/src/lexer/mod.rs b/compiler/rustc_parse/src/lexer/mod.rs index db1bea1992315..9dbddee5a56f0 100644 --- a/compiler/rustc_parse/src/lexer/mod.rs +++ b/compiler/rustc_parse/src/lexer/mod.rs @@ -1,10 +1,11 @@ use crate::errors; use crate::lexer::unicode_chars::UNICODE_ARRAY; +use crate::make_unclosed_delims_error; use rustc_ast::ast::{self, AttrStyle}; use rustc_ast::token::{self, CommentKind, Delimiter, Token, TokenKind}; use rustc_ast::tokenstream::TokenStream; use rustc_ast::util::unicode::contains_text_flow_control_chars; -use rustc_errors::{error_code, Applicability, DiagnosticBuilder, PResult, StashKey}; +use rustc_errors::{error_code, Applicability, Diagnostic, DiagnosticBuilder, StashKey}; use rustc_lexer::unescape::{self, Mode}; use rustc_lexer::Cursor; use rustc_lexer::{Base, DocStyle, RawStrError}; @@ -44,7 +45,7 @@ pub(crate) fn parse_token_trees<'a>( mut src: &'a str, mut start_pos: BytePos, override_span: Option, -) -> (PResult<'a, TokenStream>, Vec) { +) -> Result> { // Skip `#!`, if present. if let Some(shebang_len) = rustc_lexer::strip_shebang(src) { src = &src[shebang_len..]; @@ -61,7 +62,29 @@ pub(crate) fn parse_token_trees<'a>( override_span, nbsp_is_whitespace: false, }; - tokentrees::TokenTreesReader::parse_all_token_trees(string_reader) + let (token_trees, unmatched_delims) = + tokentrees::TokenTreesReader::parse_all_token_trees(string_reader); + match token_trees { + Ok(stream) if unmatched_delims.is_empty() => Ok(stream), + _ => { + // Return error if there are unmatched delimiters or unclosng delimiters. + // We emit delimiter mismatch errors first, then emit the unclosing delimiter mismatch + // because the delimiter mismatch is more likely to be the root cause of error + + let mut buffer = Vec::with_capacity(1); + // Not using `emit_unclosed_delims` to use `db.buffer` + for unmatched in unmatched_delims { + if let Some(err) = make_unclosed_delims_error(unmatched, &sess) { + err.buffer(&mut buffer); + } + } + if let Err(err) = token_trees { + // Add unclosing delimiter error + err.buffer(&mut buffer); + } + Err(buffer) + } + } } struct StringReader<'a> { diff --git a/compiler/rustc_parse/src/lexer/tokentrees.rs b/compiler/rustc_parse/src/lexer/tokentrees.rs index 5abd62bc2a448..36fd1e37d651e 100644 --- a/compiler/rustc_parse/src/lexer/tokentrees.rs +++ b/compiler/rustc_parse/src/lexer/tokentrees.rs @@ -161,7 +161,6 @@ impl<'a> TokenTreesReader<'a> { } } let (tok, _) = self.diag_info.open_braces.pop().unwrap(); - debug!("anan now: open {:#?} close {:#?}", open_delim, close_delim); self.diag_info.unmatched_delims.push(UnmatchedDelim { expected_delim: tok, found_delim: Some(close_delim), diff --git a/compiler/rustc_parse/src/lib.rs b/compiler/rustc_parse/src/lib.rs index eede099101083..d1c3fd0cd0f8f 100644 --- a/compiler/rustc_parse/src/lib.rs +++ b/compiler/rustc_parse/src/lib.rs @@ -196,30 +196,7 @@ pub fn maybe_file_to_stream( )); }); - let (token_trees, unmatched_delims) = - lexer::parse_token_trees(sess, src.as_str(), source_file.start_pos, override_span); - - match token_trees { - Ok(stream) if unmatched_delims.is_empty() => Ok(stream), - _ => { - // Return error if there are unmatched delimiters or unclosng delimiters. - // We emit delimiter mismatch errors first, then emit the unclosing delimiter mismatch - // because the delimiter mismatch is more likely to be the root cause of the - - let mut buffer = Vec::with_capacity(1); - // Not using `emit_unclosed_delims` to use `db.buffer` - for unmatched in unmatched_delims { - if let Some(err) = make_unclosed_delims_error(unmatched, &sess) { - err.buffer(&mut buffer); - } - } - if let Err(err) = token_trees { - // Add unclosing delimiter error - err.buffer(&mut buffer); - } - Err(buffer) - } - } + lexer::parse_token_trees(sess, src.as_str(), source_file.start_pos, override_span) } /// Given a stream and the `ParseSess`, produces a parser. diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index d0cf42b931b8c..f7a2a6d929174 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -19,9 +19,9 @@ use crate::errors::{ }; use crate::fluent_generated as fluent; -use rustc_ast as ast; -use crate::parser; use crate::lexer::UnmatchedDelim; +use crate::parser; +use rustc_ast as ast; use rustc_ast::ptr::P; use rustc_ast::token::{self, Delimiter, Lit, LitKind, TokenKind}; use rustc_ast::util::parser::AssocOp; From 229aef1f7d7d558332ad557ef19592ffc864465d Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 28 Feb 2023 10:07:57 +0100 Subject: [PATCH 14/14] add missing feature in core/tests --- library/core/tests/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs index 3947a64e5c6ff..ccb7be68eb1b2 100644 --- a/library/core/tests/lib.rs +++ b/library/core/tests/lib.rs @@ -67,6 +67,7 @@ #![feature(slice_internals)] #![feature(slice_partition_dedup)] #![feature(ip)] +#![feature(ip_in_core)] #![feature(iter_advance_by)] #![feature(iter_array_chunks)] #![feature(iter_collect_into)]