Skip to content

Commit 5253b0a

Browse files
committed
Auto merge of rust-lang#101949 - matthiaskrgr:rollup-xu5cqnd, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#101093 (Initial version of 1.64 release notes) - rust-lang#101713 (change AccessLevels representation) - rust-lang#101821 (Bump Unicode to version 15.0.0, regenerate tables) - rust-lang#101826 (Enforce "joined()" and "joined_with_noop()" test) - rust-lang#101835 (Allow using vendoring when running bootstrap from outside the source root) - rust-lang#101942 (Revert "Copy stage0 binaries into stage0-sysroot") - rust-lang#101943 (rustdoc: remove unused CSS `.non-exhaustive { margin-bottom }`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 98ad6a5 + 5ba52ca commit 5253b0a

File tree

22 files changed

+597
-373
lines changed

22 files changed

+597
-373
lines changed

RELEASES.md

+152
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,155 @@
1+
Version 1.64.0 (2022-09-22)
2+
===========================
3+
4+
Language
5+
--------
6+
- [make `const_err` show up in future breakage reports](https://github.com/rust-lang/rust/pull/97743/)
7+
- [allow unions with mutable references and tuples of allowed types](https://github.com/rust-lang/rust/pull/97995/)
8+
- It is now considered valid to deallocate memory pointed to by a shared reference `&T` [if every byte in `T` is inside an `UnsafeCell`](https://github.com/rust-lang/rust/pull/98017/)
9+
- Unused tuple struct fields are now warned against in an allow-by-default lint, [`unused_tuple_struct_fields`](https://github.com/rust-lang/rust/pull/95977/), similar to the existing warning for unused struct fields. This lint will become warn-by-default in the future.
10+
11+
Compiler
12+
--------
13+
- The minimum required versions for all `-linux-gnu` targets are now at least kernel 3.2 and glibc 2.17, for targets that previously supported older versions: [Increase the minimum linux-gnu versions](https://github.com/rust-lang/rust/pull/95026/)
14+
- [Keep unstable target features for asm feature checking](https://github.com/rust-lang/rust/pull/99155/)
15+
- [Add Nintendo Switch as tier 3 target](https://github.com/rust-lang/rust/pull/88991/)
16+
- Refer to Rust's [platform support page][platform-support-doc] for more
17+
information on Rust's tiered platform support.
18+
- [Only compile #[used] as llvm.compiler.used for ELF targets](https://github.com/rust-lang/rust/pull/93718/)
19+
- [sess: stabilize `-Zterminal-width` as `--diagnostic-width`](https://github.com/rust-lang/rust/pull/95635/)
20+
- [Fix repr(align) enum handling](https://github.com/rust-lang/rust/pull/96814/)
21+
- [Suggest defining variable as mutable on `&mut _` type mismatch in pats](https://github.com/rust-lang/rust/pull/98431/)
22+
- [Emit warning when named arguments are used positionally in format](https://github.com/rust-lang/rust/pull/98580/)
23+
- [Add support for link-flavor rust-lld for iOS, tvOS and watchOS](https://github.com/rust-lang/rust/pull/98771/)
24+
- [Do not mention private types from other crates as impl candidates](https://github.com/rust-lang/rust/pull/99091/)
25+
26+
Libraries
27+
---------
28+
- [Implement network primitives with ideal Rust layout, not C system layout](https://github.com/rust-lang/rust/pull/78802/)
29+
- [Remove restrictions on compare-exchange memory ordering.](https://github.com/rust-lang/rust/pull/98383/)
30+
- You can now `write!` or `writeln!` into an `OsString`: [Implement `fmt::Write` for `OsString`](https://github.com/rust-lang/rust/pull/97915/)
31+
- [Enforce that layout size fits in isize in Layout](https://github.com/rust-lang/rust/pull/95295/)
32+
- [Make RwLockReadGuard covariant](https://github.com/rust-lang/rust/pull/96820/)
33+
- [Implement `FusedIterator` for `std::net::[Into]Incoming`](https://github.com/rust-lang/rust/pull/97300/)
34+
- [`impl<T: AsRawFd> AsRawFd for {Arc,Box}<T>`](https://github.com/rust-lang/rust/pull/97437/)
35+
- [ptr::copy and ptr::swap are doing untyped copies](https://github.com/rust-lang/rust/pull/97712/)
36+
- [Add assertion that `transmute_copy`'s U is not larger than T](https://github.com/rust-lang/rust/pull/98839/)
37+
- [A soundness bug in `BTreeMap` was fixed](https://github.com/rust-lang/rust/pull/99413/) that allowed data it was borrowing to be dropped before the container.
38+
- [Add cgroupv1 support to `available_parallelism`](https://github.com/rust-lang/rust/pull/97925/)
39+
- [mem::uninitialized: mitigate many incorrect uses of this function](https://github.com/rust-lang/rust/pull/99182/)
40+
41+
Stabilized APIs
42+
---------------
43+
44+
- [`ffi::CStr`](https://doc.rust-lang.org/stable/std/ffi/struct.CStr.html)
45+
- [`ffi::CString`](https://doc.rust-lang.org/stable/std/ffi/struct.CString.html)
46+
- [`ffi::FromBytesWithNulError`](https://doc.rust-lang.org/stable/std/ffi/struct.FromBytesWithNulError.html)
47+
- [`ffi::FromVecWithNulError`](https://doc.rust-lang.org/stable/std/ffi/struct.FromVecWithNulError.html)
48+
- [`ffi::IntoStringError`](https://doc.rust-lang.org/stable/std/ffi/struct.IntoStringError.html)
49+
- [`ffi::NulError`](https://doc.rust-lang.org/stable/std/ffi/struct.NulError.html)
50+
- [`ffi::c_char`](https://doc.rust-lang.org/stable/std/ffi/type.c_char.html)
51+
- [`ffi::c_double`](https://doc.rust-lang.org/stable/std/ffi/type.c_double.html)
52+
- [`ffi::c_float`](https://doc.rust-lang.org/stable/std/ffi/type.c_float.html)
53+
- [`ffi::c_int`](https://doc.rust-lang.org/stable/std/ffi/type.c_int.html)
54+
- [`ffi::c_long`](https://doc.rust-lang.org/stable/std/ffi/type.c_long.html)
55+
- [`ffi::c_longlong`](https://doc.rust-lang.org/stable/std/ffi/type.c_longlong.html)
56+
- [`ffi::c_schar`](https://doc.rust-lang.org/stable/std/ffi/type.c_schar.html)
57+
- [`ffi::c_short`](https://doc.rust-lang.org/stable/std/ffi/type.c_short.html)
58+
- [`ffi::c_uchar`](https://doc.rust-lang.org/stable/std/ffi/type.c_uchar.html)
59+
- [`ffi::c_uint`](https://doc.rust-lang.org/stable/std/ffi/type.c_uint.html)
60+
- [`ffi::c_ulong`](https://doc.rust-lang.org/stable/std/ffi/type.c_ulong.html)
61+
- [`ffi::c_ulonglong`](https://doc.rust-lang.org/stable/std/ffi/type.c_ulonglong.html)
62+
- [`ffi::c_ushort`](https://doc.rust-lang.org/stable/std/ffi/type.c_ushort.html)
63+
- [`future::IntoFuture`](https://doc.rust-lang.org/stable/std/future/trait.IntoFuture.html)
64+
- [`future::poll_fn`](https://doc.rust-lang.org/stable/std/future/fn.poll_fn.html)
65+
- [`task::ready!`](https://doc.rust-lang.org/stable/std/task/macro.ready.html)
66+
- [`num::NonZero*::checked_mul`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroUsize.html#method.checked_mul)
67+
- [`num::NonZero*::checked_pow`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroUsize.html#method.checked_pow)
68+
- [`num::NonZero*::saturating_mul`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroUsize.html#method.saturating_mul)
69+
- [`num::NonZero*::saturating_pow`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroUsize.html#method.saturating_pow)
70+
- [`num::NonZeroI*::abs`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroIsize.html#method.abs)
71+
- [`num::NonZeroI*::checked_abs`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroIsize.html#method.checked_abs)
72+
- [`num::NonZeroI*::overflowing_abs`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroIsize.html#method.overflowing_abs)
73+
- [`num::NonZeroI*::saturating_abs`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroIsize.html#method.saturating_abs)
74+
- [`num::NonZeroI*::unsigned_abs`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroIsize.html#method.unsigned_abs)
75+
- [`num::NonZeroI*::wrapping_abs`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroIsize.html#method.wrapping_abs)
76+
- [`num::NonZeroU*::checked_add`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroUsize.html#method.checked_add)
77+
- [`num::NonZeroU*::checked_next_power_of_two`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroUsize.html#method.checked_next_power_of_two)
78+
- [`num::NonZeroU*::saturating_add`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroUsize.html#method.saturating_add)
79+
- [`os::unix::process::CommandExt::process_group`](https://doc.rust-lang.org/stable/std/os/unix/process/trait.CommandExt.html#tymethod.process_group)
80+
- [`os::windows::fs::FileTypeExt::is_symlink_dir`](https://doc.rust-lang.org/stable/std/os/windows/fs/trait.FileTypeExt.html#tymethod.is_symlink_dir)
81+
- [`os::windows::fs::FileTypeExt::is_symlink_file`](https://doc.rust-lang.org/stable/std/os/windows/fs/trait.FileTypeExt.html#tymethod.is_symlink_file)
82+
83+
These APIs are now usable in const contexts:
84+
85+
- [`slice::from_raw_parts`](https://doc.rust-lang.org/stable/core/slice/fn.from_raw_parts.html)
86+
87+
Cargo
88+
-----
89+
- Packages can now inherit settings from the workspace so that the settings
90+
can be centralized in one place. See
91+
[`workspace.package`](https://doc.rust-lang.org/nightly/cargo/reference/workspaces.html#the-workspacepackage-table)
92+
and
93+
[`workspace.dependencies`](https://doc.rust-lang.org/nightly/cargo/reference/workspaces.html#the-workspacedependencies-table)
94+
for more details on how to define these common settings.
95+
[#10859](https://github.com/rust-lang/cargo/pull/10859)
96+
- Cargo commands can now accept multiple `--target` flags to build for
97+
multiple targets at once, and the
98+
[`build.target`](https://doc.rust-lang.org/nightly/cargo/reference/config.html#buildtarget)
99+
config option may now take an array of multiple targets.
100+
[#10766](https://github.com/rust-lang/cargo/pull/10766)
101+
- The `--jobs` argument can now take a negative number to count backwards from
102+
the max CPUs.
103+
[#10844](https://github.com/rust-lang/cargo/pull/10844)
104+
- `cargo add` will now update `Cargo.lock`.
105+
[#10902](https://github.com/rust-lang/cargo/pull/10902)
106+
- Added the
107+
[`--crate-type`](https://doc.rust-lang.org/nightly/cargo/commands/cargo-rustc.html#option-cargo-rustc---crate-type)
108+
flag to `cargo rustc` to override the crate type.
109+
[#10838](https://github.com/rust-lang/cargo/pull/10838)
110+
- Significantly improved the performance fetching git dependencies from GitHub
111+
when using a hash in the `rev` field.
112+
[#10079](https://github.com/rust-lang/cargo/pull/10079)
113+
114+
Misc
115+
----
116+
- [Let rust-analyzer ship on stable, non-preview](https://github.com/rust-lang/rust/pull/98640/)
117+
118+
Compatibility Notes
119+
-------------------
120+
- The minimum required versions for all `-linux-gnu` targets are now at least kernel 3.2 and glibc 2.17, for targets that previously supported older versions: [Increase the minimum linux-gnu versions](https://github.com/rust-lang/rust/pull/95026/)
121+
- [Implement network primitives with ideal Rust layout, not C system layout](https://github.com/rust-lang/rust/pull/78802/)
122+
- [Add assertion that `transmute_copy`'s U is not larger than T](https://github.com/rust-lang/rust/pull/98839/)
123+
- [A soundness bug in `BTreeMap` was fixed](https://github.com/rust-lang/rust/pull/99413/) that allowed data it was borrowing to be dropped before the container.
124+
- [The Drop behavior of C-like enums cast to ints has changed](https://github.com/rust-lang/rust/pull/96862/). These are already discouraged by a compiler warning.
125+
- [Relate late-bound closure lifetimes to parent fn in NLL](https://github.com/rust-lang/rust/pull/98835/)
126+
- [Errors at const-eval time are now in future incompatibility reports](https://github.com/rust-lang/rust/pull/97743/)
127+
- On the `thumbv6m-none-eabi` target, some incorrect `asm!` statements were erroneously accepted if they used the high registers (r8 to r14) as an input/output operand. [This is no longer accepted](https://github.com/rust-lang/rust/pull/99155/).
128+
- [`impl Trait` was accidentally accepted as the associated type value of return-position `impl Trait`](https://github.com/rust-lang/rust/pull/97346/), without fulfilling all the trait bounds of that associated type, as long as the hidden type satisfies said bounds. This has been fixed.
129+
130+
Internal Changes
131+
----------------
132+
133+
These changes do not affect any public interfaces of Rust, but they represent
134+
significant improvements to the performance or internals of rustc and related
135+
tools.
136+
137+
- Windows builds now use profile-guided optimization, providing 10-20% improvements to compiler performance: [Utilize PGO for windows x64 rustc dist builds](https://github.com/rust-lang/rust/pull/96978/)
138+
- [Stop keeping metadata in memory before writing it to disk](https://github.com/rust-lang/rust/pull/96544/)
139+
- [compiletest: strip debuginfo by default for mode=ui](https://github.com/rust-lang/rust/pull/98140/)
140+
- Many improvements to generated code for derives, including performance improvements:
141+
- [Don't use match-destructuring for derived ops on structs.](https://github.com/rust-lang/rust/pull/98446/)
142+
- [Many small deriving cleanups](https://github.com/rust-lang/rust/pull/98741/)
143+
- [More derive output improvements](https://github.com/rust-lang/rust/pull/98758/)
144+
- [Clarify deriving code](https://github.com/rust-lang/rust/pull/98915/)
145+
- [Final derive output improvements](https://github.com/rust-lang/rust/pull/99046/)
146+
- [Stop injecting `#[allow(unused_qualifications)]` in generated `derive` implementations](https://github.com/rust-lang/rust/pull/99485/)
147+
- [Improve `derive(Debug)`](https://github.com/rust-lang/rust/pull/98190/)
148+
- [Bump to clap 3](https://github.com/rust-lang/rust/pull/98213/)
149+
- [fully move dropck to mir](https://github.com/rust-lang/rust/pull/98641/)
150+
- [Optimize `Vec::insert` for the case where `index == len`.](https://github.com/rust-lang/rust/pull/98755/)
151+
- [Convert rust-analyzer to an in-tree tool](https://github.com/rust-lang/rust/pull/99603/)
152+
1153
Version 1.63.0 (2022-08-11)
2154
==========================
3155

compiler/rustc_error_messages/locales/en-US/privacy.ftl

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ privacy_in_public_interface = {$vis_descr} {$kind} `{$descr}` in public interfac
1111
.label = can't leak {$vis_descr} {$kind}
1212
.visibility_label = `{$descr}` declared as {$vis_descr}
1313
14-
privacy_report_access_level = {$descr}
14+
privacy_report_effective_visibility = {$descr}
1515
1616
privacy_from_private_dep_in_public_interface =
1717
{$kind} `{$descr}` from private dependency '{$krate}' in public interface

compiler/rustc_feature/src/builtin_attrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
762762
// Internal attributes, Testing:
763763
// ==========================================================================
764764

765-
rustc_attr!(TEST, rustc_access_level, Normal, template!(Word), WarnFollowing),
765+
rustc_attr!(TEST, rustc_effective_visibility, Normal, template!(Word), WarnFollowing),
766766
rustc_attr!(TEST, rustc_outlives, Normal, template!(Word), WarnFollowing),
767767
rustc_attr!(TEST, rustc_capture_analysis, Normal, template!(Word), WarnFollowing),
768768
rustc_attr!(TEST, rustc_insignificant_dtor, Normal, template!(Word), WarnFollowing),

compiler/rustc_middle/src/middle/privacy.rs

+87-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! A pass that checks to make sure private fields and methods aren't used
22
//! outside their scopes. This pass will also generate a set of exported items
33
//! which are available for use externally when compiled as a library.
4-
4+
use crate::ty::Visibility;
55
use rustc_data_structures::fx::FxHashMap;
66
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
77
use rustc_macros::HashStable;
@@ -27,26 +27,107 @@ pub enum AccessLevel {
2727
Public,
2828
}
2929

30+
#[derive(Clone, Copy, PartialEq, Eq, Debug, HashStable, Default)]
31+
pub struct EffectiveVisibility {
32+
public: Option<Visibility>,
33+
exported: Option<Visibility>,
34+
reachable: Option<Visibility>,
35+
reachable_from_impl_trait: Option<Visibility>,
36+
}
37+
38+
impl EffectiveVisibility {
39+
pub fn get(&self, tag: AccessLevel) -> Option<&Visibility> {
40+
match tag {
41+
AccessLevel::Public => &self.public,
42+
AccessLevel::Exported => &self.exported,
43+
AccessLevel::Reachable => &self.reachable,
44+
AccessLevel::ReachableFromImplTrait => &self.reachable_from_impl_trait,
45+
}
46+
.as_ref()
47+
}
48+
49+
fn get_mut(&mut self, tag: AccessLevel) -> &mut Option<Visibility> {
50+
match tag {
51+
AccessLevel::Public => &mut self.public,
52+
AccessLevel::Exported => &mut self.exported,
53+
AccessLevel::Reachable => &mut self.reachable,
54+
AccessLevel::ReachableFromImplTrait => &mut self.reachable_from_impl_trait,
55+
}
56+
}
57+
58+
pub fn is_public_at_level(&self, tag: AccessLevel) -> bool {
59+
self.get(tag).map_or(false, |vis| vis.is_public())
60+
}
61+
}
62+
3063
/// Holds a map of accessibility levels for reachable HIR nodes.
3164
#[derive(Debug, Clone)]
3265
pub struct AccessLevels<Id = LocalDefId> {
33-
pub map: FxHashMap<Id, AccessLevel>,
66+
map: FxHashMap<Id, EffectiveVisibility>,
3467
}
3568

36-
impl<Id: Hash + Eq> AccessLevels<Id> {
69+
impl<Id: Hash + Eq + Copy> AccessLevels<Id> {
70+
pub fn is_public_at_level(&self, id: Id, tag: AccessLevel) -> bool {
71+
self.get_effective_vis(id)
72+
.map_or(false, |effective_vis| effective_vis.is_public_at_level(tag))
73+
}
74+
3775
/// See `AccessLevel::Reachable`.
3876
pub fn is_reachable(&self, id: Id) -> bool {
39-
self.map.get(&id) >= Some(&AccessLevel::Reachable)
77+
self.is_public_at_level(id, AccessLevel::Reachable)
4078
}
4179

4280
/// See `AccessLevel::Exported`.
4381
pub fn is_exported(&self, id: Id) -> bool {
44-
self.map.get(&id) >= Some(&AccessLevel::Exported)
82+
self.is_public_at_level(id, AccessLevel::Exported)
4583
}
4684

4785
/// See `AccessLevel::Public`.
4886
pub fn is_public(&self, id: Id) -> bool {
49-
self.map.get(&id) >= Some(&AccessLevel::Public)
87+
self.is_public_at_level(id, AccessLevel::Public)
88+
}
89+
90+
pub fn get_access_level(&self, id: Id) -> Option<AccessLevel> {
91+
self.get_effective_vis(id).and_then(|effective_vis| {
92+
for level in [
93+
AccessLevel::Public,
94+
AccessLevel::Exported,
95+
AccessLevel::Reachable,
96+
AccessLevel::ReachableFromImplTrait,
97+
] {
98+
if effective_vis.is_public_at_level(level) {
99+
return Some(level);
100+
}
101+
}
102+
None
103+
})
104+
}
105+
106+
pub fn set_access_level(&mut self, id: Id, tag: AccessLevel) {
107+
let mut effective_vis = self.get_effective_vis(id).copied().unwrap_or_default();
108+
for level in [
109+
AccessLevel::Public,
110+
AccessLevel::Exported,
111+
AccessLevel::Reachable,
112+
AccessLevel::ReachableFromImplTrait,
113+
] {
114+
if level <= tag {
115+
*effective_vis.get_mut(level) = Some(Visibility::Public);
116+
}
117+
}
118+
self.map.insert(id, effective_vis);
119+
}
120+
121+
pub fn get_effective_vis(&self, id: Id) -> Option<&EffectiveVisibility> {
122+
self.map.get(&id)
123+
}
124+
125+
pub fn iter(&self) -> impl Iterator<Item = (&Id, &EffectiveVisibility)> {
126+
self.map.iter()
127+
}
128+
129+
pub fn map_id<OutId: Hash + Eq + Copy>(&self, f: impl Fn(Id) -> OutId) -> AccessLevels<OutId> {
130+
AccessLevels { map: self.map.iter().map(|(k, v)| (f(*k), *v)).collect() }
50131
}
51132
}
52133

compiler/rustc_passes/src/dead.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_hir::def_id::{DefId, LocalDefId};
1111
use rustc_hir::intravisit::{self, Visitor};
1212
use rustc_hir::{Node, PatKind, TyKind};
1313
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
14-
use rustc_middle::middle::privacy;
14+
use rustc_middle::middle::privacy::AccessLevel;
1515
use rustc_middle::ty::query::Providers;
1616
use rustc_middle::ty::{self, DefIdTree, TyCtxt};
1717
use rustc_session::lint;
@@ -619,13 +619,10 @@ fn create_and_seed_worklist<'tcx>(
619619
// see `MarkSymbolVisitor::struct_constructors`
620620
let mut struct_constructors = Default::default();
621621
let mut worklist = access_levels
622-
.map
623622
.iter()
624-
.filter_map(
625-
|(&id, &level)| {
626-
if level >= privacy::AccessLevel::Reachable { Some(id) } else { None }
627-
},
628-
)
623+
.filter_map(|(&id, effective_vis)| {
624+
effective_vis.is_public_at_level(AccessLevel::Reachable).then_some(id)
625+
})
629626
// Seed entry point
630627
.chain(tcx.entry_fn(()).and_then(|(def_id, _)| def_id.as_local()))
631628
.collect::<Vec<_>>();

compiler/rustc_passes/src/reachable.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_hir::def_id::{DefId, LocalDefId};
1212
use rustc_hir::intravisit::{self, Visitor};
1313
use rustc_hir::Node;
1414
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
15-
use rustc_middle::middle::privacy;
15+
use rustc_middle::middle::privacy::{self, AccessLevel};
1616
use rustc_middle::ty::query::Providers;
1717
use rustc_middle::ty::{self, DefIdTree, TyCtxt};
1818
use rustc_session::config::CrateType;
@@ -373,7 +373,13 @@ fn reachable_set<'tcx>(tcx: TyCtxt<'tcx>, (): ()) -> FxHashSet<LocalDefId> {
373373
// If other crates link to us, they're going to expect to be able to
374374
// use the lang items, so we need to be sure to mark them as
375375
// exported.
376-
reachable_context.worklist.extend(access_levels.map.keys());
376+
reachable_context.worklist = access_levels
377+
.iter()
378+
.filter_map(|(&id, effective_vis)| {
379+
effective_vis.is_public_at_level(AccessLevel::ReachableFromImplTrait).then_some(id)
380+
})
381+
.collect::<Vec<_>>();
382+
377383
for item in tcx.lang_items().items().iter() {
378384
if let Some(def_id) = *item {
379385
if let Some(def_id) = def_id.as_local() {

0 commit comments

Comments
 (0)