Skip to content

Commit

Permalink
Auto merge of rust-lang#124527 - jieyouxu:rollup-eslzncy, r=jieyouxu
Browse files Browse the repository at this point in the history
Rollup of 7 pull requests

Successful merges:

 - rust-lang#124269 (Pretty-print parenthesis around binary in postfix match)
 - rust-lang#124415 (Use probes more aggressively in new solver)
 - rust-lang#124475 (Remove direct dependencies on lazy_static, once_cell and byteorder)
 - rust-lang#124484 (Fix rust-lang#124478 - offset_of! returns a temporary)
 - rust-lang#124504 (Mark unions non-const-propagatable in `KnownPanicsLint` without calling layout)
 - rust-lang#124508 (coverage: Avoid hard-coded values when visiting logical ops)
 - rust-lang#124522 ([Refactor] Rename `Lint` and `LintGroup`'s `is_loaded` to `is_externally_loaded` )

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Apr 29, 2024
2 parents e27af29 + ebce31a commit a8a1d3a
Show file tree
Hide file tree
Showing 59 changed files with 835 additions and 1,044 deletions.
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
Loading

0 comments on commit a8a1d3a

Please sign in to comment.