Skip to content

Commit

Permalink
Revert "Fix trait object reborrow suggestion"
Browse files Browse the repository at this point in the history
This reverts commit 6c0a591.
  • Loading branch information
compiler-errors committed Jul 5, 2022
1 parent 3ea2c8c commit 3305cb0
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 50 deletions.
28 changes: 21 additions & 7 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ dependencies = [
"libgit2-sys",
"log",
"memchr",
"num_cpus",
"opener",
"openssl",
"os_info",
Expand Down Expand Up @@ -445,7 +444,7 @@ dependencies = [

[[package]]
name = "cargo-util"
version = "0.1.4"
version = "0.1.3"
dependencies = [
"anyhow",
"core-foundation",
Expand Down Expand Up @@ -2330,6 +2329,20 @@ dependencies = [
"topological-sort",
]

[[package]]
name = "measureme"
version = "9.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78f7a41bc6f856a2cf0e95094ad5121f82500e2d9a0f3c0171d98f6566d8117d"
dependencies = [
"log",
"memmap2",
"parking_lot 0.11.2",
"perf-event-open-sys",
"rustc-hash",
"smallvec",
]

[[package]]
name = "measureme"
version = "10.0.0"
Expand Down Expand Up @@ -2428,7 +2441,7 @@ dependencies = [
"lazy_static",
"libc",
"log",
"measureme",
"measureme 9.1.2",
"rand 0.8.5",
"regex",
"rustc-workspace-hack",
Expand Down Expand Up @@ -3040,6 +3053,7 @@ name = "racer"
version = "2.2.2"
dependencies = [
"bitflags",
"clap 2.34.0",
"derive_more",
"env_logger 0.7.1",
"humantime 2.0.1",
Expand Down Expand Up @@ -3263,7 +3277,7 @@ dependencies = [
"difference",
"env_logger 0.9.0",
"futures 0.3.19",
"heck 0.4.0",
"heck 0.3.1",
"home",
"itertools",
"jsonrpc-core",
Expand Down Expand Up @@ -3639,7 +3653,7 @@ dependencies = [
"cstr",
"libc",
"libloading",
"measureme",
"measureme 10.0.0",
"rustc-demangle",
"rustc_ast",
"rustc_attr",
Expand Down Expand Up @@ -3737,7 +3751,7 @@ dependencies = [
"indexmap",
"jobserver",
"libc",
"measureme",
"measureme 10.0.0",
"memmap2",
"parking_lot 0.11.2",
"rustc-hash",
Expand Down Expand Up @@ -4294,7 +4308,7 @@ dependencies = [
name = "rustc_query_impl"
version = "0.0.0"
dependencies = [
"measureme",
"measureme 10.0.0",
"rustc-rayon-core",
"rustc_ast",
"rustc_data_structures",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ pub enum ObligationCauseCode<'tcx> {
ObjectTypeBound(Ty<'tcx>, ty::Region<'tcx>),

/// Obligation incurred due to an object cast.
ObjectCastObligation(/* Concrete type */ Ty<'tcx>, /* Object type */ Ty<'tcx>),
ObjectCastObligation(/* Object type */ Ty<'tcx>),

/// Obligation incurred due to a coercion.
Coercion {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,9 +484,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
err.span_label(span, explanation);
}

if let ObligationCauseCode::ObjectCastObligation(concrete_ty, obj_ty) = obligation.cause.code().peel_derives() &&
if let ObligationCauseCode::ObjectCastObligation(obj_ty) = obligation.cause.code().peel_derives() &&
let Some(self_ty) = trait_predicate.self_ty().no_bound_vars() &&
Some(trait_ref.def_id()) == self.tcx.lang_items().sized_trait() {
self.suggest_borrowing_for_object_cast(&mut err, &root_obligation, *concrete_ty, *obj_ty);
self.suggest_borrowing_for_object_cast(&mut err, &obligation, self_ty, *obj_ty);
}

if trait_predicate.is_const_if_const() && obligation.param_env.is_const() {
Expand Down Expand Up @@ -1559,7 +1560,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
obligation.cause.code().peel_derives(),
ObligationCauseCode::ItemObligation(_)
| ObligationCauseCode::BindingObligation(_, _)
| ObligationCauseCode::ObjectCastObligation(..)
| ObligationCauseCode::ObjectCastObligation(_)
| ObligationCauseCode::OpaqueType
);
if let Err(error) = self.at(&obligation.cause, obligation.param_env).eq_exp(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2216,7 +2216,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
err.span_note(tcx.def_span(item_def_id), &descr);
}
}
ObligationCauseCode::ObjectCastObligation(_, object_ty) => {
ObligationCauseCode::ObjectCastObligation(object_ty) => {
err.note(&format!(
"required for the cast to the object type `{}`",
self.ty_to_string(object_ty)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let cause = ObligationCause::new(
obligation.cause.span,
obligation.cause.body_id,
ObjectCastObligation(source, target),
ObjectCastObligation(target),
);
let outlives = ty::OutlivesPredicate(r_a, r_b);
nested.push(Obligation::with_depth(
Expand Down Expand Up @@ -910,7 +910,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let cause = ObligationCause::new(
obligation.cause.span,
obligation.cause.body_id,
ObjectCastObligation(source, target),
ObjectCastObligation(target),
);
let outlives = ty::OutlivesPredicate(r_a, r_b);
nested.push(Obligation::with_depth(
Expand All @@ -931,7 +931,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let cause = ObligationCause::new(
obligation.cause.span,
obligation.cause.body_id,
ObjectCastObligation(source, target),
ObjectCastObligation(target),
);

let predicate_to_obligation = |predicate| {
Expand Down
16 changes: 0 additions & 16 deletions src/test/ui/suggestions/suggest-borrow-to-dyn-object.rs

This file was deleted.

19 changes: 0 additions & 19 deletions src/test/ui/suggestions/suggest-borrow-to-dyn-object.stderr

This file was deleted.

0 comments on commit 3305cb0

Please sign in to comment.