Skip to content

Commit 7891306

Browse files
committed
small coherence cleanup
1 parent 0d45ef8 commit 7891306

File tree

5 files changed

+40
-7
lines changed

5 files changed

+40
-7
lines changed

compiler/rustc_trait_selection/src/traits/coherence.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -792,11 +792,8 @@ pub fn orphan_check_trait_ref<'tcx, E: Debug>(
792792
in_crate: InCrate,
793793
lazily_normalize_ty: impl FnMut(Ty<'tcx>) -> Result<Ty<'tcx>, E>,
794794
) -> Result<Result<(), OrphanCheckErr<'tcx, Ty<'tcx>>>, E> {
795-
if trait_ref.has_infer() && trait_ref.has_param() {
796-
bug!(
797-
"can't orphan check a trait ref with both params and inference variables {:?}",
798-
trait_ref
799-
);
795+
if trait_ref.has_param() {
796+
bug!("orphan check only expects inference variables: {trait_ref:?}");
800797
}
801798

802799
let mut checker = OrphanChecker::new(in_crate, lazily_normalize_ty);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/global-non-global-env-1.rs:18:5
3+
|
4+
LL | fn foo<T>() -> u32
5+
| - --- expected `u32` because of return type
6+
| |
7+
| found this type parameter
8+
...
9+
LL | impls_trait(())
10+
| ^^^^^^^^^^^^^^^ expected `u32`, found type parameter `T`
11+
|
12+
= note: expected type `u32`
13+
found type parameter `T`
14+
15+
error: aborting due to 1 previous error
16+
17+
For more information about this error, try `rustc --explain E0308`.

tests/ui/traits/winnowing/global-non-global-env-1.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//@ revisions: current next
55
//@ ignore-compare-mode-next-solver (explicit revisions)
66
//@[next] compile-flags: -Znext-solver
7-
//@ check-pass
7+
//@[next] check-pass
88

99
trait Trait<T> {}
1010
impl<T> Trait<T> for () {}
@@ -16,6 +16,7 @@ where
1616
(): Trait<T>,
1717
{
1818
impls_trait(())
19+
//[current]~^ ERROR mismatched types
1920
}
2021

2122
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/global-non-global-env-3.rs:20:5
3+
|
4+
LL | fn foo<T>() -> u32
5+
| - --- expected `u32` because of return type
6+
| |
7+
| found this type parameter
8+
...
9+
LL | impls_trait(())
10+
| ^^^^^^^^^^^^^^^ expected `u32`, found type parameter `T`
11+
|
12+
= note: expected type `u32`
13+
found type parameter `T`
14+
15+
error: aborting due to 1 previous error
16+
17+
For more information about this error, try `rustc --explain E0308`.

tests/ui/traits/winnowing/global-non-global-env-3.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//@ revisions: current next
66
//@ ignore-compare-mode-next-solver (explicit revisions)
77
//@[next] compile-flags: -Znext-solver
8-
//@ check-pass
8+
//@[next] check-pass
99

1010
trait Trait<T> {}
1111
impl Trait<u32> for () {}
@@ -18,6 +18,7 @@ where
1818
(): Trait<u32>,
1919
{
2020
impls_trait(())
21+
//[current]~^ ERROR mismatched types
2122
}
2223

2324
fn main() {}

0 commit comments

Comments
 (0)