-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Actually use the #[do_not_recommend]
attribute if present
#124708
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
tests/ui/diagnostic_namespace/do_not_recommend/as_expression.current.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error[E0277]: the trait bound `&str: AsExpression<Integer>` is not satisfied | ||
--> $DIR/as_expression.rs:57:15 | ||
| | ||
LL | SelectInt.check("bar"); | ||
| ^^^^^ the trait `AsExpression<Integer>` is not implemented for `&str` | ||
| | ||
= help: the trait `AsExpression<Text>` is implemented for `&str` | ||
= help: for that trait implementation, expected `Text`, found `Integer` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
21 changes: 21 additions & 0 deletions
21
tests/ui/diagnostic_namespace/do_not_recommend/as_expression.next.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
error[E0277]: the trait bound `&str: AsExpression<<SelectInt as Expression>::SqlType>` is not satisfied | ||
--> $DIR/as_expression.rs:57:21 | ||
| | ||
LL | SelectInt.check("bar"); | ||
| ----- ^^^^^ the trait `AsExpression<<SelectInt as Expression>::SqlType>` is not implemented for `&str` | ||
| | | ||
| required by a bound introduced by this call | ||
| | ||
= help: the trait `AsExpression<Text>` is implemented for `&str` | ||
note: required by a bound in `Foo::check` | ||
--> $DIR/as_expression.rs:48:12 | ||
| | ||
LL | fn check<T>(&self, _: T) -> <T as AsExpression<<Self as Expression>::SqlType>>::Expression | ||
| ----- required by a bound in this associated function | ||
LL | where | ||
LL | T: AsExpression<Self::SqlType>, | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Foo::check` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
60 changes: 60 additions & 0 deletions
60
tests/ui/diagnostic_namespace/do_not_recommend/as_expression.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
//@ revisions: current next | ||
//@ ignore-compare-mode-next-solver (explicit revisions) | ||
//@[next] compile-flags: -Znext-solver | ||
|
||
#![feature(do_not_recommend)] | ||
|
||
pub trait Expression { | ||
type SqlType; | ||
} | ||
|
||
pub trait AsExpression<ST> { | ||
type Expression: Expression<SqlType = ST>; | ||
} | ||
|
||
pub struct Text; | ||
pub struct Integer; | ||
|
||
pub struct Bound<T>(T); | ||
pub struct SelectInt; | ||
|
||
impl Expression for SelectInt { | ||
type SqlType = Integer; | ||
} | ||
|
||
impl<T> Expression for Bound<T> { | ||
type SqlType = T; | ||
} | ||
|
||
#[do_not_recommend] | ||
impl<T, ST> AsExpression<ST> for T | ||
where | ||
T: Expression<SqlType = ST>, | ||
{ | ||
type Expression = T; | ||
} | ||
|
||
impl AsExpression<Integer> for i32 { | ||
type Expression = Bound<Integer>; | ||
} | ||
|
||
impl AsExpression<Text> for &'_ str { | ||
type Expression = Bound<Text>; | ||
} | ||
|
||
trait Foo: Expression + Sized { | ||
fn check<T>(&self, _: T) -> <T as AsExpression<<Self as Expression>::SqlType>>::Expression | ||
where | ||
T: AsExpression<Self::SqlType>, | ||
{ | ||
todo!() | ||
} | ||
} | ||
|
||
impl<T> Foo for T where T: Expression {} | ||
|
||
fn main() { | ||
SelectInt.check("bar"); | ||
//[next]~^ ERROR the trait bound `&str: AsExpression<<SelectInt as Expression>::SqlType>` is not satisfied | ||
//[current]~^^ ERROR the trait bound `&str: AsExpression<Integer>` is not satisfied | ||
} |
11 changes: 3 additions & 8 deletions
11
tests/ui/diagnostic_namespace/do_not_recommend/simple.current.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
tests/ui/diagnostic_namespace/do_not_recommend/simple.next.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
tests/ui/diagnostic_namespace/do_not_recommend/stacked.current.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
error[E0277]: the trait bound `(): Root` is not satisfied | ||
--> $DIR/stacked.rs:19:18 | ||
| | ||
LL | needs_root::<()>(); | ||
| ^^ the trait `Root` is not implemented for `()` | ||
| | ||
note: required by a bound in `needs_root` | ||
--> $DIR/stacked.rs:16:18 | ||
| | ||
LL | fn needs_root<T: Root>() {} | ||
| ^^^^ required by this bound in `needs_root` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
15 changes: 15 additions & 0 deletions
15
tests/ui/diagnostic_namespace/do_not_recommend/stacked.next.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
error[E0277]: the trait bound `(): Root` is not satisfied | ||
--> $DIR/stacked.rs:19:18 | ||
| | ||
LL | needs_root::<()>(); | ||
| ^^ the trait `Root` is not implemented for `()` | ||
| | ||
note: required by a bound in `needs_root` | ||
--> $DIR/stacked.rs:16:18 | ||
| | ||
LL | fn needs_root<T: Root>() {} | ||
| ^^^^ required by this bound in `needs_root` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//@ revisions: current next | ||
//@ ignore-compare-mode-next-solver (explicit revisions) | ||
//@[next] compile-flags: -Znext-solver | ||
|
||
#![feature(do_not_recommend)] | ||
|
||
trait Root {} | ||
trait DontRecommend {} | ||
trait Other {} | ||
|
||
#[do_not_recommend] | ||
impl<T> Root for T where T: DontRecommend {} | ||
|
||
impl<T> DontRecommend for T where T: Other {} | ||
|
||
fn needs_root<T: Root>() {} | ||
|
||
fn main() { | ||
needs_root::<()>(); | ||
//~^ ERROR the trait bound `(): Root` is not satisfied | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like the new solver does not resolve associated types here yet?