Skip to content

Commit 3e0360f

Browse files
authored
Merge branch 'master' into is-symlink-stabilization
2 parents 36e050b + 0446743 commit 3e0360f

File tree

365 files changed

+4894
-3107
lines changed

Some content is hidden

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

365 files changed

+4894
-3107
lines changed

Cargo.toml

+9
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,15 @@ gimli.debug = 0
8989
miniz_oxide.debug = 0
9090
object.debug = 0
9191

92+
# The only package that ever uses debug builds is bootstrap.
93+
# We care a lot about bootstrap's compile times, so don't include debug info for
94+
# dependencies, only bootstrap itself.
95+
[profile.dev]
96+
debug = 0
97+
[profile.dev.package]
98+
# Only use debuginfo=1 to further reduce compile times.
99+
bootstrap.debug = 1
100+
92101
# We want the RLS to use the version of Cargo that we've got vendored in this
93102
# repository to ensure that the same exact version of Cargo is used by both the
94103
# RLS and the Cargo binary itself. The RLS depends on Cargo as a git repository

RELEASES.md

-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ Stabilised APIs
6464
- [`VecDeque::shrink_to`]
6565
- [`HashMap::shrink_to`]
6666
- [`HashSet::shrink_to`]
67-
- [`task::ready!`]
6867

6968
These APIs are now usable in const contexts:
7069

@@ -128,7 +127,6 @@ and related tools.
128127
[`VecDeque::shrink_to`]: https://doc.rust-lang.org/stable/std/collections/struct.VecDeque.html#method.shrink_to
129128
[`HashMap::shrink_to`]: https://doc.rust-lang.org/stable/std/collections/hash_map/struct.HashMap.html#method.shrink_to
130129
[`HashSet::shrink_to`]: https://doc.rust-lang.org/stable/std/collections/hash_set/struct.HashSet.html#method.shrink_to
131-
[`task::ready!`]: https://doc.rust-lang.org/stable/std/task/macro.ready.html
132130
[`std::mem::transmute`]: https://doc.rust-lang.org/stable/std/mem/fn.transmute.html
133131
[`slice::first`]: https://doc.rust-lang.org/stable/std/primitive.slice.html#method.first
134132
[`slice::split_first`]: https://doc.rust-lang.org/stable/std/primitive.slice.html#method.split_first

compiler/rustc_apfloat/src/ieee.rs

+2
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ impl<S: Semantics> fmt::Display for IeeeFloat<S> {
389389
let _: Loss = sig::shift_right(&mut sig, &mut exp, trailing_zeros as usize);
390390

391391
// Change the exponent from 2^e to 10^e.
392+
#[allow(clippy::comparison_chain)]
392393
if exp == 0 {
393394
// Nothing to do.
394395
} else if exp > 0 {
@@ -2526,6 +2527,7 @@ mod sig {
25262527
if *a_sign ^ b_sign {
25272528
let (reverse, loss);
25282529

2530+
#[allow(clippy::comparison_chain)]
25292531
if bits == 0 {
25302532
reverse = cmp(a_sig, b_sig) == Ordering::Less;
25312533
loss = Loss::ExactlyZero;

compiler/rustc_ast/src/lib.rs

-10
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,6 @@
2020
#[macro_use]
2121
extern crate rustc_macros;
2222

23-
#[macro_export]
24-
macro_rules! unwrap_or {
25-
($opt:expr, $default:expr) => {
26-
match $opt {
27-
Some(x) => x,
28-
None => $default,
29-
}
30-
};
31-
}
32-
3323
pub mod util {
3424
pub mod classify;
3525
pub mod comments;

compiler/rustc_ast_lowering/src/asm.rs

+2-62
Original file line numberDiff line numberDiff line change
@@ -202,39 +202,20 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
202202

203203
let mut used_input_regs = FxHashMap::default();
204204
let mut used_output_regs = FxHashMap::default();
205-
let mut required_features: Vec<&str> = vec![];
205+
206206
for (idx, &(ref op, op_sp)) in operands.iter().enumerate() {
207207
if let Some(reg) = op.reg() {
208-
// Make sure we don't accidentally carry features from the
209-
// previous iteration.
210-
required_features.clear();
211-
212208
let reg_class = reg.reg_class();
213209
if reg_class == asm::InlineAsmRegClass::Err {
214210
continue;
215211
}
216212

217-
// We ignore target feature requirements for clobbers: if the
218-
// feature is disabled then the compiler doesn't care what we
219-
// do with the registers.
220-
//
221-
// Note that this is only possible for explicit register
222-
// operands, which cannot be used in the asm string.
223-
let is_clobber = matches!(
224-
op,
225-
hir::InlineAsmOperand::Out {
226-
reg: asm::InlineAsmRegOrRegClass::Reg(_),
227-
late: _,
228-
expr: None
229-
}
230-
);
231-
232213
// Some register classes can only be used as clobbers. This
233214
// means that we disallow passing a value in/out of the asm and
234215
// require that the operand name an explicit register, not a
235216
// register class.
236217
if reg_class.is_clobber_only(asm_arch.unwrap())
237-
&& !(is_clobber && matches!(reg, asm::InlineAsmRegOrRegClass::Reg(_)))
218+
&& !(op.is_clobber() && matches!(reg, asm::InlineAsmRegOrRegClass::Reg(_)))
238219
{
239220
let msg = format!(
240221
"register class `{}` can only be used as a clobber, \
@@ -245,47 +226,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
245226
continue;
246227
}
247228

248-
if !is_clobber {
249-
// Validate register classes against currently enabled target
250-
// features. We check that at least one type is available for
251-
// the current target.
252-
for &(_, feature) in reg_class.supported_types(asm_arch.unwrap()) {
253-
if let Some(feature) = feature {
254-
if self.sess.target_features.contains(&Symbol::intern(feature)) {
255-
required_features.clear();
256-
break;
257-
} else {
258-
required_features.push(feature);
259-
}
260-
} else {
261-
required_features.clear();
262-
break;
263-
}
264-
}
265-
// We are sorting primitive strs here and can use unstable sort here
266-
required_features.sort_unstable();
267-
required_features.dedup();
268-
match &required_features[..] {
269-
[] => {}
270-
[feature] => {
271-
let msg = format!(
272-
"register class `{}` requires the `{}` target feature",
273-
reg_class.name(),
274-
feature
275-
);
276-
sess.struct_span_err(op_sp, &msg).emit();
277-
}
278-
features => {
279-
let msg = format!(
280-
"register class `{}` requires at least one target feature: {}",
281-
reg_class.name(),
282-
features.join(", ")
283-
);
284-
sess.struct_span_err(op_sp, &msg).emit();
285-
}
286-
}
287-
}
288-
289229
// Check for conflicts between explicit register operands.
290230
if let asm::InlineAsmRegOrRegClass::Reg(reg) = reg {
291231
let (input, output) = match op {

compiler/rustc_ast_lowering/src/item.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1345,8 +1345,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
13451345
generics
13461346
.params
13471347
.iter()
1348-
.find(|p| def_id == self.resolver.local_def_id(p.id).to_def_id())
1349-
.is_some()
1348+
.any(|p| def_id == self.resolver.local_def_id(p.id).to_def_id())
13501349
}
13511350
// Either the `bounded_ty` is not a plain type parameter, or
13521351
// it's not found in the generic type parameters list.

compiler/rustc_borrowck/src/dataflow.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ impl<'tcx> OutOfScopePrecomputer<'_, 'tcx> {
201201
let bb_data = &self.body[bb];
202202
debug_assert!(hi == bb_data.statements.len());
203203
for &succ_bb in bb_data.terminator().successors() {
204-
if self.visited.insert(succ_bb) == false {
204+
if !self.visited.insert(succ_bb) {
205205
if succ_bb == location.block && first_lo > 0 {
206206
// `succ_bb` has been seen before. If it wasn't
207207
// fully processed, add its first part to `stack`

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -972,8 +972,7 @@ fn suggest_ampmut<'tcx>(
972972
if let Some(assignment_rhs_span) = opt_assignment_rhs_span {
973973
if let Ok(src) = tcx.sess.source_map().span_to_snippet(assignment_rhs_span) {
974974
let is_mutbl = |ty: &str| -> bool {
975-
if ty.starts_with("mut") {
976-
let rest = &ty[3..];
975+
if let Some(rest) = ty.strip_prefix("mut") {
977976
match rest.chars().next() {
978977
// e.g. `&mut x`
979978
Some(c) if c.is_whitespace() => true,

compiler/rustc_borrowck/src/type_check/mod.rs

-22
Original file line numberDiff line numberDiff line change
@@ -1153,28 +1153,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
11531153
.convert_all(data);
11541154
}
11551155

1156-
/// Convenient wrapper around `relate_tys::relate_types` -- see
1157-
/// that fn for docs.
1158-
fn relate_types(
1159-
&mut self,
1160-
a: Ty<'tcx>,
1161-
v: ty::Variance,
1162-
b: Ty<'tcx>,
1163-
locations: Locations,
1164-
category: ConstraintCategory,
1165-
) -> Fallible<()> {
1166-
relate_tys::relate_types(
1167-
self.infcx,
1168-
self.param_env,
1169-
a,
1170-
v,
1171-
b,
1172-
locations,
1173-
category,
1174-
self.borrowck_context,
1175-
)
1176-
}
1177-
11781156
/// Try to relate `sub <: sup`
11791157
fn sub_types(
11801158
&mut self,

compiler/rustc_borrowck/src/type_check/relate_tys.rs

+53-59
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,44 @@
11
use rustc_infer::infer::nll_relate::{NormalizationStrategy, TypeRelating, TypeRelatingDelegate};
2-
use rustc_infer::infer::{InferCtxt, NllRegionVariableOrigin};
2+
use rustc_infer::infer::NllRegionVariableOrigin;
33
use rustc_middle::mir::ConstraintCategory;
44
use rustc_middle::ty::relate::TypeRelation;
55
use rustc_middle::ty::{self, Const, Ty};
66
use rustc_trait_selection::traits::query::Fallible;
77

88
use crate::constraints::OutlivesConstraint;
99
use crate::diagnostics::UniverseInfo;
10-
use crate::type_check::{BorrowCheckContext, Locations};
11-
12-
/// Adds sufficient constraints to ensure that `a R b` where `R` depends on `v`:
13-
///
14-
/// - "Covariant" `a <: b`
15-
/// - "Invariant" `a == b`
16-
/// - "Contravariant" `a :> b`
17-
///
18-
/// N.B., the type `a` is permitted to have unresolved inference
19-
/// variables, but not the type `b`.
20-
#[instrument(skip(infcx, param_env, borrowck_context), level = "debug")]
21-
pub(super) fn relate_types<'tcx>(
22-
infcx: &InferCtxt<'_, 'tcx>,
23-
param_env: ty::ParamEnv<'tcx>,
24-
a: Ty<'tcx>,
25-
v: ty::Variance,
26-
b: Ty<'tcx>,
27-
locations: Locations,
28-
category: ConstraintCategory,
29-
borrowck_context: &mut BorrowCheckContext<'_, 'tcx>,
30-
) -> Fallible<()> {
31-
TypeRelating::new(
32-
infcx,
33-
NllTypeRelatingDelegate::new(
34-
infcx,
35-
borrowck_context,
36-
param_env,
37-
locations,
38-
category,
39-
UniverseInfo::relate(a, b),
40-
),
41-
v,
42-
)
43-
.relate(a, b)?;
44-
Ok(())
10+
use crate::type_check::{Locations, TypeChecker};
11+
12+
impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
13+
/// Adds sufficient constraints to ensure that `a R b` where `R` depends on `v`:
14+
///
15+
/// - "Covariant" `a <: b`
16+
/// - "Invariant" `a == b`
17+
/// - "Contravariant" `a :> b`
18+
///
19+
/// N.B., the type `a` is permitted to have unresolved inference
20+
/// variables, but not the type `b`.
21+
#[instrument(skip(self), level = "debug")]
22+
pub(super) fn relate_types(
23+
&mut self,
24+
a: Ty<'tcx>,
25+
v: ty::Variance,
26+
b: Ty<'tcx>,
27+
locations: Locations,
28+
category: ConstraintCategory,
29+
) -> Fallible<()> {
30+
TypeRelating::new(
31+
self.infcx,
32+
NllTypeRelatingDelegate::new(self, locations, category, UniverseInfo::relate(a, b)),
33+
v,
34+
)
35+
.relate(a, b)?;
36+
Ok(())
37+
}
4538
}
4639

4740
struct NllTypeRelatingDelegate<'me, 'bccx, 'tcx> {
48-
infcx: &'me InferCtxt<'me, 'tcx>,
49-
borrowck_context: &'me mut BorrowCheckContext<'bccx, 'tcx>,
50-
51-
param_env: ty::ParamEnv<'tcx>,
41+
type_checker: &'me mut TypeChecker<'bccx, 'tcx>,
5242

5343
/// Where (and why) is this relation taking place?
5444
locations: Locations,
@@ -63,25 +53,24 @@ struct NllTypeRelatingDelegate<'me, 'bccx, 'tcx> {
6353

6454
impl NllTypeRelatingDelegate<'me, 'bccx, 'tcx> {
6555
fn new(
66-
infcx: &'me InferCtxt<'me, 'tcx>,
67-
borrowck_context: &'me mut BorrowCheckContext<'bccx, 'tcx>,
68-
param_env: ty::ParamEnv<'tcx>,
56+
type_checker: &'me mut TypeChecker<'bccx, 'tcx>,
6957
locations: Locations,
7058
category: ConstraintCategory,
7159
universe_info: UniverseInfo<'tcx>,
7260
) -> Self {
73-
Self { infcx, borrowck_context, param_env, locations, category, universe_info }
61+
Self { type_checker, locations, category, universe_info }
7462
}
7563
}
7664

7765
impl TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx> {
7866
fn param_env(&self) -> ty::ParamEnv<'tcx> {
79-
self.param_env
67+
self.type_checker.param_env
8068
}
8169

8270
fn create_next_universe(&mut self) -> ty::UniverseIndex {
83-
let universe = self.infcx.create_next_universe();
84-
self.borrowck_context
71+
let universe = self.type_checker.infcx.create_next_universe();
72+
self.type_checker
73+
.borrowck_context
8574
.constraints
8675
.universe_causes
8776
.insert(universe, self.universe_info.clone());
@@ -90,15 +79,18 @@ impl TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx> {
9079

9180
fn next_existential_region_var(&mut self, from_forall: bool) -> ty::Region<'tcx> {
9281
let origin = NllRegionVariableOrigin::Existential { from_forall };
93-
self.infcx.next_nll_region_var(origin)
82+
self.type_checker.infcx.next_nll_region_var(origin)
9483
}
9584

9685
fn next_placeholder_region(&mut self, placeholder: ty::PlaceholderRegion) -> ty::Region<'tcx> {
97-
self.borrowck_context.constraints.placeholder_region(self.infcx, placeholder)
86+
self.type_checker
87+
.borrowck_context
88+
.constraints
89+
.placeholder_region(self.type_checker.infcx, placeholder)
9890
}
9991

10092
fn generalize_existential(&mut self, universe: ty::UniverseIndex) -> ty::Region<'tcx> {
101-
self.infcx.next_nll_region_var_in_universe(
93+
self.type_checker.infcx.next_nll_region_var_in_universe(
10294
NllRegionVariableOrigin::Existential { from_forall: false },
10395
universe,
10496
)
@@ -110,15 +102,17 @@ impl TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx> {
110102
sub: ty::Region<'tcx>,
111103
info: ty::VarianceDiagInfo<'tcx>,
112104
) {
113-
let sub = self.borrowck_context.universal_regions.to_region_vid(sub);
114-
let sup = self.borrowck_context.universal_regions.to_region_vid(sup);
115-
self.borrowck_context.constraints.outlives_constraints.push(OutlivesConstraint {
116-
sup,
117-
sub,
118-
locations: self.locations,
119-
category: self.category,
120-
variance_info: info,
121-
});
105+
let sub = self.type_checker.borrowck_context.universal_regions.to_region_vid(sub);
106+
let sup = self.type_checker.borrowck_context.universal_regions.to_region_vid(sup);
107+
self.type_checker.borrowck_context.constraints.outlives_constraints.push(
108+
OutlivesConstraint {
109+
sup,
110+
sub,
111+
locations: self.locations,
112+
category: self.category,
113+
variance_info: info,
114+
},
115+
);
122116
}
123117

124118
// We don't have to worry about the equality of consts during borrow checking

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ impl<'a> TraitDef<'a> {
594594
GenericParamKind::Const { ty, kw_span, .. } => {
595595
let const_nodefault_kind = GenericParamKind::Const {
596596
ty: ty.clone(),
597-
kw_span: kw_span.clone(),
597+
kw_span: *kw_span,
598598

599599
// We can't have default values inside impl block
600600
default: None,

0 commit comments

Comments
 (0)