-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ICE: errors resolving bounds after type-checking for fmt::Display #65774
Comments
If possible, could you please provide a self-contained example that ICEs on e.g. the playground? |
Hmm...I tried creating a small example, but I can't seem to replicate the behavior. I'm not really sure what is happening to cause it. I have found that the error occurs even though I'm not actually creating an object of type let _ = writer.write_fmt(format_args!("{}", config)); from a different crate which is where the fmt function would get used if I did create something of the type then the error does not occur. |
triage: P-high, removing I-nominated label |
I cannot reproduce this locally:
Please do try to come up with an MCVE. I recommend taking the original code and paring it down, rather than trying to jump straight to a minimal bit of code. |
closing as not reproducible in absence of MCVE |
Thank you for being willing to try to reproduce! Would you mind trying
again with the "mpu-print" branch checked out? Tock for RISCV compiles
correctly (and has for a while) on master, but the issue has creeped in
when making the change for tock/tock#1428.
Also, I have been periodically checking new nightlies and have gotten the
same error.
…On Thu, Nov 14, 2019, 7:42 AM Felix S Klock II ***@***.***> wrote:
Closed #65774 <#65774>.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#65774?email_source=notifications&email_token=AALGL4SZ3UOTVFVEYPXVPELQTVBTFA5CNFSM4JEZKQD2YY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOU3J57RA#event-2798903236>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AALGL4VOBLW7IA53IWXPE7TQTVBTFANCNFSM4JEZKQDQ>
.
|
Ah, okay, I overlooked that detail earlier. Now I can reproduce it. Reopening (and will try to minimize, if only as fodder for a blog post on reducing i am planning) |
Okay I've narrowed it down. I don't have the test case into a state where I'm ready to post it yet (I need to clean it up a little more) But if you want to fix your problem, its this: pub trait MPU {
type MpuConfig: Default + Display = ();
...
} Namely, you are using the (feature-gated) Specifically in this case, But instead of nicely reporting that to you at the trait definition site, or even at a trait implementation site, you are instead seeing an error far far downstream, unfortunately. (As for how to work around this, I suspect your best bet is to make your own unit-struct that implements |
Okay here is the reduction (play): #![feature(associated_type_defaults)]
trait MyDisplay { fn method(&self) { } }
impl<'a, T: MyDisplay> MyDisplay for &'a mut T { }
struct T;
trait MPU {
type MpuConfig: MyDisplay = T;
}
struct S;
impl MPU for S { }
trait MyWrite {
fn my_write(&self, _: &dyn MyDisplay) { }
}
trait ProcessType {
fn process_detail_fmt(&self, _: &mut dyn MyWrite);
}
struct Process;
impl ProcessType for Process {
fn process_detail_fmt(&self, writer: &mut dyn MyWrite)
{
let mut val: Option<<S as MPU>::MpuConfig> = None;
let valref: &mut <S as MPU>::MpuConfig = val.as_mut().unwrap();
// // This causes a different ICE (but its similar if you squint right):
// //
// // `Unimplemented` selecting `Binder(<T as MyDisplay>)` during codegen
//
// writer.my_write(valref)
// This one causes the ICE:
// FulfillmentError(Obligation(predicate=Binder(TraitPredicate(<T as MyDisplay>)), depth=1),Unimplemented)
let closure = |config: &mut <S as MPU>::MpuConfig| writer.my_write(&config);
closure(valref);
}
}
fn create() -> &'static dyn ProcessType {
let input: Option<&mut Process> = None;
let process: &mut Process = input.unwrap();
process
}
pub fn main() {
create();
} |
I'm going to downgrade this from P-high to P-medium, based on:
(it may or may not be fixed by #61812; I haven't checked that.) |
This is needed to workaround a compiler error. If rust-lang/rust#65774 is fixed then we should be able to revert this commit.
cc @jonas-schievink re. #61812. |
1428: Add MPU information to panic!() print r=ppannuto a=bradjc ### Pull Request Overview This pull request changes the `MpuConfig` type to require that it implement the `fmt::Display` trait so that the process.rs panic printout can display the MPU information. This fixes #925. ### Testing Strategy This pull request was tested by running `crash_dummy` on Hail and verifying that the MPU display looks ok. ### TODO or Help Wanted 1. The output looks like: ``` Cortex-M MPU Region 0: base: 20004000, length: 8192 bytes; ReadWrite (0x3) Region 1: base: 30000, length: 1024 bytes; ReadOnly (0x6) Region 2: Unused Region 3: Unused Region 4: Unused Region 5: Unused Region 6: Unused Region 7: Unused ``` I'm not sure how to get the `0x` to display on the base address. The format string looks like `Region {}: base:{:>width$x}` and sticking a `#` in there to make it print the `0x` gives me errors. 2. The rust compiler generates an error when linking for risc-v. rust-lang/rust#65774 I have no idea what to do about that. ### Documentation Updated I added a new copy of the panic!() output to the docs to keep that up to date. - [x] Updated the relevant files in `/docs`, or no updates are required. ### Formatting - [x] Ran `make formatall`. Co-authored-by: Brad Campbell <bradjc5@gmail.com> Co-authored-by: Pat Pannuto <pat.pannuto@gmail.com>
#61812 will currently reject this trait due to the unfulfilled trait bound. I've added a test. |
Clean up comment now that rust-lang/rust#65774 has been closed.
2829: kernel: mpu: Cleanup the comment for the default config type r=hudson-ayers a=bradjc Clean up comment now that rust-lang/rust#65774 has been closed. ### Testing Strategy I tried just using `()` and I got a compiler error this time. ### TODO or Help Wanted n/a ### Documentation Updated - [x] Updated the relevant files in `/docs`, or no updates are required. ### Formatting - [x] Ran `make prepush`. Co-authored-by: Brad Campbell <bradjc5@gmail.com>
1428: Add MPU information to panic!() print r=ppannuto a=bradjc ### Pull Request Overview This pull request changes the `MpuConfig` type to require that it implement the `fmt::Display` trait so that the process.rs panic printout can display the MPU information. This fixes #925. ### Testing Strategy This pull request was tested by running `crash_dummy` on Hail and verifying that the MPU display looks ok. ### TODO or Help Wanted 1. The output looks like: ``` Cortex-M MPU Region 0: base: 20004000, length: 8192 bytes; ReadWrite (0x3) Region 1: base: 30000, length: 1024 bytes; ReadOnly (0x6) Region 2: Unused Region 3: Unused Region 4: Unused Region 5: Unused Region 6: Unused Region 7: Unused ``` I'm not sure how to get the `0x` to display on the base address. The format string looks like `Region {}: base:{:>width$x}` and sticking a `#` in there to make it print the `0x` gives me errors. 2. The rust compiler generates an error when linking for risc-v. rust-lang/rust#65774 I have no idea what to do about that. ### Documentation Updated I added a new copy of the panic!() output to the docs to keep that up to date. - [x] Updated the relevant files in `/docs`, or no updates are required. ### Formatting - [x] Ran `make formatall`. Co-authored-by: Brad Campbell <bradjc5@gmail.com> Co-authored-by: Pat Pannuto <pat.pannuto@gmail.com>
pnkfelix: here is the reduced test case (play):
(Sadly I have not been able to reduce it further. But this should serve us well enough.)
Original bug report follows:
I'm getting a compiler error when trying to compile:
I'm compiling for the
riscv32imac-unknown-none-elf
target.Full branch here:
https://github.com/tock/tock/blob/f29f8aa9bf9925893e905feb1aa42db2ce57d36f/arch/rv32i/src/pmp.rs#L26
or with full backtrace:
and more debug output on my build:
Travis also seems to agree that it will not compile: https://travis-ci.org/tock/tock/builds/602484885
The text was updated successfully, but these errors were encountered: