-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #134951 - compiler-errors:double-trait-err-msg, r=dav…
…idtwco Suppress host effect predicates if underlying trait doesn't hold Don't report two errors for when the (`HostEffectPredicate`) `T: const Trait` isn't implemented because (`TraitPredicate`) `T: Trait` doesn't even hold.
- Loading branch information
Showing
3 changed files
with
101 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
tests/ui/traits/const-traits/double-error-for-unimplemented-trait.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Make sure we don't issue *two* error messages for the trait predicate *and* host predicate. | ||
|
||
#![feature(const_trait_impl)] | ||
|
||
#[const_trait] | ||
trait Trait { | ||
type Out; | ||
} | ||
|
||
const fn needs_const<T: ~const Trait>(_: &T) {} | ||
|
||
const IN_CONST: () = { | ||
needs_const(&()); | ||
//~^ ERROR the trait bound `(): Trait` is not satisfied | ||
}; | ||
|
||
const fn conditionally_const() { | ||
needs_const(&()); | ||
//~^ ERROR the trait bound `(): Trait` is not satisfied | ||
} | ||
|
||
fn main() {} |
41 changes: 41 additions & 0 deletions
41
tests/ui/traits/const-traits/double-error-for-unimplemented-trait.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
error[E0277]: the trait bound `(): Trait` is not satisfied | ||
--> $DIR/double-error-for-unimplemented-trait.rs:13:15 | ||
| | ||
LL | needs_const(&()); | ||
| ----------- ^^^ the trait `Trait` is not implemented for `()` | ||
| | | ||
| required by a bound introduced by this call | ||
| | ||
help: this trait has no implementations, consider adding one | ||
--> $DIR/double-error-for-unimplemented-trait.rs:6:1 | ||
| | ||
LL | trait Trait { | ||
| ^^^^^^^^^^^ | ||
note: required by a bound in `needs_const` | ||
--> $DIR/double-error-for-unimplemented-trait.rs:10:25 | ||
| | ||
LL | const fn needs_const<T: ~const Trait>(_: &T) {} | ||
| ^^^^^^^^^^^^ required by this bound in `needs_const` | ||
|
||
error[E0277]: the trait bound `(): Trait` is not satisfied | ||
--> $DIR/double-error-for-unimplemented-trait.rs:18:15 | ||
| | ||
LL | needs_const(&()); | ||
| ----------- ^^^ the trait `Trait` is not implemented for `()` | ||
| | | ||
| required by a bound introduced by this call | ||
| | ||
help: this trait has no implementations, consider adding one | ||
--> $DIR/double-error-for-unimplemented-trait.rs:6:1 | ||
| | ||
LL | trait Trait { | ||
| ^^^^^^^^^^^ | ||
note: required by a bound in `needs_const` | ||
--> $DIR/double-error-for-unimplemented-trait.rs:10:25 | ||
| | ||
LL | const fn needs_const<T: ~const Trait>(_: &T) {} | ||
| ^^^^^^^^^^^^ required by this bound in `needs_const` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0277`. |