Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlight the const fn if error happened because of a bound on the impl block #88907

Commits on Sep 13, 2021

  1. Highlight the const function if error happened because of a bound on …

    …the impl block
    
    Currently, for the following code, the compiler produces the errors like the
    following error:
    ```rust
    struct Type<T>
    
    impl<T: Clone> Type<T> {
    	fn const f() {}
    }
    ```
    ```text
    error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable
     --> ./test.rs:3:6
      |
    3 | impl<T: Clone> Type<T> {
      |      ^
      |
      = note: see issue rust-lang#57563 <rust-lang#57563> for more information
      = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable
    ```
    
    This can be confusing (especially to newcomers) since the error mentions
    "const fn parameters", but highlights only the impl.
    
    This commits adds function highlighting, changing the error to the following:
    
    ```text
    error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable
     --> ./test.rs:3:6
      |
    3 | impl<T: Clone> Type<T> {
      |      ^
    4 |     pub const fn f() {}
      |     ---------------- function declared as const here
      |
      = note: see issue rust-lang#57563 <rust-lang#57563> for more information
      = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable
    ```
    WaffleLapkin committed Sep 13, 2021
    Configuration menu
    Copy the full SHA
    6ec7255 View commit details
    Browse the repository at this point in the history