@@ -948,10 +948,14 @@ impl<'a, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
948
948
// Only impose the restrictions of `ConstRibKind` for an
949
949
// actual constant expression in a provided default.
950
950
if let Some ( expr) = default {
951
- this. with_constant_rib (
952
- expr. is_potential_trivial_const_param ( ) ,
953
- |this| this. visit_expr ( expr) ,
954
- ) ;
951
+ // We allow arbitrary const expressions inside of associated consts,
952
+ // even if they are potentially not const evaluatable.
953
+ //
954
+ // Type parameters can already be used and as associated consts are
955
+ // not used as part of the type system, this is far less surprising.
956
+ this. with_constant_rib ( true , |this| {
957
+ this. visit_expr ( expr)
958
+ } ) ;
955
959
}
956
960
}
957
961
AssocItemKind :: Fn ( _, _, generics, _) => {
@@ -1225,7 +1229,7 @@ impl<'a, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
1225
1229
for item in impl_items {
1226
1230
use crate :: ResolutionError :: * ;
1227
1231
match & item. kind {
1228
- AssocItemKind :: Const ( _default, _ty, expr ) => {
1232
+ AssocItemKind :: Const ( _default, _ty, _expr ) => {
1229
1233
debug ! ( "resolve_implementation AssocItemKind::Const" , ) ;
1230
1234
// If this is a trait impl, ensure the const
1231
1235
// exists in trait
@@ -1236,18 +1240,14 @@ impl<'a, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
1236
1240
|n, s| ConstNotMemberOfTrait ( n, s) ,
1237
1241
) ;
1238
1242
1239
- this. with_constant_rib (
1240
- expr. as_ref ( ) . map_or ( false , |e| {
1241
- e. is_potential_trivial_const_param ( )
1242
- } ) ,
1243
- |this| {
1244
- visit:: walk_assoc_item (
1245
- this,
1246
- item,
1247
- AssocCtxt :: Impl ,
1248
- )
1249
- } ,
1250
- ) ;
1243
+ // We allow arbitrary const expressions inside of associated consts,
1244
+ // even if they are potentially not const evaluatable.
1245
+ //
1246
+ // Type parameters can already be used and as associated consts are
1247
+ // not used as part of the type system, this is far less surprising.
1248
+ this. with_constant_rib ( true , |this| {
1249
+ visit:: walk_assoc_item ( this, item, AssocCtxt :: Impl )
1250
+ } ) ;
1251
1251
}
1252
1252
AssocItemKind :: Fn ( _, _, generics, _) => {
1253
1253
// We also need a new scope for the impl item type parameters.
0 commit comments