diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs index 34fc62e0549da..deb37bdebda63 100644 --- a/compiler/rustc_feature/src/active.rs +++ b/compiler/rustc_feature/src/active.rs @@ -160,8 +160,6 @@ declare_features! ( (active, intrinsics, "1.0.0", None, None), /// Allows using `#[lang = ".."]` attribute for linking items to special compiler logic. (active, lang_items, "1.0.0", None, None), - /// Allows the `multiple_supertrait_upcastable` lint. - (active, multiple_supertrait_upcastable, "CURRENT_RUSTC_VERSION", None, None), /// Allows using `#[omit_gdb_pretty_printer_section]`. (active, omit_gdb_pretty_printer_section, "1.5.0", None, None), /// Allows using `#[prelude_import]` on glob `use` items. diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index 44ee4172675e0..1275d6f223c7a 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -61,7 +61,6 @@ mod late; mod let_underscore; mod levels; mod methods; -mod multiple_supertrait_upcastable; mod non_ascii_idents; mod non_fmt_panic; mod nonstandard_style; @@ -96,7 +95,6 @@ use hidden_unicode_codepoints::*; use internal::*; use let_underscore::*; use methods::*; -use multiple_supertrait_upcastable::*; use non_ascii_idents::*; use non_fmt_panic::NonPanicFmt; use nonstandard_style::*; @@ -231,7 +229,6 @@ late_lint_methods!( InvalidAtomicOrdering: InvalidAtomicOrdering, NamedAsmLabels: NamedAsmLabels, OpaqueHiddenInferredBound: OpaqueHiddenInferredBound, - MultipleSupertraitUpcastable: MultipleSupertraitUpcastable, ] ] ); diff --git a/compiler/rustc_lint/src/multiple_supertrait_upcastable.rs b/compiler/rustc_lint/src/multiple_supertrait_upcastable.rs deleted file mode 100644 index 5861b826b1ca3..0000000000000 --- a/compiler/rustc_lint/src/multiple_supertrait_upcastable.rs +++ /dev/null @@ -1,63 +0,0 @@ -use crate::{LateContext, LateLintPass, LintContext}; - -use rustc_errors::DelayDm; -use rustc_hir as hir; -use rustc_span::sym; - -declare_lint! { - /// The `multiple_supertrait_upcastable` lint detects when an object-safe trait has multiple - /// supertraits. - /// - /// ### Example - /// - /// ```rust - /// trait A {} - /// trait B {} - /// - /// #[warn(multiple_supertrait_upcastable)] - /// trait C: A + B {} - /// ``` - /// - /// {{produces}} - /// - /// ### Explanation - /// - /// To support upcasting with multiple supertraits, we need to store multiple vtables and this - /// can result in extra space overhead, even if no code actually uses upcasting. - /// This lint allows users to identify when such scenarios occur and to decide whether the - /// additional overhead is justified. - pub MULTIPLE_SUPERTRAIT_UPCASTABLE, - Allow, - "detect when an object-safe trait has multiple supertraits", - @feature_gate = sym::multiple_supertrait_upcastable; -} - -declare_lint_pass!(MultipleSupertraitUpcastable => [MULTIPLE_SUPERTRAIT_UPCASTABLE]); - -impl<'tcx> LateLintPass<'tcx> for MultipleSupertraitUpcastable { - fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) { - let def_id = item.owner_id.to_def_id(); - if let hir::ItemKind::Trait(_, _, _, _, _) = item.kind - && cx.tcx.is_object_safe(def_id) - { - let direct_super_traits_iter = cx.tcx - .super_predicates_of(def_id) - .predicates - .into_iter() - .filter_map(|(pred, _)| pred.to_opt_poly_trait_pred()); - if direct_super_traits_iter.count() > 1 { - cx.struct_span_lint( - MULTIPLE_SUPERTRAIT_UPCASTABLE, - cx.tcx.def_span(def_id), - DelayDm(|| { - format!( - "`{}` is object-safe and has multiple supertraits", - item.ident, - ) - }), - |diag| diag, - ); - } - } - } -} diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index c450c4da9a883..85510fa2c660c 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -944,7 +944,6 @@ symbols! { mul, mul_assign, mul_with_overflow, - multiple_supertrait_upcastable, must_not_suspend, must_use, naked, diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index f6cbac005ff39..9857f0516baa2 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -87,7 +87,6 @@ #![warn(missing_debug_implementations)] #![warn(missing_docs)] #![allow(explicit_outlives_requirements)] -#![cfg_attr(not(bootstrap), warn(multiple_supertrait_upcastable))] // // Library features: #![feature(alloc_layout_extra)] @@ -192,7 +191,6 @@ #![feature(unsized_fn_params)] #![feature(c_unwind)] #![feature(with_negative_coherence)] -#![cfg_attr(not(bootstrap), feature(multiple_supertrait_upcastable))] // // Rustdoc features: #![feature(doc_cfg)] diff --git a/library/core/src/error.rs b/library/core/src/error.rs index d2fac23ff18be..7152300abcbf3 100644 --- a/library/core/src/error.rs +++ b/library/core/src/error.rs @@ -28,7 +28,6 @@ use crate::fmt::{Debug, Display}; #[stable(feature = "rust1", since = "1.0.0")] #[cfg_attr(not(test), rustc_diagnostic_item = "Error")] #[rustc_has_incoherent_inherent_impls] -#[cfg_attr(not(bootstrap), allow(multiple_supertrait_upcastable))] pub trait Error: Debug + Display { /// The lower-level source of this error, if any. /// diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 890d7df8e1796..0e3fef4ead31a 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -95,7 +95,6 @@ #![warn(missing_docs)] #![allow(explicit_outlives_requirements)] #![allow(incomplete_features)] -#![cfg_attr(not(bootstrap), warn(multiple_supertrait_upcastable))] // // Library features: #![feature(const_align_offset)] @@ -232,7 +231,6 @@ #![feature(unsized_fn_params)] #![feature(asm_const)] #![feature(const_transmute_copy)] -#![cfg_attr(not(bootstrap), feature(multiple_supertrait_upcastable))] // // Target features: #![feature(arm_target_feature)] diff --git a/src/test/ui/feature-gates/feature-gate-multiple_supertrait_upcastable.rs b/src/test/ui/feature-gates/feature-gate-multiple_supertrait_upcastable.rs deleted file mode 100644 index 0467dea621b4c..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-multiple_supertrait_upcastable.rs +++ /dev/null @@ -1,12 +0,0 @@ -// check-pass - -#![deny(multiple_supertrait_upcastable)] -//~^ WARNING unknown lint: `multiple_supertrait_upcastable` -//~| WARNING unknown lint: `multiple_supertrait_upcastable` -//~| WARNING unknown lint: `multiple_supertrait_upcastable` -#![warn(multiple_supertrait_upcastable)] -//~^ WARNING unknown lint: `multiple_supertrait_upcastable` -//~| WARNING unknown lint: `multiple_supertrait_upcastable` -//~| WARNING unknown lint: `multiple_supertrait_upcastable` - -fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-multiple_supertrait_upcastable.stderr b/src/test/ui/feature-gates/feature-gate-multiple_supertrait_upcastable.stderr deleted file mode 100644 index 1f725f3541778..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-multiple_supertrait_upcastable.stderr +++ /dev/null @@ -1,57 +0,0 @@ -warning: unknown lint: `multiple_supertrait_upcastable` - --> $DIR/feature-gate-multiple_supertrait_upcastable.rs:3:1 - | -LL | #![deny(multiple_supertrait_upcastable)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `multiple_supertrait_upcastable` lint is unstable - = help: add `#![feature(multiple_supertrait_upcastable)]` to the crate attributes to enable - = note: `#[warn(unknown_lints)]` on by default - -warning: unknown lint: `multiple_supertrait_upcastable` - --> $DIR/feature-gate-multiple_supertrait_upcastable.rs:7:1 - | -LL | #![warn(multiple_supertrait_upcastable)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `multiple_supertrait_upcastable` lint is unstable - = help: add `#![feature(multiple_supertrait_upcastable)]` to the crate attributes to enable - -warning: unknown lint: `multiple_supertrait_upcastable` - --> $DIR/feature-gate-multiple_supertrait_upcastable.rs:3:1 - | -LL | #![deny(multiple_supertrait_upcastable)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `multiple_supertrait_upcastable` lint is unstable - = help: add `#![feature(multiple_supertrait_upcastable)]` to the crate attributes to enable - -warning: unknown lint: `multiple_supertrait_upcastable` - --> $DIR/feature-gate-multiple_supertrait_upcastable.rs:7:1 - | -LL | #![warn(multiple_supertrait_upcastable)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `multiple_supertrait_upcastable` lint is unstable - = help: add `#![feature(multiple_supertrait_upcastable)]` to the crate attributes to enable - -warning: unknown lint: `multiple_supertrait_upcastable` - --> $DIR/feature-gate-multiple_supertrait_upcastable.rs:3:1 - | -LL | #![deny(multiple_supertrait_upcastable)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `multiple_supertrait_upcastable` lint is unstable - = help: add `#![feature(multiple_supertrait_upcastable)]` to the crate attributes to enable - -warning: unknown lint: `multiple_supertrait_upcastable` - --> $DIR/feature-gate-multiple_supertrait_upcastable.rs:7:1 - | -LL | #![warn(multiple_supertrait_upcastable)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `multiple_supertrait_upcastable` lint is unstable - = help: add `#![feature(multiple_supertrait_upcastable)]` to the crate attributes to enable - -warning: 6 warnings emitted - diff --git a/src/test/ui/object-safety/issue-106247.rs b/src/test/ui/object-safety/issue-106247.rs new file mode 100644 index 0000000000000..64bf59e5d3aa5 --- /dev/null +++ b/src/test/ui/object-safety/issue-106247.rs @@ -0,0 +1,9 @@ +// check-pass + +#![deny(where_clauses_object_safety)] + +pub trait Trait { + fn method(&self) where Self: Sync; +} + +fn main() {} diff --git a/src/test/ui/traits/trait-upcasting/multiple_supertrait_upcastable.rs b/src/test/ui/traits/trait-upcasting/multiple_supertrait_upcastable.rs deleted file mode 100644 index 3c6ab86e4c65c..0000000000000 --- a/src/test/ui/traits/trait-upcasting/multiple_supertrait_upcastable.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![feature(multiple_supertrait_upcastable)] -#![deny(multiple_supertrait_upcastable)] - -trait A {} -trait B {} - -trait C: A + B {} -//~^ ERROR `C` is object-safe and has multiple supertraits - -fn main() {} diff --git a/src/test/ui/traits/trait-upcasting/multiple_supertrait_upcastable.stderr b/src/test/ui/traits/trait-upcasting/multiple_supertrait_upcastable.stderr deleted file mode 100644 index ad80a009ece80..0000000000000 --- a/src/test/ui/traits/trait-upcasting/multiple_supertrait_upcastable.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: `C` is object-safe and has multiple supertraits - --> $DIR/multiple_supertrait_upcastable.rs:7:1 - | -LL | trait C: A + B {} - | ^^^^^^^^^^^^^^ - | -note: the lint level is defined here - --> $DIR/multiple_supertrait_upcastable.rs:2:9 - | -LL | #![deny(multiple_supertrait_upcastable)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error -