Skip to content
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

simplify_type: don't simplify projections #92721

Closed
wants to merge 1 commit into from

Conversation

lcnr
Copy link
Contributor

@lcnr lcnr commented Jan 10, 2022

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jan 10, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 10, 2022
@lcnr lcnr force-pushed the simplify_type-projections branch 2 times, most recently from 3106bea to 7323d0d Compare January 10, 2022 12:34
@lcnr
Copy link
Contributor Author

lcnr commented Jan 10, 2022

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 10, 2022
@bors
Copy link
Contributor

bors commented Jan 10, 2022

⌛ Trying commit 13f7edc with merge be79c364343564bbcc7f36d4b3d932f2b49f3482...

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-12 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

---- [ui] ui/associated-types/hr-associated-type-bound-object.rs stdout ----
diff of stderr:

9              <&T as Clone>
10              <*const T as Clone>
11              <*mut T as Clone>
+            and 1084 others
13 note: required by a bound in `X`
14   --> $DIR/hr-associated-type-bound-object.rs:3:33
Some tests failed in compiletest suite=ui mode=ui host=x86_64-unknown-linux-gnu target=i686-unknown-linux-gnu
---
To only update this specific test, also pass `--test-args associated-types/hr-associated-type-bound-object.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/associated-types/hr-associated-type-bound-object.rs" "-Zthreads=1" "--target=i686-unknown-linux-gnu" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/associated-types/hr-associated-type-bound-object" "-A" "unused" "-Crpath" "-O" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/i686-unknown-linux-gnu/native/rust-test-helpers" "-Clinker=cc" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/associated-types/hr-associated-type-bound-object/auxiliary"
------------------------------------------

------------------------------------------
stderr:
stderr:
------------------------------------------
error[E0277]: the trait bound `for<'b> <T as X<'b>>::U: Clone` is not satisfied
   |
   |
LL | fn f<'a, T: X<'a> + ?Sized>(x: &<T as X<'a>>::U) {
   |             ^^^^^ the trait `for<'b> Clone` is not implemented for `<T as X<'b>>::U`
   = help: the following implementations were found:
   = help: the following implementations were found:
             <! as Clone>
             <&T as Clone>
             <*const T as Clone>
             <*mut T as Clone>
note: required by a bound in `X`
  --> /checkout/src/test/ui/associated-types/hr-associated-type-bound-object.rs:3:33
   |
   |
LL | trait X<'a>
   |       - required by a bound in this
LL | where
LL |     for<'b> <Self as X<'b>>::U: Clone,
   |                                 ^^^^^ required by this bound in `X`
error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.

---
test result: FAILED. 12369 passed; 1 failed; 173 ignored; 0 measured; 0 filtered out; finished in 98.05s



command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/i686-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-i686-unknown-linux-gnu" "--suite" "ui" "--mode" "ui" "--target" "i686-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-12/bin/FileCheck" "--pass" "check" "--nodejs" "/usr/bin/node" "--linker" "cc" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0  -Lnative=/checkout/obj/build/i686-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python3" "--lldb-python" "/usr/bin/python3" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "12.0.0" "--llvm-components" "aarch64 aarch64asmparser aarch64codegen aarch64desc aarch64disassembler aarch64info aarch64utils aggressiveinstcombine all all-targets amdgpu amdgpuasmparser amdgpucodegen amdgpudesc amdgpudisassembler amdgpuinfo amdgpuutils analysis arm armasmparser armcodegen armdesc armdisassembler arminfo armutils asmparser asmprinter avr avrasmparser avrcodegen avrdesc avrdisassembler avrinfo binaryformat bitreader bitstreamreader bitwriter bpf bpfasmparser bpfcodegen bpfdesc bpfdisassembler bpfinfo cfguard codegen core coroutines coverage debuginfocodeview debuginfodwarf debuginfogsym debuginfomsf debuginfopdb demangle dlltooldriver dwarflinker engine executionengine extensions filecheck frontendopenacc frontendopenmp fuzzmutate globalisel hellonew hexagon hexagonasmparser hexagoncodegen hexagondesc hexagondisassembler hexagoninfo instcombine instrumentation interfacestub interpreter ipo irreader jitlink lanai lanaiasmparser lanaicodegen lanaidesc lanaidisassembler lanaiinfo libdriver lineeditor linker lto mc mca mcdisassembler mcjit mcparser mips mipsasmparser mipscodegen mipsdesc mipsdisassembler mipsinfo mirparser msp430 msp430asmparser msp430codegen msp430desc msp430disassembler msp430info native nativecodegen nvptx nvptxcodegen nvptxdesc nvptxinfo objcarcopts object objectyaml option orcjit orcshared orctargetprocess passes perfjitevents powerpc powerpcasmparser powerpccodegen powerpcdesc powerpcdisassembler powerpcinfo profiledata remarks riscv riscvasmparser riscvcodegen riscvdesc riscvdisassembler riscvinfo runtimedyld scalaropts selectiondag sparc sparcasmparser sparccodegen sparcdesc sparcdisassembler sparcinfo support symbolize systemz systemzasmparser systemzcodegen systemzdesc systemzdisassembler systemzinfo tablegen target textapi transformutils vectorize webassembly webassemblyasmparser webassemblycodegen webassemblydesc webassemblydisassembler webassemblyinfo windowsmanifest x86 x86asmparser x86codegen x86desc x86disassembler x86info xcore xcorecodegen xcoredesc xcoredisassembler xcoreinfo xray" "--cc" "" "--cxx" "" "--cflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--channel" "nightly" "--color" "always"


Build completed unsuccessfully in 0:01:40

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is a proposed change to your comment-- does this seem right?

@@ -60,29 +60,23 @@ pub enum StripReferences {
No,
}

/// Tries to simplify a type by only returning the outermost injective¹ layer, if one exists.
/// Tries to simplify a type by only returning the outermost layer of an inductive type, if one exists.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really know what "inductive" type means here, and I expect other readers won't either =)

///
/// When using `SimplifyParams::Yes`, we still return a simplified type for params and projections²,
/// the reasoning for this can be seen at the places doing this.
/// When using `SimplifyParams::Yes`, we still return a simplified type for params.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if a better name for this would be TreatParamsAsPlaceholders-- I've been trying to push the "placeholder" terminology for "universally bound free variable".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or something like

enum TreatParams {
    AsPlaceholderTypes,
    AsBoundTypes,
}

Comment on lines +129 to +136
// Returning a simplified for projections can end up being unsound as it would
// stop us from considering not consider non blanket impls for `<_ as Trait>::Assoc` even
// though `_` can be inferred to a concrete type later at which point a concrete impl
// could actually apply.
//
// We could return `Some` here in cases where the input type is fully normalized, but
// I (@lcnr) don't know how to guarantee that.
None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Returning a simplified for projections can end up being unsound as it would
// stop us from considering not consider non blanket impls for `<_ as Trait>::Assoc` even
// though `_` can be inferred to a concrete type later at which point a concrete impl
// could actually apply.
//
// We could return `Some` here in cases where the input type is fully normalized, but
// I (@lcnr) don't know how to guarantee that.
None
// Returning a simplified for projections can end up being unsound. Consider this example:
//
// ```rust
// trait Foo { }
// impl Foo for u32 { }
//
// trait Bar { type Assoc; }
// impl Bar for f32 { type Assoc = u32; }
// impl Bar for f64 { type Assoc = u64; }
// ```
// If we are matching `<_ as Bar>::Assoc` against `Foo`, we might rule out the impl even though `_` could be inferred to `f32` and hence it might match.
None

@bors
Copy link
Contributor

bors commented Jan 10, 2022

☀️ Try build successful - checks-actions
Build commit: be79c364343564bbcc7f36d4b3d932f2b49f3482 (be79c364343564bbcc7f36d4b3d932f2b49f3482)

@rust-timer
Copy link
Collaborator

Queued be79c364343564bbcc7f36d4b3d932f2b49f3482 with parent df035a3, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (be79c364343564bbcc7f36d4b3d932f2b49f3482): comparison url.

Summary: This change led to very large relevant regressions 😿 in compiler performance.

  • Very large regression in instruction counts (up to 29.6% on incr-full builds of wf-projection-stress-65510)

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR led to changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf +perf-regression

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jan 10, 2022
@JohnCSimon
Copy link
Member

JohnCSimon commented Jan 23, 2022

triage: returning to author to address comments
@rustbot label: +S-waiting-on-author -S-waiting-on-review

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 23, 2022
@nikomatsakis
Copy link
Contributor

@lcnr

Very large regression

is this expected?

@lcnr lcnr closed this Feb 16, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Mar 3, 2022
improve comments for `simplify_type`

Should now correctly describe what's going on. Experimented with checking the invariant for projections
but that ended up requiring fairly involved changes. I assume that it is not possible to get unsoundness here,
at least for now and I can pretty much guarantee that it's impossible to trigger it by accident.

r? ````@nikomatsakis```` cc rust-lang#92721
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Mar 3, 2022
improve comments for `simplify_type`

Should now correctly describe what's going on. Experimented with checking the invariant for projections
but that ended up requiring fairly involved changes. I assume that it is not possible to get unsoundness here,
at least for now and I can pretty much guarantee that it's impossible to trigger it by accident.

r? `````@nikomatsakis````` cc rust-lang#92721
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf-regression Performance regression. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants