udpdate error message for unsized union field
This commit is contained in:
parent
4fc3765c54
commit
589d994c38
@ -1112,7 +1112,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||
err.note("structs must have a statically known size to be initialized");
|
||||
}
|
||||
ObligationCauseCode::FieldSized => {
|
||||
err.note("only the last field of a struct may have a dynamically sized type");
|
||||
err.note("only the last field of a struct or an union may have a dynamically \
|
||||
sized type");
|
||||
}
|
||||
ObligationCauseCode::ConstSized => {
|
||||
err.note("constant expressions must have a statically known size");
|
||||
|
17
src/test/ui/union-sized-field.rs
Normal file
17
src/test/ui/union-sized-field.rs
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(untagged_unions)]
|
||||
|
||||
union Foo<T: ?Sized> {
|
||||
value: T,
|
||||
}
|
||||
|
||||
fn main() {}
|
12
src/test/ui/union-sized-field.stderr
Normal file
12
src/test/ui/union-sized-field.stderr
Normal file
@ -0,0 +1,12 @@
|
||||
error[E0277]: the trait bound `T: std::marker::Sized` is not satisfied
|
||||
--> $DIR/union-sized-field.rs:14:5
|
||||
|
|
||||
14 | value: T,
|
||||
| ^^^^^^^^ `T` does not have a constant size known at compile-time
|
||||
|
|
||||
= help: the trait `std::marker::Sized` is not implemented for `T`
|
||||
= help: consider adding a `where T: std::marker::Sized` bound
|
||||
= note: only the last field of a struct or an union may have a dynamically sized type
|
||||
|
||||
error: aborting due to previous error
|
||||
|
Loading…
Reference in New Issue
Block a user