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

add a Callable trait that is implemented for unsafe functions, too #107123

Closed
wants to merge 5 commits into from

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Jan 20, 2023

This trait will be used to mark functions as const evaluable (possibly by giving this trait a const generic bool parameter that is true for const and false otherwise)

I do not expect this trait to be ever visible to users, but to be a low level implementation detail

I have not moved FnOnce::Output to Callable yet as that is very invasive. I think we may want to delay that until the old solver is gone.

With appropriately improved (via rustc_on_unimplemented) error messages for when Callable doesn't hold, we could replace most, if not all, logic around number of argument mismatch and type of argument mismatch.

pulled out of #101900

@rust-log-analyzer

This comment was marked as outdated.

@ChayimFriedman2

This comment was marked as resolved.

@oli-obk

This comment was marked as resolved.

@bors
Copy link
Contributor

bors commented Jan 27, 2023

☔ The latest upstream changes (presumably #107343) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jan 27, 2023
@rustbot rustbot added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative labels Mar 17, 2023
@rust-log-analyzer

This comment has been minimized.

@oli-obk oli-obk force-pushed the callable_trait branch 2 times, most recently from b6d8e66 to 17a06e2 Compare March 23, 2023 17:12
Comment on lines +17 to +21
error[E0277]: the trait bound `for<'a> fn(&'a <dyn Setup<From = T> as Setup>::From) -> <dyn Setup<From = T> as Setup>::From {copy::<dyn Setup<From = T>>}: Callable<(&T,)>` is not satisfied
--> $DIR/object-unsafety.rs:12:5
|
LL | copy::<dyn Setup<From = T>>(t)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Callable<(&T,)>` is not implemented for fn item `for<'a> fn(&'a <dyn Setup<From = T> as Setup>::From) -> <dyn Setup<From = T> as Setup>::From {copy::<dyn Setup<From = T>>}`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not exactly sure what happened here, but I'm assuming we just don't explain that Callable isn't implemented because Setup isn't implemented for dyn Setup, but just fail the outer obligation.

Orthogonally to that I can make it less confusing by adding a rustc_on_unimplemented to Callable to give a more targeted message.

Copy link
Member

@compiler-errors compiler-errors Apr 26, 2023

Choose a reason for hiding this comment

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

It's because &'a <dyn Setup<From = T> as Setup>::From isn't normalizing to &T (because it's not WF). It's probably not possible to make this into a better error message... I wonder if we could suppress this somehow (delayed as a bug), but I'd rather just leave it be confusing until someone complains about it.

@oli-obk oli-obk marked this pull request as ready for review March 23, 2023 17:15
@rustbot
Copy link
Collaborator

rustbot commented Mar 23, 2023

Some changes occurred to the core trait solver

cc @rust-lang/initiative-trait-system-refactor

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

The Miri subtree was changed

cc @rust-lang/miri

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@oli-obk
Copy link
Contributor Author

oli-obk commented Mar 23, 2023

r? @lcnr

@oli-obk
Copy link
Contributor Author

oli-obk commented Mar 23, 2023

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 23, 2023
@rust-log-analyzer

This comment has been minimized.

@oli-obk oli-obk force-pushed the callable_trait branch 5 times, most recently from 43c1673 to b6a9527 Compare March 24, 2023 17:21
compiler/rustc_hir_typeck/src/callee.rs Outdated Show resolved Hide resolved
compiler/rustc_hir_typeck/src/callee.rs Outdated Show resolved Hide resolved
compiler/rustc_hir_typeck/src/callee.rs Outdated Show resolved Hide resolved
compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs Outdated Show resolved Hide resolved
compiler/rustc_hir_typeck/src/method/confirm.rs Outdated Show resolved Hide resolved
compiler/rustc_infer/src/infer/opaque_types/table.rs Outdated Show resolved Hide resolved
match *self_ty.kind() {
// keep this in sync with assemble_fn_pointer_candidates until the old solver is removed.
ty::FnDef(def_id, substs) => {
let sig = tcx.fn_sig(def_id);
if sig.skip_binder().is_fn_trait_compatible()
&& tcx.codegen_fn_attrs(def_id).target_features.is_empty()
if matches!(mode, Callable)
Copy link
Member

Choose a reason for hiding this comment

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

I think it's easier to understand if we just match on (*self_ty.kind(), mode)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did that for the closures, but I don't see how we can improve anything for FnDef or FnPtr.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Mar 28, 2023

☔ The latest upstream changes (presumably #108080) made this pull request unmergeable. Please resolve the merge conflicts.

@oli-obk
Copy link
Contributor Author

oli-obk commented Jun 27, 2023

@bors try

@bors
Copy link
Contributor

bors commented Jun 27, 2023

⌛ Trying commit 27891c5 with merge f82303294ca6add47eea966608ce02688928f965...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jun 27, 2023

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

@oli-obk
Copy link
Contributor Author

oli-obk commented Jun 27, 2023

@craterbot
Copy link
Collaborator

🚨 Error: missing desired crates: {"https://crater-reports.s3.amazonaws.com/pr-107123/retry-regressed-list.txt"}

🆘 If you have any trouble with Crater please ping @rust-lang/infra!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@oli-obk
Copy link
Contributor Author

oli-obk commented Jun 27, 2023

@craterbot
Copy link
Collaborator

👌 Experiment pr-107123-1 created and queued.
🤖 Automatically detected try build f82303294ca6add47eea966608ce02688928f965
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 27, 2023
@rust-log-analyzer
Copy link
Collaborator

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

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

error: make failed
status: exit status: 2
Build completed unsuccessfully in 0:27:50
command: cd "/checkout/tests/run-make/raw-dylib-cross-compilation" && AR="ar" CC="cc -ffunction-sections -fdata-sections -fPIC -m64" CXX="c++ -ffunction-sections -fdata-sections -fPIC -m64" HOST_RPATH_DIR="/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" LD_LIB_PATH_ENVVAR="LD_LIBRARY_PATH" LLVM_BIN_DIR="/usr/lib/llvm-14/bin" LLVM_COMPONENTS="aarch64 aarch64asmparser aarch64codegen aarch64desc aarch64disassembler aarch64info aarch64utils aggressiveinstcombine all all-targets amdgpu amdgpuasmparser amdgpucodegen amdgpudesc amdgpudisassembler amdgpuinfo amdgputargetmca 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 dwp engine executionengine extensions filecheck frontendopenacc frontendopenmp fuzzmutate globalisel hexagon hexagonasmparser hexagoncodegen hexagondesc hexagondisassembler hexagoninfo instcombine instrumentation interfacestub interpreter ipo irreader jitlink lanai lanaiasmparser lanaicodegen lanaidesc lanaidisassembler lanaiinfo libdriver lineeditor linker lto m68k m68kasmparser m68kcodegen m68kdesc m68kdisassembler m68kinfo 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 ve veasmparser vecodegen vectorize vedesc vedisassembler veinfo webassembly webassemblyasmparser webassemblycodegen webassemblydesc webassemblydisassembler webassemblyinfo webassemblyutils windowsmanifest x86 x86asmparser x86codegen x86desc x86disassembler x86info x86targetmca xcore xcorecodegen xcoredesc xcoredisassembler xcoreinfo xray" LLVM_FILECHECK="/usr/lib/llvm-14/bin/FileCheck" NODE="/usr/bin/node" PYTHON="/usr/bin/python3" RUSTC="/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" RUSTDOC="/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustdoc" RUST_BUILD_STAGE="stage2-x86_64-unknown-linux-gnu" RUST_DEMANGLER="/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools-bin/rust-demangler" S="/checkout" TARGET="x86_64-unknown-linux-gnu" TARGET_RPATH_DIR="/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" TMPDIR="/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/raw-dylib-cross-compilation/raw-dylib-cross-compilation" "make"
--- stdout -------------------------------
# Build as x86 and make sure that we have x86 objects only.
LD_LIBRARY_PATH="/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/raw-dylib-cross-compilation/raw-dylib-cross-compilation:/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib:/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-bootstrap-tools/x86_64-unknown-linux-gnu/release/deps:/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/lib" '/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc' --out-dir /checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/raw-dylib-cross-compilation/raw-dylib-cross-compilation -L /checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/raw-dylib-cross-compilation/raw-dylib-cross-compilation  --crate-type lib --crate-name i686_raw_dylib_test --target i686-pc-windows-gnu lib.rs
--- stderr -------------------------------
error: requires `callable` lang_item
##[error]  --> lib.rs:17:9
   |

@craterbot
Copy link
Collaborator

🚧 Experiment pr-107123-1 is now running

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot
Copy link
Collaborator

🎉 Experiment pr-107123-1 is completed!
📊 374 regressed and 0 fixed (514 total)
📰 Open the full report.

⚠️ If you notice any spurious failure please add them to the blacklist!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-crater Status: Waiting on a crater run to be completed. labels Jun 29, 2023
@bors
Copy link
Contributor

bors commented Jul 2, 2023

☔ The latest upstream changes (presumably #113260) made this pull request unmergeable. Please resolve the merge conflicts.

@compiler-errors
Copy link
Member

@rustbot author

@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 Jul 29, 2023
@JohnCSimon
Copy link
Member

@oli-obk

ping from triage - can you post your status on this PR? This PR has not received an update in a few months. Thank you!

@Dylan-DPC
Copy link
Member

Closing this as inactive. Feel free to reöpen this pr or create a new pr if you get the time to work on this. Thanks

@Dylan-DPC Dylan-DPC closed this Mar 14, 2024
@Dylan-DPC Dylan-DPC added S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf-regression Performance regression. S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative
Projects
None yet
Development

Successfully merging this pull request may close these issues.