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

Check that built-in callable types validate their output type is Sized (in new solver) #107867

Merged
merged 2 commits into from
Feb 19, 2023

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Feb 10, 2023

Working on parity with old solver. Putting this up for consideration, it's not really needed or anything just yet. Maybe it's better to approach this from another direction (like always checking the item bounds when calling consider_assumption? we may need that for coinduction to be sound though?)

This basically implements #100096 for the new solver.

@rustbot
Copy link
Collaborator

rustbot commented Feb 10, 2023

r? @eholk

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Feb 10, 2023
@rustbot
Copy link
Collaborator

rustbot commented Feb 10, 2023

Some changes occurred to the core trait solver

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

@compiler-errors compiler-errors force-pushed the new-solver-fn-trait-safety branch from 03cbc19 to a7c3415 Compare February 10, 2023 04:11
Copy link
Contributor

@lcnr lcnr left a comment

Choose a reason for hiding this comment

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

Am in favor of landing this PR.

some related thoughts wrt naming n stuff: I am actually not too happy about the name consider_assumption given how it is used.

If we have a builtin impl we're not really considering an assumption as it's something where we know that it holds, we're simply looking at an impl header with no nested goals.

If we were to change consider_assumption to also take a list of nested obligations it would be pretty much how candidates in chalk (and probably a-mir-formality) work?

So maybe a name like fn consider_normal_candidate (with a comment explaining what normal means might be better? 🤔 idk

compiler/rustc_trait_selection/src/solve/project_goals.rs Outdated Show resolved Hide resolved
compiler/rustc_trait_selection/src/solve/trait_goals.rs Outdated Show resolved Hide resolved
@compiler-errors compiler-errors assigned lcnr and unassigned eholk Feb 15, 2023
@lcnr lcnr 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 Feb 15, 2023
@compiler-errors compiler-errors force-pushed the new-solver-fn-trait-safety branch 2 times, most recently from 454d4a6 to 189e26f Compare February 16, 2023 03:06
@compiler-errors
Copy link
Member Author

I renamed it to consider_hypothesis and moved some stuff around. Not super attached to anything, so please let me know if you think things should be renamed or moved.

@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 Feb 16, 2023
ecx: &mut EvalCtxt<'_, 'tcx>,
goal: Goal<'tcx, Self>,
impl_def_id: DefId,
assumption: ty::Predicate<'tcx>,
requirements: Vec<Goal<'tcx, ty::Predicate<'tcx>>>,
Copy link
Contributor

Choose a reason for hiding this comment

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

impl IntoIterator<Item = Goal> maybe. We have a bunch of fixed len requirements which can just be [goal] 🤔

// Use a hypothesis, which consists of a "assumption" and some "requirements",
// to satisfy a goal. If the requirements hold, then attempt to satisfy our
// goal by equating it with the assumption.
fn consider_hypothesis(
Copy link
Contributor

Choose a reason for hiding this comment

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

not too happy with hypothesis https://www.merriam-webster.com/dictionary/hypothesis

A hypothesis is an assumption, an idea that is proposed for the sake of argument so that it can be tested to see if it might be true.

In the scientific method, the hypothesis is constructed before any applicable research has been done, apart from a basic background review. You ask a question, read up on what has been studied before, and then form a hypothesis.

we know that the requirements -> assumption is correct. Looking at chalk, they use clause for this. I don't think we should do that in rustc because we already have a Clause which (at least for now) is something slightly different.

Other ideas:

  • consider_(logical)_statement (meh)
  • consider_implication (this will be how implications in the param env will be implemented (if and once we get them))
  • consider_implied_clause (changing assumption to clause: ty::Clause, will actually re)

I personally kinda like consider_implied_clause 🤔 It is a clause which is implied by some requirements. But yeah, if you don't like consider_implied_clause we can just go with whatever.

r=me after nit

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, consider_implied_clause is a totally fine name!

@compiler-errors compiler-errors force-pushed the new-solver-fn-trait-safety branch from 189e26f to 6402c98 Compare February 18, 2023 19:45
@compiler-errors
Copy link
Member Author

@bors r=lcnr

@bors
Copy link
Contributor

bors commented Feb 18, 2023

📌 Commit 6402c98 has been approved by lcnr

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 18, 2023
@bors
Copy link
Contributor

bors commented Feb 19, 2023

⌛ Testing commit 6402c98 with merge fcdbd1c...

@bors
Copy link
Contributor

bors commented Feb 19, 2023

☀️ Test successful - checks-actions
Approved by: lcnr
Pushing fcdbd1c to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Feb 19, 2023
@bors bors merged commit fcdbd1c into rust-lang:master Feb 19, 2023
@rustbot rustbot added this to the 1.69.0 milestone Feb 19, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (fcdbd1c): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

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)
1.0% [1.0%, 1.0%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

This benchmark run did not return any relevant results for this metric.

@compiler-errors compiler-errors deleted the new-solver-fn-trait-safety branch August 11, 2023 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants