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

Rollup of 7 pull requests #116260

Merged
merged 34 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
32c2ed7
Bump ui test crate
oli-obk Jul 31, 2023
c69e0c2
Move `fail` tests that need dependencies into their own folder, so th…
oli-obk Aug 3, 2023
0d5f51c
Bump ui_test crate
oli-obk Aug 4, 2023
e706367
Allow limiting the number of threads running in parallel
oli-obk Aug 4, 2023
9f4e7c6
Bump ui_test crate
oli-obk Aug 8, 2023
5f440dd
GC the Stacked Borrows allocation history
saethlin Sep 24, 2023
598f11a
ref(bootstrap.py): add `eprint` function
pouriya Sep 25, 2023
1ec85a8
Document new env var
oli-obk Sep 25, 2023
71aea48
Explain single element vector
oli-obk Sep 25, 2023
b4dc4f3
Auto merge of #3008 - oli-obk:ui_test_progress_bars, r=RalfJung
bors Sep 25, 2023
ee30aaf
fix normalization in backtrace-api tests
RalfJung Sep 25, 2023
32c0afb
Auto merge of #3083 - saethlin:gc-history, r=oli-obk
bors Sep 25, 2023
e86c68a
Auto merge of #3085 - RalfJung:test-norm, r=RalfJung
bors Sep 25, 2023
fc0d833
Preparing for merge from rustc
Sep 27, 2023
b1f5c66
Merge from rustc
Sep 27, 2023
c8a44b1
clippy
RalfJung Sep 27, 2023
1a3dd7e
Auto merge of #3087 - rust-lang:rustup-2023-09-27, r=RalfJung
bors Sep 27, 2023
3b091cb
Preparing for merge from rustc
Sep 28, 2023
f2623ac
Merge from rustc
Sep 28, 2023
024279a
Auto merge of #3089 - rust-lang:rustup-2023-09-28, r=RalfJung
bors Sep 28, 2023
66bc682
Fix `noop_method_call` detection for new diagnostic items
Jarcho Sep 27, 2023
e0f4ab8
update lockfile
RalfJung Sep 28, 2023
255ca18
Add test for 116212.
cjgillot Sep 28, 2023
3816c15
Only visit reachable nodes in SsaLocals.
cjgillot May 28, 2023
07f81cd
Move needless_raw_string_hashes to pedantic
Alexendoo Aug 27, 2023
f1b7484
Remove `rustc_lint_defs::lint_array`
DaniPopes Sep 28, 2023
b53a1b3
make adt_const_params feature suggestion more consistent with others …
asquared31415 Sep 28, 2023
f777e8c
Rollup merge of #116133 - pouriya:refactor-bootstrap.py, r=albertlars…
matthiaskrgr Sep 29, 2023
e814f1e
Rollup merge of #116201 - Jarcho:noop_fix, r=fee1-dead
matthiaskrgr Sep 29, 2023
0c45018
Rollup merge of #116231 - DaniPopes:simpler-lint-array, r=Nilstrieb
matthiaskrgr Sep 29, 2023
1ed00fe
Rollup merge of #116234 - RalfJung:miri, r=RalfJung
matthiaskrgr Sep 29, 2023
4f09f80
Rollup merge of #116239 - cjgillot:issue-116212, r=WaffleLapkin
matthiaskrgr Sep 29, 2023
92234f9
Rollup merge of #116245 - flip1995:clippy-backport, r=Manishearth
matthiaskrgr Sep 29, 2023
95262e4
Rollup merge of #116253 - asquared31415:adt_const_params_feature, r=c…
matthiaskrgr Sep 29, 2023
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
17 changes: 11 additions & 6 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2419,7 +2419,7 @@ dependencies = [
"rustc_version",
"serde",
"smallvec",
"ui_test 0.11.7",
"ui_test 0.21.2",
]

[[package]]
Expand Down Expand Up @@ -5621,18 +5621,23 @@ checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81"

[[package]]
name = "ui_test"
version = "0.11.7"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c21899b59f53717dfad29e4f46e5b21a200a1b6888ab86532a07cfc8b48dd78c"
checksum = "bfd8fb9b15c8332cf51bfc2dc4830063b2446a9c9d732421b56f2478024a3971"
dependencies = [
"annotate-snippets",
"anyhow",
"bstr",
"cargo-platform",
"cargo_metadata",
"color-eyre",
"colored",
"comma",
"crossbeam-channel",
"diff",
"indicatif",
"lazy_static",
"levenshtein",
"prettydiff",
"regex",
"rustc_version",
"rustfix",
Expand All @@ -5643,9 +5648,9 @@ dependencies = [

[[package]]
name = "ui_test"
version = "0.20.0"
version = "0.21.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfd8fb9b15c8332cf51bfc2dc4830063b2446a9c9d732421b56f2478024a3971"
checksum = "aaf4bf7c184b8dfc7a4d3b90df789b1eb992ee42811cd115f32a7a1eb781058d"
dependencies = [
"annotate-snippets",
"anyhow",
Expand Down
89 changes: 57 additions & 32 deletions compiler/rustc_hir_analysis/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_span::{Span, DUMMY_SP};
use rustc_target::spec::abi::Abi;
use rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt;
use rustc_trait_selection::traits::misc::{
type_allowed_to_implement_const_param_ty, ConstParamTyImplementationError,
};
use rustc_trait_selection::traits::outlives_bounds::InferCtxtExt as _;
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _;
use rustc_trait_selection::traits::{
Expand Down Expand Up @@ -865,43 +868,65 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) {
);
});
} else {
let err_ty_str;
let mut is_ptr = true;

let err = match ty.kind() {
let diag = match ty.kind() {
ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Error(_) => None,
ty::FnPtr(_) => Some("function pointers"),
ty::RawPtr(_) => Some("raw pointers"),
_ => {
is_ptr = false;
err_ty_str = format!("`{ty}`");
Some(err_ty_str.as_str())
}
ty::FnPtr(_) => Some(tcx.sess.struct_span_err(
hir_ty.span,
"using function pointers as const generic parameters is forbidden",
)),
ty::RawPtr(_) => Some(tcx.sess.struct_span_err(
hir_ty.span,
"using raw pointers as const generic parameters is forbidden",
)),
_ => Some(tcx.sess.struct_span_err(
hir_ty.span,
format!("`{}` is forbidden as the type of a const generic parameter", ty),
)),
};

if let Some(unsupported_type) = err {
if is_ptr {
tcx.sess.span_err(
hir_ty.span,
format!(
"using {unsupported_type} as const generic parameters is forbidden",
),
);
} else {
let mut err = tcx.sess.struct_span_err(
hir_ty.span,
format!(
"{unsupported_type} is forbidden as the type of a const generic parameter",
),
);
err.note("the only supported types are integers, `bool` and `char`");
if tcx.sess.is_nightly_build() {
err.help(
"more complex types are supported with `#![feature(adt_const_params)]`",
);
if let Some(mut diag) = diag {
diag.note("the only supported types are integers, `bool` and `char`");

let cause = ObligationCause::misc(hir_ty.span, param.def_id);
let may_suggest_feature = match type_allowed_to_implement_const_param_ty(
tcx,
tcx.param_env(param.def_id),
ty,
cause,
) {
// Can never implement `ConstParamTy`, don't suggest anything.
Err(ConstParamTyImplementationError::NotAnAdtOrBuiltinAllowed) => false,
// May be able to implement `ConstParamTy`. Only emit the feature help
// if the type is local, since the user may be able to fix the local type.
Err(ConstParamTyImplementationError::InfrigingFields(..)) => {
fn ty_is_local(ty: Ty<'_>) -> bool {
match ty.kind() {
ty::Adt(adt_def, ..) => adt_def.did().is_local(),
// Arrays and slices use the inner type's `ConstParamTy`.
ty::Array(ty, ..) => ty_is_local(*ty),
ty::Slice(ty) => ty_is_local(*ty),
// `&` references use the inner type's `ConstParamTy`.
// `&mut` are not supported.
ty::Ref(_, ty, ast::Mutability::Not) => ty_is_local(*ty),
// Say that a tuple is local if any of its components are local.
// This is not strictly correct, but it's likely that the user can fix the local component.
ty::Tuple(tys) => tys.iter().any(|ty| ty_is_local(ty)),
_ => false,
}
}

ty_is_local(ty)
}
err.emit();
// Implments `ConstParamTy`, suggest adding the feature to enable.
Ok(..) => true,
};
if may_suggest_feature && tcx.sess.is_nightly_build() {
diag.help(
"add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types",
);
}

diag.emit();
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_lint/src/foreign_modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@ use rustc_hir::def::DefKind;
use rustc_middle::query::Providers;
use rustc_middle::ty::layout::LayoutError;
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
use rustc_session::lint::{lint_array, LintArray};
use rustc_span::{sym, Span, Symbol};
use rustc_target::abi::FIRST_VARIANT;

use crate::lints::{BuiltinClashingExtern, BuiltinClashingExternSub};
use crate::types;
use crate::{types, LintVec};

pub(crate) fn provide(providers: &mut Providers) {
*providers = Providers { clashing_extern_declarations, ..*providers };
}

pub(crate) fn get_lints() -> LintArray {
lint_array!(CLASHING_EXTERN_DECLARATIONS)
pub(crate) fn get_lints() -> LintVec {
vec![CLASHING_EXTERN_DECLARATIONS]
}

fn clashing_extern_declarations(tcx: TyCtxt<'_>, (): ()) {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ pub use late::{check_crate, late_lint_mod, unerased_lint_store};
pub use passes::{EarlyLintPass, LateLintPass};
pub use rustc_session::lint::Level::{self, *};
pub use rustc_session::lint::{BufferedEarlyLint, FutureIncompatibleInfo, Lint, LintId};
pub use rustc_session::lint::{LintArray, LintPass};
pub use rustc_session::lint::{LintPass, LintVec};

fluent_messages! { "../messages.ftl" }

Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_lint/src/noop_method_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ impl<'tcx> LateLintPass<'tcx> for NoopMethodCall {
let Ok(Some(i)) = ty::Instance::resolve(cx.tcx, cx.param_env, did, args) else { return };
// (Re)check that it implements the noop diagnostic.
let Some(name) = cx.tcx.get_diagnostic_name(i.def_id()) else { return };
if !matches!(
name,
sym::noop_method_borrow | sym::noop_method_clone | sym::noop_method_deref
) {
return;
}

let receiver_ty = cx.typeck_results().expr_ty(receiver);
let expr_ty = cx.typeck_results().expr_ty_adjusted(expr);
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_lint/src/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ macro_rules! declare_combined_late_lint_pass {
}
}

$v fn get_lints() -> $crate::LintArray {
$v fn get_lints() -> $crate::LintVec {
let mut lints = Vec::new();
$(lints.extend_from_slice(&$pass::get_lints());)*
lints
Expand Down Expand Up @@ -226,7 +226,7 @@ macro_rules! declare_combined_early_lint_pass {
}
}

$v fn get_lints() -> $crate::LintArray {
$v fn get_lints() -> $crate::LintVec {
let mut lints = Vec::new();
$(lints.extend_from_slice(&$pass::get_lints());)*
lints
Expand Down
13 changes: 2 additions & 11 deletions compiler/rustc_lint_defs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -785,16 +785,7 @@ macro_rules! declare_tool_lint {
);
}

/// Declares a static `LintArray` and return it as an expression.
#[macro_export]
macro_rules! lint_array {
($( $lint:expr ),* ,) => { lint_array!( $($lint),* ) };
($( $lint:expr ),*) => {{
vec![$($lint),*]
}}
}

pub type LintArray = Vec<&'static Lint>;
pub type LintVec = Vec<&'static Lint>;

pub trait LintPass {
fn name(&self) -> &'static str;
Expand All @@ -808,7 +799,7 @@ macro_rules! impl_lint_pass {
fn name(&self) -> &'static str { stringify!($ty) }
}
impl $ty {
pub fn get_lints() -> $crate::LintArray { $crate::lint_array!($($lint),*) }
pub fn get_lints() -> $crate::LintVec { vec![$($lint),*] }
}
};
}
Expand Down
12 changes: 4 additions & 8 deletions compiler/rustc_mir_transform/src/ssa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,10 @@ impl SsaLocals {
visitor.assignments[local] = Set1::One(LocationExtended::Arg);
}

if body.basic_blocks.len() > 2 {
for (bb, data) in traversal::reverse_postorder(body) {
visitor.visit_basic_block_data(bb, data);
}
} else {
for (bb, data) in body.basic_blocks.iter_enumerated() {
visitor.visit_basic_block_data(bb, data);
}
// For SSA assignments, a RPO visit will see the assignment before it sees any use.
// We only visit reachable nodes: computing `dominates` on an unreachable node ICEs.
for (bb, data) in traversal::reverse_postorder(body) {
visitor.visit_basic_block_data(bb, data);
}

for var_debug_info in &body.var_debug_info {
Expand Down
Loading
Loading