-
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
improve const infer error #78249
improve const infer error #78249
Conversation
@@ -200,17 +200,11 @@ impl<'tcx> UnifyValue for ConstVarValue<'tcx> { | |||
// universe is the minimum of the two universes, because that is | |||
// the one which contains the fewest names in scope. | |||
let universe = cmp::min(universe1, universe2); | |||
(ConstVariableValue::Unknown { universe }, value1.origin.span) | |||
(ConstVariableValue::Unknown { universe }, value1.origin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And inline the ConstVarValue { .. }
part here. I don't even think the span should be relevant here, so maybe DUMMY_SP
would be more semantic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The span is relevant here. It isn't really deterministic which const infer we use when reporting errors afaict, so we pretty much require all const infer variables to have relevant origin data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I was basing my assumption off
rust/compiler/rustc_infer/src/infer/type_variable.rs
Lines 482 to 494 in d1c2815
// If both sides are *unknown*, it hardly matters, does it? | |
( | |
&TypeVariableValue::Unknown { universe: universe1 }, | |
&TypeVariableValue::Unknown { universe: universe2 }, | |
) => { | |
// If we unify two unbound variables, ?T and ?U, then whatever | |
// value they wind up taking (which must be the same value) must | |
// be nameable by both universes. Therefore, the resulting | |
// universe is the minimum of the two universes, because that is | |
// the one which contains the fewest names in scope. | |
let universe = cmp::min(universe1, universe2); | |
Ok(TypeVariableValue::Unknown { universe }) | |
} |
which doesn't keep track of span information, but it's not important either way.
@bors r+ rollup |
📌 Commit e1c524c has been approved by |
🌲 The tree is currently closed for pull requests below priority 1000, this pull request will be tested once the tree is reopened |
…as-schievink Rollup of 15 pull requests Successful merges: - rust-lang#76649 (Add a spin loop hint for Arc::downgrade) - rust-lang#77392 (add `insert` to `Option`) - rust-lang#77716 (Revert "Allow dynamic linking for iOS/tvOS targets.") - rust-lang#78109 (Check for exhaustion in RangeInclusive::contains and slicing) - rust-lang#78198 (Simplify assert terminator only if condition evaluates to expected value) - rust-lang#78243 (--test-args flag description) - rust-lang#78249 (improve const infer error) - rust-lang#78250 (Document inline-const) - rust-lang#78264 (Add regression test for issue-77475) - rust-lang#78274 (Update description of Empty Enum for accuracy) - rust-lang#78278 (move `visit_predicate` into `TypeVisitor`) - rust-lang#78292 (Loop instead of recursion) - rust-lang#78293 (Always store Rustdoc theme when it's changed) - rust-lang#78300 (Make codegen coverage_context optional, and check) - rust-lang#78307 (Revert "Set .llvmbc and .llvmcmd sections as allocatable") Failed merges: r? `@ghost`
For type inference we probably have to be careful about subtyping and stuff but considering that subtyping shouldn't be relevant for constants I don't really see a reason why we may not want to reuse the const origin here.
r? @varkor