Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
arielb1 committed Dec 16, 2018
1 parent 95bec6e commit 78f7e85
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
12 changes: 4 additions & 8 deletions src/librustc_typeck/check/mod.rs
Expand Up @@ -2743,14 +2743,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
trait_ref, self_ty, expected_vid
);
match self_ty.sty {
ty::Infer(ty::TyVar(v)) => {
let root_vid = self.root_var(v);
debug!("self_type_matches_expected_vid - root_vid={:?}", root_vid);
if root_vid == expected_vid {
true
} else {
false
}
ty::Infer(ty::TyVar(found_vid)) => {
let found_vid = self.root_var(found_vid);
debug!("self_type_matches_expected_vid - found_vid={:?}", found_vid);
expected_vid == found_vid
}
_ => false
}
Expand Down
18 changes: 11 additions & 7 deletions src/test/ui/coercion/coerce-issue-49593-box-never.rs
Expand Up @@ -14,21 +14,21 @@
#![allow(unreachable_code)]

use std::error::Error;
use std::char::ParseCharError; /* some Error */
use std::mem;

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

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

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

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

fn foo_no_never() {
let mut x /* : Box<S> */ = None;
let mut x /* : Option<S> */ = None;
let mut first_iter = false;
loop {
if !first_iter {
let y: Box<Xyz>
let y: Box<dyn Xyz>
= /* Box<$0> is coerced to Box<Xyz> here */ Box::new(x.unwrap());
}

x = Some(S);
first_iter = true;
}

let mut y : Option<S> = None;
// assert types are equal
mem::replace(&mut x, &mut y);
}

fn main() {
Expand Down

0 comments on commit 78f7e85

Please sign in to comment.