Rollup merge of #38150 - estebank:fix-23286, r=nikomatsakis
Point out the known type when field doesn't satisfy bound
For file
```rust
use std::path::Path;
fn f(p: Path) { }
```
provide the following error
```nocode
error[E0277]: the trait bound `[u8]: std::marker::Sized` is not satisfied in `std::path::Path`
--> file.rs:3:6
|
3 | fn f(p: Path) { }
| ^ within `std::path::Path`, the trait `std::marker::Sized` is not implemented for `[u8]`
|
= note: `[u8]` does not have a constant size known at compile-time
= note: required because it appears within the type `std::path::Path`
= note: all local variables must have a statically known size
```
Fix #23286.
This commit is contained in:
commit
2fb2d307e0
3 changed files with 81 additions and 8 deletions
34
src/test/compile-fail/E0277-2.rs
Normal file
34
src/test/compile-fail/E0277-2.rs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
// Copyright 2016 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.
|
||||
|
||||
struct Foo {
|
||||
bar: Bar
|
||||
}
|
||||
|
||||
struct Bar {
|
||||
baz: Baz
|
||||
}
|
||||
|
||||
struct Baz {
|
||||
x: *const u8
|
||||
}
|
||||
|
||||
fn is_send<T: Send>() { }
|
||||
|
||||
fn main() {
|
||||
is_send::<Foo>();
|
||||
//~^ ERROR the trait bound `*const u8: std::marker::Send` is not satisfied in `Foo`
|
||||
//~| NOTE within `Foo`, the trait `std::marker::Send` is not implemented for `*const u8`
|
||||
//~| NOTE: `*const u8` cannot be sent between threads safely
|
||||
//~| NOTE: required because it appears within the type `Baz`
|
||||
//~| NOTE: required because it appears within the type `Bar`
|
||||
//~| NOTE: required because it appears within the type `Foo`
|
||||
//~| NOTE: required by `is_send`
|
||||
}
|
||||
|
|
@ -8,6 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
trait Foo {
|
||||
fn bar(&self);
|
||||
}
|
||||
|
|
@ -16,6 +18,13 @@ fn some_func<T: Foo>(foo: T) {
|
|||
foo.bar();
|
||||
}
|
||||
|
||||
fn f(p: Path) { }
|
||||
//~^ ERROR the trait bound `[u8]: std::marker::Sized` is not satisfied in `std::path::Path`
|
||||
//~| NOTE within `std::path::Path`, the trait `std::marker::Sized` is not implemented for `[u8]`
|
||||
//~| NOTE `[u8]` does not have a constant size known at compile-time
|
||||
//~| NOTE required because it appears within the type `std::path::Path`
|
||||
//~| NOTE all local variables must have a statically known size
|
||||
|
||||
fn main() {
|
||||
some_func(5i32);
|
||||
//~^ ERROR the trait bound `i32: Foo` is not satisfied
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue