rust
rust copied to clipboard
Prevent auto-application of associated functions with placeholders
Fixes #101920
r? @compiler-errors
(rust-highfive has picked a reviewer for you, use r? to override)
I notice that even when the type is known and this isn't an issue (e.g)
fn main() {
let b = Box::new("abc");
let ptr = b.into_raw();
}
Applying the fix results in incorrect code: Box::<&str>::into_raw()
Should the fix instead transform this to Box::<&str>::into_raw(b)
?
Should the fix instead transform this to Box::<&str>::into_raw(b)?
I think so, yes.
Currently working on automatically adjusting the arguments, but not sure how to handle the case of
struct GenericAssocMethod<T>(T);
impl<T> GenericAssocMethod<T> {
fn default_hello() {}
}
let x = GenericAssocMethod(33);
x.default_hello();
Where the generic arguments can't be inferred in the GenericAssocMethod::<_>::default_hello
form. Applying this or leaving it results in invalid code which causes cargo to print a bug message.
I've temporarily commented out the problematic test case since this seems like incorrect behaviour from Cargo
Where the generic arguments can't be inferred in the GenericAssocMethod::<_>::default_hello form. Applying this or leaving it results in invalid code which causes cargo to print a bug message.
Then this suggestion should probably not be MachineApplicable
, and we shouldn't have a test case that has // run-rustfix
for it, but just a regular error test case for it.
Marking this as S-waiting-on-author
so it can be adjusted to make it not MachineApplicable
if it doesn't actually fit the criteria for MachineApplicable
, namely that it should produce code that compiles when applied.
:umbrella: The latest upstream changes (presumably #102306) made this pull request unmergeable. Please resolve the merge conflicts.
@rustbot label -S-waiting-on-author +S-waiting-on-review
:umbrella: The latest upstream changes (presumably #102875) made this pull request unmergeable. Please resolve the merge conflicts.
Some changes occurred in src/tools/cargo
cc @ehuss
🤔 Sorry about the ping, I think I might have made a mistake while rebasing
The job x86_64-gnu-llvm-13
failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
---- [ui] src/test/ui/suggestions/inner_type2.rs stdout ----
diff of stderr:
17 LL | item.method();
18 | ^^^^^^ method not found in `MaybeUninit<Struct<u32>>`
19 |
- = help: if this `MaybeUninit::<Struct<u32>>` has been initialized, use one of the `assume_init` methods to access the inner value
+ = help: if this `MaybeUninit<Struct<u32>>` has been initialized, use one of the `assume_init` methods to access the inner value
21 note: the method `method` exists on the type `Struct<u32>`
23 |
The actual stderr differed from the expected stderr.
The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/suggestions/inner_type2/inner_type2.stderr
Some tests failed in compiletest suite=ui mode=ui host=x86_64-unknown-linux-gnu target=x86_64-unknown-linux-gnu
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args suggestions/inner_type2.rs`
error: 1 errors occurred comparing output.
status: exit status: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/suggestions/inner_type2.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/suggestions/inner_type2" "-A" "unused" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/suggestions/inner_type2/auxiliary"
stdout: none
--- stderr -------------------------------
error[E0599]: no method named `method` found for struct `LocalKey` in the current scope
|
|
LL | STRUCT.method();
| ^^^^^^ method not found in `LocalKey<Struct<u32>>`
|
= help: use `with` or `try_with` to access thread local storage
note: the method `method` exists on the type `Struct<u32>`
|
LL | pub fn method(&self) {}
| ^^^^^^^^^^^^^^^^^^^^
error[E0599]: no method named `method` found for union `MaybeUninit` in the current scope
|
|
LL | item.method();
| ^^^^^^ method not found in `MaybeUninit<Struct<u32>>`
|
= help: if this `MaybeUninit<Struct<u32>>` has been initialized, use one of the `assume_init` methods to access the inner value
note: the method `method` exists on the type `Struct<u32>`
|
LL | pub fn method(&self) {}
| ^^^^^^^^^^^^^^^^^^^^
:umbrella: The latest upstream changes (presumably #103310) made this pull request unmergeable. Please resolve the merge conflicts.
:umbrella: The latest upstream changes (presumably #103978) made this pull request unmergeable. Please resolve the merge conflicts.
@bors r+
Why didn't bors respond, lol
@bors r+
:pushpin: Commit 7df4b0b66252748108b5d7edee27ee5776222f64 has been approved by compiler-errors
It is now in the queue for this repository.
:hourglass: Testing commit 7df4b0b66252748108b5d7edee27ee5776222f64 with merge 5eef9b2c50ddd4e445c10043908f785b08456489...
:sunny: Test successful - checks-actions Approved by: compiler-errors Pushing 5eef9b2c50ddd4e445c10043908f785b08456489 to master...
:sunny: Test successful - checks-actions Approved by: compiler-errors Pushing 5eef9b2c50ddd4e445c10043908f785b08456489 to master...
Finished benchmarking commit (5eef9b2c50ddd4e445c10043908f785b08456489): comparison URL.
Overall result: ❌ regressions - no action needed
@rustbot label: -perf-regression
Instruction count
This is a highly reliable metric that was used to determine the overall result at the top of this comment.
mean | range | count | |
---|---|---|---|
Regressions ❌ (primary) |
- | - | 0 |
Regressions ❌ (secondary) |
1.2% | [1.2%, 1.2%] | 1 |
Improvements ✅ (primary) |
- | - | 0 |
Improvements ✅ (secondary) |
- | - | 0 |
All ❌✅ (primary) | - | - | 0 |
Max RSS (memory usage)
Results
This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
mean | range | count | |
---|---|---|---|
Regressions ❌ (primary) |
- | - | 0 |
Regressions ❌ (secondary) |
- | - | 0 |
Improvements ✅ (primary) |
- | - | 0 |
Improvements ✅ (secondary) |
-2.6% | [-3.5%, -1.3%] | 3 |
All ❌✅ (primary) | - | - | 0 |
Cycles
This benchmark run did not return any relevant results for this metric.