Skip to content

Commit 8f117a7

Browse files
committed
Auto merge of #91865 - matthiaskrgr:rollup-rai9ecq, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - #91699 (Add `-webkit-appearance: none` to search input) - #91846 (rustdoc: Reduce number of arguments for `run_test` a bit) - #91847 (Fix FIXME for `generic_arg_infer` in `create_substs_for_ast_path`) - #91849 (GATs outlives lint: Try to prove bounds) - #91855 (Stabilize const_cstr_unchecked) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 1796de7 + ff214b7 commit 8f117a7

File tree

18 files changed

+300
-177
lines changed

18 files changed

+300
-177
lines changed

Diff for: compiler/rustc_codegen_llvm/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
77
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
88
#![feature(bool_to_option)]
9-
#![feature(const_cstr_unchecked)]
109
#![feature(crate_visibility_modifier)]
1110
#![feature(extern_types)]
1211
#![feature(in_band_lifetimes)]

Diff for: compiler/rustc_infer/src/infer/free_regions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_middle::ty::{self, Lift, Region, TyCtxt};
1111
///
1212
/// This stuff is a bit convoluted and should be refactored, but as we
1313
/// transition to NLL, it'll all go away anyhow.
14-
pub struct RegionRelations<'a, 'tcx> {
14+
pub(crate) struct RegionRelations<'a, 'tcx> {
1515
pub tcx: TyCtxt<'tcx>,
1616

1717
/// The context used for debug messages

Diff for: compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use std::fmt;
2828
/// assuming such values can be found. It returns the final values of
2929
/// all the variables as well as a set of errors that must be reported.
3030
#[instrument(level = "debug", skip(region_rels, var_infos, data))]
31-
pub fn resolve<'tcx>(
31+
pub(crate) fn resolve<'tcx>(
3232
region_rels: &RegionRelations<'_, 'tcx>,
3333
var_infos: VarInfos,
3434
data: RegionConstraintData<'tcx>,

Diff for: compiler/rustc_typeck/src/astconv/mod.rs

+33-55
Original file line numberDiff line numberDiff line change
@@ -414,34 +414,40 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
414414
arg: &GenericArg<'_>,
415415
) -> subst::GenericArg<'tcx> {
416416
let tcx = self.astconv.tcx();
417+
418+
let mut handle_ty_args = |has_default, ty: &hir::Ty<'_>| {
419+
if has_default {
420+
tcx.check_optional_stability(
421+
param.def_id,
422+
Some(arg.id()),
423+
arg.span(),
424+
None,
425+
|_, _| {
426+
// Default generic parameters may not be marked
427+
// with stability attributes, i.e. when the
428+
// default parameter was defined at the same time
429+
// as the rest of the type. As such, we ignore missing
430+
// stability attributes.
431+
},
432+
)
433+
}
434+
if let (hir::TyKind::Infer, false) = (&ty.kind, self.astconv.allow_ty_infer()) {
435+
self.inferred_params.push(ty.span);
436+
tcx.ty_error().into()
437+
} else {
438+
self.astconv.ast_ty_to_ty(ty).into()
439+
}
440+
};
441+
417442
match (&param.kind, arg) {
418443
(GenericParamDefKind::Lifetime, GenericArg::Lifetime(lt)) => {
419444
self.astconv.ast_region_to_region(lt, Some(param)).into()
420445
}
421446
(&GenericParamDefKind::Type { has_default, .. }, GenericArg::Type(ty)) => {
422-
if has_default {
423-
tcx.check_optional_stability(
424-
param.def_id,
425-
Some(arg.id()),
426-
arg.span(),
427-
None,
428-
|_, _| {
429-
// Default generic parameters may not be marked
430-
// with stability attributes, i.e. when the
431-
// default parameter was defined at the same time
432-
// as the rest of the type. As such, we ignore missing
433-
// stability attributes.
434-
},
435-
)
436-
}
437-
if let (hir::TyKind::Infer, false) =
438-
(&ty.kind, self.astconv.allow_ty_infer())
439-
{
440-
self.inferred_params.push(ty.span);
441-
tcx.ty_error().into()
442-
} else {
443-
self.astconv.ast_ty_to_ty(ty).into()
444-
}
447+
handle_ty_args(has_default, ty)
448+
}
449+
(&GenericParamDefKind::Type { has_default, .. }, GenericArg::Infer(inf)) => {
450+
handle_ty_args(has_default, &inf.to_ty())
445451
}
446452
(GenericParamDefKind::Const { .. }, GenericArg::Const(ct)) => {
447453
ty::Const::from_opt_const_arg_anon_const(
@@ -453,41 +459,13 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
453459
)
454460
.into()
455461
}
456-
(&GenericParamDefKind::Const { has_default }, hir::GenericArg::Infer(inf)) => {
457-
if has_default {
458-
tcx.const_param_default(param.def_id).into()
459-
} else if self.astconv.allow_ty_infer() {
460-
// FIXME(const_generics): Actually infer parameter here?
461-
todo!()
462-
} else {
463-
self.inferred_params.push(inf.span);
464-
tcx.ty_error().into()
465-
}
466-
}
467-
(
468-
&GenericParamDefKind::Type { has_default, .. },
469-
hir::GenericArg::Infer(inf),
470-
) => {
471-
if has_default {
472-
tcx.check_optional_stability(
473-
param.def_id,
474-
Some(arg.id()),
475-
arg.span(),
476-
None,
477-
|_, _| {
478-
// Default generic parameters may not be marked
479-
// with stability attributes, i.e. when the
480-
// default parameter was defined at the same time
481-
// as the rest of the type. As such, we ignore missing
482-
// stability attributes.
483-
},
484-
);
485-
}
462+
(&GenericParamDefKind::Const { .. }, hir::GenericArg::Infer(inf)) => {
463+
let ty = tcx.at(self.span).type_of(param.def_id);
486464
if self.astconv.allow_ty_infer() {
487-
self.astconv.ast_ty_to_ty(&inf.to_ty()).into()
465+
self.astconv.ct_infer(ty, Some(param), inf.span).into()
488466
} else {
489467
self.inferred_params.push(inf.span);
490-
tcx.ty_error().into()
468+
tcx.const_error(ty).into()
491469
}
492470
}
493471
_ => unreachable!(),

Diff for: compiler/rustc_typeck/src/check/wfcheck.rs

+46-8
Original file line numberDiff line numberDiff line change
@@ -426,22 +426,48 @@ fn check_gat_where_clauses(
426426
}
427427
}
428428

429-
// If there are any missing clauses, emit an error
430-
let mut clauses = clauses.unwrap_or_default();
429+
// If there are any clauses that aren't provable, emit an error
430+
let clauses = clauses.unwrap_or_default();
431431
debug!(?clauses);
432432
if !clauses.is_empty() {
433-
let written_predicates: ty::GenericPredicates<'_> =
434-
tcx.explicit_predicates_of(trait_item.def_id);
433+
let param_env = tcx.param_env(trait_item.def_id);
434+
435435
let mut clauses: Vec<_> = clauses
436-
.drain_filter(|clause| !written_predicates.predicates.iter().any(|p| &p.0 == clause))
436+
.into_iter()
437+
.filter(|clause| match clause.kind().skip_binder() {
438+
ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(a, b)) => {
439+
!region_known_to_outlive(
440+
tcx,
441+
trait_item.hir_id(),
442+
param_env,
443+
&FxHashSet::default(),
444+
a,
445+
b,
446+
)
447+
}
448+
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(a, b)) => {
449+
!ty_known_to_outlive(
450+
tcx,
451+
trait_item.hir_id(),
452+
param_env,
453+
&FxHashSet::default(),
454+
a,
455+
b,
456+
)
457+
}
458+
_ => bug!("Unexpected PredicateKind"),
459+
})
437460
.map(|clause| format!("{}", clause))
438461
.collect();
462+
439463
// We sort so that order is predictable
440464
clauses.sort();
465+
441466
if !clauses.is_empty() {
467+
let plural = if clauses.len() > 1 { "s" } else { "" };
442468
let mut err = tcx.sess.struct_span_err(
443469
trait_item.span,
444-
&format!("Missing required bounds on {}", trait_item.ident),
470+
&format!("missing required bound{} on `{}`", plural, trait_item.ident),
445471
);
446472

447473
let suggestion = format!(
@@ -455,11 +481,22 @@ fn check_gat_where_clauses(
455481
);
456482
err.span_suggestion(
457483
trait_item.generics.where_clause.tail_span_for_suggestion(),
458-
"add the required where clauses",
484+
&format!("add the required where clause{}", plural),
459485
suggestion,
460486
Applicability::MachineApplicable,
461487
);
462488

489+
let bound = if clauses.len() > 1 { "these bounds are" } else { "this bound is" };
490+
err.note(&format!(
491+
"{} currently required to ensure that impls have maximum flexibility",
492+
bound
493+
));
494+
err.note(
495+
"we are soliciting feedback, see issue #87479 \
496+
<https://github.com/rust-lang/rust/issues/87479> \
497+
for more information",
498+
);
499+
463500
err.emit()
464501
}
465502
}
@@ -541,7 +578,8 @@ fn region_known_to_outlive<'tcx>(
541578
});
542579

543580
use rustc_infer::infer::outlives::obligations::TypeOutlivesDelegate;
544-
(&infcx).push_sub_region_constraint(origin, region_a, region_b);
581+
// `region_a: region_b` -> `region_b <= region_a`
582+
(&infcx).push_sub_region_constraint(origin, region_b, region_a);
545583

546584
let errors = infcx.resolve_regions(
547585
id.expect_owner().to_def_id(),

Diff for: library/std/src/ffi/c_str.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,7 @@ impl CStr {
12591259
#[inline]
12601260
#[must_use]
12611261
#[stable(feature = "cstr_from_bytes", since = "1.10.0")]
1262-
#[rustc_const_unstable(feature = "const_cstr_unchecked", issue = "90343")]
1262+
#[rustc_const_stable(feature = "const_cstr_unchecked", since = "1.59.0")]
12631263
pub const unsafe fn from_bytes_with_nul_unchecked(bytes: &[u8]) -> &CStr {
12641264
// SAFETY: Casting to CStr is safe because its internal representation
12651265
// is a [u8] too (safe only inside std).

Diff for: library/std/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@
252252
#![feature(char_internals)]
253253
#![cfg_attr(not(bootstrap), feature(concat_bytes))]
254254
#![feature(concat_idents)]
255-
#![feature(const_cstr_unchecked)]
256255
#![feature(const_fn_floating_point_arithmetic)]
257256
#![feature(const_fn_fn_ptr_basics)]
258257
#![feature(const_fn_trait_bound)]

0 commit comments

Comments
 (0)