Skip to content
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

[beta] backports and stage0 bump #117005

Merged
merged 12 commits into from
Oct 21, 2023
33 changes: 13 additions & 20 deletions compiler/rustc_borrowck/src/region_infer/opaque_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,26 +328,19 @@ fn check_opaque_type_well_formed<'tcx>(

// Require that the hidden type actually fulfills all the bounds of the opaque type, even without
// the bounds that the function supplies.
let mut obligations = vec![];
infcx
.insert_hidden_type(
OpaqueTypeKey { def_id, args: identity_args },
&ObligationCause::misc(definition_span, def_id),
param_env,
definition_ty,
true,
&mut obligations,
)
.unwrap();
infcx.add_item_bounds_for_hidden_type(
def_id.to_def_id(),
identity_args,
ObligationCause::misc(definition_span, def_id),
param_env,
definition_ty,
&mut obligations,
);
ocx.register_obligations(obligations);
let opaque_ty = Ty::new_opaque(tcx, def_id.to_def_id(), identity_args);
ocx.eq(&ObligationCause::misc(definition_span, def_id), param_env, opaque_ty, definition_ty)
.map_err(|err| {
infcx
.err_ctxt()
.report_mismatched_types(
&ObligationCause::misc(definition_span, def_id),
opaque_ty,
definition_ty,
err,
)
.emit()
})?;

// Require the hidden type to be well-formed with only the generics of the opaque type.
// Defining use functions may have more bounds than the opaque type, which is ok, as long as the
Expand Down
20 changes: 1 addition & 19 deletions compiler/rustc_infer/src/infer/opaque_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,25 +145,7 @@ impl<'tcx> InferCtxt<'tcx> {
return None;
}
}
DefiningAnchor::Bubble => {
if let ty::Alias(ty::Opaque, _) = b.kind() {
// In bubble mode we don't know which of the two opaque types is supposed to have the other
// as a hidden type (both, none or either one of them could be in its defining scope).
let predicate = ty::PredicateKind::AliasRelate(
a.into(),
b.into(),
ty::AliasRelationDirection::Equate,
);
let obligation = traits::Obligation::new(
self.tcx,
cause.clone(),
param_env,
predicate,
);
let obligations = vec![obligation];
return Some(Ok(InferOk { value: (), obligations }));
}
}
DefiningAnchor::Bubble => {}
DefiningAnchor::Error => return None,
};
if let ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, .. }) = *b.kind() {
Expand Down
13 changes: 10 additions & 3 deletions compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1767,6 +1767,7 @@ impl CheckAttrVisitor<'_> {
.collect();

let mut int_reprs = 0;
let mut is_explicit_rust = false;
let mut is_c = false;
let mut is_simd = false;
let mut is_transparent = false;
Expand All @@ -1778,7 +1779,9 @@ impl CheckAttrVisitor<'_> {
}

match hint.name_or_empty() {
sym::Rust => {}
sym::Rust => {
is_explicit_rust = true;
}
sym::C => {
is_c = true;
match target {
Expand Down Expand Up @@ -1888,12 +1891,16 @@ impl CheckAttrVisitor<'_> {

// Error on repr(transparent, <anything else>).
if is_transparent && hints.len() > 1 {
let hint_spans: Vec<_> = hint_spans.clone().collect();
let hint_spans = hint_spans.clone().collect();
self.tcx.sess.emit_err(errors::TransparentIncompatible {
hint_spans,
target: target.to_string(),
});
}
if is_explicit_rust && (int_reprs > 0 || is_c || is_simd) {
let hint_spans = hint_spans.clone().collect();
self.tcx.sess.emit_err(errors::ReprConflicting { hint_spans });
}
// Warn on repr(u8, u16), repr(C, simd), and c-like-enum-repr(C, u8)
if (int_reprs > 1)
|| (is_simd && is_c)
Expand All @@ -1910,7 +1917,7 @@ impl CheckAttrVisitor<'_> {
CONFLICTING_REPR_HINTS,
hir_id,
hint_spans.collect::<Vec<Span>>(),
errors::ReprConflicting,
errors::ReprConflictingLint,
);
}
}
Expand Down
9 changes: 8 additions & 1 deletion compiler/rustc_passes/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,9 +558,16 @@ pub struct ReprIdent {
pub span: Span,
}

#[derive(Diagnostic)]
#[diag(passes_repr_conflicting, code = "E0566")]
pub struct ReprConflicting {
#[primary_span]
pub hint_spans: Vec<Span>,
}

#[derive(LintDiagnostic)]
#[diag(passes_repr_conflicting, code = "E0566")]
pub struct ReprConflicting;
pub struct ReprConflictingLint;

#[derive(Diagnostic)]
#[diag(passes_used_static)]
Expand Down
23 changes: 2 additions & 21 deletions compiler/rustc_trait_selection/src/traits/fulfill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use rustc_infer::infer::DefineOpaqueTypes;
use rustc_infer::traits::ProjectionCacheKey;
use rustc_infer::traits::{PolyTraitObligation, SelectionError, TraitEngine};
use rustc_middle::mir::interpret::ErrorHandled;
use rustc_middle::traits::DefiningAnchor;
use rustc_middle::ty::abstract_const::NotConstEvaluatable;
use rustc_middle::ty::error::{ExpectedFound, TypeError};
use rustc_middle::ty::GenericArgsRef;
Expand Down Expand Up @@ -626,27 +625,9 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
}
}
ty::PredicateKind::Ambiguous => ProcessResult::Unchanged,
ty::PredicateKind::AliasRelate(..)
if matches!(self.selcx.infcx.defining_use_anchor, DefiningAnchor::Bubble) =>
{
ProcessResult::Unchanged
ty::PredicateKind::AliasRelate(..) => {
bug!("AliasRelate is only used for new solver")
}
ty::PredicateKind::AliasRelate(a, b, relate) => match relate {
ty::AliasRelationDirection::Equate => match self
.selcx
.infcx
.at(&obligation.cause, obligation.param_env)
.eq(DefineOpaqueTypes::Yes, a, b)
{
Ok(inf_ok) => ProcessResult::Changed(mk_pending(inf_ok.into_obligations())),
Err(_) => ProcessResult::Error(FulfillmentErrorCode::CodeSelectionError(
SelectionError::Unimplemented,
)),
},
ty::AliasRelationDirection::Subtype => {
bug!("AliasRelate with subtyping is only used for new solver")
}
},
ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct, ty)) => {
match self.selcx.infcx.at(&obligation.cause, obligation.param_env).eq(
DefineOpaqueTypes::No,
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_trait_selection/src/traits/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,7 @@ fn opt_normalize_projection_type<'a, 'b, 'tcx>(

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

let result = if projected_term.has_projections() {
let mut result = if projected_term.has_projections() {
let mut normalizer = AssocTypeNormalizer::new(
selcx,
param_env,
Expand All @@ -1243,14 +1243,14 @@ fn opt_normalize_projection_type<'a, 'b, 'tcx>(
);
let normalized_ty = normalizer.fold(projected_term);

let mut deduped = SsoHashSet::with_capacity(projected_obligations.len());
projected_obligations.retain(|obligation| deduped.insert(obligation.clone()));

Normalized { value: normalized_ty, obligations: projected_obligations }
} else {
Normalized { value: projected_term, obligations: projected_obligations }
};

let mut deduped = SsoHashSet::with_capacity(result.obligations.len());
result.obligations.retain(|obligation| deduped.insert(obligation.clone()));

if use_cache {
infcx.inner.borrow_mut().projection_cache().insert_term(cache_key, result.clone());
}
Expand Down
23 changes: 2 additions & 21 deletions compiler/rustc_trait_selection/src/traits/select/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ use rustc_infer::traits::TraitObligation;
use rustc_middle::dep_graph::dep_kinds;
use rustc_middle::dep_graph::DepNodeIndex;
use rustc_middle::mir::interpret::ErrorHandled;
use rustc_middle::traits::DefiningAnchor;
use rustc_middle::ty::abstract_const::NotConstEvaluatable;
use rustc_middle::ty::fold::BottomUpFolder;
use rustc_middle::ty::relate::TypeRelation;
Expand Down Expand Up @@ -1003,27 +1002,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
}
}
}
ty::PredicateKind::AliasRelate(..)
if matches!(self.infcx.defining_use_anchor, DefiningAnchor::Bubble) =>
{
Ok(EvaluatedToAmbig)
ty::PredicateKind::AliasRelate(..) => {
bug!("AliasRelate is only used for new solver")
}
ty::PredicateKind::AliasRelate(a, b, relate) => match relate {
ty::AliasRelationDirection::Equate => match self
.infcx
.at(&obligation.cause, obligation.param_env)
.eq(DefineOpaqueTypes::Yes, a, b)
{
Ok(inf_ok) => self.evaluate_predicates_recursively(
previous_stack,
inf_ok.into_obligations(),
),
Err(_) => Ok(EvaluatedToErr),
},
ty::AliasRelationDirection::Subtype => {
bug!("AliasRelate subtyping is only used for new solver")
}
},
ty::PredicateKind::Ambiguous => Ok(EvaluatedToAmbig),
ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct, ty)) => {
match self.infcx.at(&obligation.cause, obligation.param_env).eq(
Expand Down
1 change: 0 additions & 1 deletion library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@
//
// Language features:
// tidy-alphabetical-start
#![cfg_attr(not(bootstrap), feature(effects))]
#![feature(abi_unadjusted)]
#![feature(adt_const_params)]
#![feature(allow_internal_unsafe)]
Expand Down
28 changes: 19 additions & 9 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ fn clean_generic_param_def<'tcx>(
},
)
}
ty::GenericParamDefKind::Const { has_default, .. } => (
ty::GenericParamDefKind::Const { has_default, is_host_effect } => (
def.name,
GenericParamDefKind::Const {
ty: Box::new(clean_middle_ty(
Expand All @@ -562,6 +562,7 @@ fn clean_generic_param_def<'tcx>(
)),
false => None,
},
is_host_effect,
},
),
};
Expand Down Expand Up @@ -618,6 +619,7 @@ fn clean_generic_param<'tcx>(
ty: Box::new(clean_ty(ty, cx)),
default: default
.map(|ct| Box::new(ty::Const::from_anon_const(cx.tcx, ct.def_id).to_string())),
is_host_effect: cx.tcx.has_attr(param.def_id, sym::rustc_host),
},
),
};
Expand Down Expand Up @@ -2540,14 +2542,22 @@ fn clean_generic_args<'tcx>(
let args = generic_args
.args
.iter()
.map(|arg| match arg {
hir::GenericArg::Lifetime(lt) if !lt.is_anonymous() => {
GenericArg::Lifetime(clean_lifetime(*lt, cx))
}
hir::GenericArg::Lifetime(_) => GenericArg::Lifetime(Lifetime::elided()),
hir::GenericArg::Type(ty) => GenericArg::Type(clean_ty(ty, cx)),
hir::GenericArg::Const(ct) => GenericArg::Const(Box::new(clean_const(ct, cx))),
hir::GenericArg::Infer(_inf) => GenericArg::Infer,
.filter_map(|arg| {
Some(match arg {
hir::GenericArg::Lifetime(lt) if !lt.is_anonymous() => {
GenericArg::Lifetime(clean_lifetime(*lt, cx))
}
hir::GenericArg::Lifetime(_) => GenericArg::Lifetime(Lifetime::elided()),
hir::GenericArg::Type(ty) => GenericArg::Type(clean_ty(ty, cx)),
// FIXME(effects): This will still emit `<true>` for non-const impls of const traits
hir::GenericArg::Const(ct)
if cx.tcx.has_attr(ct.value.def_id, sym::rustc_host) =>
{
return None;
}
hir::GenericArg::Const(ct) => GenericArg::Const(Box::new(clean_const(ct, cx))),
hir::GenericArg::Infer(_inf) => GenericArg::Infer,
})
})
.collect::<Vec<_>>()
.into();
Expand Down
7 changes: 4 additions & 3 deletions src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1315,7 +1315,7 @@ impl WherePredicate {
pub(crate) enum GenericParamDefKind {
Lifetime { outlives: Vec<Lifetime> },
Type { did: DefId, bounds: Vec<GenericBound>, default: Option<Box<Type>>, synthetic: bool },
Const { ty: Box<Type>, default: Option<Box<String>> },
Const { ty: Box<Type>, default: Option<Box<String>>, is_host_effect: bool },
}

impl GenericParamDefKind {
Expand All @@ -1335,9 +1335,10 @@ impl GenericParamDef {
Self { name, kind: GenericParamDefKind::Lifetime { outlives: Vec::new() } }
}

pub(crate) fn is_synthetic_type_param(&self) -> bool {
pub(crate) fn is_synthetic_param(&self) -> bool {
match self.kind {
GenericParamDefKind::Lifetime { .. } | GenericParamDefKind::Const { .. } => false,
GenericParamDefKind::Lifetime { .. } => false,
GenericParamDefKind::Const { is_host_effect, .. } => is_host_effect,
GenericParamDefKind::Type { synthetic, .. } => synthetic,
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/librustdoc/clean/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ pub(crate) fn ty_args_to_args<'tcx>(
arg: index,
}),
))),
// FIXME(effects): this relies on the host effect being called `host`, which users could also name
// their const generics.
// FIXME(effects): this causes `host = true` and `host = false` generics to also be emitted.
GenericArgKind::Const(ct) if let ty::ConstKind::Param(p) = ct.kind() && p.name == sym::host => None,
GenericArgKind::Const(ct) => {
Some(GenericArg::Const(Box::new(clean_middle_const(kind.rebind(ct), cx))))
}
Expand Down
3 changes: 1 addition & 2 deletions src/librustdoc/html/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,7 @@ impl clean::Generics {
cx: &'a Context<'tcx>,
) -> impl fmt::Display + 'a + Captures<'tcx> {
display_fn(move |f| {
let mut real_params =
self.params.iter().filter(|p| !p.is_synthetic_type_param()).peekable();
let mut real_params = self.params.iter().filter(|p| !p.is_synthetic_param()).peekable();
if real_params.peek().is_none() {
return Ok(());
}
Expand Down
16 changes: 9 additions & 7 deletions src/librustdoc/json/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ impl FromWithTcx<clean::GenericParamDefKind> for GenericParamDefKind {
default: default.map(|x| (*x).into_tcx(tcx)),
synthetic,
},
Const { ty, default } => GenericParamDefKind::Const {
Const { ty, default, is_host_effect: _ } => GenericParamDefKind::Const {
type_: (*ty).into_tcx(tcx),
default: default.map(|x| *x),
},
Expand Down Expand Up @@ -491,12 +491,14 @@ impl FromWithTcx<clean::WherePredicate> for WherePredicate {
default: default.map(|ty| (*ty).into_tcx(tcx)),
synthetic,
},
clean::GenericParamDefKind::Const { ty, default } => {
GenericParamDefKind::Const {
type_: (*ty).into_tcx(tcx),
default: default.map(|d| *d),
}
}
clean::GenericParamDefKind::Const {
ty,
default,
is_host_effect: _,
} => GenericParamDefKind::Const {
type_: (*ty).into_tcx(tcx),
default: default.map(|d| *d),
},
};
GenericParamDef { name, kind }
})
Expand Down
1 change: 1 addition & 0 deletions src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#![feature(array_methods)]
#![feature(assert_matches)]
#![feature(box_patterns)]
#![feature(if_let_guard)]
#![feature(impl_trait_in_assoc_type)]
#![feature(iter_intersperse)]
#![feature(lazy_cell)]
Expand Down
2 changes: 1 addition & 1 deletion src/llvm-project
Submodule llvm-project updated 60 files
+3 −0 .github/workflows/llvm-tests.yml
+1 −1 .github/workflows/release-binaries.yml
+1 −1 clang/docs/ClangFormatStyleOptions.rst
+4 −4 clang/docs/ReleaseNotes.rst
+15 −3 clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
+7 −2 clang/lib/Driver/ToolChains/MinGW.cpp
+24 −0 clang/lib/Format/UnwrappedLineParser.cpp
+11 −0 clang/lib/Format/UnwrappedLineParser.h
+2 −0 clang/lib/Headers/CMakeLists.txt
+9 −0 clang/lib/Headers/cuda_wrappers/bits/basic_string.h
+9 −0 clang/lib/Headers/cuda_wrappers/bits/basic_string.tcc
+17 −14 clang/lib/Sema/SemaChecking.cpp
+64 −15 clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
+38 −0 clang/test/ClangScanDeps/relative-filenames.c
+10 −0 clang/test/Driver/mingw-linker-options.c
+3 −0 clang/test/Driver/mingw.cpp
+35 −0 clang/test/FixIt/format-darwin-enum-class.cpp
+63 −5 clang/test/FixIt/format.cpp
+1 −1 clang/tools/clang-format/git-clang-format
+50 −0 clang/unittests/Format/FormatTest.cpp
+11 −6 clang/utils/TableGen/ClangAttrEmitter.cpp
+19 −0 compiler-rt/CMakeLists.txt
+3 −0 compiler-rt/test/lsan/TestCases/create_thread_leak.cpp
+1 −1 libcxx/include/__config
+2 −2 libcxx/include/__utility/pair.h
+31 −0 libcxx/test/std/utilities/utility/pairs/pairs.pair/ctor.pair_like.pass.cpp
+22 −20 lld/COFF/Driver.cpp
+2 −0 lld/COFF/InputFiles.cpp
+1 −1 lld/Common/Filesystem.cpp
+31 −0 lld/test/COFF/comdat-drectve.s
+18 −14 lld/test/COFF/print-search-paths.s
+0 −24 lldb/cmake/modules/LLDBConfig.cmake
+13 −0 lldb/cmake/modules/LLDBStandalone.cmake
+4 −6 lldb/source/API/CMakeLists.txt
+1 −1 llvm/CMakeLists.txt
+1 −1 llvm/lib/Analysis/LazyValueInfo.cpp
+1 −1 llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+3 −0 llvm/lib/MC/MCWin64EH.cpp
+6 −1 llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+23 −5 llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+1 −1 llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+18 −3 llvm/lib/Target/X86/X86ISelLowering.cpp
+32 −29 llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+21 −0 llvm/test/CodeGen/AArch64/sched-loop-align.ll
+16 −0 llvm/test/CodeGen/PowerPC/and-extend-combine.ll
+75 −0 llvm/test/CodeGen/PowerPC/pgo-ref-directive.ll
+10 −0 llvm/test/CodeGen/X86/code-model-elf-sections.ll
+138 −0 llvm/test/CodeGen/X86/movmsk-cmp.ll
+190 −0 llvm/test/CodeGen/X86/pr67333.ll
+4 −4 llvm/test/CodeGen/X86/subvector-broadcast.ll
+9 −7 llvm/test/CodeGen/X86/vector-interleaved-store-i8-stride-7.ll
+120 −122 llvm/test/CodeGen/X86/widen_bitcnt.ll
+34 −30 llvm/test/CodeGen/X86/zero_extend_vector_inreg_of_broadcast.ll
+3 −1 llvm/test/Instrumentation/AddressSanitizer/basic.ll
+15 −4 llvm/test/Instrumentation/AddressSanitizer/global_metadata_array.ll
+47 −3 llvm/test/Instrumentation/AddressSanitizer/global_with_comdat.ll
+37 −0 llvm/test/Transforms/CorrelatedValuePropagation/merge-range-and-undef.ll
+1 −1 llvm/utils/gn/secondary/llvm/version.gni
+1 −1 llvm/utils/lit/lit/__init__.py
+1 −1 llvm/utils/release/export.sh
Loading
Loading