diff --git a/src/librustc/ty/maps/plumbing.rs b/src/librustc/ty/maps/plumbing.rs index f02c7cbd0ea3e..ffa1081469f86 100644 --- a/src/librustc/ty/maps/plumbing.rs +++ b/src/librustc/ty/maps/plumbing.rs @@ -84,7 +84,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { let span = self.sess.codemap().def_span(span); let mut err = struct_span_err!(self.sess, span, E0391, - "unsupported cyclic reference between types/traits detected"); + "cyclic dependency detected"); err.span_label(span, "cyclic reference"); err.span_note(self.sess.codemap().def_span(stack[0].0), diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index eb67c9ce4b7d8..c918f7ac62e62 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -36,7 +36,7 @@ use rustc_typeck as typeck; use rustc_privacy; use rustc_plugin::registry::Registry; use rustc_plugin as plugin; -use rustc_passes::{self, ast_validation, loops, consts, static_recursion, hir_stats}; +use rustc_passes::{self, ast_validation, loops, consts, hir_stats}; use rustc_const_eval::{self, check_match}; use super::Compilation; @@ -990,10 +990,6 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(trans: &TransCrate, "loop checking", || loops::check_crate(sess, &hir_map)); - time(time_passes, - "static item recursion checking", - || static_recursion::check_crate(sess, &hir_map))?; - let mut local_providers = ty::maps::Providers::default(); default_provide(&mut local_providers); trans.provide(&mut local_providers); diff --git a/src/librustc_passes/diagnostics.rs b/src/librustc_passes/diagnostics.rs index 743f7b7326e9e..8a19615c1adcb 100644 --- a/src/librustc_passes/diagnostics.rs +++ b/src/librustc_passes/diagnostics.rs @@ -128,22 +128,6 @@ impl !Enterprise for Foo { } Please note that negative impls are only allowed for auto traits. "##, -E0265: r##" -This error indicates that a static or constant references itself. -All statics and constants need to resolve to a value in an acyclic manner. - -For example, neither of the following can be sensibly compiled: - -```compile_fail,E0265 -const X: u32 = X; -``` - -```compile_fail,E0265 -const X: u32 = Y; -const Y: u32 = X; -``` -"##, - E0267: r##" This error indicates the use of a loop keyword (`break` or `continue`) inside a closure but outside of any loop. Erroneous code example: diff --git a/src/librustc_passes/lib.rs b/src/librustc_passes/lib.rs index 7db1f5665fbe5..6b9f407cbdb4d 100644 --- a/src/librustc_passes/lib.rs +++ b/src/librustc_passes/lib.rs @@ -42,7 +42,6 @@ pub mod consts; pub mod hir_stats; pub mod loops; mod mir_stats; -pub mod static_recursion; __build_diagnostic_array! { librustc_passes, DIAGNOSTICS } diff --git a/src/librustc_passes/static_recursion.rs b/src/librustc_passes/static_recursion.rs deleted file mode 100644 index 987243b523473..0000000000000 --- a/src/librustc_passes/static_recursion.rs +++ /dev/null @@ -1,280 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This compiler pass detects constants that refer to themselves -// recursively. - -use rustc::hir::map as hir_map; -use rustc::session::Session; -use rustc::hir::def::{Def, CtorKind}; -use rustc::util::common::ErrorReported; -use rustc::util::nodemap::{NodeMap, NodeSet}; - -use syntax::ast; -use syntax_pos::Span; -use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap}; -use rustc::hir; - -struct CheckCrateVisitor<'a, 'hir: 'a> { - sess: &'a Session, - hir_map: &'a hir_map::Map<'hir>, - // `discriminant_map` is a cache that associates the `NodeId`s of local - // variant definitions with the discriminant expression that applies to - // each one. If the variant uses the default values (starting from `0`), - // then `None` is stored. - discriminant_map: NodeMap>, - detected_recursive_ids: NodeSet, -} - -impl<'a, 'hir: 'a> Visitor<'hir> for CheckCrateVisitor<'a, 'hir> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'hir> { - NestedVisitorMap::None - } - - fn visit_item(&mut self, it: &'hir hir::Item) { - match it.node { - hir::ItemStatic(..) | - hir::ItemConst(..) => { - let mut recursion_visitor = CheckItemRecursionVisitor::new(self); - recursion_visitor.visit_item(it); - } - hir::ItemEnum(ref enum_def, ref generics) => { - // We could process the whole enum, but handling the variants - // with discriminant expressions one by one gives more specific, - // less redundant output. - for variant in &enum_def.variants { - if let Some(_) = variant.node.disr_expr { - let mut recursion_visitor = CheckItemRecursionVisitor::new(self); - recursion_visitor.populate_enum_discriminants(enum_def); - recursion_visitor.visit_variant(variant, generics, it.id); - } - } - } - _ => {} - } - intravisit::walk_item(self, it) - } - - fn visit_trait_item(&mut self, ti: &'hir hir::TraitItem) { - match ti.node { - hir::TraitItemKind::Const(_, ref default) => { - if let Some(_) = *default { - let mut recursion_visitor = CheckItemRecursionVisitor::new(self); - recursion_visitor.visit_trait_item(ti); - } - } - _ => {} - } - intravisit::walk_trait_item(self, ti) - } - - fn visit_impl_item(&mut self, ii: &'hir hir::ImplItem) { - match ii.node { - hir::ImplItemKind::Const(..) => { - let mut recursion_visitor = CheckItemRecursionVisitor::new(self); - recursion_visitor.visit_impl_item(ii); - } - _ => {} - } - intravisit::walk_impl_item(self, ii) - } -} - -pub fn check_crate<'hir>(sess: &Session, hir_map: &hir_map::Map<'hir>) - -> Result<(), ErrorReported> -{ - let mut visitor = CheckCrateVisitor { - sess, - hir_map, - discriminant_map: NodeMap(), - detected_recursive_ids: NodeSet(), - }; - sess.track_errors(|| { - // FIXME(#37712) could use ItemLikeVisitor if trait items were item-like - hir_map.krate().visit_all_item_likes(&mut visitor.as_deep_visitor()); - }) -} - -struct CheckItemRecursionVisitor<'a, 'b: 'a, 'hir: 'b> { - sess: &'b Session, - hir_map: &'b hir_map::Map<'hir>, - discriminant_map: &'a mut NodeMap>, - idstack: Vec, - detected_recursive_ids: &'a mut NodeSet, -} - -impl<'a, 'b: 'a, 'hir: 'b> CheckItemRecursionVisitor<'a, 'b, 'hir> { - fn new(v: &'a mut CheckCrateVisitor<'b, 'hir>) -> Self { - CheckItemRecursionVisitor { - sess: v.sess, - hir_map: v.hir_map, - discriminant_map: &mut v.discriminant_map, - idstack: Vec::new(), - detected_recursive_ids: &mut v.detected_recursive_ids, - } - } - fn with_item_id_pushed(&mut self, id: ast::NodeId, f: F, span: Span) - where F: Fn(&mut Self) - { - if self.idstack.iter().any(|&x| x == id) { - if self.detected_recursive_ids.contains(&id) { - return; - } - self.detected_recursive_ids.insert(id); - let any_static = self.idstack.iter().any(|&x| { - if let hir_map::NodeItem(item) = self.hir_map.get(x) { - if let hir::ItemStatic(..) = item.node { - true - } else { - false - } - } else { - false - } - }); - if !any_static { - struct_span_err!(self.sess, span, E0265, "recursive constant") - .span_label(span, "recursion not allowed in constant") - .emit(); - } - return; - } - self.idstack.push(id); - f(self); - self.idstack.pop(); - } - // If a variant has an expression specifying its discriminant, then it needs - // to be checked just like a static or constant. However, if there are more - // variants with no explicitly specified discriminant, those variants will - // increment the same expression to get their values. - // - // So for every variant, we need to track whether there is an expression - // somewhere in the enum definition that controls its discriminant. We do - // this by starting from the end and searching backward. - fn populate_enum_discriminants(&mut self, enum_definition: &'hir hir::EnumDef) { - // Get the map, and return if we already processed this enum or if it - // has no variants. - match enum_definition.variants.first() { - None => { - return; - } - Some(variant) if self.discriminant_map.contains_key(&variant.node.data.id()) => { - return; - } - _ => {} - } - - // Go through all the variants. - let mut variant_stack: Vec = Vec::new(); - for variant in enum_definition.variants.iter().rev() { - variant_stack.push(variant.node.data.id()); - // When we find an expression, every variant currently on the stack - // is affected by that expression. - if let Some(expr) = variant.node.disr_expr { - for id in &variant_stack { - self.discriminant_map.insert(*id, Some(expr)); - } - variant_stack.clear() - } - } - // If we are at the top, that always starts at 0, so any variant on the - // stack has a default value and does not need to be checked. - for id in &variant_stack { - self.discriminant_map.insert(*id, None); - } - } -} - -impl<'a, 'b: 'a, 'hir: 'b> Visitor<'hir> for CheckItemRecursionVisitor<'a, 'b, 'hir> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'hir> { - NestedVisitorMap::OnlyBodies(&self.hir_map) - } - fn visit_item(&mut self, it: &'hir hir::Item) { - self.with_item_id_pushed(it.id, |v| intravisit::walk_item(v, it), it.span); - } - - fn visit_enum_def(&mut self, - enum_definition: &'hir hir::EnumDef, - generics: &'hir hir::Generics, - item_id: ast::NodeId, - _: Span) { - self.populate_enum_discriminants(enum_definition); - intravisit::walk_enum_def(self, enum_definition, generics, item_id); - } - - fn visit_variant(&mut self, - variant: &'hir hir::Variant, - _: &'hir hir::Generics, - _: ast::NodeId) { - let variant_id = variant.node.data.id(); - let maybe_expr = *self.discriminant_map.get(&variant_id).unwrap_or_else(|| { - span_bug!(variant.span, - "`check_static_recursion` attempted to visit \ - variant with unknown discriminant") - }); - // If `maybe_expr` is `None`, that's because no discriminant is - // specified that affects this variant. Thus, no risk of recursion. - if let Some(expr) = maybe_expr { - let expr = &self.hir_map.body(expr).value; - self.with_item_id_pushed(expr.id, |v| intravisit::walk_expr(v, expr), expr.span); - } - } - - fn visit_trait_item(&mut self, ti: &'hir hir::TraitItem) { - self.with_item_id_pushed(ti.id, |v| intravisit::walk_trait_item(v, ti), ti.span); - } - - fn visit_impl_item(&mut self, ii: &'hir hir::ImplItem) { - self.with_item_id_pushed(ii.id, |v| intravisit::walk_impl_item(v, ii), ii.span); - } - - fn visit_path(&mut self, path: &'hir hir::Path, _: ast::NodeId) { - match path.def { - Def::Static(def_id, _) | - Def::AssociatedConst(def_id) | - Def::Const(def_id) => { - if let Some(node_id) = self.hir_map.as_local_node_id(def_id) { - match self.hir_map.get(node_id) { - hir_map::NodeItem(item) => self.visit_item(item), - hir_map::NodeTraitItem(item) => self.visit_trait_item(item), - hir_map::NodeImplItem(item) => self.visit_impl_item(item), - hir_map::NodeForeignItem(_) => {} - _ => { - span_bug!(path.span, - "expected item, found {}", - self.hir_map.node_to_string(node_id)); - } - } - } - } - // For variants, we only want to check expressions that - // affect the specific variant used, but we need to check - // the whole enum definition to see what expression that - // might be (if any). - Def::VariantCtor(variant_id, CtorKind::Const) => { - if let Some(variant_id) = self.hir_map.as_local_node_id(variant_id) { - let variant = self.hir_map.expect_variant(variant_id); - let enum_id = self.hir_map.get_parent(variant_id); - let enum_item = self.hir_map.expect_item(enum_id); - if let hir::ItemEnum(ref enum_def, ref generics) = enum_item.node { - self.populate_enum_discriminants(enum_def); - self.visit_variant(variant, generics, enum_id); - } else { - span_bug!(path.span, - "`check_static_recursion` found \ - non-enum in Def::VariantCtor"); - } - } - } - _ => (), - } - intravisit::walk_path(self, path); - } -} diff --git a/src/test/compile-fail/coherence-inherited-assoc-ty-cycle-err.rs b/src/test/compile-fail/coherence-inherited-assoc-ty-cycle-err.rs index 5d7f33967402c..2f4d82e2ef514 100644 --- a/src/test/compile-fail/coherence-inherited-assoc-ty-cycle-err.rs +++ b/src/test/compile-fail/coherence-inherited-assoc-ty-cycle-err.rs @@ -17,7 +17,7 @@ #![feature(specialization)] trait Trait { type Assoc; } -//~^ unsupported cyclic reference between types/traits detected [E0391] +//~^ cyclic dependency detected [E0391] impl Trait for Vec { type Assoc = (); diff --git a/src/test/compile-fail/const-size_of-cycle.rs b/src/test/compile-fail/const-size_of-cycle.rs index cbeafdfe6acc9..6218dcbf5f2c5 100644 --- a/src/test/compile-fail/const-size_of-cycle.rs +++ b/src/test/compile-fail/const-size_of-cycle.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern: unsupported cyclic reference between types/traits detected +// error-pattern: cyclic dependency detected #![feature(const_fn)] diff --git a/src/test/compile-fail/cycle-projection-based-on-where-clause.rs b/src/test/compile-fail/cycle-projection-based-on-where-clause.rs index 7af2f11bd2815..ee4722c010f16 100644 --- a/src/test/compile-fail/cycle-projection-based-on-where-clause.rs +++ b/src/test/compile-fail/cycle-projection-based-on-where-clause.rs @@ -25,7 +25,7 @@ trait Trait { type Item; } struct A where T : Trait, T : Add - //~^ ERROR unsupported cyclic reference between types/traits detected + //~^ ERROR cyclic dependency detected //~| ERROR associated type `Item` not found for `T` { data: T diff --git a/src/test/compile-fail/cycle-trait-default-type-trait.rs b/src/test/compile-fail/cycle-trait-default-type-trait.rs index e6caeb34a8c8f..88672088bcb4c 100644 --- a/src/test/compile-fail/cycle-trait-default-type-trait.rs +++ b/src/test/compile-fail/cycle-trait-default-type-trait.rs @@ -12,7 +12,7 @@ // again references the trait. trait Foo> { - //~^ ERROR unsupported cyclic reference + //~^ ERROR cyclic dependency detected } fn main() { } diff --git a/src/test/compile-fail/cycle-trait-supertrait-direct.rs b/src/test/compile-fail/cycle-trait-supertrait-direct.rs index ef3fead18f6aa..626567ccc0ead 100644 --- a/src/test/compile-fail/cycle-trait-supertrait-direct.rs +++ b/src/test/compile-fail/cycle-trait-supertrait-direct.rs @@ -11,7 +11,7 @@ // Test a supertrait cycle where a trait extends itself. trait Chromosome: Chromosome { - //~^ ERROR unsupported cyclic reference + //~^ ERROR cyclic dependency detected } fn main() { } diff --git a/src/test/compile-fail/infinite-vec-type-recursion.rs b/src/test/compile-fail/infinite-vec-type-recursion.rs index e5120840f7672..25d0590db1b75 100644 --- a/src/test/compile-fail/infinite-vec-type-recursion.rs +++ b/src/test/compile-fail/infinite-vec-type-recursion.rs @@ -9,6 +9,6 @@ // except according to those terms. type x = Vec; -//~^ ERROR unsupported cyclic reference +//~^ ERROR cyclic dependency detected fn main() { let b: x = Vec::new(); } diff --git a/src/test/compile-fail/issue-17252.rs b/src/test/compile-fail/issue-17252.rs index 0c04e295e1458..1c3e6890c8e2e 100644 --- a/src/test/compile-fail/issue-17252.rs +++ b/src/test/compile-fail/issue-17252.rs @@ -8,12 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -const FOO: usize = FOO; //~ ERROR recursive constant +const FOO: usize = FOO; //~ ERROR E0391 fn main() { let _x: [u8; FOO]; // caused stack overflow prior to fix let _y: usize = 1 + { - const BAR: usize = BAR; //~ ERROR recursive constant + const BAR: usize = BAR; let _z: [u8; BAR]; // caused stack overflow prior to fix 1 }; diff --git a/src/test/compile-fail/issue-20772.rs b/src/test/compile-fail/issue-20772.rs index 7ae4250d4203b..88395e5f1eafa 100644 --- a/src/test/compile-fail/issue-20772.rs +++ b/src/test/compile-fail/issue-20772.rs @@ -9,7 +9,7 @@ // except according to those terms. trait T : Iterator -//~^ ERROR unsupported cyclic reference between types/traits detected +//~^ ERROR cyclic dependency detected //~| ERROR associated type `Item` not found for `Self` {} diff --git a/src/test/compile-fail/issue-20825.rs b/src/test/compile-fail/issue-20825.rs index 7d082a3148f76..aeb798b382875 100644 --- a/src/test/compile-fail/issue-20825.rs +++ b/src/test/compile-fail/issue-20825.rs @@ -13,7 +13,7 @@ pub trait Subscriber { } pub trait Processor: Subscriber { - //~^ ERROR unsupported cyclic reference between types/traits detected [E0391] + //~^ ERROR cyclic dependency detected [E0391] type Input; } diff --git a/src/test/compile-fail/issue-21177.rs b/src/test/compile-fail/issue-21177.rs index f49b71953835b..40c95b98f1264 100644 --- a/src/test/compile-fail/issue-21177.rs +++ b/src/test/compile-fail/issue-21177.rs @@ -14,7 +14,7 @@ trait Trait { } fn foo>() { } -//~^ ERROR unsupported cyclic reference between types/traits detected +//~^ ERROR cyclic dependency detected //~| ERROR associated type `B` not found for `T` fn main() { } diff --git a/src/test/compile-fail/issue-22673.rs b/src/test/compile-fail/issue-22673.rs index 442e6bcda5a09..fde2d001542b8 100644 --- a/src/test/compile-fail/issue-22673.rs +++ b/src/test/compile-fail/issue-22673.rs @@ -9,7 +9,7 @@ // except according to those terms. trait Expr : PartialEq { - //~^ ERROR: unsupported cyclic reference between types/traits detected + //~^ ERROR: cyclic dependency detected type Item; } diff --git a/src/test/compile-fail/issue-26548.rs b/src/test/compile-fail/issue-26548.rs index 39c6e97268f98..16a650cc6d886 100644 --- a/src/test/compile-fail/issue-26548.rs +++ b/src/test/compile-fail/issue-26548.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern: unsupported cyclic reference between types/traits detected +// error-pattern: cyclic dependency detected // note-pattern: the cycle begins when computing layout of // note-pattern: ...which then requires computing layout of // note-pattern: ...which then again requires computing layout of diff --git a/src/test/compile-fail/issue-34373.rs b/src/test/compile-fail/issue-34373.rs index 7bbc680197e84..b18e05af47c97 100644 --- a/src/test/compile-fail/issue-34373.rs +++ b/src/test/compile-fail/issue-34373.rs @@ -15,7 +15,7 @@ trait Trait { } pub struct Foo>>; -type DefaultFoo = Foo; //~ ERROR unsupported cyclic reference +type DefaultFoo = Foo; //~ ERROR cyclic dependency detected fn main() { } diff --git a/src/test/compile-fail/issue-44415.rs b/src/test/compile-fail/issue-44415.rs index 3b7089f497526..930a427e9a5e0 100644 --- a/src/test/compile-fail/issue-44415.rs +++ b/src/test/compile-fail/issue-44415.rs @@ -15,7 +15,7 @@ use std::intrinsics; struct Foo { bytes: [u8; unsafe { intrinsics::size_of::() }], - //~^ ERROR unsupported cyclic reference between types/traits detected + //~^ ERROR cyclic dependency detected x: usize, } diff --git a/src/test/compile-fail/resolve-self-in-impl.rs b/src/test/compile-fail/resolve-self-in-impl.rs index 55ae37404a9fa..7210c857125d6 100644 --- a/src/test/compile-fail/resolve-self-in-impl.rs +++ b/src/test/compile-fail/resolve-self-in-impl.rs @@ -21,10 +21,10 @@ impl Tr for S where Self: Copy {} // OK impl Tr for S where S: Copy {} // OK impl Tr for S where Self::A: Copy {} // OK -impl Tr for Self {} //~ ERROR unsupported cyclic reference between types/traits detected -impl Tr for S {} //~ ERROR unsupported cyclic reference between types/traits detected -impl Self {} //~ ERROR unsupported cyclic reference between types/traits detected -impl S {} //~ ERROR unsupported cyclic reference between types/traits detected -impl Tr for S {} //~ ERROR unsupported cyclic reference between types/traits detected +impl Tr for Self {} //~ ERROR cyclic dependency detected +impl Tr for S {} //~ ERROR cyclic dependency detected +impl Self {} //~ ERROR cyclic dependency detected +impl S {} //~ ERROR cyclic dependency detected +impl Tr for S {} //~ ERROR cyclic dependency detected fn main() {} diff --git a/src/test/ui/cycle-trait-supertrait-indirect.rs b/src/test/ui/cycle-trait-supertrait-indirect.rs index c3b0276bcf9cb..447505e886f81 100644 --- a/src/test/ui/cycle-trait-supertrait-indirect.rs +++ b/src/test/ui/cycle-trait-supertrait-indirect.rs @@ -18,7 +18,7 @@ trait B: C { } trait C: B { } - //~^ ERROR unsupported cyclic reference + //~^ ERROR cyclic dependency detected //~| cyclic reference fn main() { } diff --git a/src/test/ui/cycle-trait-supertrait-indirect.stderr b/src/test/ui/cycle-trait-supertrait-indirect.stderr index 107644037a9ca..a01565546462d 100644 --- a/src/test/ui/cycle-trait-supertrait-indirect.stderr +++ b/src/test/ui/cycle-trait-supertrait-indirect.stderr @@ -1,4 +1,4 @@ -error[E0391]: unsupported cyclic reference between types/traits detected +error[E0391]: cyclic dependency detected --> $DIR/cycle-trait-supertrait-indirect.rs:20:1 | 20 | trait C: B { } diff --git a/src/test/ui/impl-trait/auto-trait-leak.rs b/src/test/ui/impl-trait/auto-trait-leak.rs index 705390e3b969c..5a6aac43ec770 100644 --- a/src/test/ui/impl-trait/auto-trait-leak.rs +++ b/src/test/ui/impl-trait/auto-trait-leak.rs @@ -42,7 +42,7 @@ fn after() -> impl Fn(i32) { // independently resolved and only require the concrete // return type, which can't depend on the obligation. fn cycle1() -> impl Clone { - //~^ ERROR unsupported cyclic reference between types/traits detected + //~^ ERROR cyclic dependency detected //~| cyclic reference send(cycle2().clone()); diff --git a/src/test/ui/impl-trait/auto-trait-leak.stderr b/src/test/ui/impl-trait/auto-trait-leak.stderr index 838a3002e3aa7..d6e31ba1e1f9c 100644 --- a/src/test/ui/impl-trait/auto-trait-leak.stderr +++ b/src/test/ui/impl-trait/auto-trait-leak.stderr @@ -28,7 +28,7 @@ note: required by `send` 24 | fn send(_: T) {} | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0391]: unsupported cyclic reference between types/traits detected +error[E0391]: cyclic dependency detected --> $DIR/auto-trait-leak.rs:44:1 | 44 | fn cycle1() -> impl Clone { diff --git a/src/test/ui/issue-12511.rs b/src/test/ui/issue-12511.rs index e1335c7d558e1..e4d6076868717 100644 --- a/src/test/ui/issue-12511.rs +++ b/src/test/ui/issue-12511.rs @@ -12,7 +12,7 @@ trait t1 : t2 { } trait t2 : t1 { -//~^ ERROR unsupported cyclic reference between types/traits detected +//~^ ERROR cyclic dependency detected //~| cyclic reference } diff --git a/src/test/ui/issue-12511.stderr b/src/test/ui/issue-12511.stderr index cbf005a70b028..aec828a90d1a7 100644 --- a/src/test/ui/issue-12511.stderr +++ b/src/test/ui/issue-12511.stderr @@ -1,4 +1,4 @@ -error[E0391]: unsupported cyclic reference between types/traits detected +error[E0391]: cyclic dependency detected --> $DIR/issue-12511.rs:14:1 | 14 | trait t2 : t1 { diff --git a/src/test/ui/issue-23302.rs b/src/test/ui/issue-23302-1.rs similarity index 71% rename from src/test/ui/issue-23302.rs rename to src/test/ui/issue-23302-1.rs index 2d93ab0c30c8f..10a538301162c 100644 --- a/src/test/ui/issue-23302.rs +++ b/src/test/ui/issue-23302-1.rs @@ -11,18 +11,7 @@ // Check that an enum with recursion in the discriminant throws // the appropriate error (rather than, say, blowing the stack). enum X { - A = X::A as isize, //~ ERROR E0265 + A = X::A as isize, //~ ERROR E0391 } -// Since `Y::B` here defaults to `Y::A+1`, this is also a -// recursive definition. -enum Y { - A = Y::B as isize, //~ ERROR E0265 - B, -} - -const A: i32 = B; //~ ERROR E0265 - -const B: i32 = A; //~ ERROR E0265 - fn main() { } diff --git a/src/test/ui/issue-23302-1.stderr b/src/test/ui/issue-23302-1.stderr new file mode 100644 index 0000000000000..0658c07fb1dbe --- /dev/null +++ b/src/test/ui/issue-23302-1.stderr @@ -0,0 +1,15 @@ +error[E0391]: cyclic dependency detected + --> $DIR/issue-23302-1.rs:14:9 + | +14 | A = X::A as isize, //~ ERROR E0391 + | ^^^^^^^^^^^^^ cyclic reference + | +note: the cycle begins when const-evaluating `X::A::{{initializer}}`... + --> $DIR/issue-23302-1.rs:14:5 + | +14 | A = X::A as isize, //~ ERROR E0391 + | ^^^^^^^^^^^^^^^^^ + = note: ...which then again requires const-evaluating `X::A::{{initializer}}`, completing the cycle. + +error: aborting due to previous error + diff --git a/src/test/compile-fail/issue-17718-recursive.rs b/src/test/ui/issue-23302-2.rs similarity index 64% rename from src/test/compile-fail/issue-17718-recursive.rs rename to src/test/ui/issue-23302-2.rs index 9959b0c6fc523..d1af19eb579f5 100644 --- a/src/test/compile-fail/issue-17718-recursive.rs +++ b/src/test/ui/issue-23302-2.rs @@ -1,4 +1,4 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -8,7 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -const A: usize = B; //~ ERROR: recursive constant -const B: usize = A; //~ ERROR: recursive constant +// Since `Y::B` here defaults to `Y::A+1`, this is also a +// recursive definition. +enum Y { + A = Y::B as isize, //~ ERROR E0391 + B, +} -fn main() {} +fn main() { } diff --git a/src/test/ui/issue-23302-2.stderr b/src/test/ui/issue-23302-2.stderr new file mode 100644 index 0000000000000..c4a1c4f80c82c --- /dev/null +++ b/src/test/ui/issue-23302-2.stderr @@ -0,0 +1,15 @@ +error[E0391]: cyclic dependency detected + --> $DIR/issue-23302-2.rs:14:9 + | +14 | A = Y::B as isize, //~ ERROR E0391 + | ^^^^^^^^^^^^^ cyclic reference + | +note: the cycle begins when const-evaluating `Y::A::{{initializer}}`... + --> $DIR/issue-23302-2.rs:14:5 + | +14 | A = Y::B as isize, //~ ERROR E0391 + | ^^^^^^^^^^^^^^^^^ + = note: ...which then again requires const-evaluating `Y::A::{{initializer}}`, completing the cycle. + +error: aborting due to previous error + diff --git a/src/test/compile-fail/const-recursive.rs b/src/test/ui/issue-23302-3.rs similarity index 69% rename from src/test/compile-fail/const-recursive.rs rename to src/test/ui/issue-23302-3.rs index 7c05a817243b4..1d750b09025b9 100644 --- a/src/test/compile-fail/const-recursive.rs +++ b/src/test/ui/issue-23302-3.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -const a: isize = b; //~ ERROR recursive constant -const b: isize = a; //~ ERROR recursive constant +const A: i32 = B; //~ ERROR E0391 -fn main() { -} +const B: i32 = A; + +fn main() { } diff --git a/src/test/ui/issue-23302-3.stderr b/src/test/ui/issue-23302-3.stderr new file mode 100644 index 0000000000000..76f543cff7913 --- /dev/null +++ b/src/test/ui/issue-23302-3.stderr @@ -0,0 +1,20 @@ +error[E0391]: cyclic dependency detected + --> $DIR/issue-23302-3.rs:11:16 + | +11 | const A: i32 = B; //~ ERROR E0391 + | ^ cyclic reference + | +note: the cycle begins when processing `B`... + --> $DIR/issue-23302-3.rs:13:1 + | +13 | const B: i32 = A; + | ^^^^^^^^^^^^^^^^^ +note: ...which then requires processing `A`... + --> $DIR/issue-23302-3.rs:13:16 + | +13 | const B: i32 = A; + | ^ + = note: ...which then again requires processing `B`, completing the cycle. + +error: aborting due to previous error + diff --git a/src/test/ui/issue-23302.stderr b/src/test/ui/issue-23302.stderr deleted file mode 100644 index 4e93809fac374..0000000000000 --- a/src/test/ui/issue-23302.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error[E0265]: recursive constant - --> $DIR/issue-23302.rs:14:9 - | -14 | A = X::A as isize, //~ ERROR E0265 - | ^^^^^^^^^^^^^ recursion not allowed in constant - -error[E0265]: recursive constant - --> $DIR/issue-23302.rs:20:9 - | -20 | A = Y::B as isize, //~ ERROR E0265 - | ^^^^^^^^^^^^^ recursion not allowed in constant - -error[E0265]: recursive constant - --> $DIR/issue-23302.rs:24:1 - | -24 | const A: i32 = B; //~ ERROR E0265 - | ^^^^^^^^^^^^^^^^^ recursion not allowed in constant - -error[E0265]: recursive constant - --> $DIR/issue-23302.rs:26:1 - | -26 | const B: i32 = A; //~ ERROR E0265 - | ^^^^^^^^^^^^^^^^^ recursion not allowed in constant - -error: aborting due to 4 previous errors - diff --git a/src/test/ui/issue-36163.rs b/src/test/ui/issue-36163.rs index 2337f82afa49f..4c74d9d9173d8 100644 --- a/src/test/ui/issue-36163.rs +++ b/src/test/ui/issue-36163.rs @@ -8,16 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -const A: i32 = Foo::B; //~ ERROR E0265 +const A: isize = Foo::B as isize; enum Foo { - B = A, //~ ERROR E0265 + B = A, //~ ERROR E0391 } -enum Bar { - C = Bar::C, //~ ERROR E0265 -} - -const D: i32 = A; - fn main() {} diff --git a/src/test/ui/issue-36163.stderr b/src/test/ui/issue-36163.stderr index 5a107d88f2e4f..d0337fc32b03e 100644 --- a/src/test/ui/issue-36163.stderr +++ b/src/test/ui/issue-36163.stderr @@ -1,20 +1,20 @@ -error[E0265]: recursive constant - --> $DIR/issue-36163.rs:11:1 - | -11 | const A: i32 = Foo::B; //~ ERROR E0265 - | ^^^^^^^^^^^^^^^^^^^^^^ recursion not allowed in constant - -error[E0265]: recursive constant +error[E0391]: cyclic dependency detected --> $DIR/issue-36163.rs:14:9 | -14 | B = A, //~ ERROR E0265 - | ^ recursion not allowed in constant - -error[E0265]: recursive constant - --> $DIR/issue-36163.rs:18:9 +14 | B = A, //~ ERROR E0391 + | ^ cyclic reference + | +note: the cycle begins when const-evaluating `Foo::B::{{initializer}}`... + --> $DIR/issue-36163.rs:14:5 + | +14 | B = A, //~ ERROR E0391 + | ^^^^^ +note: ...which then requires const-evaluating `A`... + --> $DIR/issue-36163.rs:14:9 | -18 | C = Bar::C, //~ ERROR E0265 - | ^^^^^^ recursion not allowed in constant +14 | B = A, //~ ERROR E0391 + | ^ + = note: ...which then again requires const-evaluating `Foo::B::{{initializer}}`, completing the cycle. -error: aborting due to 3 previous errors +error: aborting due to previous error diff --git a/src/test/ui/resolve/issue-23305.rs b/src/test/ui/resolve/issue-23305.rs index f249e0e1127ee..34f8a0a48431c 100644 --- a/src/test/ui/resolve/issue-23305.rs +++ b/src/test/ui/resolve/issue-23305.rs @@ -13,6 +13,6 @@ pub trait ToNbt { } impl ToNbt {} -//~^ ERROR unsupported cyclic reference +//~^ ERROR cyclic dependency detected fn main() {} diff --git a/src/test/ui/resolve/issue-23305.stderr b/src/test/ui/resolve/issue-23305.stderr index 5bba9fc41e276..a0b4d424ec968 100644 --- a/src/test/ui/resolve/issue-23305.stderr +++ b/src/test/ui/resolve/issue-23305.stderr @@ -1,4 +1,4 @@ -error[E0391]: unsupported cyclic reference between types/traits detected +error[E0391]: cyclic dependency detected --> $DIR/issue-23305.rs:15:12 | 15 | impl ToNbt {}