Skip to content

Commit a8a1d3a

Browse files
committed
Auto merge of rust-lang#124527 - jieyouxu:rollup-eslzncy, r=jieyouxu
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
2 parents e27af29 + ebce31a commit a8a1d3a

File tree

59 files changed

+835
-1044
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+835
-1044
lines changed

Cargo.lock

-7
Original file line numberDiff line numberDiff line change
@@ -2113,7 +2113,6 @@ dependencies = [
21132113
"fs-err",
21142114
"getopts",
21152115
"jsonpath_lib",
2116-
"once_cell",
21172116
"regex",
21182117
"serde_json",
21192118
"shlex",
@@ -2232,7 +2231,6 @@ name = "linkchecker"
22322231
version = "0.1.0"
22332232
dependencies = [
22342233
"html5ever",
2235-
"once_cell",
22362234
"regex",
22372235
]
22382236

@@ -2491,7 +2489,6 @@ dependencies = [
24912489
"directories",
24922490
"getrandom",
24932491
"jemalloc-sys",
2494-
"lazy_static",
24952492
"libc",
24962493
"libffi",
24972494
"libloading",
@@ -4791,12 +4788,10 @@ dependencies = [
47914788
"arrayvec",
47924789
"askama",
47934790
"base64",
4794-
"byteorder",
47954791
"expect-test",
47964792
"indexmap",
47974793
"itertools 0.12.1",
47984794
"minifier",
4799-
"once_cell",
48004795
"regex",
48014796
"rustdoc-json-types",
48024797
"serde",
@@ -5351,7 +5346,6 @@ version = "0.1.0"
53515346
dependencies = [
53525347
"build_helper",
53535348
"glob",
5354-
"once_cell",
53555349
]
53565350

53575351
[[package]]
@@ -5596,7 +5590,6 @@ version = "0.1.0"
55965590
dependencies = [
55975591
"cargo_metadata 0.15.4",
55985592
"ignore",
5599-
"lazy_static",
56005593
"miropt-test-tools",
56015594
"regex",
56025595
"rustc-hash",

compiler/rustc_ast_pretty/src/pprust/state/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ impl<'a> State<'a> {
488488
self.space();
489489
}
490490
MatchKind::Postfix => {
491-
self.print_expr_as_cond(expr);
491+
self.print_expr_maybe_paren(expr, parser::PREC_POSTFIX, fixup);
492492
self.word_nbsp(".match");
493493
}
494494
}

compiler/rustc_driver_impl/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ Available lint options:
971971

972972
let lint_store = unerased_lint_store(sess);
973973
let (loaded, builtin): (Vec<_>, _) =
974-
lint_store.get_lints().iter().cloned().partition(|&lint| lint.is_loaded);
974+
lint_store.get_lints().iter().cloned().partition(|&lint| lint.is_externally_loaded);
975975
let loaded = sort_lints(sess, loaded);
976976
let builtin = sort_lints(sess, builtin);
977977

compiler/rustc_lint/src/context.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ struct LintAlias {
110110

111111
struct LintGroup {
112112
lint_ids: Vec<LintId>,
113-
is_loaded: bool,
113+
is_externally_loaded: bool,
114114
depr: Option<LintAlias>,
115115
}
116116

@@ -159,7 +159,9 @@ impl LintStore {
159159
// Don't display deprecated lint groups.
160160
depr.is_none()
161161
})
162-
.map(|(k, LintGroup { lint_ids, is_loaded, .. })| (*k, lint_ids.clone(), *is_loaded))
162+
.map(|(k, LintGroup { lint_ids, is_externally_loaded, .. })| {
163+
(*k, lint_ids.clone(), *is_externally_loaded)
164+
})
163165
}
164166

165167
pub fn register_early_pass(
@@ -218,7 +220,7 @@ impl LintStore {
218220
.entry(edition.lint_name())
219221
.or_insert(LintGroup {
220222
lint_ids: vec![],
221-
is_loaded: lint.is_loaded,
223+
is_externally_loaded: lint.is_externally_loaded,
222224
depr: None,
223225
})
224226
.lint_ids
@@ -231,7 +233,7 @@ impl LintStore {
231233
.entry("future_incompatible")
232234
.or_insert(LintGroup {
233235
lint_ids: vec![],
234-
is_loaded: lint.is_loaded,
236+
is_externally_loaded: lint.is_externally_loaded,
235237
depr: None,
236238
})
237239
.lint_ids
@@ -246,29 +248,29 @@ impl LintStore {
246248
alias,
247249
LintGroup {
248250
lint_ids: vec![],
249-
is_loaded: false,
251+
is_externally_loaded: false,
250252
depr: Some(LintAlias { name: lint_name, silent: true }),
251253
},
252254
);
253255
}
254256

255257
pub fn register_group(
256258
&mut self,
257-
is_loaded: bool,
259+
is_externally_loaded: bool,
258260
name: &'static str,
259261
deprecated_name: Option<&'static str>,
260262
to: Vec<LintId>,
261263
) {
262264
let new = self
263265
.lint_groups
264-
.insert(name, LintGroup { lint_ids: to, is_loaded, depr: None })
266+
.insert(name, LintGroup { lint_ids: to, is_externally_loaded, depr: None })
265267
.is_none();
266268
if let Some(deprecated) = deprecated_name {
267269
self.lint_groups.insert(
268270
deprecated,
269271
LintGroup {
270272
lint_ids: vec![],
271-
is_loaded,
273+
is_externally_loaded,
272274
depr: Some(LintAlias { name, silent: false }),
273275
},
274276
);

compiler/rustc_lint/src/unused.rs

+1
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
176176
| hir::BinOpKind::Shr => Some("bitwise operation"),
177177
},
178178
hir::ExprKind::AddrOf(..) => Some("borrow"),
179+
hir::ExprKind::OffsetOf(..) => Some("`offset_of` call"),
179180
hir::ExprKind::Unary(..) => Some("unary operation"),
180181
_ => None,
181182
};

compiler/rustc_lint_defs/src/lib.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,8 @@ pub struct Lint {
323323

324324
pub future_incompatible: Option<FutureIncompatibleInfo>,
325325

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

328329
/// `Some` if this lint is feature gated, otherwise `None`.
329330
pub feature_gate: Option<Symbol>,
@@ -468,7 +469,7 @@ impl Lint {
468469
default_level: Level::Forbid,
469470
desc: "",
470471
edition_lint_opts: None,
471-
is_loaded: false,
472+
is_externally_loaded: false,
472473
report_in_external_macro: false,
473474
future_incompatible: None,
474475
feature_gate: None,
@@ -817,7 +818,7 @@ macro_rules! declare_lint {
817818
name: stringify!($NAME),
818819
default_level: $crate::$Level,
819820
desc: $desc,
820-
is_loaded: false,
821+
is_externally_loaded: false,
821822
$($v: true,)*
822823
$(feature_gate: Some($gate),)?
823824
$(future_incompatible: Some($crate::FutureIncompatibleInfo {
@@ -859,7 +860,7 @@ macro_rules! declare_tool_lint {
859860
edition_lint_opts: None,
860861
report_in_external_macro: $external,
861862
future_incompatible: None,
862-
is_loaded: true,
863+
is_externally_loaded: true,
863864
$(feature_gate: Some($gate),)?
864865
crate_level_only: false,
865866
..$crate::Lint::default_fields_for_macro()

compiler/rustc_middle/src/traits/solve.rs

+5
Original file line numberDiff line numberDiff line change
@@ -332,4 +332,9 @@ pub enum CandidateSource {
332332
/// }
333333
/// ```
334334
AliasBound,
335+
/// A candidate that is registered only during coherence to represent some
336+
/// yet-unknown impl that could be produced downstream without violating orphan
337+
/// rules.
338+
// FIXME: Merge this with the forced ambiguity candidates, so those don't use `Misc`.
339+
CoherenceUnknowable,
335340
}

compiler/rustc_middle/src/traits/solve/inspect.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,6 @@ pub enum ProbeKind<'tcx> {
141141
TryNormalizeNonRigid { result: QueryResult<'tcx> },
142142
/// Probe entered when normalizing the self ty during candidate assembly
143143
NormalizedSelfTyAssembly,
144-
/// Some candidate to prove the current goal.
145-
///
146-
/// FIXME: Remove this in favor of always using more strongly typed variants.
147-
MiscCandidate { name: &'static str, result: QueryResult<'tcx> },
148144
/// A candidate for proving a trait or alias-relate goal.
149145
TraitCandidate { source: CandidateSource, result: QueryResult<'tcx> },
150146
/// Used in the probe that wraps normalizing the non-self type for the unsize
@@ -154,4 +150,6 @@ pub enum ProbeKind<'tcx> {
154150
/// do a probe to find out what projection type(s) may be used to prove that
155151
/// the source type upholds all of the target type's object bounds.
156152
UpcastProjectionCompatibility,
153+
/// Try to unify an opaque type with an existing key in the storage.
154+
OpaqueTypeStorageLookup { result: QueryResult<'tcx> },
157155
}

compiler/rustc_middle/src/traits/solve/inspect/format.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ impl<'a, 'b> ProofTreeFormatter<'a, 'b> {
112112
ProbeKind::UpcastProjectionCompatibility => {
113113
write!(self.f, "PROBING FOR PROJECTION COMPATIBILITY FOR UPCASTING:")
114114
}
115-
ProbeKind::MiscCandidate { name, result } => {
116-
write!(self.f, "CANDIDATE {name}: {result:?}")
115+
ProbeKind::OpaqueTypeStorageLookup { result } => {
116+
write!(self.f, "PROBING FOR AN EXISTING OPAQUE: {result:?}")
117117
}
118118
ProbeKind::TraitCandidate { source, result } => {
119119
write!(self.f, "CANDIDATE {source:?}: {result:?}")

compiler/rustc_mir_build/src/build/matches/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
7373
let expr_span = expr.span;
7474

7575
match expr.kind {
76-
ExprKind::LogicalOp { op: LogicalOp::And, lhs, rhs } => {
77-
this.visit_coverage_branch_operation(LogicalOp::And, expr_span);
76+
ExprKind::LogicalOp { op: op @ LogicalOp::And, lhs, rhs } => {
77+
this.visit_coverage_branch_operation(op, expr_span);
7878
let lhs_then_block = unpack!(this.then_else_break_inner(block, lhs, args));
7979
let rhs_then_block = unpack!(this.then_else_break_inner(lhs_then_block, rhs, args));
8080
rhs_then_block.unit()
8181
}
82-
ExprKind::LogicalOp { op: LogicalOp::Or, lhs, rhs } => {
83-
this.visit_coverage_branch_operation(LogicalOp::Or, expr_span);
82+
ExprKind::LogicalOp { op: op @ LogicalOp::Or, lhs, rhs } => {
83+
this.visit_coverage_branch_operation(op, expr_span);
8484
let local_scope = this.local_scope();
8585
let (lhs_success_block, failure_block) =
8686
this.in_if_then_scope(local_scope, expr_span, |this| {

compiler/rustc_mir_transform/src/known_panics_lint.rs

+13-7
Original file line numberDiff line numberDiff line change
@@ -896,13 +896,19 @@ impl CanConstProp {
896896
};
897897
for (local, val) in cpv.can_const_prop.iter_enumerated_mut() {
898898
let ty = body.local_decls[local].ty;
899-
match tcx.layout_of(param_env.and(ty)) {
900-
Ok(layout) if layout.size < Size::from_bytes(MAX_ALLOC_LIMIT) => {}
901-
// Either the layout fails to compute, then we can't use this local anyway
902-
// or the local is too large, then we don't want to.
903-
_ => {
904-
*val = ConstPropMode::NoPropagation;
905-
continue;
899+
if ty.is_union() {
900+
// Do not const prop unions as they can
901+
// ICE during layout calc
902+
*val = ConstPropMode::NoPropagation;
903+
} else {
904+
match tcx.layout_of(param_env.and(ty)) {
905+
Ok(layout) if layout.size < Size::from_bytes(MAX_ALLOC_LIMIT) => {}
906+
// Either the layout fails to compute, then we can't use this local anyway
907+
// or the local is too large, then we don't want to.
908+
_ => {
909+
*val = ConstPropMode::NoPropagation;
910+
continue;
911+
}
906912
}
907913
}
908914
}

0 commit comments

Comments
 (0)