Skip to content

Commit 37a05d8

Browse files
Rollup merge of #113453 - spastorino:new-rpitit-30, r=compiler-errors
Remove unused from_method from rustc_on_unimplemented Fixes #113439 `on_unimplemented_note` was calling `item_name` for RPITITs and that produced ICEs. I've added a regression test for that but also have removed `from_method` symbol entirely because it wasn't even used and by doing that the `item_name` call was also removed. r? ``@compiler-errors``
2 parents 2b78119 + 6d80879 commit 37a05d8

File tree

5 files changed

+52
-20
lines changed

5 files changed

+52
-20
lines changed

compiler/rustc_span/src/symbol.rs

-1
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,6 @@ symbols! {
759759
from_desugaring,
760760
from_fn,
761761
from_iter,
762-
from_method,
763762
from_output,
764763
from_residual,
765764
from_size_align_unchecked,

compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs

+1-19
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ pub trait TypeErrCtxtExt<'tcx> {
4141
static ALLOWED_FORMAT_SYMBOLS: &[Symbol] = &[
4242
kw::SelfUpper,
4343
sym::ItemContext,
44-
sym::from_method,
4544
sym::from_desugaring,
4645
sym::direct,
4746
sym::cause,
@@ -172,23 +171,6 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
172171
}
173172
}
174173

175-
if let ObligationCauseCode::ItemObligation(item)
176-
| ObligationCauseCode::BindingObligation(item, _)
177-
| ObligationCauseCode::ExprItemObligation(item, ..)
178-
| ObligationCauseCode::ExprBindingObligation(item, ..) = *obligation.cause.code()
179-
{
180-
// FIXME: maybe also have some way of handling methods
181-
// from other traits? That would require name resolution,
182-
// which we might want to be some sort of hygienic.
183-
//
184-
// Currently I'm leaving it for what I need for `try`.
185-
if self.tcx.trait_of_item(item) == Some(trait_ref.def_id) {
186-
let method = self.tcx.item_name(item);
187-
flags.push((sym::from_method, None));
188-
flags.push((sym::from_method, Some(method.to_string())));
189-
}
190-
}
191-
192174
if let Some(k) = obligation.cause.span.desugaring_kind() {
193175
flags.push((sym::from_desugaring, None));
194176
flags.push((sym::from_desugaring, Some(format!("{:?}", k))));
@@ -672,7 +654,7 @@ impl<'tcx> OnUnimplementedFormatString {
672654
None => {
673655
if let Some(val) = options.get(&s) {
674656
val
675-
} else if s == sym::from_desugaring || s == sym::from_method {
657+
} else if s == sym::from_desugaring {
676658
// don't break messages using these two arguments incorrectly
677659
&empty_string
678660
} else if s == sym::ItemContext {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error[E0277]: the trait bound `impl Foo<u8>: Foo<char>` is not satisfied
2+
--> $DIR/return-dont-satisfy-bounds.rs:13:34
3+
|
4+
LL | fn foo<F2: Foo<u8>>(self) -> impl Foo<u8> {
5+
| ^^^^^^^^^^^^ the trait `Foo<char>` is not implemented for `impl Foo<u8>`
6+
|
7+
= help: the trait `Foo<char>` is implemented for `Bar`
8+
note: required by a bound in `Foo::foo::{opaque#0}`
9+
--> $DIR/return-dont-satisfy-bounds.rs:7:30
10+
|
11+
LL | fn foo<F2>(self) -> impl Foo<T>;
12+
| ^^^^^^ required by this bound in `Foo::foo::{opaque#0}`
13+
14+
error: aborting due to previous error
15+
16+
For more information about this error, try `rustc --explain E0277`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error[E0277]: the trait bound `impl Foo<u8>: Foo<char>` is not satisfied
2+
--> $DIR/return-dont-satisfy-bounds.rs:13:34
3+
|
4+
LL | fn foo<F2: Foo<u8>>(self) -> impl Foo<u8> {
5+
| ^^^^^^^^^^^^ the trait `Foo<char>` is not implemented for `impl Foo<u8>`
6+
|
7+
= help: the trait `Foo<char>` is implemented for `Bar`
8+
note: required by a bound in `Foo::{opaque#0}`
9+
--> $DIR/return-dont-satisfy-bounds.rs:7:30
10+
|
11+
LL | fn foo<F2>(self) -> impl Foo<T>;
12+
| ^^^^^^ required by this bound in `Foo::{opaque#0}`
13+
14+
error: aborting due to previous error
15+
16+
For more information about this error, try `rustc --explain E0277`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
2+
// revisions: current next
3+
4+
#![feature(return_position_impl_trait_in_trait)]
5+
6+
trait Foo<T> {
7+
fn foo<F2>(self) -> impl Foo<T>;
8+
}
9+
10+
struct Bar;
11+
12+
impl Foo<char> for Bar {
13+
fn foo<F2: Foo<u8>>(self) -> impl Foo<u8> {
14+
//~^ ERROR: the trait bound `impl Foo<u8>: Foo<char>` is not satisfied [E0277]
15+
self
16+
}
17+
}
18+
19+
fn main() {}

0 commit comments

Comments
 (0)