diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-09-27 21:35:08 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-27 21:35:08 +0200 |
| commit | a935064faeda0c995960a407d47b4db8f16ac16b (patch) | |
| tree | 0e790d3018397981df40d9a79cff46593a46ebb8 /compiler/rustc_hir_analysis/src/coherence | |
| parent | ae43f27f83ca92cb3b73b2bf5b31b0b21fc8fb26 (diff) | |
| parent | 01a063f9df39fd7442874726afd8c9583987da44 (diff) | |
| download | rust-a935064faeda0c995960a407d47b4db8f16ac16b.tar.gz rust-a935064faeda0c995960a407d47b4db8f16ac16b.zip | |
Rollup merge of #130826 - fmease:compiler-mv-obj-safe-dyn-compat, r=compiler-errors
Compiler: Rename "object safe" to "dyn compatible" Completed T-lang FCP: https://github.com/rust-lang/lang-team/issues/286#issuecomment-2338905118. Tracking issue: https://github.com/rust-lang/rust/issues/130852 Excludes `compiler/rustc_codegen_cranelift` (to be filed separately). Includes Stable MIR. Regarding https://github.com/rust-lang/rust/labels/relnotes, I guess I will manually open a https://github.com/rust-lang/rust/labels/relnotes-tracking-issue since this change affects everything (compiler, library, tools, docs, books, everyday language). r? ghost
Diffstat (limited to 'compiler/rustc_hir_analysis/src/coherence')
| -rw-r--r-- | compiler/rustc_hir_analysis/src/coherence/mod.rs | 7 | ||||
| -rw-r--r-- | compiler/rustc_hir_analysis/src/coherence/orphan.rs | 10 |
2 files changed, 9 insertions, 8 deletions
diff --git a/compiler/rustc_hir_analysis/src/coherence/mod.rs b/compiler/rustc_hir_analysis/src/coherence/mod.rs index b25406583f6..69d36426447 100644 --- a/compiler/rustc_hir_analysis/src/coherence/mod.rs +++ b/compiler/rustc_hir_analysis/src/coherence/mod.rs @@ -183,8 +183,8 @@ fn check_object_overlap<'tcx>( // check for overlap with the automatic `impl Trait for dyn Trait` if let ty::Dynamic(data, ..) = trait_ref.self_ty().kind() { - // This is something like impl Trait1 for Trait2. Illegal - // if Trait1 is a supertrait of Trait2 or Trait2 is not object safe. + // This is something like `impl Trait1 for Trait2`. Illegal if + // Trait1 is a supertrait of Trait2 or Trait2 is not dyn-compatible. let component_def_ids = data.iter().flat_map(|predicate| { match predicate.skip_binder() { @@ -197,7 +197,8 @@ fn check_object_overlap<'tcx>( }); for component_def_id in component_def_ids { - if !tcx.is_object_safe(component_def_id) { + if !tcx.is_dyn_compatible(component_def_id) { + // FIXME(dyn_compat_renaming): Rename test and update comment. // Without the 'object_safe_for_dispatch' feature this is an error // which will be reported by wfcheck. Ignore it here. // This is tested by `coherence-impl-trait-for-trait-object-safe.rs`. diff --git a/compiler/rustc_hir_analysis/src/coherence/orphan.rs b/compiler/rustc_hir_analysis/src/coherence/orphan.rs index 5fdaba41fb2..04770469132 100644 --- a/compiler/rustc_hir_analysis/src/coherence/orphan.rs +++ b/compiler/rustc_hir_analysis/src/coherence/orphan.rs @@ -109,16 +109,16 @@ pub(crate) fn orphan_check_impl( // // auto trait AutoTrait {} // - // trait ObjectSafeTrait { + // trait DynCompatibleTrait { // fn f(&self) where Self: AutoTrait; // } // - // We can allow f to be called on `dyn ObjectSafeTrait + AutoTrait`. + // We can allow f to be called on `dyn DynCompatibleTrait + AutoTrait`. // // If we didn't deny `impl AutoTrait for dyn Trait`, it would be unsound - // for the ObjectSafeTrait shown above to be object safe because someone - // could take some type implementing ObjectSafeTrait but not AutoTrait, - // unsize it to `dyn ObjectSafeTrait`, and call .f() which has no + // for the `DynCompatibleTrait` shown above to be dyn-compatible because someone + // could take some type implementing `DynCompatibleTrait` but not `AutoTrait`, + // unsize it to `dyn DynCompatibleTrait`, and call `.f()` which has no // concrete implementation (issue #50781). enum LocalImpl { Allow, |
