-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Arguments of an impl method may have stronger implied bounds than trait method #105295
Comments
MIRI claims undefined behavior here:
Given that this code only consists of safe code, that smells like a compiler bug. |
First crashes in nightly-2020-10-07. Bisection detailsI used: cargo-bisect-rustc --preserve --script ./unsound.sh --start 2020-01-01 --end 2020-12-05 With unsound.sh containing: ! cargo test 2>&1 | grep "SEGV" Earlier versions report a lifetime error: Lifetime error reported with nightly-2020-10-06
Was that lifetime error correct? |
WG-prioritization assigning priority (Zulip discussion). @rustbot label -I-prioritize +P-critical |
Yes, the lifetime error is correct |
Looks like it may be a bug in @rustbot claim |
Almost certainly due to #73905. |
The issue is minimized to this basically: pub struct Listeners<'a> {
listeners: RefCell<Vec<Box<dyn FnMut(()) + 'a>>>
}
pub trait ListenersInterface {
fn listeners<'b>(&'b self) -> &'b Listeners<'b>;
}
impl<'a> ListenersInterface for Listeners<'a> {
fn listeners<'b>(&'b self) -> &'a Listeners<'b> {
self
}
} The fact that the Basically, for this to be sound, given the assumptions of the This boils down to: given |
edit: Oh it's already a runtime error. I thought it was an ICE 👀. An exploit of this bug for an actual ub: trait Trait {
fn get<'s>(s: &'s str, _: &'static &'static ()) -> &'static str;
}
impl Trait for () {
fn get<'s>(s: &'s str, _: &'static &'s ()) -> &'static str {
s
}
}
fn main() {
let val = <() as Trait>::get(&String::from("blah blah blah"), &&());
println!("{}", val);
} |
This reminds me of #25860 |
Visiting during T-compiler meeting, reprioritizing. @rustbot label -P-critical +P-high |
closing as a duplicate of #80176, currently have a deny by default future-compat lint here. We'll convert that lint to a hard error soon-ish |
I tried this code:
I expected to see this happen: the two tests do the same thing
Instead, this happened: the first unit test SEG faults, the second succeeds
Meta
rustc --version --verbose
:Caused by:
process didn't exit successfully:
/Users/adamritter/Documents/GitHub/synced_collection/target/debug/deps/synccollection-9d89a83a383169be
(signal: 11, SIGSEGV: invalid memory reference)```The text was updated successfully, but these errors were encountered: