forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#105575 - compiler-errors:impl-wf-lint, r=oli-obk
Add `IMPLIED_BOUNDS_ENTAILMENT` lint Implements a lint (rust-lang#105572) version of the hard-error introduced in rust-lang#105483. Context is in that PR. r? `@lcnr` cc `@oli-obk` who had asked for this to be a lint first Not sure if this needs to be an FCP, since it's a lint for now.
- Loading branch information
Showing
9 changed files
with
223 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
22 changes: 22 additions & 0 deletions
22
src/test/ui/implied-bounds/impl-implied-bounds-compatibility-unnormalized.rs
This file contains 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,22 @@ | ||
#![deny(implied_bounds_entailment)] | ||
|
||
trait Project { | ||
type Ty; | ||
} | ||
impl Project for &'_ &'_ () { | ||
type Ty = (); | ||
} | ||
trait Trait { | ||
fn get<'s>(s: &'s str, _: ()) -> &'static str; | ||
} | ||
impl Trait for () { | ||
fn get<'s>(s: &'s str, _: <&'static &'s () as Project>::Ty) -> &'static str { | ||
//~^ ERROR impl method assumes more implied bounds than the corresponding trait method | ||
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
s | ||
} | ||
} | ||
fn main() { | ||
let val = <() as Trait>::get(&String::from("blah blah blah"), ()); | ||
println!("{}", val); | ||
} |
16 changes: 16 additions & 0 deletions
16
src/test/ui/implied-bounds/impl-implied-bounds-compatibility-unnormalized.stderr
This file contains 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,16 @@ | ||
error: impl method assumes more implied bounds than the corresponding trait method | ||
--> $DIR/impl-implied-bounds-compatibility-unnormalized.rs:13:5 | ||
| | ||
LL | fn get<'s>(s: &'s str, _: <&'static &'s () as Project>::Ty) -> &'static str { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #105572 <https://github.com/rust-lang/rust/issues/105572> | ||
note: the lint level is defined here | ||
--> $DIR/impl-implied-bounds-compatibility-unnormalized.rs:1:9 | ||
| | ||
LL | #![deny(implied_bounds_entailment)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
21 changes: 21 additions & 0 deletions
21
src/test/ui/implied-bounds/impl-implied-bounds-compatibility.rs
This file contains 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 @@ | ||
#![deny(implied_bounds_entailment)] | ||
|
||
use std::cell::RefCell; | ||
|
||
pub struct MessageListeners<'a> { | ||
listeners: RefCell<Vec<Box<dyn FnMut(()) + 'a>>>, | ||
} | ||
|
||
pub trait MessageListenersInterface { | ||
fn listeners<'c>(&'c self) -> &'c MessageListeners<'c>; | ||
} | ||
|
||
impl<'a> MessageListenersInterface for MessageListeners<'a> { | ||
fn listeners<'b>(&'b self) -> &'a MessageListeners<'b> { | ||
//~^ ERROR impl method assumes more implied bounds than the corresponding trait method | ||
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
self | ||
} | ||
} | ||
|
||
fn main() {} |
16 changes: 16 additions & 0 deletions
16
src/test/ui/implied-bounds/impl-implied-bounds-compatibility.stderr
This file contains 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,16 @@ | ||
error: impl method assumes more implied bounds than the corresponding trait method | ||
--> $DIR/impl-implied-bounds-compatibility.rs:14:5 | ||
| | ||
LL | fn listeners<'b>(&'b self) -> &'a MessageListeners<'b> { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #105572 <https://github.com/rust-lang/rust/issues/105572> | ||
note: the lint level is defined here | ||
--> $DIR/impl-implied-bounds-compatibility.rs:1:9 | ||
| | ||
LL | #![deny(implied_bounds_entailment)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
This file contains 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