-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Silence knock-down errors on [type error]
bindings
#106199
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,9 @@ | ||
error[E0423]: expected value, found trait `SomeTrait` | ||
--> $DIR/E0033.rs:6:37 | ||
| | ||
LL | let trait_obj: &dyn SomeTrait = SomeTrait; | ||
| ^^^^^^^^^ not a value | ||
|
||
error[E0038]: the trait `SomeTrait` cannot be made into an object | ||
--> $DIR/E0033.rs:6:20 | ||
| | ||
LL | let trait_obj: &dyn SomeTrait = SomeTrait; | ||
| ^^^^^^^^^^^^^^ `SomeTrait` cannot be made into an object | ||
| | ||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> | ||
--> $DIR/E0033.rs:2:8 | ||
| | ||
LL | trait SomeTrait { | ||
| --------- this trait cannot be made into an object... | ||
LL | fn foo(); | ||
| ^^^ ...because associated function `foo` has no `self` parameter | ||
help: consider turning `foo` into a method by giving it a `&self` argument | ||
| | ||
LL | fn foo(&self); | ||
| +++++ | ||
help: alternatively, consider constraining `foo` so it does not apply to trait objects | ||
| | ||
LL | fn foo() where Self: Sized; | ||
| +++++++++++++++++ | ||
|
||
error[E0033]: type `&dyn SomeTrait` cannot be dereferenced | ||
--> $DIR/E0033.rs:10:9 | ||
--> $DIR/E0033.rs:11:9 | ||
| | ||
LL | let &invalid = trait_obj; | ||
| ^^^^^^^^ type `&dyn SomeTrait` cannot be dereferenced | ||
|
||
error: aborting due to 3 previous errors | ||
error: aborting due to previous error | ||
|
||
Some errors have detailed explanations: E0033, E0038, E0423. | ||
For more information about an error, try `rustc --explain E0033`. | ||
For more information about this error, try `rustc --explain E0033`. |
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
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 |
---|---|---|
@@ -1,9 +1,13 @@ | ||
// The purpose of this test is not to validate the output of the compiler. | ||
// Instead, it ensures the suggestion is generated without performing an arithmetic overflow. | ||
|
||
struct S; | ||
impl S { | ||
fn foo(&self) {} | ||
} | ||
fn main() { | ||
let x = not_found; //~ ERROR cannot find value `not_found` in this scope | ||
simd_gt::<()>(x); | ||
let x = S; | ||
foo::<()>(x); | ||
//~^ ERROR this associated function takes 0 generic arguments but 1 generic argument was supplied | ||
//~| ERROR cannot find function `simd_gt` in this scope | ||
//~| ERROR cannot find function `foo` in this scope | ||
} |
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 |
---|---|---|
@@ -1,30 +1,30 @@ | ||
error[E0425]: cannot find value `not_found` in this scope | ||
--> $DIR/issue-104287.rs:5:13 | ||
| | ||
LL | let x = not_found; | ||
| ^^^^^^^^^ not found in this scope | ||
|
||
error[E0107]: this associated function takes 0 generic arguments but 1 generic argument was supplied | ||
--> $DIR/issue-104287.rs:6:5 | ||
--> $DIR/issue-104287.rs:10:5 | ||
| | ||
LL | simd_gt::<()>(x); | ||
| ^^^^^^^------ help: remove these generics | ||
LL | foo::<()>(x); | ||
| ^^^------ help: remove these generics | ||
| | | ||
| expected 0 generic arguments | ||
| | ||
note: associated function defined here, with 0 generic parameters | ||
--> $DIR/issue-104287.rs:6:8 | ||
| | ||
LL | fn foo(&self) {} | ||
| ^^^ | ||
|
||
error[E0425]: cannot find function `simd_gt` in this scope | ||
--> $DIR/issue-104287.rs:6:5 | ||
error[E0425]: cannot find function `foo` in this scope | ||
--> $DIR/issue-104287.rs:10:5 | ||
| | ||
LL | simd_gt::<()>(x); | ||
| ^^^^^^^ not found in this scope | ||
LL | foo::<()>(x); | ||
| ^^^ not found in this scope | ||
| | ||
help: use the `.` operator to call the method `SimdPartialOrd::simd_gt` on `[type error]` | ||
help: use the `.` operator to call the method `foo` on `&S` | ||
| | ||
LL - simd_gt::<()>(x); | ||
LL + x.simd_gt(); | ||
LL - foo::<()>(x); | ||
LL + x.foo(); | ||
| | ||
|
||
error: aborting due to 3 previous errors | ||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0107, E0425. | ||
For more information about an error, try `rustc --explain E0107`. |
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,17 @@ | ||
// fn foo() -> String { | ||
// String::new() | ||
// } | ||
|
||
fn test(s: &str) { | ||
println!("{}", s); | ||
} | ||
|
||
fn test2(s: String) { | ||
println!("{}", s); | ||
} | ||
|
||
fn main() { | ||
let x = foo(); //~ERROR cannot find function `foo` in this scope | ||
test(&x); | ||
test2(x); // Does not complain about `x` being a `&str`. | ||
} |
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,9 @@ | ||
error[E0425]: cannot find function `foo` in this scope | ||
--> $DIR/quiet-type-err-let-binding.rs:14:13 | ||
| | ||
LL | let x = foo(); | ||
| ^^^ not found in this scope | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0425`. |
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.
Why did you change this UI test? I think the UI test was added to check for an ICE that resulted specifically from this combination of resolver errors.
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.
Because the error that produced the ICE would no longer emit with the correct propagation of
[type error]
. The relevant part seemed to be the error that I kept.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.
Hm, I'm not sure if this modified UI test is "faithful" to the ICE anymore, either, though. I'm tempted to leave it as-is even if the error output turns into basically nothing. Either that, or we should just yeet this test completely..
I guess I don't care strongly any way.