Use fewer origins when creating type variables.#124955
Merged
bors merged 2 commits intorust-lang:masterfrom May 10, 2024
Merged
Use fewer origins when creating type variables.#124955bors merged 2 commits intorust-lang:masterfrom
bors merged 2 commits intorust-lang:masterfrom
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.
Collaborator
|
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 |
Contributor
|
really happy about your focus on cleaning up rustc, work like this is incredibly valuable ❤️ @bors r+ rollup |
Collaborator
Contributor
Author
|
Thanks! I find cleanup work valuable, it's nice to hear when others agree :) |
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
May 10, 2024
…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
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
May 10, 2024
…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
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
May 10, 2024
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``
flip1995
pushed a commit
to flip1995/rust
that referenced
this pull request
May 17, 2024
Use fewer origins when creating type variables. To reduce lots of repetitive boilerplate code. Details in the individual commit messages. r? ``@lcnr``
flip1995
pushed a commit
to flip1995/rust
that referenced
this pull request
May 17, 2024
…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
github-merge-queue bot
pushed a commit
to servo/servo
that referenced
this pull request
Jul 30, 2024
* 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>
github-merge-queue bot
pushed a commit
to servo/servo
that referenced
this pull request
Aug 7, 2024
* 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>
Gae24
pushed a commit
to Gae24/servo
that referenced
this pull request
Aug 7, 2024
* 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
To reduce lots of repetitive boilerplate code. Details in the individual commit messages.
r? @lcnr