Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
} = self.lower_poly_trait_ref(
&trait_bound.trait_ref,
trait_bound.span,
hir::BoundConstness::Never,
trait_bound.modifiers.constness,
hir::BoundPolarity::Positive,
dummy_self,
&mut user_written_bounds,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ fn main() {
trait NonConst {}
const fn handle(_: &dyn const NonConst) {}
//~^ ERROR const trait bounds are not allowed in trait object types
//~| ERROR `const` can only be applied to `#[const_trait]` traits
const fn take(_: &dyn [const] NonConst) {}
//~^ ERROR `[const]` is not allowed here
//~| ERROR `[const]` can only be applied to `#[const_trait]` traits
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,34 @@ LL | const fn handle(_: &dyn const NonConst) {}
| ^^^^^^^^^^^^^^

error: `[const]` is not allowed here
--> $DIR/const-trait-bounds-trait-objects.rs:17:23
--> $DIR/const-trait-bounds-trait-objects.rs:18:23
|
LL | const fn take(_: &dyn [const] NonConst) {}
| ^^^^^^^
|
= note: trait objects cannot have `[const]` trait bounds

error: aborting due to 4 previous errors
error: `const` can only be applied to `#[const_trait]` traits
--> $DIR/const-trait-bounds-trait-objects.rs:15:25
|
LL | const fn handle(_: &dyn const NonConst) {}
| ^^^^^ can't be applied to `NonConst`
|
help: mark `NonConst` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait NonConst {}
| ++++++++++++++

error: `[const]` can only be applied to `#[const_trait]` traits
--> $DIR/const-trait-bounds-trait-objects.rs:18:23
|
LL | const fn take(_: &dyn [const] NonConst) {}
| ^^^^^^^ can't be applied to `NonConst`
|
help: mark `NonConst` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait NonConst {}
| ++++++++++++++

error: aborting due to 6 previous errors

Loading