-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Use fewer origins when creating type variables. #124955
Conversation
`InferCtxt::next_{ty,const,int,float}_var_id` each have a single call site, in `InferCtt::next_{ty,const,int,float}_var` respectively. The only remaining method that creates a var_id is `InferCtxt::next_ty_var_id_in_universe`, which has one use outside the crate.
`InferCtxt::next_{ty,const}_var*` all take an origin, but the `param_def_id` is almost always `None`. This commit changes them to just take a `Span` and build the origin within the method, and adds new methods for the rare cases where `param_def_id` might not be `None`. This avoids a lot of tedious origin building. Specifically: - next_ty_var{,_id_in_universe,_in_universe}: now take `Span` instead of `TypeVariableOrigin` - next_ty_var_with_origin: added - next_const_var{,_in_universe}: takes Span instead of ConstVariableOrigin - next_const_var_with_origin: added - next_region_var, next_region_var_in_universe: these are unchanged, still take RegionVariableOrigin The API inconsistency (ty/const vs region) seems worth it for the large conciseness improvements.
Some changes occurred in match lowering cc @Nadrieril Some changes occurred in need_type_info.rs cc @lcnr Some changes occurred in src/tools/clippy cc @rust-lang/clippy Some changes occurred to the core trait solver cc @rust-lang/initiative-trait-system-refactor changes to the core type system |
really happy about your focus on cleaning up rustc, work like this is incredibly valuable ❤️ @bors r+ rollup |
Thanks! I find cleanup work valuable, it's nice to hear when others agree :) |
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#124551 (Add benchmarks for `impl Debug for str`) - rust-lang#124914 (Remove `#[macro_use] extern crate rustc middle` from numerous crates) - rust-lang#124915 (`rustc_target` cleanups) - rust-lang#124918 (Eliminate some `FIXME(lcnr)` comments) - rust-lang#124927 (opt-dist: use xz2 instead of xz crate) - rust-lang#124936 (analyse visitor: build proof tree in probe) - rust-lang#124943 (always use `GenericArgsRef`) Failed merges: - rust-lang#124955 (Use fewer origins when creating type variables.) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#124551 (Add benchmarks for `impl Debug for str`) - rust-lang#124915 (`rustc_target` cleanups) - rust-lang#124918 (Eliminate some `FIXME(lcnr)` comments) - rust-lang#124927 (opt-dist: use xz2 instead of xz crate) - rust-lang#124936 (analyse visitor: build proof tree in probe) - rust-lang#124943 (always use `GenericArgsRef`) - rust-lang#124955 (Use fewer origins when creating type variables.) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#124955 - nnethercote:next_ty_var, r=lcnr Use fewer origins when creating type variables. To reduce lots of repetitive boilerplate code. Details in the individual commit messages. r? ``@lcnr``
Use fewer origins when creating type variables. To reduce lots of repetitive boilerplate code. Details in the individual commit messages. r? ``@lcnr``
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#124551 (Add benchmarks for `impl Debug for str`) - rust-lang#124915 (`rustc_target` cleanups) - rust-lang#124918 (Eliminate some `FIXME(lcnr)` comments) - rust-lang#124927 (opt-dist: use xz2 instead of xz crate) - rust-lang#124936 (analyse visitor: build proof tree in probe) - rust-lang#124943 (always use `GenericArgsRef`) - rust-lang#124955 (Use fewer origins when creating type variables.) r? `@ghost` `@rustbot` modify labels: rollup
* Update for nix Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * Update to Rust 1.80.0 Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * Rename to BindingMode from BindingAnnotation rust-lang/rust#124047 Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * Remove TypeVariableOriginKind rust-lang/rust#123016 Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * Remove TypeVariableOrigin rust-lang/rust#124955 Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * Remove LintDiagnostic::msg rust-lang/rust#125410 Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * common.rs fmt mistake indents Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * trace_in_no_trace.rs remove mistake space Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * trace_in_no_trace.rs remove mistake head space Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> --------- Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
* Update for nix Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * Update to Rust 1.80.0 Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * Rename to BindingMode from BindingAnnotation rust-lang/rust#124047 Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * Remove TypeVariableOriginKind rust-lang/rust#123016 Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * Remove TypeVariableOrigin rust-lang/rust#124955 Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * Remove LintDiagnostic::msg rust-lang/rust#125410 Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * common.rs fmt mistake indents Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * trace_in_no_trace.rs remove mistake space Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * trace_in_no_trace.rs remove mistake head space Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * Workaround for #32912 It's dirty but it worked on 2000 runs Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --------- Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> Co-authored-by: Samson <16504129+sagudev@users.noreply.github.com>
* Update for nix Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * Update to Rust 1.80.0 Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * Rename to BindingMode from BindingAnnotation rust-lang/rust#124047 Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * Remove TypeVariableOriginKind rust-lang/rust#123016 Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * Remove TypeVariableOrigin rust-lang/rust#124955 Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * Remove LintDiagnostic::msg rust-lang/rust#125410 Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * common.rs fmt mistake indents Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * trace_in_no_trace.rs remove mistake space Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * trace_in_no_trace.rs remove mistake head space Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * Workaround for servo#32912 It's dirty but it worked on 2000 runs Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --------- Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> Co-authored-by: Samson <16504129+sagudev@users.noreply.github.com>
To reduce lots of repetitive boilerplate code. Details in the individual commit messages.
r? @lcnr