associated function `assumed_wf_types` repeats parent impl WF work
Open
Nobody has claimed this yet.
C-bug
needs-triage
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code:
cat > associated_fn_assumed_wf_repro.py <<'PY'
#!/usr/bin/env python3
import os
import subprocess
import time
from pathlib import Path
N = int(os.environ.get("N", "2000"))
RUSTC = os.environ.get("RUSTC", "rustc")
TIMEOUT = float(os.environ.get("TIMEOUT", "120"))
def write_many_assoc_fns(path: Path) -> None:
params = ", ".join(f"T{i}" for i in range(N))
phantom = ", ".join(f"*const T{i}" for i in range(N))
methods = "\n".join(f" pub fn m{i}(&self) {{}}" for i in range(N))
path.write_text(
f"""#![allow(dead_code)]
pub struct S<{params}>(core::marker::PhantomData<({phantom})>);
impl<{params}> S<{params}> {{
{methods}
}}
""",
encoding="utf-8",
)
src = Path(f"associated_fn_assumed_wf_{N}.rs")
out = Path(f"associated_fn_assumed_wf_{N}.rmeta")
write_many_assoc_fns(src)
start = time.perf_counter()
try:
proc = subprocess.run(
[
RUSTC,
"--edition=2024",
"--crate-type=lib",
"--emit=metadata",
"-Awarnings",
str(src),
"-o",
str(out),
],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
timeout=TIMEOUT,
check=False,
)
seconds = time.perf_counter() - start
print(f"N={N} status={proc.returncode} elapsed={seconds:.3f}s source={src.stat().st_size}")
except subprocess.TimeoutExpired:
seconds = time.perf_counter() - start
print(f"N={N} status=timeout>{TIMEOUT:g}s elapsed={seconds:.3f}s source={src.stat().st_size}")
PY
RUSTC=/path/to/rustc N=2000 python3 associated_fn_assumed_wf_repro.py
Here are the timings I collected with the same rustc binary:
N source_bytes elapsed_s exit_status
500 28026 0.930 0
1000 56526 6.366 0
2000 118526 46.836 0
4000 242525 timeout>120 -1
Meta
rustc --version --verbose: 4008bbdf34b
Backtrace
<backtrace>
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided associated_fn_assumed_wf_repro.py reproduction with the listed N values and a matching rustc binary, then investigate the compiler work associated with assumed_wf_types and parent impl well-formedness checking. Done means the reproduction still compiles successfully without the reported runtime scaling and timeout behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust
- Domain
- compilers, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100