Skip to content

Commit 8681d4c

Browse files
committed
Auto merge of #104902 - matthiaskrgr:rollup-oo27a4u, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #104716 (move 2 candidates into builtin candidate) - #104760 (Clarify `SyntaxExtensionKind::LegacyDerive`.) - #104797 (rustc_codegen_ssa: write `.dwp` in a streaming fashion) - #104835 (Use infcx.partially_normalize_associated_types_in) - #104853 (Fix typo in miri sysroot) - #104879 (jsondoclint: Recognise Typedef as valid kind for Type::ResolvedPath) - #104887 (rustbuild: Don't build doc::SharedAssets when building JSON docs.) - #104896 (rustdoc: fix broken tooltip CSS) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 051cab2 + 12e1b84 commit 8681d4c

File tree

22 files changed

+251
-300
lines changed

22 files changed

+251
-300
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -676,17 +676,18 @@ fn link_dwarf_object<'a>(
676676
thorin::MissingReferencedObjectBehaviour::Skip,
677677
)?;
678678

679-
let output = package.finish()?.write()?;
680-
let mut output_stream = BufWriter::new(
679+
let output_stream = BufWriter::new(
681680
OpenOptions::new()
682681
.read(true)
683682
.write(true)
684683
.create(true)
685684
.truncate(true)
686685
.open(dwp_out_filename)?,
687686
);
688-
output_stream.write_all(&output)?;
689-
output_stream.flush()?;
687+
let mut output_stream = object::write::StreamingBuffer::new(output_stream);
688+
package.finish()?.emit(&mut output_stream)?;
689+
output_stream.result()?;
690+
output_stream.into_inner().flush()?;
690691

691692
Ok(())
692693
}) {

compiler/rustc_expand/src/base.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -676,8 +676,13 @@ pub enum SyntaxExtensionKind {
676676

677677
/// A token-based derive macro.
678678
Derive(
679-
/// An expander with signature TokenStream -> TokenStream (not yet).
679+
/// An expander with signature TokenStream -> TokenStream.
680680
/// The produced TokenSteam is appended to the input TokenSteam.
681+
///
682+
/// FIXME: The text above describes how this should work. Currently it
683+
/// is handled identically to `LegacyDerive`. It should be migrated to
684+
/// a token-based representation like `Bang` and `Attr`, instead of
685+
/// using `MultiItemModifier`.
681686
Box<dyn MultiItemModifier + sync::Sync + sync::Send>,
682687
),
683688

compiler/rustc_hir_typeck/src/method/probe.rs

+18-8
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use rustc_span::lev_distance::{
3131
use rustc_span::symbol::sym;
3232
use rustc_span::{symbol::Ident, Span, Symbol, DUMMY_SP};
3333
use rustc_trait_selection::autoderef::{self, Autoderef};
34+
use rustc_trait_selection::infer::InferCtxtExt as _;
3435
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt;
3536
use rustc_trait_selection::traits::query::method_autoderef::MethodAutoderefBadTy;
3637
use rustc_trait_selection::traits::query::method_autoderef::{
@@ -716,9 +717,10 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
716717
// maybe shouldn't include `Param`s, but rather fresh variables or be canonicalized,
717718
// see issue #89650
718719
let cause = traits::ObligationCause::misc(self.span, self.body_id);
719-
let selcx = &mut traits::SelectionContext::new(self.fcx);
720-
let traits::Normalized { value: xform_self_ty, obligations } =
721-
traits::normalize(selcx, self.param_env, cause, xform_self_ty);
720+
let InferOk { value: xform_self_ty, obligations } = self
721+
.fcx
722+
.partially_normalize_associated_types_in(cause, self.param_env, xform_self_ty);
723+
722724
debug!(
723725
"assemble_inherent_impl_probe after normalization: xform_self_ty = {:?}/{:?}",
724726
xform_self_ty, xform_ret_ty
@@ -1490,7 +1492,6 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
14901492
let mut xform_ret_ty = probe.xform_ret_ty;
14911493
debug!(?xform_ret_ty);
14921494

1493-
let selcx = &mut traits::SelectionContext::new(self);
14941495
let cause = traits::ObligationCause::misc(self.span, self.body_id);
14951496

14961497
let mut parent_pred = None;
@@ -1504,19 +1505,28 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
15041505
// `xform_ret_ty` hasn't been normalized yet, only `xform_self_ty`,
15051506
// see the reasons mentioned in the comments in `assemble_inherent_impl_probe`
15061507
// for why this is necessary
1507-
let traits::Normalized {
1508+
let InferOk {
15081509
value: normalized_xform_ret_ty,
15091510
obligations: normalization_obligations,
1510-
} = traits::normalize(selcx, self.param_env, cause.clone(), probe.xform_ret_ty);
1511+
} = self.fcx.partially_normalize_associated_types_in(
1512+
cause.clone(),
1513+
self.param_env,
1514+
probe.xform_ret_ty,
1515+
);
15111516
xform_ret_ty = normalized_xform_ret_ty;
15121517
debug!("xform_ret_ty after normalization: {:?}", xform_ret_ty);
15131518

15141519
// Check whether the impl imposes obligations we have to worry about.
15151520
let impl_def_id = probe.item.container_id(self.tcx);
15161521
let impl_bounds = self.tcx.predicates_of(impl_def_id);
15171522
let impl_bounds = impl_bounds.instantiate(self.tcx, substs);
1518-
let traits::Normalized { value: impl_bounds, obligations: norm_obligations } =
1519-
traits::normalize(selcx, self.param_env, cause.clone(), impl_bounds);
1523+
1524+
let InferOk { value: impl_bounds, obligations: norm_obligations } =
1525+
self.fcx.partially_normalize_associated_types_in(
1526+
cause.clone(),
1527+
self.param_env,
1528+
impl_bounds,
1529+
);
15201530

15211531
// Convert the bounds into obligations.
15221532
let impl_obligations = traits::predicates_for_generics(

compiler/rustc_middle/src/traits/mod.rs

-23
Original file line numberDiff line numberDiff line change
@@ -651,12 +651,6 @@ pub enum ImplSource<'tcx, N> {
651651
/// Same as above, but for a function pointer type with the given signature.
652652
FnPointer(ImplSourceFnPointerData<'tcx, N>),
653653

654-
/// ImplSource for a builtin `DeterminantKind` trait implementation.
655-
DiscriminantKind(ImplSourceDiscriminantKindData),
656-
657-
/// ImplSource for a builtin `Pointee` trait implementation.
658-
Pointee(ImplSourcePointeeData),
659-
660654
/// ImplSource automatically generated for a generator.
661655
Generator(ImplSourceGeneratorData<'tcx, N>),
662656

@@ -682,8 +676,6 @@ impl<'tcx, N> ImplSource<'tcx, N> {
682676
ImplSource::Future(c) => c.nested,
683677
ImplSource::Object(d) => d.nested,
684678
ImplSource::FnPointer(d) => d.nested,
685-
ImplSource::DiscriminantKind(ImplSourceDiscriminantKindData)
686-
| ImplSource::Pointee(ImplSourcePointeeData) => vec![],
687679
ImplSource::TraitAlias(d) => d.nested,
688680
ImplSource::TraitUpcasting(d) => d.nested,
689681
ImplSource::ConstDestruct(i) => i.nested,
@@ -701,8 +693,6 @@ impl<'tcx, N> ImplSource<'tcx, N> {
701693
ImplSource::Future(c) => &c.nested,
702694
ImplSource::Object(d) => &d.nested,
703695
ImplSource::FnPointer(d) => &d.nested,
704-
ImplSource::DiscriminantKind(ImplSourceDiscriminantKindData)
705-
| ImplSource::Pointee(ImplSourcePointeeData) => &[],
706696
ImplSource::TraitAlias(d) => &d.nested,
707697
ImplSource::TraitUpcasting(d) => &d.nested,
708698
ImplSource::ConstDestruct(i) => &i.nested,
@@ -751,12 +741,6 @@ impl<'tcx, N> ImplSource<'tcx, N> {
751741
fn_ty: p.fn_ty,
752742
nested: p.nested.into_iter().map(f).collect(),
753743
}),
754-
ImplSource::DiscriminantKind(ImplSourceDiscriminantKindData) => {
755-
ImplSource::DiscriminantKind(ImplSourceDiscriminantKindData)
756-
}
757-
ImplSource::Pointee(ImplSourcePointeeData) => {
758-
ImplSource::Pointee(ImplSourcePointeeData)
759-
}
760744
ImplSource::TraitAlias(d) => ImplSource::TraitAlias(ImplSourceTraitAliasData {
761745
alias_def_id: d.alias_def_id,
762746
substs: d.substs,
@@ -876,13 +860,6 @@ pub struct ImplSourceFnPointerData<'tcx, N> {
876860
pub nested: Vec<N>,
877861
}
878862

879-
// FIXME(@lcnr): This should be refactored and merged with other builtin vtables.
880-
#[derive(Clone, Debug, PartialEq, Eq, TyEncodable, TyDecodable, HashStable)]
881-
pub struct ImplSourceDiscriminantKindData;
882-
883-
#[derive(Clone, Debug, PartialEq, Eq, TyEncodable, TyDecodable, HashStable)]
884-
pub struct ImplSourcePointeeData;
885-
886863
#[derive(Clone, PartialEq, Eq, TyEncodable, TyDecodable, HashStable, Lift)]
887864
#[derive(TypeFoldable, TypeVisitable)]
888865
pub struct ImplSourceConstDestructData<N> {

compiler/rustc_middle/src/traits/select.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ pub type EvaluationCache<'tcx> = Cache<
105105
/// parameter environment.
106106
#[derive(PartialEq, Eq, Debug, Clone, TypeFoldable, TypeVisitable)]
107107
pub enum SelectionCandidate<'tcx> {
108+
/// A builtin implementation for some specific traits, used in cases
109+
/// where we cannot rely an ordinary library implementations.
110+
///
111+
/// The most notable examples are `sized`, `Copy` and `Clone`. This is also
112+
/// used for the `DiscriminantKind` and `Pointee` trait, both of which have
113+
/// an associated type.
108114
BuiltinCandidate {
109115
/// `false` if there are no *further* obligations.
110116
has_nested: bool,
@@ -141,12 +147,6 @@ pub enum SelectionCandidate<'tcx> {
141147
is_const: bool,
142148
},
143149

144-
/// Builtin implementation of `DiscriminantKind`.
145-
DiscriminantKindCandidate,
146-
147-
/// Builtin implementation of `Pointee`.
148-
PointeeCandidate,
149-
150150
TraitAliasCandidate,
151151

152152
/// Matching `dyn Trait` with a supertrait of `Trait`. The index is the

compiler/rustc_middle/src/traits/structural_impls.rs

-12
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSource<'tcx, N> {
1919

2020
super::ImplSource::FnPointer(ref d) => write!(f, "({:?})", d),
2121

22-
super::ImplSource::DiscriminantKind(ref d) => write!(f, "{:?}", d),
23-
24-
super::ImplSource::Pointee(ref d) => write!(f, "{:?}", d),
25-
2622
super::ImplSource::Object(ref d) => write!(f, "{:?}", d),
2723

2824
super::ImplSource::Param(ref n, ct) => {
@@ -137,11 +133,3 @@ impl<N: fmt::Debug> fmt::Debug for traits::ImplSourceConstDestructData<N> {
137133
write!(f, "ImplSourceConstDestructData(nested={:?})", self.nested)
138134
}
139135
}
140-
141-
///////////////////////////////////////////////////////////////////////////
142-
// Lift implementations
143-
144-
TrivialTypeTraversalAndLiftImpls! {
145-
super::ImplSourceDiscriminantKindData,
146-
super::ImplSourcePointeeData,
147-
}

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

+8-10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use super::{
99
};
1010
use crate::infer::error_reporting::{TyCategory, TypeAnnotationNeeded as ErrorCode};
1111
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
12+
use crate::infer::InferCtxtExt as _;
1213
use crate::infer::{self, InferCtxt, TyCtxtInferExt};
1314
use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
1415
use crate::traits::query::normalize::AtExt as _;
@@ -28,7 +29,7 @@ use rustc_hir::GenericParam;
2829
use rustc_hir::Item;
2930
use rustc_hir::Node;
3031
use rustc_infer::infer::error_reporting::TypeErrCtxt;
31-
use rustc_infer::infer::TypeTrace;
32+
use rustc_infer::infer::{InferOk, TypeTrace};
3233
use rustc_middle::traits::select::OverflowError;
3334
use rustc_middle::ty::abstract_const::NotConstEvaluatable;
3435
use rustc_middle::ty::error::ExpectedFound;
@@ -2530,18 +2531,15 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
25302531
}
25312532

25322533
self.probe(|_| {
2533-
let mut selcx = SelectionContext::new(self);
2534-
25352534
let cleaned_pred =
25362535
pred.fold_with(&mut ParamToVarFolder { infcx: self, var_map: Default::default() });
25372536

2538-
let cleaned_pred = super::project::normalize(
2539-
&mut selcx,
2540-
param_env,
2541-
ObligationCause::dummy(),
2542-
cleaned_pred,
2543-
)
2544-
.value;
2537+
let InferOk { value: cleaned_pred, .. } =
2538+
self.infcx.partially_normalize_associated_types_in(
2539+
ObligationCause::dummy(),
2540+
param_env,
2541+
cleaned_pred,
2542+
);
25452543

25462544
let obligation =
25472545
Obligation::new(self.tcx, ObligationCause::dummy(), param_env, cleaned_pred);

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+8-13
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
use super::{
2-
DefIdOrName, Obligation, ObligationCause, ObligationCauseCode, PredicateObligation,
3-
SelectionContext,
4-
};
1+
use super::{DefIdOrName, Obligation, ObligationCause, ObligationCauseCode, PredicateObligation};
52

63
use crate::autoderef::Autoderef;
74
use crate::infer::InferCtxt;
8-
use crate::traits::normalize_to;
95

106
use hir::def::CtorOf;
117
use hir::HirId;
@@ -23,7 +19,7 @@ use rustc_hir::lang_items::LangItem;
2319
use rustc_hir::{AsyncGeneratorKind, GeneratorKind, Node};
2420
use rustc_infer::infer::error_reporting::TypeErrCtxt;
2521
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
26-
use rustc_infer::infer::LateBoundRegionConversionTime;
22+
use rustc_infer::infer::{InferOk, LateBoundRegionConversionTime};
2723
use rustc_middle::hir::map;
2824
use rustc_middle::ty::{
2925
self, suggest_arbitrary_trait_bound, suggest_constraining_type_param, AdtKind, DefIdTree,
@@ -2979,13 +2975,12 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
29792975
self.tcx.mk_substs_trait(trait_pred.self_ty(), []),
29802976
)
29812977
});
2982-
let projection_ty = normalize_to(
2983-
&mut SelectionContext::new(self),
2984-
obligation.param_env,
2985-
obligation.cause.clone(),
2986-
projection_ty,
2987-
&mut vec![],
2988-
);
2978+
let InferOk { value: projection_ty, .. } = self
2979+
.partially_normalize_associated_types_in(
2980+
obligation.cause.clone(),
2981+
obligation.param_env,
2982+
projection_ty,
2983+
);
29892984

29902985
debug!(
29912986
normalized_projection_type = ?self.resolve_vars_if_possible(projection_ty)

0 commit comments

Comments
 (0)