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 #124527

Merged
merged 18 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
a0a8442
Remove direct dependencies on lazy_static, once_cell and byteorder
GKFX Apr 28, 2024
ca79086
Fix #124478 - offset_of! returns a temporary
GKFX Apr 28, 2024
2348eb2
Update mir-opt tests, add proper regression test
GKFX Apr 28, 2024
8aa3c59
Move rustfmt changes out
GKFX Apr 28, 2024
254a9fb
Prohibit const prop of unions in `KnownPanicsLint`
gurry Apr 29, 2024
a25a11a
coverage: Avoid hard-coded values when visiting logical ops
Zalathar Apr 29, 2024
c8ff8a4
Pretty-print parenthesis around binary in postfix match
scrabsha Apr 22, 2024
d31b7db
[Refactor] Rename Lint and LintGroup\'s is_loaded to is_externally_lo…
blyxyas Apr 29, 2024
5776aec
Make names more accurate
compiler-errors Apr 26, 2024
7cf1c54
Actually use probes when needed and stop relying on existing outer pr…
compiler-errors Apr 26, 2024
2eb7c81
Only register candidate if it is associated w a shallow certainty
compiler-errors Apr 28, 2024
f1c53da
Rollup merge of #124269 - scrabsha:sasha/fix-124206, r=dtolnay
jieyouxu Apr 29, 2024
4355749
Rollup merge of #124415 - compiler-errors:candidates, r=lcnr
jieyouxu Apr 29, 2024
3151ad5
Rollup merge of #124475 - GKFX:more-dependency-pruning, r=oli-obk
jieyouxu Apr 29, 2024
0580588
Rollup merge of #124484 - GKFX:offset_of_must_use, r=jieyouxu
jieyouxu Apr 29, 2024
43265f5
Rollup merge of #124504 - gurry:123710-union-ICE, r=oli-obk
jieyouxu Apr 29, 2024
0797adb
Rollup merge of #124508 - Zalathar:op, r=jieyouxu
jieyouxu Apr 29, 2024
ebce31a
Rollup merge of #124522 - blyxyas:refactor-is-loaded, r=jieyouxu
jieyouxu Apr 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 0 additions & 7 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2113,7 +2113,6 @@ dependencies = [
"fs-err",
"getopts",
"jsonpath_lib",
"once_cell",
"regex",
"serde_json",
"shlex",
Expand Down Expand Up @@ -2232,7 +2231,6 @@ name = "linkchecker"
version = "0.1.0"
dependencies = [
"html5ever",
"once_cell",
"regex",
]

Expand Down Expand Up @@ -2491,7 +2489,6 @@ dependencies = [
"directories",
"getrandom",
"jemalloc-sys",
"lazy_static",
"libc",
"libffi",
"libloading",
Expand Down Expand Up @@ -4791,12 +4788,10 @@ dependencies = [
"arrayvec",
"askama",
"base64",
"byteorder",
"expect-test",
"indexmap",
"itertools 0.12.1",
"minifier",
"once_cell",
"regex",
"rustdoc-json-types",
"serde",
Expand Down Expand Up @@ -5351,7 +5346,6 @@ version = "0.1.0"
dependencies = [
"build_helper",
"glob",
"once_cell",
]

[[package]]
Expand Down Expand Up @@ -5596,7 +5590,6 @@ version = "0.1.0"
dependencies = [
"cargo_metadata 0.15.4",
"ignore",
"lazy_static",
"miropt-test-tools",
"regex",
"rustc-hash",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_pretty/src/pprust/state/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ impl<'a> State<'a> {
self.space();
}
MatchKind::Postfix => {
self.print_expr_as_cond(expr);
self.print_expr_maybe_paren(expr, parser::PREC_POSTFIX, fixup);
self.word_nbsp(".match");
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ Available lint options:

let lint_store = unerased_lint_store(sess);
let (loaded, builtin): (Vec<_>, _) =
lint_store.get_lints().iter().cloned().partition(|&lint| lint.is_loaded);
lint_store.get_lints().iter().cloned().partition(|&lint| lint.is_externally_loaded);
let loaded = sort_lints(sess, loaded);
let builtin = sort_lints(sess, builtin);

Expand Down
18 changes: 10 additions & 8 deletions compiler/rustc_lint/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ struct LintAlias {

struct LintGroup {
lint_ids: Vec<LintId>,
is_loaded: bool,
is_externally_loaded: bool,
depr: Option<LintAlias>,
}

Expand Down Expand Up @@ -159,7 +159,9 @@ impl LintStore {
// Don't display deprecated lint groups.
depr.is_none()
})
.map(|(k, LintGroup { lint_ids, is_loaded, .. })| (*k, lint_ids.clone(), *is_loaded))
.map(|(k, LintGroup { lint_ids, is_externally_loaded, .. })| {
(*k, lint_ids.clone(), *is_externally_loaded)
})
}

pub fn register_early_pass(
Expand Down Expand Up @@ -218,7 +220,7 @@ impl LintStore {
.entry(edition.lint_name())
.or_insert(LintGroup {
lint_ids: vec![],
is_loaded: lint.is_loaded,
is_externally_loaded: lint.is_externally_loaded,
depr: None,
})
.lint_ids
Expand All @@ -231,7 +233,7 @@ impl LintStore {
.entry("future_incompatible")
.or_insert(LintGroup {
lint_ids: vec![],
is_loaded: lint.is_loaded,
is_externally_loaded: lint.is_externally_loaded,
depr: None,
})
.lint_ids
Expand All @@ -246,29 +248,29 @@ impl LintStore {
alias,
LintGroup {
lint_ids: vec![],
is_loaded: false,
is_externally_loaded: false,
depr: Some(LintAlias { name: lint_name, silent: true }),
},
);
}

pub fn register_group(
&mut self,
is_loaded: bool,
is_externally_loaded: bool,
name: &'static str,
deprecated_name: Option<&'static str>,
to: Vec<LintId>,
) {
let new = self
.lint_groups
.insert(name, LintGroup { lint_ids: to, is_loaded, depr: None })
.insert(name, LintGroup { lint_ids: to, is_externally_loaded, depr: None })
.is_none();
if let Some(deprecated) = deprecated_name {
self.lint_groups.insert(
deprecated,
LintGroup {
lint_ids: vec![],
is_loaded,
is_externally_loaded,
depr: Some(LintAlias { name, silent: false }),
},
);
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_lint/src/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
| hir::BinOpKind::Shr => Some("bitwise operation"),
},
hir::ExprKind::AddrOf(..) => Some("borrow"),
hir::ExprKind::OffsetOf(..) => Some("`offset_of` call"),
hir::ExprKind::Unary(..) => Some("unary operation"),
_ => None,
};
Expand Down
9 changes: 5 additions & 4 deletions compiler/rustc_lint_defs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ pub struct Lint {

pub future_incompatible: Option<FutureIncompatibleInfo>,

pub is_loaded: bool,
/// `true` if this lint is being loaded by another tool (e.g. Clippy).
pub is_externally_loaded: bool,

/// `Some` if this lint is feature gated, otherwise `None`.
pub feature_gate: Option<Symbol>,
Expand Down Expand Up @@ -468,7 +469,7 @@ impl Lint {
default_level: Level::Forbid,
desc: "",
edition_lint_opts: None,
is_loaded: false,
is_externally_loaded: false,
report_in_external_macro: false,
future_incompatible: None,
feature_gate: None,
Expand Down Expand Up @@ -817,7 +818,7 @@ macro_rules! declare_lint {
name: stringify!($NAME),
default_level: $crate::$Level,
desc: $desc,
is_loaded: false,
is_externally_loaded: false,
$($v: true,)*
$(feature_gate: Some($gate),)?
$(future_incompatible: Some($crate::FutureIncompatibleInfo {
Expand Down Expand Up @@ -859,7 +860,7 @@ macro_rules! declare_tool_lint {
edition_lint_opts: None,
report_in_external_macro: $external,
future_incompatible: None,
is_loaded: true,
is_externally_loaded: true,
$(feature_gate: Some($gate),)?
crate_level_only: false,
..$crate::Lint::default_fields_for_macro()
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_middle/src/traits/solve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,4 +332,9 @@ pub enum CandidateSource {
/// }
/// ```
AliasBound,
/// A candidate that is registered only during coherence to represent some
/// yet-unknown impl that could be produced downstream without violating orphan
/// rules.
// FIXME: Merge this with the forced ambiguity candidates, so those don't use `Misc`.
CoherenceUnknowable,
}
6 changes: 2 additions & 4 deletions compiler/rustc_middle/src/traits/solve/inspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,6 @@ pub enum ProbeKind<'tcx> {
TryNormalizeNonRigid { result: QueryResult<'tcx> },
/// Probe entered when normalizing the self ty during candidate assembly
NormalizedSelfTyAssembly,
/// Some candidate to prove the current goal.
///
/// FIXME: Remove this in favor of always using more strongly typed variants.
MiscCandidate { name: &'static str, result: QueryResult<'tcx> },
/// A candidate for proving a trait or alias-relate goal.
TraitCandidate { source: CandidateSource, result: QueryResult<'tcx> },
/// Used in the probe that wraps normalizing the non-self type for the unsize
Expand All @@ -154,4 +150,6 @@ pub enum ProbeKind<'tcx> {
/// do a probe to find out what projection type(s) may be used to prove that
/// the source type upholds all of the target type's object bounds.
UpcastProjectionCompatibility,
/// Try to unify an opaque type with an existing key in the storage.
OpaqueTypeStorageLookup { result: QueryResult<'tcx> },
}
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/traits/solve/inspect/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ impl<'a, 'b> ProofTreeFormatter<'a, 'b> {
ProbeKind::UpcastProjectionCompatibility => {
write!(self.f, "PROBING FOR PROJECTION COMPATIBILITY FOR UPCASTING:")
}
ProbeKind::MiscCandidate { name, result } => {
write!(self.f, "CANDIDATE {name}: {result:?}")
ProbeKind::OpaqueTypeStorageLookup { result } => {
write!(self.f, "PROBING FOR AN EXISTING OPAQUE: {result:?}")
}
ProbeKind::TraitCandidate { source, result } => {
write!(self.f, "CANDIDATE {source:?}: {result:?}")
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_mir_build/src/build/matches/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let expr_span = expr.span;

match expr.kind {
ExprKind::LogicalOp { op: LogicalOp::And, lhs, rhs } => {
this.visit_coverage_branch_operation(LogicalOp::And, expr_span);
ExprKind::LogicalOp { op: op @ LogicalOp::And, lhs, rhs } => {
this.visit_coverage_branch_operation(op, expr_span);
let lhs_then_block = unpack!(this.then_else_break_inner(block, lhs, args));
let rhs_then_block = unpack!(this.then_else_break_inner(lhs_then_block, rhs, args));
rhs_then_block.unit()
}
ExprKind::LogicalOp { op: LogicalOp::Or, lhs, rhs } => {
this.visit_coverage_branch_operation(LogicalOp::Or, expr_span);
ExprKind::LogicalOp { op: op @ LogicalOp::Or, lhs, rhs } => {
this.visit_coverage_branch_operation(op, expr_span);
let local_scope = this.local_scope();
let (lhs_success_block, failure_block) =
this.in_if_then_scope(local_scope, expr_span, |this| {
Expand Down
20 changes: 13 additions & 7 deletions compiler/rustc_mir_transform/src/known_panics_lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -896,13 +896,19 @@ impl CanConstProp {
};
for (local, val) in cpv.can_const_prop.iter_enumerated_mut() {
let ty = body.local_decls[local].ty;
match tcx.layout_of(param_env.and(ty)) {
Ok(layout) if layout.size < Size::from_bytes(MAX_ALLOC_LIMIT) => {}
// Either the layout fails to compute, then we can't use this local anyway
// or the local is too large, then we don't want to.
_ => {
*val = ConstPropMode::NoPropagation;
continue;
if ty.is_union() {
// Do not const prop unions as they can
// ICE during layout calc
*val = ConstPropMode::NoPropagation;
} else {
match tcx.layout_of(param_env.and(ty)) {
Ok(layout) if layout.size < Size::from_bytes(MAX_ALLOC_LIMIT) => {}
// Either the layout fails to compute, then we can't use this local anyway
// or the local is too large, then we don't want to.
_ => {
*val = ConstPropMode::NoPropagation;
continue;
}
}
}
}
Expand Down