Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 36153f1

Browse files
committedMay 24, 2024
Auto merge of rust-lang#125521 - matthiaskrgr:rollup-ph2bz3h, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#125467 (Only suppress binop error in favor of semicolon suggestion if we're in an assignment statement) - rust-lang#125483 (compiler: validate.rs belongs next to what it validates) - rust-lang#125485 (Migrate `run-make/rustdoc-with-output-dir-option` to `rmake.rs`) - rust-lang#125497 (Fix some SIMD intrinsics documentation) - rust-lang#125501 (Resolve anon const's parent predicates to direct parent instead of opaque's parent) - rust-lang#125503 (rustdoc-json: Add test for keywords with `--document-private-items`) - rust-lang#125519 (tag more stuff with `WG-trait-system-refactor`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 697ac29 + ee54e29 commit 36153f1

File tree

31 files changed

+171
-121
lines changed

31 files changed

+171
-121
lines changed
 

‎Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -4252,6 +4252,7 @@ dependencies = [
42524252
"rustc_fluent_macro",
42534253
"rustc_hir",
42544254
"rustc_index",
4255+
"rustc_infer",
42554256
"rustc_macros",
42564257
"rustc_middle",
42574258
"rustc_mir_build",

‎compiler/rustc_const_eval/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
#![feature(yeet_expr)]
1515
#![feature(if_let_guard)]
1616

17+
pub mod check_consts;
1718
pub mod const_eval;
1819
mod errors;
1920
pub mod interpret;
20-
pub mod transform;
2121
pub mod util;
2222

2323
use std::sync::atomic::AtomicBool;

‎compiler/rustc_const_eval/src/transform/mod.rs

-2
This file was deleted.

‎compiler/rustc_hir_analysis/src/collect/predicates_of.rs

+47-75
Original file line numberDiff line numberDiff line change
@@ -461,83 +461,55 @@ pub(super) fn explicit_predicates_of<'tcx>(
461461
}
462462
}
463463
} else {
464-
if matches!(def_kind, DefKind::AnonConst) && tcx.features().generic_const_exprs {
465-
let hir_id = tcx.local_def_id_to_hir_id(def_id);
466-
let parent_def_id = tcx.hir().get_parent_item(hir_id);
467-
468-
if let Some(defaulted_param_def_id) =
469-
tcx.hir().opt_const_param_default_param_def_id(hir_id)
470-
{
471-
// In `generics_of` we set the generics' parent to be our parent's parent which means that
472-
// we lose out on the predicates of our actual parent if we dont return those predicates here.
473-
// (See comment in `generics_of` for more information on why the parent shenanigans is necessary)
474-
//
475-
// struct Foo<T, const N: usize = { <T as Trait>::ASSOC }>(T) where T: Trait;
476-
// ^^^ ^^^^^^^^^^^^^^^^^^^^^^^ the def id we are calling
477-
// ^^^ explicit_predicates_of on
478-
// parent item we dont have set as the
479-
// parent of generics returned by `generics_of`
480-
//
481-
// In the above code we want the anon const to have predicates in its param env for `T: Trait`
482-
// and we would be calling `explicit_predicates_of(Foo)` here
483-
let parent_preds = tcx.explicit_predicates_of(parent_def_id);
484-
485-
// If we dont filter out `ConstArgHasType` predicates then every single defaulted const parameter
486-
// will ICE because of #106994. FIXME(generic_const_exprs): remove this when a more general solution
487-
// to #106994 is implemented.
488-
let filtered_predicates = parent_preds
489-
.predicates
490-
.into_iter()
491-
.filter(|(pred, _)| {
492-
if let ty::ClauseKind::ConstArgHasType(ct, _) = pred.kind().skip_binder() {
493-
match ct.kind() {
494-
ty::ConstKind::Param(param_const) => {
495-
let defaulted_param_idx = tcx
496-
.generics_of(parent_def_id)
497-
.param_def_id_to_index[&defaulted_param_def_id.to_def_id()];
498-
param_const.index < defaulted_param_idx
499-
}
500-
_ => bug!(
501-
"`ConstArgHasType` in `predicates_of`\
502-
that isn't a `Param` const"
503-
),
464+
if matches!(def_kind, DefKind::AnonConst)
465+
&& tcx.features().generic_const_exprs
466+
&& let Some(defaulted_param_def_id) =
467+
tcx.hir().opt_const_param_default_param_def_id(tcx.local_def_id_to_hir_id(def_id))
468+
{
469+
// In `generics_of` we set the generics' parent to be our parent's parent which means that
470+
// we lose out on the predicates of our actual parent if we dont return those predicates here.
471+
// (See comment in `generics_of` for more information on why the parent shenanigans is necessary)
472+
//
473+
// struct Foo<T, const N: usize = { <T as Trait>::ASSOC }>(T) where T: Trait;
474+
// ^^^ ^^^^^^^^^^^^^^^^^^^^^^^ the def id we are calling
475+
// ^^^ explicit_predicates_of on
476+
// parent item we dont have set as the
477+
// parent of generics returned by `generics_of`
478+
//
479+
// In the above code we want the anon const to have predicates in its param env for `T: Trait`
480+
// and we would be calling `explicit_predicates_of(Foo)` here
481+
let parent_def_id = tcx.local_parent(def_id);
482+
let parent_preds = tcx.explicit_predicates_of(parent_def_id);
483+
484+
// If we dont filter out `ConstArgHasType` predicates then every single defaulted const parameter
485+
// will ICE because of #106994. FIXME(generic_const_exprs): remove this when a more general solution
486+
// to #106994 is implemented.
487+
let filtered_predicates = parent_preds
488+
.predicates
489+
.into_iter()
490+
.filter(|(pred, _)| {
491+
if let ty::ClauseKind::ConstArgHasType(ct, _) = pred.kind().skip_binder() {
492+
match ct.kind() {
493+
ty::ConstKind::Param(param_const) => {
494+
let defaulted_param_idx = tcx
495+
.generics_of(parent_def_id)
496+
.param_def_id_to_index[&defaulted_param_def_id.to_def_id()];
497+
param_const.index < defaulted_param_idx
504498
}
505-
} else {
506-
true
499+
_ => bug!(
500+
"`ConstArgHasType` in `predicates_of`\
501+
that isn't a `Param` const"
502+
),
507503
}
508-
})
509-
.cloned();
510-
return GenericPredicates {
511-
parent: parent_preds.parent,
512-
predicates: { tcx.arena.alloc_from_iter(filtered_predicates) },
513-
};
514-
}
515-
516-
let parent_def_kind = tcx.def_kind(parent_def_id);
517-
if matches!(parent_def_kind, DefKind::OpaqueTy) {
518-
// In `instantiate_identity` we inherit the predicates of our parent.
519-
// However, opaque types do not have a parent (see `gather_explicit_predicates_of`), which means
520-
// that we lose out on the predicates of our actual parent if we dont return those predicates here.
521-
//
522-
//
523-
// fn foo<T: Trait>() -> impl Iterator<Output = Another<{ <T as Trait>::ASSOC }> > { todo!() }
524-
// ^^^^^^^^^^^^^^^^^^^ the def id we are calling
525-
// explicit_predicates_of on
526-
//
527-
// In the above code we want the anon const to have predicates in its param env for `T: Trait`.
528-
// However, the anon const cannot inherit predicates from its parent since it's opaque.
529-
//
530-
// To fix this, we call `explicit_predicates_of` directly on `foo`, the parent's parent.
531-
532-
// In the above example this is `foo::{opaque#0}` or `impl Iterator`
533-
let parent_hir_id = tcx.local_def_id_to_hir_id(parent_def_id.def_id);
534-
535-
// In the above example this is the function `foo`
536-
let item_def_id = tcx.hir().get_parent_item(parent_hir_id);
537-
538-
// In the above code example we would be calling `explicit_predicates_of(foo)` here
539-
return tcx.explicit_predicates_of(item_def_id);
540-
}
504+
} else {
505+
true
506+
}
507+
})
508+
.cloned();
509+
return GenericPredicates {
510+
parent: parent_preds.parent,
511+
predicates: { tcx.arena.alloc_from_iter(filtered_predicates) },
512+
};
541513
}
542514
gather_explicit_predicates_of(tcx, def_id)
543515
}

‎compiler/rustc_hir_typeck/src/op.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -381,10 +381,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
381381
let maybe_missing_semi = self.check_for_missing_semi(expr, &mut err);
382382

383383
// We defer to the later error produced by `check_lhs_assignable`.
384-
// We only downgrade this if it's the LHS, though.
384+
// We only downgrade this if it's the LHS, though, and if this is a
385+
// valid assignment statement.
385386
if maybe_missing_semi
386387
&& let hir::Node::Expr(parent) = self.tcx.parent_hir_node(expr.hir_id)
387388
&& let hir::ExprKind::Assign(lhs, _, _) = parent.kind
389+
&& let hir::Node::Stmt(stmt) = self.tcx.parent_hir_node(parent.hir_id)
390+
&& let hir::StmtKind::Expr(_) | hir::StmtKind::Semi(_) = stmt.kind
388391
&& lhs.hir_id == expr.hir_id
389392
{
390393
err.downgrade_to_delayed_bug();

‎compiler/rustc_mir_transform/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ rustc_errors = { path = "../rustc_errors" }
1616
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
1717
rustc_hir = { path = "../rustc_hir" }
1818
rustc_index = { path = "../rustc_index" }
19+
rustc_infer = { path = "../rustc_infer" }
1920
rustc_macros = { path = "../rustc_macros" }
2021
rustc_middle = { path = "../rustc_middle" }
2122
rustc_mir_build = { path = "../rustc_mir_build" }

‎compiler/rustc_mir_transform/src/inline.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! Inlining pass for MIR functions
22
use crate::deref_separator::deref_finder;
33
use rustc_attr::InlineAttr;
4-
use rustc_const_eval::transform::validate::validate_types;
54
use rustc_hir::def::DefKind;
65
use rustc_hir::def_id::DefId;
76
use rustc_index::bit_set::BitSet;
@@ -21,6 +20,7 @@ use rustc_target::spec::abi::Abi;
2120
use crate::cost_checker::CostChecker;
2221
use crate::simplify::simplify_cfg;
2322
use crate::util;
23+
use crate::validate::validate_types;
2424
use std::iter;
2525
use std::ops::{Range, RangeFrom};
2626

‎compiler/rustc_mir_transform/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ mod simplify_comparison_integral;
109109
mod sroa;
110110
mod unreachable_enum_branching;
111111
mod unreachable_prop;
112+
mod validate;
112113

113-
use rustc_const_eval::transform::check_consts::{self, ConstCx};
114-
use rustc_const_eval::transform::validate;
114+
use rustc_const_eval::check_consts::{self, ConstCx};
115115
use rustc_mir_dataflow::rustc_peek;
116116

117117
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

‎compiler/rustc_mir_transform/src/promote_consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use std::assert_matches::assert_matches;
3030
use std::cell::Cell;
3131
use std::{cmp, iter, mem};
3232

33-
use rustc_const_eval::transform::check_consts::{qualifs, ConstCx};
33+
use rustc_const_eval::check_consts::{qualifs, ConstCx};
3434

3535
/// A `MirPass` for promotion.
3636
///

‎library/core/src/intrinsics/simd.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,15 @@ extern "rust-intrinsic" {
152152
#[rustc_nounwind]
153153
pub fn simd_fabs<T>(x: T) -> T;
154154

155-
/// Elementwise minimum of a vector.
155+
/// Elementwise minimum of two vectors.
156156
///
157157
/// `T` must be a vector of floating-point primitive types.
158158
///
159159
/// Follows IEEE-754 `minNum` semantics.
160160
#[rustc_nounwind]
161161
pub fn simd_fmin<T>(x: T, y: T) -> T;
162162

163-
/// Elementwise maximum of a vector.
163+
/// Elementwise maximum of two vectors.
164164
///
165165
/// `T` must be a vector of floating-point primitive types.
166166
///
@@ -387,7 +387,7 @@ extern "rust-intrinsic" {
387387
#[rustc_nounwind]
388388
pub fn simd_reduce_mul_ordered<T, U>(x: T, y: U) -> U;
389389

390-
/// Add elements within a vector in arbitrary order. May also be re-associated with
390+
/// Multiply elements within a vector in arbitrary order. May also be re-associated with
391391
/// unordered additions on the inputs/outputs.
392392
///
393393
/// `T` must be a vector of integer or floating-point primitive types.
@@ -405,7 +405,7 @@ extern "rust-intrinsic" {
405405
#[rustc_nounwind]
406406
pub fn simd_reduce_all<T>(x: T) -> bool;
407407

408-
/// Check if all mask values are true.
408+
/// Check if any mask value is true.
409409
///
410410
/// `T` must be a vector of integer primitive types.
411411
///

‎src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use clippy_config::msrvs::{self, Msrv};
77
use hir::LangItem;
88
use rustc_attr::StableSince;
9-
use rustc_const_eval::transform::check_consts::ConstCx;
9+
use rustc_const_eval::check_consts::ConstCx;
1010
use rustc_hir as hir;
1111
use rustc_hir::def_id::DefId;
1212
use rustc_infer::infer::TyCtxtInferExt;

‎src/tools/miri/tests/panic/mir-validation.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
thread 'rustc' panicked at compiler/rustc_const_eval/src/transform/validate.rs:LL:CC:
1+
thread 'rustc' panicked at compiler/rustc_mir_transform/src/validate.rs:LL:CC:
22
broken MIR in Item(DefId) (after phase change to runtime-optimized) at bb0[1]:
33
(*(_2.0: *mut i32)), has deref at the wrong place
44
stack backtrace:

‎src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ run-make/rmeta-preferred/Makefile
228228
run-make/rustc-macro-dep-files/Makefile
229229
run-make/rustdoc-io-error/Makefile
230230
run-make/rustdoc-verify-output-files/Makefile
231-
run-make/rustdoc-with-output-option/Makefile
232231
run-make/sanitizer-cdylib-link/Makefile
233232
run-make/sanitizer-dylib-link/Makefile
234233
run-make/sanitizer-staticlib-link/Makefile

‎tests/crashes/118403.rs

-8
This file was deleted.

‎tests/crashes/121574-2.rs

-8
This file was deleted.

‎tests/crashes/121574.rs

-6
This file was deleted.

‎tests/run-make/rustdoc-with-output-option/Makefile

-8
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
use run_make_support::{htmldocck, rustdoc, tmp_dir};
2+
3+
fn main() {
4+
let out_dir = tmp_dir().join("rustdoc");
5+
6+
rustdoc()
7+
.input("src/lib.rs")
8+
.crate_name("foobar")
9+
.crate_type("lib")
10+
// This is intentionally using `--output` option flag and not the `output()` method.
11+
.arg("--output")
12+
.arg(&out_dir)
13+
.run();
14+
15+
assert!(htmldocck().arg(out_dir).arg("src/lib.rs").status().unwrap().success());
16+
}

‎tests/rustdoc-json/keyword_private.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Ensure keyword docs are present with --document-private-items
2+
3+
//@ compile-flags: --document-private-items
4+
#![feature(rustdoc_internals)]
5+
6+
// @!has "$.index[*][?(@.name=='match')]"
7+
// @has "$.index[*][?(@.name=='foo')]"
8+
// @is "$.index[*][?(@.name=='foo')].attrs" '["#[doc(keyword = \"match\")]"]'
9+
// @is "$.index[*][?(@.name=='foo')].docs" '"this is a test!"'
10+
#[doc(keyword = "match")]
11+
/// this is a test!
12+
pub mod foo {}
13+
14+
// @!has "$.index[*][?(@.name=='hello')]"
15+
// @has "$.index[*][?(@.name=='bar')]"
16+
// @is "$.index[*][?(@.name=='bar')].attrs" '["#[doc(keyword = \"hello\")]"]'
17+
// @is "$.index[*][?(@.name=='bar')].docs" '"hello"'
18+
#[doc(keyword = "hello")]
19+
/// hello
20+
mod bar {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
pub fn bad(x: &mut bool) {
2+
if true
3+
*x = true {}
4+
//~^ ERROR cannot multiply `bool` by `&mut bool`
5+
}
6+
7+
pub fn bad2(x: &mut bool) {
8+
let y: bool;
9+
y = true
10+
*x = true;
11+
//~^ ERROR cannot multiply `bool` by `&mut bool`
12+
}
13+
14+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
error[E0369]: cannot multiply `bool` by `&mut bool`
2+
--> $DIR/nested-assignment-may-be-deref.rs:3:5
3+
|
4+
LL | if true
5+
| ---- bool
6+
LL | *x = true {}
7+
| ^- &mut bool
8+
|
9+
help: you might have meant to write a semicolon here
10+
|
11+
LL | if true;
12+
| +
13+
14+
error[E0369]: cannot multiply `bool` by `&mut bool`
15+
--> $DIR/nested-assignment-may-be-deref.rs:10:5
16+
|
17+
LL | y = true
18+
| ---- bool
19+
LL | *x = true;
20+
| ^- &mut bool
21+
|
22+
help: you might have meant to write a semicolon here
23+
|
24+
LL | y = true;
25+
| +
26+
27+
error: aborting due to 2 previous errors
28+
29+
For more information about this error, try `rustc --explain E0369`.
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.