-
Notifications
You must be signed in to change notification settings - Fork 12.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #112537 - compiler-errors:dont-record-adjustments-twi…
…ce, r=cjgillot Don't record adjustments twice in `note_source_of_type_mismatch_constraint` We call `lookup_method` a few times in `note_source_of_type_mismatch_constraint`, but that function has side-effects to the typeck results. Replace it with a less side-effect-y variant of the function for use in diagnostics. Specifically the ICE in #112532 happens because we're recording deref adjustments twice for a call receiver, which causes `ExprUseVisitor` to be angry. Fixes #112532
- Loading branch information
Showing
5 changed files
with
93 additions
and
7 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
29 changes: 29 additions & 0 deletions
29
tests/ui/typeck/dont-record-adjustments-when-pointing-at-arg.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,29 @@ | ||
pub trait NSWindow: Sized { | ||
fn frame(self) -> () { | ||
unimplemented!() | ||
} | ||
fn setFrame_display_(self, display: ()) {} | ||
} | ||
impl NSWindow for () {} | ||
|
||
pub struct NSRect {} | ||
|
||
use std::ops::Deref; | ||
struct MainThreadSafe<T = ()>(T); | ||
impl<T> Deref for MainThreadSafe<T> { | ||
type Target = T; | ||
|
||
fn deref(&self) -> &T { | ||
unimplemented!() | ||
} | ||
} | ||
|
||
fn main() { | ||
|| { | ||
let ns_window = MainThreadSafe(()); | ||
// Don't record adjustments twice for `*ns_window` | ||
(*ns_window).frame(); | ||
ns_window.setFrame_display_(0); | ||
//~^ ERROR mismatched types | ||
}; | ||
} |
17 changes: 17 additions & 0 deletions
17
tests/ui/typeck/dont-record-adjustments-when-pointing-at-arg.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,17 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/dont-record-adjustments-when-pointing-at-arg.rs:26:37 | ||
| | ||
LL | ns_window.setFrame_display_(0); | ||
| ----------------- ^ expected `()`, found integer | ||
| | | ||
| arguments to this method are incorrect | ||
| | ||
note: method defined here | ||
--> $DIR/dont-record-adjustments-when-pointing-at-arg.rs:5:8 | ||
| | ||
LL | fn setFrame_display_(self, display: ()) {} | ||
| ^^^^^^^^^^^^^^^^^ ----------- | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |