Skip to content

Commit 105cd49

Browse files
authored
Rollup merge of rust-lang#72714 - JohnTitor:debug-assert, r=nikomatsakis
Fix debug assertion in typeck Fixes rust-lang#72410
2 parents f9a3086 + a11024f commit 105cd49

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

src/librustc_typeck/collect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1927,7 +1927,7 @@ fn explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicat
19271927
let re_root_empty = tcx.lifetimes.re_root_empty;
19281928
let predicate = ty::OutlivesPredicate(ty, re_root_empty);
19291929
predicates.push((
1930-
ty::PredicateKind::TypeOutlives(ty::Binder::dummy(predicate))
1930+
ty::PredicateKind::TypeOutlives(ty::Binder::bind(predicate))
19311931
.to_predicate(tcx),
19321932
span,
19331933
));

src/test/ui/traits/issue-72410.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Regression test for #72410, this should be used with debug assertion enabled.
2+
3+
// should be fine
4+
pub trait Foo {
5+
fn map()
6+
where
7+
Self: Sized,
8+
for<'a> &'a mut [u8]: ;
9+
}
10+
11+
// should fail
12+
pub trait Bar {
13+
fn map()
14+
where for<'a> &'a mut [dyn Bar]: ;
15+
//~^ ERROR: the trait `Bar` cannot be made into an object
16+
}
17+
18+
fn main() {}

src/test/ui/traits/issue-72410.stderr

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error[E0038]: the trait `Bar` cannot be made into an object
2+
--> $DIR/issue-72410.rs:14:19
3+
|
4+
LL | pub trait Bar {
5+
| --- this trait cannot be made into an object...
6+
LL | fn map()
7+
| --- ...because associated function `map` has no `self` parameter
8+
LL | where for<'a> &'a mut [dyn Bar]: ;
9+
| ^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object
10+
|
11+
help: consider turning `map` into a method by giving it a `&self` argument or constraining it so it does not apply to trait objects
12+
|
13+
LL | where for<'a> &'a mut [dyn Bar]:, Self: Sized ;
14+
| ^^^^^^^^^^^^^
15+
16+
error: aborting due to previous error
17+
18+
For more information about this error, try `rustc --explain E0038`.

0 commit comments

Comments
 (0)