Skip to content

Commit 66622ad

Browse files
committed
Fix the logic
1 parent d4f9196 commit 66622ad

File tree

3 files changed

+28
-12
lines changed

3 files changed

+28
-12
lines changed

compiler/rustc_next_trait_solver/src/solve/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ where
163163
}
164164

165165
if self.cx().features().impl_stability() {
166+
// If we are in std, and the feature is not enabled through #[unstable_feature_bound(..)]
166167
return self.evaluate_added_goals_and_make_canonical_response(Certainty::Maybe(
167168
MaybeCause::Ambiguity,
168169
));

compiler/rustc_trait_selection/src/traits/fulfill.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -773,13 +773,21 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
773773
}
774774
}
775775
}
776-
// Check if feature is enabled at crate level with #[feature(..)] or if we are currently in codegen.
777-
if self.selcx.tcx().features().enabled(symbol)
778-
|| (self.selcx.infcx.typing_mode() == TypingMode::PostAnalysis)
779-
{
780-
return ProcessResult::Changed(Default::default());
781-
} else {
776+
777+
if self.selcx.tcx().features().impl_stability() {
778+
// If we are in std/core, and the feature is not enabled through #[unstable_feature_bound(..)].
782779
return ProcessResult::Unchanged;
780+
} else {
781+
// Outside of std/core, check if feature is enabled at crate level with #[feature(..)]
782+
// or if we are currently in codegen.
783+
if self.selcx.tcx().features().enabled(symbol)
784+
|| (self.selcx.infcx.typing_mode() == TypingMode::PostAnalysis)
785+
{
786+
return ProcessResult::Changed(Default::default());
787+
} else {
788+
return ProcessResult::Unchanged;
789+
}
790+
783791
}
784792
}
785793
},

compiler/rustc_trait_selection/src/traits/select/mod.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -846,13 +846,20 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
846846
}
847847
}
848848
}
849-
// Check if feature is enabled at crate level with #[feature(..)] or if we are currently in codegen.
850-
if self.tcx().features().enabled(symbol)
851-
|| (self.infcx.typing_mode() == TypingMode::PostAnalysis)
852-
{
853-
return Ok(EvaluatedToOk);
854-
} else {
849+
850+
if self.tcx().features().impl_stability() {
851+
// If we are in std/core, and the feature is not enabled through #[unstable_feature_bound(..)].
855852
return Ok(EvaluatedToAmbig);
853+
} else {
854+
// Outside of std/core, check if feature is enabled at crate level with #[feature(..)]
855+
// or if we are currently in codegen.
856+
if self.tcx().features().enabled(symbol)
857+
|| (self.infcx.typing_mode() == TypingMode::PostAnalysis)
858+
{
859+
return Ok(EvaluatedToOk);
860+
} else {
861+
return Ok(EvaluatedToAmbig);
862+
}
856863
}
857864
}
858865

0 commit comments

Comments
 (0)