Skip to content

Commit 46befd8

Browse files
Display only crate name for external trait impl restrictions
1 parent 72c1d65 commit 46befd8

4 files changed

Lines changed: 4 additions & 4 deletions

File tree

compiler/rustc_middle/src/ty/trait_def.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl ImplRestrictionKind {
140140
if restricted_to.krate == rustc_hir::def_id::LOCAL_CRATE {
141141
with_crate_prefix!(with_no_trimmed_paths!(tcx.def_path_str(restricted_to)))
142142
} else {
143-
with_no_trimmed_paths!(tcx.def_path_str(restricted_to))
143+
tcx.def_path_str(restricted_to.krate.as_mod_def_id())
144144
}
145145
}
146146
}

tests/ui/impl-restriction/impl-restriction-check.e2015.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ note: trait restricted here
1010
LL | pub impl(crate) trait TopLevel {}
1111
| ^^^^^^^^^^^
1212

13-
error: trait cannot be implemented outside `external::inner`
13+
error: trait cannot be implemented outside `external`
1414
--> $DIR/impl-restriction-check.rs:13:1
1515
|
1616
LL | impl external::inner::Inner for LocalType {}

tests/ui/impl-restriction/impl-restriction-check.e2018.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ note: trait restricted here
1010
LL | pub impl(crate) trait TopLevel {}
1111
| ^^^^^^^^^^^
1212

13-
error: trait cannot be implemented outside `external::inner`
13+
error: trait cannot be implemented outside `external`
1414
--> $DIR/impl-restriction-check.rs:13:1
1515
|
1616
LL | impl external::inner::Inner for LocalType {}

tests/ui/impl-restriction/impl-restriction-check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ extern crate external_impl_restriction as external;
1010
struct LocalType; // needed to avoid orphan rule errors
1111

1212
impl external::TopLevel for LocalType {} //~ ERROR trait cannot be implemented outside `external`
13-
impl external::inner::Inner for LocalType {} //~ ERROR trait cannot be implemented outside `external::inner`
13+
impl external::inner::Inner for LocalType {} //~ ERROR trait cannot be implemented outside `external`
1414

1515
pub mod foo {
1616
pub mod bar {

0 commit comments

Comments
 (0)