- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
          Move Const::{from_anon_const,try_from_lit} to hir_ty_lowering
          #133610
        
          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
Conversation
| HIR ty lowering was modified cc @fmease | 
| if let Some(generics) = node.generics() { | ||
| debug!("const_evaluatable_predicates_of({:?}): visit_generics", def_id); | ||
| collector.visit_generics(generics); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't really think of anything that would need this, nor what the rustc_middle::ty-equivalent would be. All the tests passed though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah its a bit weird, hir::Generics is some amalgamation of generics_of, and some predicates_of (inline written bounds, e.g. <T: Trait>). We don't really care about generics_of since we don't want to add const evaluatable bounds for const parameter defaults, and any const arguments in types of const parmeters (e.g. <const N: Bar<{ 10 }>>) must be fully concrete so there's no need to add const evaluatable bounds for them.
So yeah 👍 to removing this
d660c44    to
    0c762b6      
    Compare
  
    
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
0c762b6    to
    352a6c8      
    Compare
  
    | Curious if this improves performance since we no longer re-lower const args. @bors try @rust-timer queue | 
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
Move `Const::{from_anon_const,try_from_lit}` to hir_ty_lowering
Fixes rust-lang#128176.
This accomplishes one of the followup items from rust-lang#131081.
These operations are much more about lowering the HIR than about
`Const`s themselves. They fit better in hir_ty_lowering with
`lower_const_arg` (formerly `Const::from_const_arg`) and the rest.
To accomplish this, `const_evaluatable_predicates_of` had to be changed
to not use `from_anon_const` anymore. Instead of visiting the HIR and
lowering anon consts on the fly, it now visits the `rustc_middle::ty`
data structures instead and directly looks for `UnevaluatedConst`s. This
approach was proposed in:
rust-lang#131081 (comment)
r? `@BoxyUwU`
    
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
| ☀️ Try build successful - checks-actions | 
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
| Finished benchmarking commit (16870bf): comparison URL. Overall result: ❌ regressions - no action neededBenchmarking 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 may lead to changes in compiler perf. @bors rollup=never Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise. 
 Max RSS (memory usage)Results (primary 0.8%)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. 
 CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 773.667s -> 772.898s (-0.10%) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very cool! :3 small review + fixing the intra doc link that's now broken then should be good to go
| //@ known-bug: rust-lang/rust#128176 | ||
| //@ check-pass | ||
|  | ||
| // Regression test for #128176. | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Regression test for #128176. | |
| // Regression test for #128176. Previously we would call `type_of` on the `1` anon const before the anon const had been lowered and had the `type_of` fed with a result. | 
| I wouldn't have really expected any perf effects since most of this PR only has an effect under  | 
| @bors r+ don't need to block this PR on figuring out exactly why that test stopped ICEing since its gce only | 
| 🌲 The tree is currently closed for pull requests below priority 100. This pull request will be tested once the tree is reopened. | 
| @bors rollup=maybe | 
| ☔ The latest upstream changes (presumably #133728) made this pull request unmergeable. Please resolve the merge conflicts. | 
5c37ec1    to
    4dd0b08      
    Compare
  
    
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
These operations are much more about lowering the HIR than about `Const`s themselves. They fit better in hir_ty_lowering with `lower_const_arg` (formerly `Const::from_const_arg`) and the rest. To accomplish this, `const_evaluatable_predicates_of` had to be changed to not use `from_anon_const` anymore. Instead of visiting the HIR and lowering anon consts on the fly, it now visits the `rustc_middle::ty` data structures instead and directly looks for `UnevaluatedConst`s. This approach was proposed in: rust-lang#131081 (comment)
4dd0b08    to
    dcf332b      
    Compare
  
    | @bors r=BoxyUwU | 
…llaumeGomez Rollup of 10 pull requests Successful merges: - rust-lang#131713 (Stabilize `const_maybe_uninit_write`) - rust-lang#133535 (show forbidden_lint_groups in future-compat reports) - rust-lang#133610 (Move `Const::{from_anon_const,try_from_lit}` to hir_ty_lowering) - rust-lang#133701 (Use c"lit" for CStrings without unwrap) - rust-lang#133704 (fix ICE when promoted has layout size overflow) - rust-lang#133705 (add "profiler" and "optimized-compiler-builtins" option coverage for ci-rustc) - rust-lang#133710 (Reducing `target_feature` check-cfg merge conflicts) - rust-lang#133732 (Fix `-Zdump-mir-dataflow`) - rust-lang#133746 (Change `AttrArgs::Eq` to a struct variant) - rust-lang#133763 (Fix `f16::midpoint` const feature gate) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#133610 - camelid:move-from_anon_const, r=BoxyUwU Move `Const::{from_anon_const,try_from_lit}` to hir_ty_lowering Fixes rust-lang#128176. This accomplishes one of the followup items from rust-lang#131081. These operations are much more about lowering the HIR than about `Const`s themselves. They fit better in hir_ty_lowering with `lower_const_arg` (formerly `Const::from_const_arg`) and the rest. To accomplish this, `const_evaluatable_predicates_of` had to be changed to not use `from_anon_const` anymore. Instead of visiting the HIR and lowering anon consts on the fly, it now visits the `rustc_middle::ty` data structures instead and directly looks for `UnevaluatedConst`s. This approach was proposed in: rust-lang#131081 (comment) r? `@BoxyUwU`
Fixes #128176.
This accomplishes one of the followup items from #131081.
These operations are much more about lowering the HIR than about
Consts themselves. They fit better in hir_ty_lowering withlower_const_arg(formerlyConst::from_const_arg) and the rest.To accomplish this,
const_evaluatable_predicates_ofhad to be changedto not use
from_anon_constanymore. Instead of visiting the HIR andlowering anon consts on the fly, it now visits the
rustc_middle::tydata structures instead and directly looks for
UnevaluatedConsts. Thisapproach was proposed in:
#131081 (comment)
r? @BoxyUwU