Skip to content

rustc_args_required_const should mark its const arguments as const #61180

Closed
@lu-zero

Description

@lu-zero

calling a rustc_args_required_const-marked function from a rustc_args_required_const-marked function does not work as intended.

here the playground

#![feature(rustc_attrs)]

trait T {
    #[rustc_args_required_const(1)]
    fn t(self, b: i32);
}

#[inline]
#[rustc_args_required_const(1)]
const fn ex_t(a: u8, b: i32) {
    let _ = a as i32 + b;
}

#[inline]
#[rustc_args_required_const(1)]
fn ex_t2(a: u8, b: i32) {
    ex_t(a, b);
}

impl T for u8 {
    #[rustc_args_required_const(1)]
    fn t(self, b: i32) {
        // println!("{}", b);
        ex_t(self, b);
    }
}

fn main() {
    let a = 42u8;
    
    a.t(42);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions