-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
[WIP] reject more impossible trivial bounds (HRTBs and trivial after normalization) #95611
Conversation
@bors try |
⌛ Trying commit 2d05446c6dd15d6df2efbbbbd2e586666055b281 with merge eeb2054ba7aab4629538fba83b4971e554d70ee9... |
This comment was marked as outdated.
This comment was marked as outdated.
☀️ Try build successful - checks-actions |
@craterbot check |
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
I don't think a crater run makes sense for just a warning. (It won't cause crates to not compile.) |
Good point. Totally forgot that this needs to filter out crates for the signal to be visible lol |
@craterbot cancel |
🚨 Error: failed to parse the command 🆘 If you have any trouble with Crater please ping |
@craterbot abort |
🗑️ Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
2d05446
to
e23c11b
Compare
@bors try |
⌛ Trying commit e23c11b4384d3f6ab0f21ac0ca9e75febd006be2 with merge 751cdbaf3a893bc71b2c617bb7be22dfea5f0862... |
This comment has been minimized.
This comment has been minimized.
☀️ Try build successful - checks-actions |
@craterbot check |
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
🚧 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
🎉 Experiment
|
This crater run looks relatively clean. In fact, there are only a few relevant failure cases I could find. The first is in pub fn parse_file<P, T>(p: P) -> Result<Vec<T>, Box<dyn Error>>
where
P: AsRef<Path>,
T: FromStr<Err = Box<dyn Error>>,
<T as FromStr>::Err: Error + 'static,
{
let contents = read_file(p)?;
parse_raw_data(contents)
} This is because Another failure is in one of the amadeus tests. Specifically, one of the generated methods: #[derive(Data, Clone, PartialEq, Serialize, Deserialize, Debug)]
struct Row {
a: String,
b: u64,
c: f64,
// d: List<Row>,
e: List<Value>,
}
#[inline(always)]
fn hash_a<H>(&self, _state: &mut H)
where
H: __::Hasher,
for<'a> __::Wrapper<'a, Row>: __::Hash,
{ ... } Is not satisfied because This API isn't even fleshed out in the Amadeus API: constellation-rs/amadeus#69 The rest of the crates are due to derive macros hiding unsatisfisable
Adding |
e23c11b
to
c7a419d
Compare
r? @nikomatsakis (feel free to redirect) Also, does this need T-lang sign-off? |
I'm somewhat surprised by this statement. I actually think the opposite! I expect us to move towards permitting any where-clause, no matter how nonsensical. |
@nikomatsakis: Hm. I actually am a fan of warning the user early if their WC is nonsense, since except for macro-generated code, they're very unlikely to have written something like this. And even in macro-generated code, it sometimes reveals something that the user of the macro forgot to do, like implementing another trait they were required to implement in tandem with a derive. It feels strange that the user would have to wait until the function/impl is used to receive feedback that their code is wrong, and somewhat inconsistent, too, since this only currently happens when HRTBs are involved. but if not, then what's the alternative? like, should we be making the places that assume these bounds hold (after erasing lifetimes) fallible so they can bubble up errors when evaluated during codegen (or suppress them)? should we be avoiding generating MIR at all, since some MIR construction steps and optimizations ICE when given bounds like this? Or maybe we should remove this Anywho, I'd still like to fix ICEs like #94651 somehow, and remove special-casing from specific MIR optimizations like in #95398. Thoughts would be appreciated. |
Warning early is one thing, errors are another. Note though that with approaches like this it might be less clear whether a where-clause is actually wrong. |
Yes, I would change that so that the code is always accepted. I do thing a warning is a good idea, just not hard errors. |
Now this is a good question! I'd like to dig into this a bit more. I agree we should not ICE! If I recall, was part of the problem having to do with MIR inlining into a context where those where clauses were not available? We talked about this at some point. |
Not exactly. This is due to the fact when we have a WC like And ICEs of this nature can show up in many different places. MIR inlining is one, but #95398 shows that it also manifests in the |
☔ The latest upstream changes (presumably #93803) made this pull request unmergeable. Please resolve the merge conflicts. |
compiler-errors says that this is still in development and should be tagged as either S-experimental or S-blocked. @rustbot label: -S-waiting-on-review +S-experimental |
…i-obk Don't ICE when trying to copy unsized value in const prop When we have a trivially false where-clause predicate like `Self: Sized` where `Self = dyn Trait`, we sometimes don't throw an error during typeck for an illegal operation such as copying an unsized type. This, unfortunately, cannot be made into an error (at least not without some migration -- see rust-lang#95611 for example), but we should at least not ICE, since this function will never actually be reachable from main, for example. r? `@RalfJung` since I think you added these assertions? but feel free to reassign. Fixes rust-lang#102553
We really should be rejecting bounds that are global, even if they have higher-ranked lifetimes. We have the ability to prove whether
for<'a> &'a mut String: Clone
is true or not, so there's no reason to silently allow this to typecheck, especially because it's inconsistent with a non-HRTB like&'static mut String: Clone
and is the source of ICEsFor now, though, just add a warning that it may be denied in the future.