Skip to content

Commit 489647f

Browse files
committed
Auto merge of rust-lang#117005 - cuviper:beta-next, r=cuviper
[beta] backports and stage0 bump - Bump stage0 to released stable compiler - Hide host effect params from docs rust-lang#116670 - Fix a performance regression in obligation deduplication. rust-lang#116826 - Make `#[repr(Rust)]` and `#[repr(C)]` incompatible with one another rust-lang#116829 - Update to LLVM 17.0.3 rust-lang#116840 - Disable effects in libcore again rust-lang#116856 - revert rust-lang#114586 rust-lang#116879 r? cuviper
2 parents ae8769d + eec25d6 commit 489647f

31 files changed

+602
-508
lines changed

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

+13-20
Original file line numberDiff line numberDiff line change
@@ -328,26 +328,19 @@ fn check_opaque_type_well_formed<'tcx>(
328328

329329
// Require that the hidden type actually fulfills all the bounds of the opaque type, even without
330330
// the bounds that the function supplies.
331-
let mut obligations = vec![];
332-
infcx
333-
.insert_hidden_type(
334-
OpaqueTypeKey { def_id, args: identity_args },
335-
&ObligationCause::misc(definition_span, def_id),
336-
param_env,
337-
definition_ty,
338-
true,
339-
&mut obligations,
340-
)
341-
.unwrap();
342-
infcx.add_item_bounds_for_hidden_type(
343-
def_id.to_def_id(),
344-
identity_args,
345-
ObligationCause::misc(definition_span, def_id),
346-
param_env,
347-
definition_ty,
348-
&mut obligations,
349-
);
350-
ocx.register_obligations(obligations);
331+
let opaque_ty = Ty::new_opaque(tcx, def_id.to_def_id(), identity_args);
332+
ocx.eq(&ObligationCause::misc(definition_span, def_id), param_env, opaque_ty, definition_ty)
333+
.map_err(|err| {
334+
infcx
335+
.err_ctxt()
336+
.report_mismatched_types(
337+
&ObligationCause::misc(definition_span, def_id),
338+
opaque_ty,
339+
definition_ty,
340+
err,
341+
)
342+
.emit()
343+
})?;
351344

352345
// Require the hidden type to be well-formed with only the generics of the opaque type.
353346
// Defining use functions may have more bounds than the opaque type, which is ok, as long as the

compiler/rustc_infer/src/infer/opaque_types.rs

+1-19
Original file line numberDiff line numberDiff line change
@@ -145,25 +145,7 @@ impl<'tcx> InferCtxt<'tcx> {
145145
return None;
146146
}
147147
}
148-
DefiningAnchor::Bubble => {
149-
if let ty::Alias(ty::Opaque, _) = b.kind() {
150-
// In bubble mode we don't know which of the two opaque types is supposed to have the other
151-
// as a hidden type (both, none or either one of them could be in its defining scope).
152-
let predicate = ty::PredicateKind::AliasRelate(
153-
a.into(),
154-
b.into(),
155-
ty::AliasRelationDirection::Equate,
156-
);
157-
let obligation = traits::Obligation::new(
158-
self.tcx,
159-
cause.clone(),
160-
param_env,
161-
predicate,
162-
);
163-
let obligations = vec![obligation];
164-
return Some(Ok(InferOk { value: (), obligations }));
165-
}
166-
}
148+
DefiningAnchor::Bubble => {}
167149
DefiningAnchor::Error => return None,
168150
};
169151
if let ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, .. }) = *b.kind() {

compiler/rustc_passes/src/check_attr.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -1767,6 +1767,7 @@ impl CheckAttrVisitor<'_> {
17671767
.collect();
17681768

17691769
let mut int_reprs = 0;
1770+
let mut is_explicit_rust = false;
17701771
let mut is_c = false;
17711772
let mut is_simd = false;
17721773
let mut is_transparent = false;
@@ -1778,7 +1779,9 @@ impl CheckAttrVisitor<'_> {
17781779
}
17791780

17801781
match hint.name_or_empty() {
1781-
sym::Rust => {}
1782+
sym::Rust => {
1783+
is_explicit_rust = true;
1784+
}
17821785
sym::C => {
17831786
is_c = true;
17841787
match target {
@@ -1888,12 +1891,16 @@ impl CheckAttrVisitor<'_> {
18881891

18891892
// Error on repr(transparent, <anything else>).
18901893
if is_transparent && hints.len() > 1 {
1891-
let hint_spans: Vec<_> = hint_spans.clone().collect();
1894+
let hint_spans = hint_spans.clone().collect();
18921895
self.tcx.sess.emit_err(errors::TransparentIncompatible {
18931896
hint_spans,
18941897
target: target.to_string(),
18951898
});
18961899
}
1900+
if is_explicit_rust && (int_reprs > 0 || is_c || is_simd) {
1901+
let hint_spans = hint_spans.clone().collect();
1902+
self.tcx.sess.emit_err(errors::ReprConflicting { hint_spans });
1903+
}
18971904
// Warn on repr(u8, u16), repr(C, simd), and c-like-enum-repr(C, u8)
18981905
if (int_reprs > 1)
18991906
|| (is_simd && is_c)
@@ -1910,7 +1917,7 @@ impl CheckAttrVisitor<'_> {
19101917
CONFLICTING_REPR_HINTS,
19111918
hir_id,
19121919
hint_spans.collect::<Vec<Span>>(),
1913-
errors::ReprConflicting,
1920+
errors::ReprConflictingLint,
19141921
);
19151922
}
19161923
}

compiler/rustc_passes/src/errors.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -558,9 +558,16 @@ pub struct ReprIdent {
558558
pub span: Span,
559559
}
560560

561+
#[derive(Diagnostic)]
562+
#[diag(passes_repr_conflicting, code = "E0566")]
563+
pub struct ReprConflicting {
564+
#[primary_span]
565+
pub hint_spans: Vec<Span>,
566+
}
567+
561568
#[derive(LintDiagnostic)]
562569
#[diag(passes_repr_conflicting, code = "E0566")]
563-
pub struct ReprConflicting;
570+
pub struct ReprConflictingLint;
564571

565572
#[derive(Diagnostic)]
566573
#[diag(passes_used_static)]

compiler/rustc_trait_selection/src/traits/fulfill.rs

+2-21
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use rustc_infer::infer::DefineOpaqueTypes;
66
use rustc_infer::traits::ProjectionCacheKey;
77
use rustc_infer::traits::{PolyTraitObligation, SelectionError, TraitEngine};
88
use rustc_middle::mir::interpret::ErrorHandled;
9-
use rustc_middle::traits::DefiningAnchor;
109
use rustc_middle::ty::abstract_const::NotConstEvaluatable;
1110
use rustc_middle::ty::error::{ExpectedFound, TypeError};
1211
use rustc_middle::ty::GenericArgsRef;
@@ -626,27 +625,9 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
626625
}
627626
}
628627
ty::PredicateKind::Ambiguous => ProcessResult::Unchanged,
629-
ty::PredicateKind::AliasRelate(..)
630-
if matches!(self.selcx.infcx.defining_use_anchor, DefiningAnchor::Bubble) =>
631-
{
632-
ProcessResult::Unchanged
628+
ty::PredicateKind::AliasRelate(..) => {
629+
bug!("AliasRelate is only used for new solver")
633630
}
634-
ty::PredicateKind::AliasRelate(a, b, relate) => match relate {
635-
ty::AliasRelationDirection::Equate => match self
636-
.selcx
637-
.infcx
638-
.at(&obligation.cause, obligation.param_env)
639-
.eq(DefineOpaqueTypes::Yes, a, b)
640-
{
641-
Ok(inf_ok) => ProcessResult::Changed(mk_pending(inf_ok.into_obligations())),
642-
Err(_) => ProcessResult::Error(FulfillmentErrorCode::CodeSelectionError(
643-
SelectionError::Unimplemented,
644-
)),
645-
},
646-
ty::AliasRelationDirection::Subtype => {
647-
bug!("AliasRelate with subtyping is only used for new solver")
648-
}
649-
},
650631
ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct, ty)) => {
651632
match self.selcx.infcx.at(&obligation.cause, obligation.param_env).eq(
652633
DefineOpaqueTypes::No,

compiler/rustc_trait_selection/src/traits/project.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1233,7 +1233,7 @@ fn opt_normalize_projection_type<'a, 'b, 'tcx>(
12331233

12341234
let projected_term = selcx.infcx.resolve_vars_if_possible(projected_term);
12351235

1236-
let result = if projected_term.has_projections() {
1236+
let mut result = if projected_term.has_projections() {
12371237
let mut normalizer = AssocTypeNormalizer::new(
12381238
selcx,
12391239
param_env,
@@ -1243,14 +1243,14 @@ fn opt_normalize_projection_type<'a, 'b, 'tcx>(
12431243
);
12441244
let normalized_ty = normalizer.fold(projected_term);
12451245

1246-
let mut deduped = SsoHashSet::with_capacity(projected_obligations.len());
1247-
projected_obligations.retain(|obligation| deduped.insert(obligation.clone()));
1248-
12491246
Normalized { value: normalized_ty, obligations: projected_obligations }
12501247
} else {
12511248
Normalized { value: projected_term, obligations: projected_obligations }
12521249
};
12531250

1251+
let mut deduped = SsoHashSet::with_capacity(result.obligations.len());
1252+
result.obligations.retain(|obligation| deduped.insert(obligation.clone()));
1253+
12541254
if use_cache {
12551255
infcx.inner.borrow_mut().projection_cache().insert_term(cache_key, result.clone());
12561256
}

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

+2-21
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ use rustc_infer::traits::TraitObligation;
3838
use rustc_middle::dep_graph::dep_kinds;
3939
use rustc_middle::dep_graph::DepNodeIndex;
4040
use rustc_middle::mir::interpret::ErrorHandled;
41-
use rustc_middle::traits::DefiningAnchor;
4241
use rustc_middle::ty::abstract_const::NotConstEvaluatable;
4342
use rustc_middle::ty::fold::BottomUpFolder;
4443
use rustc_middle::ty::relate::TypeRelation;
@@ -1003,27 +1002,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
10031002
}
10041003
}
10051004
}
1006-
ty::PredicateKind::AliasRelate(..)
1007-
if matches!(self.infcx.defining_use_anchor, DefiningAnchor::Bubble) =>
1008-
{
1009-
Ok(EvaluatedToAmbig)
1005+
ty::PredicateKind::AliasRelate(..) => {
1006+
bug!("AliasRelate is only used for new solver")
10101007
}
1011-
ty::PredicateKind::AliasRelate(a, b, relate) => match relate {
1012-
ty::AliasRelationDirection::Equate => match self
1013-
.infcx
1014-
.at(&obligation.cause, obligation.param_env)
1015-
.eq(DefineOpaqueTypes::Yes, a, b)
1016-
{
1017-
Ok(inf_ok) => self.evaluate_predicates_recursively(
1018-
previous_stack,
1019-
inf_ok.into_obligations(),
1020-
),
1021-
Err(_) => Ok(EvaluatedToErr),
1022-
},
1023-
ty::AliasRelationDirection::Subtype => {
1024-
bug!("AliasRelate subtyping is only used for new solver")
1025-
}
1026-
},
10271008
ty::PredicateKind::Ambiguous => Ok(EvaluatedToAmbig),
10281009
ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct, ty)) => {
10291010
match self.infcx.at(&obligation.cause, obligation.param_env).eq(

library/core/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@
196196
//
197197
// Language features:
198198
// tidy-alphabetical-start
199-
#![cfg_attr(not(bootstrap), feature(effects))]
200199
#![feature(abi_unadjusted)]
201200
#![feature(adt_const_params)]
202201
#![feature(allow_internal_unsafe)]

src/librustdoc/clean/mod.rs

+19-9
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ fn clean_generic_param_def<'tcx>(
542542
},
543543
)
544544
}
545-
ty::GenericParamDefKind::Const { has_default, .. } => (
545+
ty::GenericParamDefKind::Const { has_default, is_host_effect } => (
546546
def.name,
547547
GenericParamDefKind::Const {
548548
ty: Box::new(clean_middle_ty(
@@ -562,6 +562,7 @@ fn clean_generic_param_def<'tcx>(
562562
)),
563563
false => None,
564564
},
565+
is_host_effect,
565566
},
566567
),
567568
};
@@ -618,6 +619,7 @@ fn clean_generic_param<'tcx>(
618619
ty: Box::new(clean_ty(ty, cx)),
619620
default: default
620621
.map(|ct| Box::new(ty::Const::from_anon_const(cx.tcx, ct.def_id).to_string())),
622+
is_host_effect: cx.tcx.has_attr(param.def_id, sym::rustc_host),
621623
},
622624
),
623625
};
@@ -2540,14 +2542,22 @@ fn clean_generic_args<'tcx>(
25402542
let args = generic_args
25412543
.args
25422544
.iter()
2543-
.map(|arg| match arg {
2544-
hir::GenericArg::Lifetime(lt) if !lt.is_anonymous() => {
2545-
GenericArg::Lifetime(clean_lifetime(*lt, cx))
2546-
}
2547-
hir::GenericArg::Lifetime(_) => GenericArg::Lifetime(Lifetime::elided()),
2548-
hir::GenericArg::Type(ty) => GenericArg::Type(clean_ty(ty, cx)),
2549-
hir::GenericArg::Const(ct) => GenericArg::Const(Box::new(clean_const(ct, cx))),
2550-
hir::GenericArg::Infer(_inf) => GenericArg::Infer,
2545+
.filter_map(|arg| {
2546+
Some(match arg {
2547+
hir::GenericArg::Lifetime(lt) if !lt.is_anonymous() => {
2548+
GenericArg::Lifetime(clean_lifetime(*lt, cx))
2549+
}
2550+
hir::GenericArg::Lifetime(_) => GenericArg::Lifetime(Lifetime::elided()),
2551+
hir::GenericArg::Type(ty) => GenericArg::Type(clean_ty(ty, cx)),
2552+
// FIXME(effects): This will still emit `<true>` for non-const impls of const traits
2553+
hir::GenericArg::Const(ct)
2554+
if cx.tcx.has_attr(ct.value.def_id, sym::rustc_host) =>
2555+
{
2556+
return None;
2557+
}
2558+
hir::GenericArg::Const(ct) => GenericArg::Const(Box::new(clean_const(ct, cx))),
2559+
hir::GenericArg::Infer(_inf) => GenericArg::Infer,
2560+
})
25512561
})
25522562
.collect::<Vec<_>>()
25532563
.into();

src/librustdoc/clean/types.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1315,7 +1315,7 @@ impl WherePredicate {
13151315
pub(crate) enum GenericParamDefKind {
13161316
Lifetime { outlives: Vec<Lifetime> },
13171317
Type { did: DefId, bounds: Vec<GenericBound>, default: Option<Box<Type>>, synthetic: bool },
1318-
Const { ty: Box<Type>, default: Option<Box<String>> },
1318+
Const { ty: Box<Type>, default: Option<Box<String>>, is_host_effect: bool },
13191319
}
13201320

13211321
impl GenericParamDefKind {
@@ -1335,9 +1335,10 @@ impl GenericParamDef {
13351335
Self { name, kind: GenericParamDefKind::Lifetime { outlives: Vec::new() } }
13361336
}
13371337

1338-
pub(crate) fn is_synthetic_type_param(&self) -> bool {
1338+
pub(crate) fn is_synthetic_param(&self) -> bool {
13391339
match self.kind {
1340-
GenericParamDefKind::Lifetime { .. } | GenericParamDefKind::Const { .. } => false,
1340+
GenericParamDefKind::Lifetime { .. } => false,
1341+
GenericParamDefKind::Const { is_host_effect, .. } => is_host_effect,
13411342
GenericParamDefKind::Type { synthetic, .. } => synthetic,
13421343
}
13431344
}

src/librustdoc/clean/utils.rs

+4
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ pub(crate) fn ty_args_to_args<'tcx>(
104104
arg: index,
105105
}),
106106
))),
107+
// FIXME(effects): this relies on the host effect being called `host`, which users could also name
108+
// their const generics.
109+
// FIXME(effects): this causes `host = true` and `host = false` generics to also be emitted.
110+
GenericArgKind::Const(ct) if let ty::ConstKind::Param(p) = ct.kind() && p.name == sym::host => None,
107111
GenericArgKind::Const(ct) => {
108112
Some(GenericArg::Const(Box::new(clean_middle_const(kind.rebind(ct), cx))))
109113
}

src/librustdoc/html/format.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,7 @@ impl clean::Generics {
250250
cx: &'a Context<'tcx>,
251251
) -> impl fmt::Display + 'a + Captures<'tcx> {
252252
display_fn(move |f| {
253-
let mut real_params =
254-
self.params.iter().filter(|p| !p.is_synthetic_type_param()).peekable();
253+
let mut real_params = self.params.iter().filter(|p| !p.is_synthetic_param()).peekable();
255254
if real_params.peek().is_none() {
256255
return Ok(());
257256
}

src/librustdoc/json/conversions.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ impl FromWithTcx<clean::GenericParamDefKind> for GenericParamDefKind {
453453
default: default.map(|x| (*x).into_tcx(tcx)),
454454
synthetic,
455455
},
456-
Const { ty, default } => GenericParamDefKind::Const {
456+
Const { ty, default, is_host_effect: _ } => GenericParamDefKind::Const {
457457
type_: (*ty).into_tcx(tcx),
458458
default: default.map(|x| *x),
459459
},
@@ -491,12 +491,14 @@ impl FromWithTcx<clean::WherePredicate> for WherePredicate {
491491
default: default.map(|ty| (*ty).into_tcx(tcx)),
492492
synthetic,
493493
},
494-
clean::GenericParamDefKind::Const { ty, default } => {
495-
GenericParamDefKind::Const {
496-
type_: (*ty).into_tcx(tcx),
497-
default: default.map(|d| *d),
498-
}
499-
}
494+
clean::GenericParamDefKind::Const {
495+
ty,
496+
default,
497+
is_host_effect: _,
498+
} => GenericParamDefKind::Const {
499+
type_: (*ty).into_tcx(tcx),
500+
default: default.map(|d| *d),
501+
},
500502
};
501503
GenericParamDef { name, kind }
502504
})

src/librustdoc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#![feature(array_methods)]
77
#![feature(assert_matches)]
88
#![feature(box_patterns)]
9+
#![feature(if_let_guard)]
910
#![feature(impl_trait_in_assoc_type)]
1011
#![feature(iter_intersperse)]
1112
#![feature(lazy_cell)]

src/llvm-project

Submodule llvm-project updated 60 files

0 commit comments

Comments
 (0)