Skip to content

Syntactically invalid suggestion for "help: consider further restricting this bound" #93828

Description

@dunglas

Hi there!

Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=a4dec9e7f93eb65805bcd2d986ba009e

extern crate async_trait;
extern crate reqwest;

use async_trait::async_trait;
use reqwest::{Client, IntoUrl};

#[async_trait]
pub trait ClientExt {
    async fn publish<T: IntoUrl>(&self, url: T) -> String;
}

#[async_trait]
impl ClientExt for Client {
    async fn publish<T: IntoUrl>(&self, url: T) -> String {
        "Foo".to_string()
    }
}

The current output is:

help: consider further restricting this bound
   |
14 |     async fn publish<T + std::marker::Send: IntoUrl>(&self, url: T) -> String {
   |                        +++++++++++++++++++

Ideally the output should look like:

help: consider further restricting this bound
   |
14 |     async fn publish<T: IntoUrl + std::marker::Send>(&self, url: T) -> String {
   |                                                    +++++++++++++++++++

The generated code is invalid, the restricting must be placed after the trait name.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions