Skip to content

Commit 3305cb0

Browse files
Revert "Fix trait object reborrow suggestion"
This reverts commit 6c0a591.
1 parent 3ea2c8c commit 3305cb0

File tree

7 files changed

+30
-50
lines changed

7 files changed

+30
-50
lines changed

Cargo.lock

+21-7
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,6 @@ dependencies = [
333333
"libgit2-sys",
334334
"log",
335335
"memchr",
336-
"num_cpus",
337336
"opener",
338337
"openssl",
339338
"os_info",
@@ -445,7 +444,7 @@ dependencies = [
445444

446445
[[package]]
447446
name = "cargo-util"
448-
version = "0.1.4"
447+
version = "0.1.3"
449448
dependencies = [
450449
"anyhow",
451450
"core-foundation",
@@ -2330,6 +2329,20 @@ dependencies = [
23302329
"topological-sort",
23312330
]
23322331

2332+
[[package]]
2333+
name = "measureme"
2334+
version = "9.1.2"
2335+
source = "registry+https://github.com/rust-lang/crates.io-index"
2336+
checksum = "78f7a41bc6f856a2cf0e95094ad5121f82500e2d9a0f3c0171d98f6566d8117d"
2337+
dependencies = [
2338+
"log",
2339+
"memmap2",
2340+
"parking_lot 0.11.2",
2341+
"perf-event-open-sys",
2342+
"rustc-hash",
2343+
"smallvec",
2344+
]
2345+
23332346
[[package]]
23342347
name = "measureme"
23352348
version = "10.0.0"
@@ -2428,7 +2441,7 @@ dependencies = [
24282441
"lazy_static",
24292442
"libc",
24302443
"log",
2431-
"measureme",
2444+
"measureme 9.1.2",
24322445
"rand 0.8.5",
24332446
"regex",
24342447
"rustc-workspace-hack",
@@ -3040,6 +3053,7 @@ name = "racer"
30403053
version = "2.2.2"
30413054
dependencies = [
30423055
"bitflags",
3056+
"clap 2.34.0",
30433057
"derive_more",
30443058
"env_logger 0.7.1",
30453059
"humantime 2.0.1",
@@ -3263,7 +3277,7 @@ dependencies = [
32633277
"difference",
32643278
"env_logger 0.9.0",
32653279
"futures 0.3.19",
3266-
"heck 0.4.0",
3280+
"heck 0.3.1",
32673281
"home",
32683282
"itertools",
32693283
"jsonrpc-core",
@@ -3639,7 +3653,7 @@ dependencies = [
36393653
"cstr",
36403654
"libc",
36413655
"libloading",
3642-
"measureme",
3656+
"measureme 10.0.0",
36433657
"rustc-demangle",
36443658
"rustc_ast",
36453659
"rustc_attr",
@@ -3737,7 +3751,7 @@ dependencies = [
37373751
"indexmap",
37383752
"jobserver",
37393753
"libc",
3740-
"measureme",
3754+
"measureme 10.0.0",
37413755
"memmap2",
37423756
"parking_lot 0.11.2",
37433757
"rustc-hash",
@@ -4294,7 +4308,7 @@ dependencies = [
42944308
name = "rustc_query_impl"
42954309
version = "0.0.0"
42964310
dependencies = [
4297-
"measureme",
4311+
"measureme 10.0.0",
42984312
"rustc-rayon-core",
42994313
"rustc_ast",
43004314
"rustc_data_structures",

compiler/rustc_middle/src/traits/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ pub enum ObligationCauseCode<'tcx> {
253253
ObjectTypeBound(Ty<'tcx>, ty::Region<'tcx>),
254254

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

258258
/// Obligation incurred due to a coercion.
259259
Coercion {

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -484,9 +484,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
484484
err.span_label(span, explanation);
485485
}
486486

487-
if let ObligationCauseCode::ObjectCastObligation(concrete_ty, obj_ty) = obligation.cause.code().peel_derives() &&
487+
if let ObligationCauseCode::ObjectCastObligation(obj_ty) = obligation.cause.code().peel_derives() &&
488+
let Some(self_ty) = trait_predicate.self_ty().no_bound_vars() &&
488489
Some(trait_ref.def_id()) == self.tcx.lang_items().sized_trait() {
489-
self.suggest_borrowing_for_object_cast(&mut err, &root_obligation, *concrete_ty, *obj_ty);
490+
self.suggest_borrowing_for_object_cast(&mut err, &obligation, self_ty, *obj_ty);
490491
}
491492

492493
if trait_predicate.is_const_if_const() && obligation.param_env.is_const() {
@@ -1559,7 +1560,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
15591560
obligation.cause.code().peel_derives(),
15601561
ObligationCauseCode::ItemObligation(_)
15611562
| ObligationCauseCode::BindingObligation(_, _)
1562-
| ObligationCauseCode::ObjectCastObligation(..)
1563+
| ObligationCauseCode::ObjectCastObligation(_)
15631564
| ObligationCauseCode::OpaqueType
15641565
);
15651566
if let Err(error) = self.at(&obligation.cause, obligation.param_env).eq_exp(

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2216,7 +2216,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
22162216
err.span_note(tcx.def_span(item_def_id), &descr);
22172217
}
22182218
}
2219-
ObligationCauseCode::ObjectCastObligation(_, object_ty) => {
2219+
ObligationCauseCode::ObjectCastObligation(object_ty) => {
22202220
err.note(&format!(
22212221
"required for the cast to the object type `{}`",
22222222
self.ty_to_string(object_ty)

compiler/rustc_trait_selection/src/traits/select/confirmation.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
813813
let cause = ObligationCause::new(
814814
obligation.cause.span,
815815
obligation.cause.body_id,
816-
ObjectCastObligation(source, target),
816+
ObjectCastObligation(target),
817817
);
818818
let outlives = ty::OutlivesPredicate(r_a, r_b);
819819
nested.push(Obligation::with_depth(
@@ -910,7 +910,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
910910
let cause = ObligationCause::new(
911911
obligation.cause.span,
912912
obligation.cause.body_id,
913-
ObjectCastObligation(source, target),
913+
ObjectCastObligation(target),
914914
);
915915
let outlives = ty::OutlivesPredicate(r_a, r_b);
916916
nested.push(Obligation::with_depth(
@@ -931,7 +931,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
931931
let cause = ObligationCause::new(
932932
obligation.cause.span,
933933
obligation.cause.body_id,
934-
ObjectCastObligation(source, target),
934+
ObjectCastObligation(target),
935935
);
936936

937937
let predicate_to_obligation = |predicate| {

src/test/ui/suggestions/suggest-borrow-to-dyn-object.rs

-16
This file was deleted.

src/test/ui/suggestions/suggest-borrow-to-dyn-object.stderr

-19
This file was deleted.

0 commit comments

Comments
 (0)