rustc_resolve: Further reduce mutability in resolver - #160090
Conversation
|
I'll try changing |
|
Reminder, once the PR becomes ready for a review, use |
|
I'm not sure how difficult this would be or whether it's feasible, but could we use different types for |
Not feasible, functions taking Or rather infeasible without duplicating a large number of resolver functions. |
This comment has been minimized.
This comment has been minimized.
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
rustc_resolve: Further reduce mutability in resolver
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (df44b1a): comparison URL. Overall result: ❌ regressions - no action neededBenchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up. @rustbot label: -S-waiting-on-perf -perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 3.7%, secondary 0.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 2.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 490.002s -> 491.705s (0.35%) |
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@rustbot ready |
|
@bors r+ rollup |
rustc_resolve: Further reduce mutability in resolver `resolver.cm()` now returns a conditionally mutable reference (`RefOrMut`) that cannot be mutated, and `resolver.cm_mut()` returns a conditionally mutable reference that can be mutated. The "can be mutated" property is checked dynamically, so this can potentially panic in some obscure error reporting cases not covered by the test suite, but they should be easily fixable and will be caught sooner or later, but it's more useful to see which code path *actually* use resolver in mutable way rather than just take `RefOrMut`. The second commit uses standard `NonNull` in the implementation of `RefOrMut`. r? @mu001999 cc @LorrensP-2158466
Rollup of 17 pull requests Successful merges: - #159014 ([rustdoc] Do not take `doc(cfg())` into account when filtering doctests) - #159130 (a bit optimize four-digit chunks in integer formatting) - #159592 (core: implement bounded random sampling) - #159898 (Add intrinsic-test alias and set sample rate) - #158247 (hermit/fs: Return `unsupported()` instead of `from_raw_os_error(22)`) - #158649 (Hermit: fix `readdir()` ) - #159049 (Avoid ICE in From/TryFrom cast suggestion when encountering HRTBs) - #160053 (test: add test suite for the 85681 issue) - #160087 (Add regression test for nested associated-type projection ICE) - #160090 (rustc_resolve: Further reduce mutability in resolver) - #160099 (Resolver: split module resolutions into local and external resolutions) - #160106 (Add suggestions for `must_implement_one_of`) - #160117 (Remove unnecessary format usage) - #160134 (Work around Wine bug 60084 by calling WSAStartup at most once) - #160142 (bootstrap: remove use-lld config alias) - #160148 (Rename `errors.rs` file to `diagnostics.rs` (15/N)) - #160151 (Mark a doctest as requiring unwinding)
rustc_resolve: Further reduce mutability in resolver `resolver.cm()` now returns a conditionally mutable reference (`RefOrMut`) that cannot be mutated, and `resolver.cm_mut()` returns a conditionally mutable reference that can be mutated. The "can be mutated" property is checked dynamically, so this can potentially panic in some obscure error reporting cases not covered by the test suite, but they should be easily fixable and will be caught sooner or later, but it's more useful to see which code path *actually* use resolver in mutable way rather than just take `RefOrMut`. The second commit uses standard `NonNull` in the implementation of `RefOrMut`. r? @mu001999 cc @LorrensP-2158466
Rollup of 18 pull requests Successful merges: - #159130 (a bit optimize four-digit chunks in integer formatting) - #159592 (core: implement bounded random sampling) - #159898 (Add intrinsic-test alias and set sample rate) - #158247 (hermit/fs: Return `unsupported()` instead of `from_raw_os_error(22)`) - #158649 (Hermit: fix `readdir()` ) - #159049 (Avoid ICE in From/TryFrom cast suggestion when encountering HRTBs) - #160053 (test: add test suite for the 85681 issue) - #160087 (Add regression test for nested associated-type projection ICE) - #160090 (rustc_resolve: Further reduce mutability in resolver) - #160099 (Resolver: split module resolutions into local and external resolutions) - #160106 (Add suggestions for `must_implement_one_of`) - #160117 (Remove unnecessary format usage) - #160134 (Work around Wine bug 60084 by calling WSAStartup at most once) - #160139 (iter: specialize Take::count using advance_by) - #160142 (bootstrap: remove use-lld config alias) - #160148 (Rename `errors.rs` file to `diagnostics.rs` (15/N)) - #160151 (Mark a doctest as requiring unwinding) - #160166 (Use correct feature gates for `f16`/`f128` `From` impls)
rustc_resolve: Further reduce mutability in resolver `resolver.cm()` now returns a conditionally mutable reference (`RefOrMut`) that cannot be mutated, and `resolver.cm_mut()` returns a conditionally mutable reference that can be mutated. The "can be mutated" property is checked dynamically, so this can potentially panic in some obscure error reporting cases not covered by the test suite, but they should be easily fixable and will be caught sooner or later, but it's more useful to see which code path *actually* use resolver in mutable way rather than just take `RefOrMut`. The second commit uses standard `NonNull` in the implementation of `RefOrMut`. r? @mu001999 cc @LorrensP-2158466
…uwer Rollup of 18 pull requests Successful merges: - #159898 (Add intrinsic-test alias and set sample rate) - #158247 (hermit/fs: Return `unsupported()` instead of `from_raw_os_error(22)`) - #158649 (Hermit: fix `readdir()` ) - #158693 (Add type-check to offload intrinisc calls) - #159049 (Avoid ICE in From/TryFrom cast suggestion when encountering HRTBs) - #159411 ([rustdoc] Correctly handle output options with --show-coverage) - #160053 (test: add test suite for the 85681 issue) - #160087 (Add regression test for nested associated-type projection ICE) - #160090 (rustc_resolve: Further reduce mutability in resolver) - #160099 (Resolver: split module resolutions into local and external resolutions) - #160106 (Add suggestions for `must_implement_one_of`) - #160117 (Remove unnecessary format usage) - #160134 (Work around Wine bug 60084 by calling WSAStartup at most once) - #160139 (iter: specialize Take::count using advance_by) - #160142 (bootstrap: remove use-lld config alias) - #160148 (Rename `errors.rs` file to `diagnostics.rs` (15/N)) - #160151 (Mark a doctest as requiring unwinding) - #160166 (Use correct feature gates for `f16`/`f128` `From` impls)
Rollup of 20 pull requests Successful merges: - #157669 (cfi: add diag mode support) - #158247 (hermit/fs: Return `unsupported()` instead of `from_raw_os_error(22)`) - #158649 (Hermit: fix `readdir()` ) - #158693 (Add type-check to offload intrinisc calls) - #159049 (Avoid ICE in From/TryFrom cast suggestion when encountering HRTBs) - #159411 ([rustdoc] Correctly handle output options with --show-coverage) - #160053 (test: add test suite for the 85681 issue) - #160087 (Add regression test for nested associated-type projection ICE) - #160090 (rustc_resolve: Further reduce mutability in resolver) - #160099 (Resolver: split module resolutions into local and external resolutions) - #160101 (Add missing `needs-unwind` annotation to `add-spawn-hook-reentrancy-159923` test) - #160106 (Add suggestions for `must_implement_one_of`) - #160117 (Remove unnecessary format usage) - #160134 (Work around Wine bug 60084 by calling WSAStartup at most once) - #160139 (iter: specialize Take::count using advance_by) - #160142 (bootstrap: remove use-lld config alias) - #160148 (Rename `errors.rs` file to `diagnostics.rs` (15/N)) - #160151 (Mark a doctest as requiring unwinding) - #160166 (Use correct feature gates for `f16`/`f128` `From` impls) - #160178 (Remove unused `va_start` intrinsic)
Rollup of 20 pull requests Successful merges: - #157669 (cfi: add diag mode support) - #158247 (hermit/fs: Return `unsupported()` instead of `from_raw_os_error(22)`) - #158649 (Hermit: fix `readdir()` ) - #158693 (Add type-check to offload intrinisc calls) - #159049 (Avoid ICE in From/TryFrom cast suggestion when encountering HRTBs) - #159411 ([rustdoc] Correctly handle output options with --show-coverage) - #160053 (test: add test suite for the 85681 issue) - #160087 (Add regression test for nested associated-type projection ICE) - #160090 (rustc_resolve: Further reduce mutability in resolver) - #160099 (Resolver: split module resolutions into local and external resolutions) - #160101 (Add missing `needs-unwind` annotation to `add-spawn-hook-reentrancy-159923` test) - #160106 (Add suggestions for `must_implement_one_of`) - #160117 (Remove unnecessary format usage) - #160134 (Work around Wine bug 60084 by calling WSAStartup at most once) - #160139 (iter: specialize Take::count using advance_by) - #160142 (bootstrap: remove use-lld config alias) - #160148 (Rename `errors.rs` file to `diagnostics.rs` (15/N)) - #160151 (Mark a doctest as requiring unwinding) - #160166 (Use correct feature gates for `f16`/`f128` `From` impls) - #160178 (Remove unused `va_start` intrinsic)
Rollup merge of #160090 - petrochenkov:cmonst, r=mu001999 rustc_resolve: Further reduce mutability in resolver `resolver.cm()` now returns a conditionally mutable reference (`RefOrMut`) that cannot be mutated, and `resolver.cm_mut()` returns a conditionally mutable reference that can be mutated. The "can be mutated" property is checked dynamically, so this can potentially panic in some obscure error reporting cases not covered by the test suite, but they should be easily fixable and will be caught sooner or later, but it's more useful to see which code path *actually* use resolver in mutable way rather than just take `RefOrMut`. The second commit converts `RefOrMut` to an enum instead of using raw pointers. r? @mu001999 cc @LorrensP-2158466
|
@rust-timer build 3bb5bfc |
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (3bb5bfc): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up. @rustbot label: -S-waiting-on-perf -perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -1.2%, secondary 0.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 0.2%, secondary -3.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 491.471s -> 489.765s (-0.35%) |
resolver.cm()now returns a conditionally mutable reference (RefOrMut) that cannot be mutated, andresolver.cm_mut()returns a conditionally mutable reference that can be mutated.The "can be mutated" property is checked dynamically, so this can potentially panic in some obscure error reporting cases not covered by the test suite, but they should be easily fixable and will be caught sooner or later, but it's more useful to see which code path actually use resolver in mutable way rather than just take
RefOrMut.The second commit converts
RefOrMutto an enum instead of using raw pointers.r? @mu001999
cc @LorrensP-2158466