Skip to content

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

New issue

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

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

Already on GitHub? # to your account

Closed
dunglas opened this issue Feb 9, 2022 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@dunglas
Copy link

dunglas commented Feb 9, 2022

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.

@dunglas dunglas added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 9, 2022
notriddle added a commit to notriddle/async-trait that referenced this issue Mar 7, 2022
Fixes rust-lang/rust#93828 (which is really a bug in `async_trait`,
not rustc).

Before:

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

After:

	help: consider further restricting this bound
	   |
	13 |     async fn publish<T: IntoUrl + std::marker::Send>(&self, url: T) -> String {
	   |                                 +++++++++++++++++++
notriddle added a commit to notriddle/async-trait that referenced this issue Mar 7, 2022
Fixes rust-lang/rust#93828 (which is really a bug in `async_trait`,
not rustc).

Before:

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

After:

	help: consider further restricting this bound
	   |
	13 |     async fn publish<T: IntoUrl + std::marker::Send>(&self, url: T) -> String {
	   |                                 +++++++++++++++++++
@compiler-errors
Copy link
Member

This was fixed in #93803

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants