Skip to content

Commit f21369a

Browse files
committed
---
yaml --- r: 275871 b: refs/heads/auto c: 89bbd2c h: refs/heads/master i: 275869: fbc85b9 275867: 8a65dfd 275863: 0c5b2b5 275855: e9da46c 275839: 3dd4acb
1 parent 3331c07 commit f21369a

File tree

4 files changed

+30
-10
lines changed

4 files changed

+30
-10
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
88
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
99
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1010
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
11-
refs/heads/auto: 2c9dfafa572272a758357d6bd5d51c0b22a9fdd3
11+
refs/heads/auto: 89bbd2c8b75f31f06496158e8e309557cfeaeed5
1212
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1313
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
1414
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1

branches/auto/src/librustc_typeck/check/cast.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,18 @@ impl<'tcx> CastCheck<'tcx> {
128128
span: span,
129129
};
130130

131-
// For better error messages, we try to check whether the
132-
// target type is known to be sized now (we will also check
133-
// later, once inference is more complete done).
134-
if !fcx.type_is_known_to_be_sized(cast_ty, span) {
135-
check.report_cast_to_unsized_type(fcx);
136-
return Err(ErrorReported);
131+
// For better error messages, check for some obviously unsized
132+
// cases now. We do a more thorough check at the end, once
133+
// inference is more completely known.
134+
match cast_ty.sty {
135+
ty::TyTrait(..) | ty::TySlice(..) => {
136+
check.report_cast_to_unsized_type(fcx);
137+
Err(ErrorReported)
138+
}
139+
_ => {
140+
Ok(check)
141+
}
137142
}
138-
139-
Ok(check)
140143
}
141144

142145
fn report_cast_error<'a>(&self,

branches/auto/src/librustc_typeck/check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3518,7 +3518,7 @@ fn check_expr_with_expectation_and_lvalue_pref<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
35183518
// Find the type of `e`. Supply hints based on the type we are casting to,
35193519
// if appropriate.
35203520
let t_cast = fcx.to_ty(t);
3521-
let t_cast = structurally_resolved_type(fcx, expr.span, t_cast);
3521+
let t_cast = fcx.infcx().resolve_type_vars_if_possible(&t_cast);
35223522
check_expr_with_expectation(fcx, e, ExpectCastableToType(t_cast));
35233523
let t_expr = fcx.expr_ty(e);
35243524
let t_cast = fcx.infcx().resolve_type_vars_if_possible(&t_cast);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Check that we allow a cast to `_` so long as the target type can be
12+
// inferred elsewhere.
13+
14+
pub fn main() {
15+
let i: *const i32 = 0 as _;
16+
assert!(i.is_null());
17+
}

0 commit comments

Comments
 (0)