-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 #119540 - fmease:no-effect-args-inside-dyn-trait, r=c…
…ompiler-errors Don't synthesize host effect args inside trait object types While we were indeed emitting an error for `~const` & `const` trait bounds in trait object types, we were still synthesizing host effect args for them. Since we don't record the original trait bound modifiers for dyn-Trait in `hir::TyKind::TraitObject` (unlike we do for let's say impl-Trait, `hir::TyKind::OpaqueTy`), AstConv just assumes `ty::BoundConstness::NotConst` in `conv_object_ty_poly_trait_ref` which given `<host> dyn ~const NonConstTrait` resulted in us not realizing that `~const` was used on a non-const trait which lead to a failed assertion in the end. Instead of updating `hir::TyKind::TraitObject` to track this kind of information, just strip the user-provided constness (similar to #119505). Fixes #119524.
- Loading branch information
Showing
3 changed files
with
47 additions
and
15 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
10 changes: 9 additions & 1 deletion
10
tests/ui/rfcs/rfc-2632-const-trait-impl/const-trait-bounds-trait-objects.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 |
---|---|---|
@@ -1,9 +1,17 @@ | ||
#![feature(const_trait_impl)] | ||
#![feature(const_trait_impl, effects)] | ||
// edition: 2021 | ||
|
||
#[const_trait] | ||
trait Trait {} | ||
|
||
fn main() { | ||
let _: &dyn const Trait; //~ ERROR const trait bounds are not allowed in trait object types | ||
let _: &dyn ~const Trait; //~ ERROR `~const` is not allowed here | ||
} | ||
|
||
// Regression test for issue #119525. | ||
trait NonConst {} | ||
const fn handle(_: &dyn const NonConst) {} | ||
//~^ ERROR const trait bounds are not allowed in trait object types | ||
const fn take(_: &dyn ~const NonConst) {} | ||
//~^ ERROR `~const` is not allowed here |
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