Skip to content

Rollup of 7 pull requests #125521

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

Merged
merged 17 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
a02aba7
Only suppress binop error in favor of semicolon suggestion if we're i…
compiler-errors May 23, 2024
daff843
Migrate `run-make/rustdoc-with-output-dir-option` to `rmake.rs`
GuillaumeGomez May 24, 2024
a85f6a6
Fix some SIMD intrinsics documentation
meesfrensel May 24, 2024
3ee8498
rustdoc-json: Add test for keywords with `--document-private-items`
aDotInTheVoid May 24, 2024
db6ec26
compiler: const_eval/transform/validate.rs -> mir_transform/validate.rs
workingjubilee May 24, 2024
87048a4
compiler: unnest rustc_const_eval::check_consts
workingjubilee May 24, 2024
584975d
clippy: unnest check_consts
workingjubilee May 24, 2024
14fc3fd
miri: receive the blessings of validate.rs
workingjubilee May 24, 2024
de517b7
Actually just remove the special case altogether
compiler-errors May 24, 2024
c97ed58
tag more stuff with `WG-trait-system-refactor`
lcnr May 24, 2024
fafe13a
Rollup merge of #125467 - compiler-errors:binop-in-bool-expectation, …
matthiaskrgr May 24, 2024
f23ebf0
Rollup merge of #125483 - workingjubilee:move-transform-validate-to-m…
matthiaskrgr May 24, 2024
09047b8
Rollup merge of #125485 - GuillaumeGomez:migrate-rmake-rustdoc, r=jie…
matthiaskrgr May 24, 2024
363fbb9
Rollup merge of #125497 - meesfrensel:patch-1, r=calebzulawski
matthiaskrgr May 24, 2024
104e1a4
Rollup merge of #125501 - compiler-errors:opaque-opaque-anon-ct, r=Bo…
matthiaskrgr May 24, 2024
f1eef38
Rollup merge of #125503 - aDotInTheVoid:rdj-keyword-attr, r=Guillaume…
matthiaskrgr May 24, 2024
ee54e29
Rollup merge of #125519 - lcnr:tag-next-solver, r=compiler-errors
matthiaskrgr May 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4252,6 +4252,7 @@ dependencies = [
"rustc_fluent_macro",
"rustc_hir",
"rustc_index",
"rustc_infer",
"rustc_macros",
"rustc_middle",
"rustc_mir_build",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
#![feature(yeet_expr)]
#![feature(if_let_guard)]

pub mod check_consts;
pub mod const_eval;
mod errors;
pub mod interpret;
pub mod transform;
pub mod util;

use std::sync::atomic::AtomicBool;
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_const_eval/src/transform/mod.rs

This file was deleted.

122 changes: 47 additions & 75 deletions compiler/rustc_hir_analysis/src/collect/predicates_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,83 +461,55 @@ pub(super) fn explicit_predicates_of<'tcx>(
}
}
} else {
if matches!(def_kind, DefKind::AnonConst) && tcx.features().generic_const_exprs {
let hir_id = tcx.local_def_id_to_hir_id(def_id);
let parent_def_id = tcx.hir().get_parent_item(hir_id);

if let Some(defaulted_param_def_id) =
tcx.hir().opt_const_param_default_param_def_id(hir_id)
{
// In `generics_of` we set the generics' parent to be our parent's parent which means that
// we lose out on the predicates of our actual parent if we dont return those predicates here.
// (See comment in `generics_of` for more information on why the parent shenanigans is necessary)
//
// struct Foo<T, const N: usize = { <T as Trait>::ASSOC }>(T) where T: Trait;
// ^^^ ^^^^^^^^^^^^^^^^^^^^^^^ the def id we are calling
// ^^^ explicit_predicates_of on
// parent item we dont have set as the
// parent of generics returned by `generics_of`
//
// In the above code we want the anon const to have predicates in its param env for `T: Trait`
// and we would be calling `explicit_predicates_of(Foo)` here
let parent_preds = tcx.explicit_predicates_of(parent_def_id);

// If we dont filter out `ConstArgHasType` predicates then every single defaulted const parameter
// will ICE because of #106994. FIXME(generic_const_exprs): remove this when a more general solution
// to #106994 is implemented.
let filtered_predicates = parent_preds
.predicates
.into_iter()
.filter(|(pred, _)| {
if let ty::ClauseKind::ConstArgHasType(ct, _) = pred.kind().skip_binder() {
match ct.kind() {
ty::ConstKind::Param(param_const) => {
let defaulted_param_idx = tcx
.generics_of(parent_def_id)
.param_def_id_to_index[&defaulted_param_def_id.to_def_id()];
param_const.index < defaulted_param_idx
}
_ => bug!(
"`ConstArgHasType` in `predicates_of`\
that isn't a `Param` const"
),
if matches!(def_kind, DefKind::AnonConst)
&& tcx.features().generic_const_exprs
&& let Some(defaulted_param_def_id) =
tcx.hir().opt_const_param_default_param_def_id(tcx.local_def_id_to_hir_id(def_id))
{
// In `generics_of` we set the generics' parent to be our parent's parent which means that
// we lose out on the predicates of our actual parent if we dont return those predicates here.
// (See comment in `generics_of` for more information on why the parent shenanigans is necessary)
//
// struct Foo<T, const N: usize = { <T as Trait>::ASSOC }>(T) where T: Trait;
// ^^^ ^^^^^^^^^^^^^^^^^^^^^^^ the def id we are calling
// ^^^ explicit_predicates_of on
// parent item we dont have set as the
// parent of generics returned by `generics_of`
//
// In the above code we want the anon const to have predicates in its param env for `T: Trait`
// and we would be calling `explicit_predicates_of(Foo)` here
let parent_def_id = tcx.local_parent(def_id);
let parent_preds = tcx.explicit_predicates_of(parent_def_id);

// If we dont filter out `ConstArgHasType` predicates then every single defaulted const parameter
// will ICE because of #106994. FIXME(generic_const_exprs): remove this when a more general solution
// to #106994 is implemented.
let filtered_predicates = parent_preds
.predicates
.into_iter()
.filter(|(pred, _)| {
if let ty::ClauseKind::ConstArgHasType(ct, _) = pred.kind().skip_binder() {
match ct.kind() {
ty::ConstKind::Param(param_const) => {
let defaulted_param_idx = tcx
.generics_of(parent_def_id)
.param_def_id_to_index[&defaulted_param_def_id.to_def_id()];
param_const.index < defaulted_param_idx
}
} else {
true
_ => bug!(
"`ConstArgHasType` in `predicates_of`\
that isn't a `Param` const"
),
}
})
.cloned();
return GenericPredicates {
parent: parent_preds.parent,
predicates: { tcx.arena.alloc_from_iter(filtered_predicates) },
};
}

let parent_def_kind = tcx.def_kind(parent_def_id);
if matches!(parent_def_kind, DefKind::OpaqueTy) {
// In `instantiate_identity` we inherit the predicates of our parent.
// However, opaque types do not have a parent (see `gather_explicit_predicates_of`), which means
// that we lose out on the predicates of our actual parent if we dont return those predicates here.
//
//
// fn foo<T: Trait>() -> impl Iterator<Output = Another<{ <T as Trait>::ASSOC }> > { todo!() }
// ^^^^^^^^^^^^^^^^^^^ the def id we are calling
// explicit_predicates_of on
//
// In the above code we want the anon const to have predicates in its param env for `T: Trait`.
// However, the anon const cannot inherit predicates from its parent since it's opaque.
//
// To fix this, we call `explicit_predicates_of` directly on `foo`, the parent's parent.

// In the above example this is `foo::{opaque#0}` or `impl Iterator`
let parent_hir_id = tcx.local_def_id_to_hir_id(parent_def_id.def_id);

// In the above example this is the function `foo`
let item_def_id = tcx.hir().get_parent_item(parent_hir_id);

// In the above code example we would be calling `explicit_predicates_of(foo)` here
return tcx.explicit_predicates_of(item_def_id);
}
} else {
true
}
})
.cloned();
return GenericPredicates {
parent: parent_preds.parent,
predicates: { tcx.arena.alloc_from_iter(filtered_predicates) },
};
}
gather_explicit_predicates_of(tcx, def_id)
}
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_hir_typeck/src/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,10 +381,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let maybe_missing_semi = self.check_for_missing_semi(expr, &mut err);

// We defer to the later error produced by `check_lhs_assignable`.
// We only downgrade this if it's the LHS, though.
// We only downgrade this if it's the LHS, though, and if this is a
// valid assignment statement.
if maybe_missing_semi
&& let hir::Node::Expr(parent) = self.tcx.parent_hir_node(expr.hir_id)
&& let hir::ExprKind::Assign(lhs, _, _) = parent.kind
&& let hir::Node::Stmt(stmt) = self.tcx.parent_hir_node(parent.hir_id)
&& let hir::StmtKind::Expr(_) | hir::StmtKind::Semi(_) = stmt.kind
&& lhs.hir_id == expr.hir_id
{
err.downgrade_to_delayed_bug();
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_mir_transform/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ rustc_errors = { path = "../rustc_errors" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
rustc_hir = { path = "../rustc_hir" }
rustc_index = { path = "../rustc_index" }
rustc_infer = { path = "../rustc_infer" }
rustc_macros = { path = "../rustc_macros" }
rustc_middle = { path = "../rustc_middle" }
rustc_mir_build = { path = "../rustc_mir_build" }
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/inline.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Inlining pass for MIR functions
use crate::deref_separator::deref_finder;
use rustc_attr::InlineAttr;
use rustc_const_eval::transform::validate::validate_types;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::DefId;
use rustc_index::bit_set::BitSet;
Expand All @@ -21,6 +20,7 @@ use rustc_target::spec::abi::Abi;
use crate::cost_checker::CostChecker;
use crate::simplify::simplify_cfg;
use crate::util;
use crate::validate::validate_types;
use std::iter;
use std::ops::{Range, RangeFrom};

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_mir_transform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ mod simplify_comparison_integral;
mod sroa;
mod unreachable_enum_branching;
mod unreachable_prop;
mod validate;

use rustc_const_eval::transform::check_consts::{self, ConstCx};
use rustc_const_eval::transform::validate;
use rustc_const_eval::check_consts::{self, ConstCx};
use rustc_mir_dataflow::rustc_peek;

rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/promote_consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use std::assert_matches::assert_matches;
use std::cell::Cell;
use std::{cmp, iter, mem};

use rustc_const_eval::transform::check_consts::{qualifs, ConstCx};
use rustc_const_eval::check_consts::{qualifs, ConstCx};

/// A `MirPass` for promotion.
///
Expand Down
8 changes: 4 additions & 4 deletions library/core/src/intrinsics/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,15 @@ extern "rust-intrinsic" {
#[rustc_nounwind]
pub fn simd_fabs<T>(x: T) -> T;

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

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

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

/// Check if all mask values are true.
/// Check if any mask value is true.
///
/// `T` must be a vector of integer primitive types.
///
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use clippy_config::msrvs::{self, Msrv};
use hir::LangItem;
use rustc_attr::StableSince;
use rustc_const_eval::transform::check_consts::ConstCx;
use rustc_const_eval::check_consts::ConstCx;
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_infer::infer::TyCtxtInferExt;
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/tests/panic/mir-validation.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
thread 'rustc' panicked at compiler/rustc_const_eval/src/transform/validate.rs:LL:CC:
thread 'rustc' panicked at compiler/rustc_mir_transform/src/validate.rs:LL:CC:
broken MIR in Item(DefId) (after phase change to runtime-optimized) at bb0[1]:
(*(_2.0: *mut i32)), has deref at the wrong place
stack backtrace:
Expand Down
1 change: 0 additions & 1 deletion src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ run-make/rmeta-preferred/Makefile
run-make/rustc-macro-dep-files/Makefile
run-make/rustdoc-io-error/Makefile
run-make/rustdoc-verify-output-files/Makefile
run-make/rustdoc-with-output-option/Makefile
run-make/sanitizer-cdylib-link/Makefile
run-make/sanitizer-dylib-link/Makefile
run-make/sanitizer-staticlib-link/Makefile
Expand Down
8 changes: 0 additions & 8 deletions tests/crashes/118403.rs

This file was deleted.

8 changes: 0 additions & 8 deletions tests/crashes/121574-2.rs

This file was deleted.

6 changes: 0 additions & 6 deletions tests/crashes/121574.rs

This file was deleted.

8 changes: 0 additions & 8 deletions tests/run-make/rustdoc-with-output-option/Makefile

This file was deleted.

16 changes: 16 additions & 0 deletions tests/run-make/rustdoc-with-output-option/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use run_make_support::{htmldocck, rustdoc, tmp_dir};

fn main() {
let out_dir = tmp_dir().join("rustdoc");

rustdoc()
.input("src/lib.rs")
.crate_name("foobar")
.crate_type("lib")
// This is intentionally using `--output` option flag and not the `output()` method.
.arg("--output")
.arg(&out_dir)
.run();

assert!(htmldocck().arg(out_dir).arg("src/lib.rs").status().unwrap().success());
}
20 changes: 20 additions & 0 deletions tests/rustdoc-json/keyword_private.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Ensure keyword docs are present with --document-private-items

//@ compile-flags: --document-private-items
#![feature(rustdoc_internals)]

// @!has "$.index[*][?(@.name=='match')]"
// @has "$.index[*][?(@.name=='foo')]"
// @is "$.index[*][?(@.name=='foo')].attrs" '["#[doc(keyword = \"match\")]"]'
// @is "$.index[*][?(@.name=='foo')].docs" '"this is a test!"'
#[doc(keyword = "match")]
/// this is a test!
pub mod foo {}

// @!has "$.index[*][?(@.name=='hello')]"
// @has "$.index[*][?(@.name=='bar')]"
// @is "$.index[*][?(@.name=='bar')].attrs" '["#[doc(keyword = \"hello\")]"]'
// @is "$.index[*][?(@.name=='bar')].docs" '"hello"'
#[doc(keyword = "hello")]
/// hello
mod bar {}
14 changes: 14 additions & 0 deletions tests/ui/binop/nested-assignment-may-be-deref.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pub fn bad(x: &mut bool) {
if true
*x = true {}
//~^ ERROR cannot multiply `bool` by `&mut bool`
}

pub fn bad2(x: &mut bool) {
let y: bool;
y = true
*x = true;
//~^ ERROR cannot multiply `bool` by `&mut bool`
}

fn main() {}
29 changes: 29 additions & 0 deletions tests/ui/binop/nested-assignment-may-be-deref.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
error[E0369]: cannot multiply `bool` by `&mut bool`
--> $DIR/nested-assignment-may-be-deref.rs:3:5
|
LL | if true
| ---- bool
LL | *x = true {}
| ^- &mut bool
|
help: you might have meant to write a semicolon here
|
LL | if true;
| +

error[E0369]: cannot multiply `bool` by `&mut bool`
--> $DIR/nested-assignment-may-be-deref.rs:10:5
|
LL | y = true
| ---- bool
LL | *x = true;
| ^- &mut bool
|
help: you might have meant to write a semicolon here
|
LL | y = true;
| +

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0369`.
Loading
Loading