Uh oh!
There was an error while loading. Please reload this page.
refactor the BorrowckErrors trait to take fn(self) - #48902
Conversation
rust-highfive
commented
Mar 10, 2018
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @petrochenkov (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
| pub trait BorrowckErrors<'cx> { | ||
| fn struct_span_err_with_code<S: Into<MultiSpan>>(self, | ||
| sp: S, | ||
| msg: &str, |
There was a problem hiding this comment.
Formatting is broken here in in few other places.
petrochenkov
commented
Mar 10, 2018
LGTM, r=me after fixing formatting |
csmoe
commented
Mar 11, 2018
r @petrochenkov |
petrochenkov
commented
Mar 11, 2018
@bors r+ |
bors
commented
Mar 11, 2018
📌 Commit cb5ac97 has been approved by |
…lf, r=petrochenkov refactor the `BorrowckErrors` trait to take `fn(self)` Fixesrust-lang#48783
| sp: S, | ||
| msg: &str) | ||
| -> DiagnosticBuilder<'cx> | ||
| where Self: Sized + Copy |
There was a problem hiding this comment.
Wait -- this where clause should not be needed, right? (I would have probably moved it into the trait, in any case, but it shouldn't be needed in the impls...)
There was a problem hiding this comment.
Nit: I would move these into the trait definition, as the trait is meant to be implemented for references.
There was a problem hiding this comment.
...then you could remove them from all these places
There was a problem hiding this comment.
it seems the where clause cannot be removed here:
error[E0277]: the trait bound `Self: std::marker::Sized` is not satisfied
--> librustc_mir/util/borrowck_errors.rs:287:22
|
287 | fn cannot_assign(self, span: Span, desc: &str, o: Origin) -> DiagnosticBuilder<'cx>
| ^^^^ `Self` does not have a constant size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `Self`
= help: consider adding a `where Self: std::marker::Sized` bound
= note: all local variables must have a statically known size
There was a problem hiding this comment.
@nikomatsakis
the compiler complained that the self in trait should be Sized + Copy, and I found that TyCtxt already #[derive(Copy, Clone)], so I rewrote pub trait BorrowckError<'tcx>: Sized + Copy {} instead of appending where clause in every method. Is this make sense?
There was a problem hiding this comment.
Yep! That's what I was proposing, in fact.
nikomatsakis
left a comment
There was a problem hiding this comment.
Thanks @csmoe -- left one more nit :)
813c57d to
4d24236Compare4d24236 to
5511624Comparenikomatsakis
commented
Mar 19, 2018
@bors r+ rollup |
bors
commented
Mar 19, 2018
📌 Commit 5511624 has been approved by |
…lf, r=nikomatsakis refactor the `BorrowckErrors` trait to take `fn(self)` Fixesrust-lang#48783
Fixes#48783