Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
721e0a8
modify `asm_experimental_reg` example to not need x86_64
folkertdev Jul 18, 2026
b68b9bc
stabilize passing 128-bit integers via vector registers with `asm!` o…
folkertdev Jul 18, 2026
dcf4a3d
allocations are allowed to grow
RalfJung Jul 22, 2026
076de87
[Priroda] Add source-shaped value UI coverage
moabo3li Jul 24, 2026
ad3ce24
test: add regression test for bool indexing codegen
amirHdev Jul 26, 2026
bc56612
Prepare for merging from rust-lang/rust
Jul 27, 2026
0a7b19e
Merge ref 'dfbea5bc945a' from rust-lang/rust
Jul 27, 2026
a3eac7e
fmt
Jul 27, 2026
316b77b
skip weak memory buffer handling when there is only one thread
RalfJung Jul 14, 2026
83a423b
bless test-cargo-miri
RalfJung Jul 27, 2026
47dfbec
Merge pull request #5191 from RalfJung/single-thread-no-store-buffer
RalfJung Jul 27, 2026
2e6ce93
Merge pull request #5228 from rust-lang/rustup-2026-07-27
RalfJung Jul 27, 2026
47eb30f
[Priroda] Add source-shaped value renderer plumbing
moabo3li Jul 24, 2026
7edd27f
[Priroda] Render source-shaped struct values
moabo3li Jul 24, 2026
543afd7
[Priroda] Render source-shaped enum values
moabo3li Jul 24, 2026
65ee03d
[Priroda] Render source-shaped tuple values
moabo3li Jul 24, 2026
77b975c
[Priroda] Render source-shaped array and slice values
moabo3li Jul 24, 2026
925bc0e
fix ptr_from_addr_cast comment
zjp-CN Jul 28, 2026
d203782
Prepare for merging from rust-lang/rust
Jul 28, 2026
aa711f6
Merge ref 'd3ea0356830d' from rust-lang/rust
Jul 28, 2026
045757c
Merge pull request #5231 from KMiri-rs/fix-ptr_from_addr_cast-comment
RalfJung Jul 28, 2026
204ccaa
tests: libc-poll: test a more reaosnable FD number for POLLNVAL
RalfJung Jul 28, 2026
9c4c3fe
macos poll seems be kinda broken
RalfJung Jul 28, 2026
e80409a
Merge pull request #5232 from rust-lang/rustup-2026-07-28
RalfJung Jul 28, 2026
745f929
Merge pull request #5229 from moabo3li/locals-projected-names-and-typ…
oli-obk Jul 28, 2026
c10cc83
add aarch64 SHA256 intrinsics
jrakibi Jul 11, 2026
856278b
x86/sha: drop "reg" from variable names
jrakibi Jul 12, 2026
56f6073
Allow only implementing `Read::read_buf`
WaffleLapkin Jan 9, 2023
c78d212
Merge pull request #5064 from jrakibi/25-05-aarch64-sha256-intrinsics
RalfJung Jul 28, 2026
39429fd
Fix links to `std::io::Read::read`
joshtriplett Jul 28, 2026
20ac212
tests: prefer max-llvm-major-version over open LLVM ranges
AayushMainali-Github Jul 29, 2026
c72ad96
Prepare for merging from rust-lang/rust
Jul 29, 2026
6fc625b
Merge ref '701a6513a48e' from rust-lang/rust
Jul 29, 2026
8093103
Merge pull request #5233 from rust-lang/rustup-2026-07-29
RalfJung Jul 29, 2026
939e545
Prepare for merging from rust-lang/rust
Aug 1, 2026
660e976
Merge ref 'cb9d1b064054' from rust-lang/rust
Aug 1, 2026
d529bff
fmt
Aug 1, 2026
62def3b
Merge pull request #5236 from rust-lang/rustup-2026-08-01
RalfJung Aug 1, 2026
f31f253
Lower `mut` restriction to `ty::FieldDef`
CoCo-Japan-pan Jul 24, 2026
2fc373e
bless thir-print
CoCo-Japan-pan Jul 25, 2026
12a05e2
Emit error in mutation of restricted field
CoCo-Japan-pan Jul 24, 2026
0dcb605
Emit error in struct expressions with restricted fields
CoCo-Japan-pan Jul 25, 2026
8ebb026
Add UI tests for mutation of restricted fields
CoCo-Japan-pan Jul 24, 2026
dc78bf0
Add UI tests for mutating restricted fields with inline assembly
CoCo-Japan-pan Aug 1, 2026
2edaa5e
Add UI tests for struct expressions with restricted fields
CoCo-Japan-pan Jul 25, 2026
490f95c
Remove the incomplete marker from `mut` restrictions
CoCo-Japan-pan Aug 1, 2026
c9d77c9
show clear error when encountering an argfile
RalfJung Aug 1, 2026
61f9cf8
Merge pull request #5237 from RalfJung/cargo-miri-argfile
RalfJung Aug 1, 2026
7d0aafd
Specialize `advance_by` method of `Fuse`
a1phyr Aug 1, 2026
e5b6364
fix: Do not stop `visible_parent_map` breadth-first search reaching c…
zalanlevai Jul 25, 2026
c4d12cb
Setup `core::io::prelude`
bushrat011899 May 21, 2026
0791c08
Setup `alloc::io::prelude`
bushrat011899 May 21, 2026
d951987
Expand documentation for `alloc::io`
bushrat011899 Jul 19, 2026
32117cd
Move general IO tests to `alloctests`
bushrat011899 May 21, 2026
125be4b
Move `std::io::util` tests to `alloctests`
bushrat011899 May 21, 2026
39bf757
Move `std::io::cursor` tests to `alloctests`
bushrat011899 May 21, 2026
f67f57d
Move `std::io::buffered` tests to `alloctests`
bushrat011899 May 21, 2026
29da936
Move `std::io::impls` benchmarks to `alloctests`
bushrat011899 May 25, 2026
5b49a9d
Move `std::io::copy` tests to `alloctests`
bushrat011899 Aug 1, 2026
6fdf21c
Move a helper to `rustc_trait_selection` and let `rustc_borrowck` use…
joshtriplett Aug 1, 2026
425c312
`rustc_borrowck`: Eliminate dependency on `rustc_traits`
joshtriplett Aug 1, 2026
b72b849
Prepare for merging from rust-lang/rust
Aug 2, 2026
c4de87e
Merge ref '73dc9167f1cd' from rust-lang/rust
Aug 2, 2026
937dfd4
fmt
Aug 2, 2026
b488a90
update genmc spinloop test output
RalfJung Aug 2, 2026
79aa9b1
Merge pull request #5238 from rust-lang/rustup-2026-08-02
RalfJung Aug 2, 2026
285c9a7
Rollup merge of #159906 - CoCo-Japan-pan:mut-restriction-check, r=jhp…
JonathanBrouwer Aug 2, 2026
d0d0a63
Rollup merge of #156527 - bushrat011899:core_io_test_merge, r=clarfon…
JonathanBrouwer Aug 2, 2026
9444510
Rollup merge of #159525 - folkertdev:stabilize-x86-i128-asm, r=Amanieu
JonathanBrouwer Aug 2, 2026
4c8051c
Rollup merge of #160342 - a1phyr:fuse_advnce_by, r=joboet
JonathanBrouwer Aug 2, 2026
27fdf5c
Rollup merge of #160358 - joshtriplett:borrowck-simplify-deps, r=mejrs
JonathanBrouwer Aug 2, 2026
5a56aa9
Rollup merge of #160375 - RalfJung:miri, r=RalfJung
JonathanBrouwer Aug 2, 2026
627be85
Rollup merge of #106643 - WaffleLapkin:read_recursive, r=joshtriplett
JonathanBrouwer Aug 2, 2026
60fbc97
Rollup merge of #159499 - AayushMainali-Github:main, r=jieyouxu
JonathanBrouwer Aug 2, 2026
7a376f7
Rollup merge of #159729 - RalfJung:alloc-grow, r=Darksonn
JonathanBrouwer Aug 2, 2026
c657ee1
Rollup merge of #159881 - zalanlevai:fix-incomplete-visible-parent-ma…
JonathanBrouwer Aug 2, 2026
22e6f7c
Rollup merge of #159977 - amirHdev:test-123216-bool-indexing, r=petro…
JonathanBrouwer Aug 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3760,7 +3760,6 @@ dependencies = [
"rustc_session",
"rustc_span",
"rustc_trait_selection",
"rustc_traits",
"smallvec",
"tracing",
]
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_borrowck/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ rustc_mir_dataflow = { path = "../rustc_mir_dataflow" }
rustc_session = { path = "../rustc_session" }
rustc_span = { path = "../rustc_span" }
rustc_trait_selection = { path = "../rustc_trait_selection" }
rustc_traits = { path = "../rustc_traits" }
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
tracing = "0.1"
# tidy-alphabetical-end
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ use rustc_span::Span;
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::error_reporting::infer::nice_region_error::NiceRegionError;
use rustc_trait_selection::traits::ObligationCtxt;
use rustc_traits::{type_op_ascribe_user_type_with_span, type_op_prove_predicate_with_cause};
use rustc_trait_selection::traits::query::type_op::ascribe_user_type::type_op_ascribe_user_type_with_span;
use rustc_trait_selection::traits::query::type_op::prove_predicate::type_op_prove_predicate_with_cause;
use tracing::{debug, instrument};

use crate::MirBorrowckCtxt;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ declare_features! (
/// Allows `mut ref` and `mut ref mut` identifier patterns.
(incomplete, mut_ref, "1.79.0", Some(123076)),
/// Allows `mut(crate) field: Type` restrictions.
(incomplete, mut_restriction, "1.98.0", Some(105077)),
(unstable, mut_restriction, "CURRENT_RUSTC_VERSION", Some(105077)),
/// Allows using `#[naked]` on `extern "Rust"` functions.
(unstable, naked_functions_rustic_abi, "1.88.0", Some(138997)),
/// Allows using `#[target_feature(enable = "...")]` on `#[naked]` on functions.
Expand Down
25 changes: 14 additions & 11 deletions compiler/rustc_hir_analysis/src/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,12 @@ fn lower_variant<'tcx>(
did: f.def_id.to_def_id(),
name: f.ident.name,
vis: tcx.visibility(f.def_id),
mut_restriction: match f.mut_restriction.kind {
hir::RestrictionKind::Unrestricted => ty::RestrictionKind::Unrestricted,
hir::RestrictionKind::Restricted(path) => {
ty::RestrictionKind::Restricted(path.res, f.mut_restriction.span)
}
},
safety: f.safety,
value: f.default.map(|v| v.def_id.to_def_id()),
})
Expand Down Expand Up @@ -926,19 +932,16 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
false,
is_auto == hir::IsAuto::Yes,
safety,
if let hir::RestrictionKind::Restricted(path) = impl_restriction.kind {
ty::trait_def::ImplRestrictionKind::Restricted(path.res, impl_restriction.span)
} else {
ty::trait_def::ImplRestrictionKind::Unrestricted
match impl_restriction.kind {
hir::RestrictionKind::Restricted(path) => {
ty::RestrictionKind::Restricted(path.res, impl_restriction.span)
}
hir::RestrictionKind::Unrestricted => ty::RestrictionKind::Unrestricted,
},
),
hir::ItemKind::TraitAlias(constness, ..) => (
constness,
true,
false,
hir::Safety::Safe,
ty::trait_def::ImplRestrictionKind::Unrestricted,
),
hir::ItemKind::TraitAlias(constness, ..) => {
(constness, true, false, hir::Safety::Safe, ty::RestrictionKind::Unrestricted)
}
_ => span_bug!(item.span, "trait_def_of_item invoked on non-trait"),
};

Expand Down
12 changes: 11 additions & 1 deletion compiler/rustc_metadata/src/rmeta/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ use rustc_hir::diagnostic_items::DiagnosticItems;
use rustc_index::Idx;
use rustc_middle::middle::lib_features::LibFeatures;
use rustc_middle::mir::interpret::{AllocDecodingSession, AllocDecodingState};
use rustc_middle::ty::Visibility;
use rustc_middle::ty::codec::TyDecoder;
use rustc_middle::ty::{RestrictionKind, Visibility};
use rustc_middle::{bug, implement_ty_decoder};
use rustc_proc_macro::bridge::client::Client as ProcMacroClient;
use rustc_serialize::opaque::MemDecoder;
Expand Down Expand Up @@ -1145,6 +1145,7 @@ impl CrateMetadata {
did,
name: self.item_name(did.index),
vis: self.get_visibility(tcx, did.index),
mut_restriction: self.get_mut_restriction(tcx, did.index),
safety: self.get_safety(did.index),
value: self.get_default_field(tcx, did.index),
})
Expand Down Expand Up @@ -1207,6 +1208,15 @@ impl CrateMetadata {
.map_id(|index| ModId::new_unchecked(self.local_def_id(index)))
}

fn get_mut_restriction(&self, tcx: TyCtxt<'_>, id: DefIndex) -> RestrictionKind {
self.root
.tables
.mut_restriction
.get(self, id)
.unwrap_or_else(|| self.missing("mut_restriction", id))
.decode((self, tcx))
}

fn get_safety(&self, id: DefIndex) -> Safety {
self.root.tables.safety.get(self, id)
}
Expand Down
32 changes: 21 additions & 11 deletions compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,14 +501,14 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) {
}

if let Some(def_id) = child.res.opt_def_id() {
let mut fallback = false;

if child.ident.name == kw::Underscore {
fallback_map.push((def_id, parent));
return;
fallback = true;
}

if tcx.is_doc_hidden(parent) {
fallback_map.push((def_id, parent));
return;
fallback = true;
}

// If the re-export itself is `#[doc(hidden)]`, deprioritize it.
Expand All @@ -519,20 +519,30 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) {
.and_then(|r| r.id())
.is_some_and(|id| tcx.is_doc_hidden(id))
{
fallback_map.push((def_id, parent));
return;
fallback = true;
}

match visible_parent_map.entry(def_id) {
Entry::Occupied(mut entry) => {
// If `child` is defined in crate `cnum`, ensure
// that it is mapped to a parent in `cnum`.
if def_id.is_local() && entry.get().is_local() {
entry.insert(parent);
if !fallback {
// If `child` is defined in crate `cnum`, ensure
// that it is mapped to a parent in `cnum`.
if def_id.is_local() && entry.get().is_local() {
entry.insert(parent);
}
}
}
Entry::Vacant(entry) => {
entry.insert(parent);
if fallback {
// We do all of the same steps to fallback entries as to
// preferred entries, except for recording them in a separate map.
// It is important to not return early in the fallback cases to
// ensure that we extend the BFS to the children of fallback items.
fallback_map.push((def_id, parent));
} else {
entry.insert(parent);
}

if child.res.module_like_def_id().is_some() {
bfs_queue.push_back(def_id);
}
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_metadata/src/rmeta/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1698,6 +1698,9 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {

for field in &variant.fields {
self.tables.safety.set(field.did.index, field.safety);
record!(
self.tables.mut_restriction[field.did] <- field.mut_restriction
);
}

if let Some((CtorKind::Fn, ctor_def_id)) = variant.ctor {
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_metadata/src/rmeta/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ define_tables! {
associated_types_for_impl_traits_in_trait_or_impl: Table<DefIndex, LazyValue<DefIdMap<Vec<DefId>>>>,
live_args_for_alias_from_outlives_bounds: Table<DefIndex, LazyValue<Option<ty::EarlyBinder<'static, Vec<ty::GenericArg<'static>>>>>>,
args_known_to_outlive_alias_params: Table<DefIndex, LazyValue<ty::EarlyBinder<'static, Vec<(ty::Region<'static>, Vec<ty::GenericArg<'static>>)>>>>,
mut_restriction: Table<DefIndex, LazyValue<ty::RestrictionKind>>,
}

#[derive(TyEncodable, TyDecodable)]
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_metadata/src/rmeta/parameterized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ trivially_parameterized_over_tcx! {
rustc_middle::ty::Generics,
rustc_middle::ty::ImplTraitInTraitData,
rustc_middle::ty::IntrinsicDef,
rustc_middle::ty::RestrictionKind,
rustc_middle::ty::TraitDef,
rustc_middle::ty::Variance,
rustc_middle::ty::Visibility<DefIndex>,
Expand Down
74 changes: 69 additions & 5 deletions compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ use crate::ty::codec::{TyDecoder, TyEncoder};
pub use crate::ty::diagnostics::*;
use crate::ty::fast_reject::SimplifiedType;
use crate::ty::layout::{FnAbiError, LayoutError};
use crate::ty::print::{with_crate_prefix, with_no_trimmed_paths};
use crate::ty::util::Discr;
use crate::ty::walk::TypeWalker;

Expand Down Expand Up @@ -402,6 +403,66 @@ impl Visibility {
}
}

#[derive(Debug, StableHash, PartialEq, Clone, Copy, Encodable, Decodable)]
pub enum RestrictionKind {
Unrestricted,
Restricted(DefId, Span),
}

impl RestrictionKind {
/// Returns `true` if the behavior is allowed/unrestricted in the given module.
/// A value of `false` indicates that the behavior is prohibited.
pub fn is_allowed_in(self, module: DefId, tcx: TyCtxt<'_>) -> bool {
match self {
RestrictionKind::Unrestricted => true,
RestrictionKind::Restricted(restricted_to, _) => {
tcx.is_descendant_of(module, restricted_to)
}
}
}

/// Obtain the [`Span`] of the restriction. Panics if the restriction is unrestricted.
pub fn expect_span(self) -> Span {
match self {
RestrictionKind::Unrestricted => {
bug!("called `expect_span` on an unrestricted item")
}
RestrictionKind::Restricted(_, span) => span,
}
}

/// Obtain the path of the restriction. If unrestricted, an empty string is returned.
pub fn restriction_path(self, tcx: TyCtxt<'_>) -> String {
match self {
RestrictionKind::Unrestricted => String::new(),
RestrictionKind::Restricted(restricted_to, _) => {
if restricted_to.krate == rustc_hir::def_id::LOCAL_CRATE {
with_crate_prefix!(with_no_trimmed_paths!(tcx.def_path_str(restricted_to)))
} else {
tcx.def_path_str(restricted_to.krate.as_mod_id())
}
}
}
}

/// Obtain the stricter restriction between `self` and `rhs`.
/// Panics if the restrictions do not reference the same crate.
pub fn stricter_of(self, rhs: Self, tcx: TyCtxt<'_>) -> Self {
match (self, rhs) {
(RestrictionKind::Unrestricted, r) | (r, RestrictionKind::Unrestricted) => r,
(
RestrictionKind::Restricted(left_did, _),
RestrictionKind::Restricted(right_did, _),
) => {
if left_did.krate != right_did.krate {
bug!("stricter_of: left and right restriction do not reference the same crate");
}
if tcx.is_descendant_of(left_did, right_did) { self } else { rhs }
}
}
}
}

#[derive(Clone, Debug, PartialEq, Eq, Copy, Hash, TyEncodable, TyDecodable, StableHash)]
#[derive(TypeFoldable, TypeVisitable)]
pub struct ClosureSizeProfileData<'tcx> {
Expand Down Expand Up @@ -1537,6 +1598,7 @@ pub struct FieldDef {
pub did: DefId,
pub name: Symbol,
pub vis: Visibility<ModId>,
pub mut_restriction: RestrictionKind,
pub safety: hir::Safety,
pub value: Option<DefId>,
}
Expand All @@ -1551,16 +1613,18 @@ impl PartialEq for FieldDef {
// of `FieldDef` changes, a compile-error will be produced, reminding
// us to revisit this assumption.

let Self { did: lhs_did, name: _, vis: _, safety: _, value: _ } = &self;
let Self { did: lhs_did, name: _, vis: _, mut_restriction: _, safety: _, value: _ } = &self;

let Self { did: rhs_did, name: _, vis: _, safety: _, value: _ } = other;
let Self { did: rhs_did, name: _, vis: _, mut_restriction: _, safety: _, value: _ } = other;

let res = lhs_did == rhs_did;

// Double check that implicit assumption detailed above.
if cfg!(debug_assertions) && res {
let deep =
self.name == other.name && self.vis == other.vis && self.safety == other.safety;
let deep = self.name == other.name
&& self.vis == other.vis
&& self.mut_restriction == other.mut_restriction
&& self.safety == other.safety;
assert!(deep, "FieldDef for the same def-id has differing data");
}

Expand All @@ -1580,7 +1644,7 @@ impl Hash for FieldDef {
// of `FieldDef` changes, a compile-error will be produced, reminding
// us to revisit this assumption.

let Self { did, name: _, vis: _, safety: _, value: _ } = &self;
let Self { did, name: _, vis: _, mut_restriction: _, safety: _, value: _ } = &self;

did.hash(s)
}
Expand Down
51 changes: 2 additions & 49 deletions compiler/rustc_middle/src/ty/trait_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@ use tracing::debug;
use crate::query::LocalCrate;
use crate::traits::specialization_graph;
use crate::ty::fast_reject::{self, SimplifiedType, TreatParams};
use crate::ty::print::{with_crate_prefix, with_no_trimmed_paths};
use crate::ty::{self, Ident, Interner, Ty, TyCtxt, VisitorResult};
use crate::ty::{self, Ident, Interner, RestrictionKind, Ty, TyCtxt, VisitorResult};

/// A trait's definition with type information.
#[derive(StableHash, Encodable, Decodable)]
pub struct TraitDef {
pub def_id: DefId,

/// Restrictions on trait implementations.
pub impl_restriction: ImplRestrictionKind,
pub impl_restriction: RestrictionKind,

pub safety: hir::Safety,

Expand Down Expand Up @@ -102,52 +101,6 @@ pub enum TraitSpecializationKind {
AlwaysApplicable,
}

/// Whether the trait implementation is unrestricted or restricted within a specific module.
#[derive(StableHash, PartialEq, Clone, Copy, Encodable, Decodable)]
pub enum ImplRestrictionKind {
/// The restriction does not affect this trait, and it can be implemented anywhere.
Unrestricted,
/// This trait can only be implemented within the specified module.
Restricted(DefId, Span),
}

impl ImplRestrictionKind {
/// Returns `true` if the behavior is allowed/unrestricted in the given module.
/// A value of `false` indicates that the behavior is prohibited.
pub fn is_allowed_in(self, module: DefId, tcx: TyCtxt<'_>) -> bool {
match self {
ImplRestrictionKind::Unrestricted => true,
ImplRestrictionKind::Restricted(restricted_to, _) => {
tcx.is_descendant_of(module, restricted_to)
}
}
}

/// Obtain the [`Span`] of the restriction. Panics if the restriction is unrestricted.
pub fn expect_span(self) -> Span {
match self {
ImplRestrictionKind::Unrestricted => {
bug!("called `expect_span` on an unrestricted item")
}
ImplRestrictionKind::Restricted(_, span) => span,
}
}

/// Obtain the path of the restriction. If unrestricted, an empty string is returned.
pub fn restriction_path(self, tcx: TyCtxt<'_>) -> String {
match self {
ImplRestrictionKind::Unrestricted => String::new(),
ImplRestrictionKind::Restricted(restricted_to, _) => {
if restricted_to.krate == rustc_hir::def_id::LOCAL_CRATE {
with_crate_prefix!(with_no_trimmed_paths!(tcx.def_path_str(restricted_to)))
} else {
tcx.def_path_str(restricted_to.krate.as_mod_id())
}
}
}
}
}

#[derive(Default, Debug, StableHash)]
pub struct TraitImpls {
blanket_impls: Vec<DefId>,
Expand Down
Loading
Loading