Skip to content

Commit 78f7e85

Browse files
committed
address review comments
1 parent 95bec6e commit 78f7e85

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/librustc_typeck/check/mod.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2743,14 +2743,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
27432743
trait_ref, self_ty, expected_vid
27442744
);
27452745
match self_ty.sty {
2746-
ty::Infer(ty::TyVar(v)) => {
2747-
let root_vid = self.root_var(v);
2748-
debug!("self_type_matches_expected_vid - root_vid={:?}", root_vid);
2749-
if root_vid == expected_vid {
2750-
true
2751-
} else {
2752-
false
2753-
}
2746+
ty::Infer(ty::TyVar(found_vid)) => {
2747+
let found_vid = self.root_var(found_vid);
2748+
debug!("self_type_matches_expected_vid - found_vid={:?}", found_vid);
2749+
expected_vid == found_vid
27542750
}
27552751
_ => false
27562752
}

src/test/ui/coercion/coerce-issue-49593-box-never.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@
1414
#![allow(unreachable_code)]
1515

1616
use std::error::Error;
17-
use std::char::ParseCharError; /* some Error */
17+
use std::mem;
1818

1919
fn raw_ptr_box<T>(t: T) -> *mut T {
2020
panic!()
2121
}
2222

23-
fn foo(x: !) -> Box<Error> {
24-
/* *mut $0 is coerced to *mut Error here */ Box::<_ /* ! */>::new(x)
23+
fn foo(x: !) -> Box<dyn Error> {
24+
/* *mut $0 is coerced to Box<dyn Error> here */ Box::<_ /* ! */>::new(x)
2525
}
2626

27-
fn foo_raw_ptr(x: !) -> *mut Error {
27+
fn foo_raw_ptr(x: !) -> *mut dyn Error {
2828
/* *mut $0 is coerced to *mut Error here */ raw_ptr_box::<_ /* ! */>(x)
2929
}
3030

31-
fn no_coercion(d: *mut Error) -> *mut Error {
31+
fn no_coercion(d: *mut dyn Error) -> *mut dyn Error {
3232
/* an unsize coercion won't compile here, and it is indeed not used
3333
because there is nothing requiring the _ to be Sized */
3434
d as *mut _
@@ -41,17 +41,21 @@ impl Xyz for S {}
4141
impl Xyz for T {}
4242

4343
fn foo_no_never() {
44-
let mut x /* : Box<S> */ = None;
44+
let mut x /* : Option<S> */ = None;
4545
let mut first_iter = false;
4646
loop {
4747
if !first_iter {
48-
let y: Box<Xyz>
48+
let y: Box<dyn Xyz>
4949
= /* Box<$0> is coerced to Box<Xyz> here */ Box::new(x.unwrap());
5050
}
5151

5252
x = Some(S);
5353
first_iter = true;
5454
}
55+
56+
let mut y : Option<S> = None;
57+
// assert types are equal
58+
mem::replace(&mut x, &mut y);
5559
}
5660

5761
fn main() {

0 commit comments

Comments
 (0)