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
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2384,7 +2384,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
Some(ConstItemRhs::TypeConst(anon)) => {
hir::ConstItemRhs::TypeConst(self.lower_anon_const_to_const_arg_and_alloc(anon))
}
None if attr::contains_name(attrs, sym::type_const) => {
None if find_attr!(attrs, AttributeKind::TypeConst(_)) => {
let const_arg = ConstArg {
hir_id: self.next_id(),
kind: hir::ConstArgKind::Error(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//@ needs-rustc-debug-assertions

#![feature(min_generic_const_args)]
#![expect(incomplete_features)]

trait Tr {
#[type_const]
const SIZE: usize;
}

struct T;

impl Tr for T {
#[type_const]
const SIZE: usize;
//~^ ERROR associated constant in `impl` without body
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error: associated constant in `impl` without body
--> $DIR/type-const-assoc-const-without-body.rs:15:5
|
LL | const SIZE: usize;
| ^^^^^^^^^^^^^^^^^-
| |
| help: provide a definition for the constant: `= <expr>;`

error: aborting due to 1 previous error

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//@ needs-rustc-debug-assertions

#![feature(min_generic_const_args)]
#![expect(incomplete_features)]

impl S { //~ ERROR cannot find type `S` in this scope
#[type_const]
const SIZE: usize;
//~^ ERROR associated constant in `impl` without body
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
error: associated constant in `impl` without body
--> $DIR/type-const-inherent-assoc-const-without-body.rs:8:5
|
LL | const SIZE: usize;
| ^^^^^^^^^^^^^^^^^-
| |
| help: provide a definition for the constant: `= <expr>;`

error[E0425]: cannot find type `S` in this scope
--> $DIR/type-const-inherent-assoc-const-without-body.rs:6:6
|
LL | impl S {
| ^ not found in this scope

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0425`.
Loading