') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); Continue work on associated const equality by JulianKnodt · Pull Request #93285 · rust-lang/rust · GitHub
Skip to content

Continue work on associated const equality - #93285

Merged
bors merged 4 commits into
rust-lang:masterfrom
JulianKnodt:const_eq_2
Feb 2, 2022
Merged

Continue work on associated const equality#93285
bors merged 4 commits into
rust-lang:masterfrom
JulianKnodt:const_eq_2

Conversation

@JulianKnodt

@JulianKnodtJulianKnodt commented Jan 25, 2022

Copy link
Copy Markdown
Contributor

This actually implements some more complex logic for assigning associated consts to values.
Inside of projection candidates, it now defers to a separate function for either consts or
types. To reduce amount of code, projections are now generic over T, where T is either a Type or
a Const. I can add some comments back later, but this was the fastest way to implement it.

It also now finds the correct type of consts in type_of.


The current main TODO is finding the const of the def id for the LeafDef.

Right now it works if the function isn't called, but once you use the trait impl with the bound it fails inside projection.
I was hoping to get some help in getting the &'tcx ty::Const<'tcx>, in addition to a bunch of other todo!()s which I think may not be hit.

r? @oli-obk

Updates #92827

@rustbotrustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jan 25, 2022
@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 25, 2022
Comment threadcompiler/rustc_trait_selection/src/traits/project.rs Outdated
@rust-log-analyzer

This comment has been minimized.

@bors

bors commented Jan 25, 2022

Copy link
Copy Markdown
Collaborator

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

Comment threadcompiler/rustc_trait_selection/src/traits/project.rs Outdated
@JulianKnodt

Copy link
Copy Markdown
ContributorAuthor

Hm, after naively adding in Term instead of being generic over Ty and Const, I feel pretty strongly that it makes a lot of sense for now to special case the few branches where const is hit. If you feel pretty strongly that it should be a term, I can still do that, but I do think it would be a better idea to have it not be an enum.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bors

bors commented Jan 27, 2022

Copy link
Copy Markdown
Collaborator

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

@oli-obkoli-obk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yea, I like this a lot more than the previous version, thanks for trying it out!

You accidentally included a cargo submodule update.

Comment threadcompiler/rustc_trait_selection/src/traits/project.rs Outdated
Comment threadcompiler/rustc_trait_selection/src/traits/project.rs Outdated
Comment threadcompiler/rustc_trait_selection/src/traits/project.rs Outdated
Comment threadcompiler/rustc_trait_selection/src/traits/project.rs Outdated
Comment threadcompiler/rustc_trait_selection/src/traits/error_reporting/mod.rs Outdated
Comment threadcompiler/rustc_trait_selection/src/traits/project.rs Outdated
Comment threadcompiler/rustc_trait_selection/src/traits/project.rs Outdated
Comment threadcompiler/rustc_traits/src/normalize_projection_ty.rs Outdated
Comment threadsrc/test/ui/associated-consts/assoc-const.rs Outdated
Comment threadcompiler/rustc_infer/src/infer/at.rs Outdated
@oli-obk

Copy link
Copy Markdown
Contributor

Hm, after naively adding in Term instead of being generic over Ty and Const, I feel pretty strongly that it makes a lot of sense for now to special case the few branches where const is hit. If you feel pretty strongly that it should be a term, I can still do that, but I do think it would be a better idea to have it not be an enum.

Hmm... can you point me to the source of examples that you think are unreachable for constants (or is it just those that now have .ty().unwrap() added in this PR?

@JulianKnodt

Copy link
Copy Markdown
ContributorAuthor

It's mostly the points where there are ty().unwrap()s. I also feel it's both safer in terms of previous code still working, and also more efficient since it won't have to do pattern matching and require extra storage in the cache. I do realize it is significant code bloat tho, so I can avoid it, it might just be that my usage of golang has been getting to my brain

@JulianKnodt
JulianKnodtforce-pushed the const_eq_2 branch 3 times, most recently from 8bda326 to 2d7af2dCompareJanuary 27, 2022 14:40
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@borsbors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Feb 1, 2022
@JulianKnodt

Copy link
Copy Markdown
ContributorAuthor

@bors r+
r? @oli-obk

@bors

bors commented Feb 1, 2022

Copy link
Copy Markdown
Collaborator

💡 This pull request was already approved, no need to approve it again.

@bors

bors commented Feb 1, 2022

Copy link
Copy Markdown
Collaborator

📌 Commit 78fb74a has been approved by JulianKnodt

@JulianKnodt

Copy link
Copy Markdown
ContributorAuthor

I'm not sure if that's how it's done but I hope it's fine?

@mati865

mati865 commented Feb 1, 2022

Copy link
Copy Markdown
Member

@JulianKnodt it's @bors r=oli-obk

@bors

bors commented Feb 1, 2022

Copy link
Copy Markdown
Collaborator

@mati865: 🔑 Insufficient privileges: Not in reviewers

@oli-obk

Copy link
Copy Markdown
Contributor

@bors r-

@borsbors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 1, 2022
@oli-obk

Copy link
Copy Markdown
Contributor

@bors r+

Sorry about the lack of instructions.

@bors

bors commented Feb 1, 2022

Copy link
Copy Markdown
Collaborator

📌 Commit 78fb74a has been approved by oli-obk

@borsbors 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 1, 2022
@JulianKnodt

Copy link
Copy Markdown
ContributorAuthor

my bad, I should've asked before just doing

@bors

bors commented Feb 1, 2022

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 78fb74a with merge 1ea4851...

@bors

bors commented Feb 2, 2022

Copy link
Copy Markdown
Collaborator

☀️ Test successful - checks-actions
Approved by: oli-obk
Pushing 1ea4851 to master...

@borsbors added the merged-by-bors This PR was explicitly merged by bors. label Feb 2, 2022
@bors
bors merged commit 1ea4851 into rust-lang:masterFeb 2, 2022
@rustbotrustbot added this to the 1.60.0 milestone Feb 2, 2022
@JulianKnodt
JulianKnodt deleted the const_eq_2 branch February 2, 2022 02:41
@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (1ea4851): comparison url.

Summary: This benchmark run did not return any relevant results.

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

@rustbot label: -perf-regression

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

F-associated_const_equality`#![feature(associated_const_equality)]`merged-by-borsThis PR was explicitly merged by bors.S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Projects

Development

Successfully merging this pull request may close these issues.

9 participants

@JulianKnodt@rust-log-analyzer@bors@oli-obk@rust-timer@mati865@rust-highfive@fmease@rustbot