about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2023-09-19 11:35:50 +0200
committerGitHub <noreply@github.com>2023-09-19 11:35:50 +0200
commit66b7bdf2797877ee328d98adb1f0f30fb2b950cc (patch)
tree2d87dc719d4a8548d61babd518be91cd12bf6419 /compiler/rustc_codegen_llvm/src
parent3f68468bc6eb231305c1c0abf28384b6363bc173 (diff)
parenta30ad3a5a6362c31b16d3bd3f21bbae1315bfaec (diff)
downloadrust-66b7bdf2797877ee328d98adb1f0f30fb2b950cc.tar.gz
rust-66b7bdf2797877ee328d98adb1f0f30fb2b950cc.zip
Rollup merge of #114941 - compiler-errors:inline-shadowed-by-dyn, r=lcnr
Don't resolve generic impls that may be shadowed by dyn built-in impls

**NOTE:** This is a hack. This is not trying to be a general fix for the issue that we've allowed overlapping built-in trait object impls and user-written impls for quite a long time, and traits like `Any` rely on this (#57893) -- this PR specifically aims to mitigate a new unsoundness that is uncovered by the MIR inliner (#114928) that interacts with this pre-existing issue.

Builtin `dyn Trait` impls may overlap with user-provided blanket impls (`impl<T: ?Sized> Trait for T`) in generic contexts. This leads to bugs when instances are resolved in polymorphic contexts, since we typically prefer object candidates over impl candidates.

This PR implements a (hacky) heuristic to `resolve_associated_item` to account for that unfortunate hole in the type system -- we now bail with ambiguity if we try to resolve a non-rigid instance whose self type is not known to be sized. This makes sure we can still inline instances like `impl<T: Sized> Trait for T`, which can never overlap with `dyn Trait`'s built-in impl, but we avoid inlining an impl that may be shadowed by a `dyn Trait`.

Fixes #114928
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions