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 8 pull requests #81510

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9abcfa5
Don't link with --export-dynamic on wasm32-wasi
sunfishcode Jan 21, 2021
e94cf57
Make functional record update/struct update syntax works inside closu…
null-sleep Jan 23, 2021
77a9e3e
combine: stop eagerly evaluating consts
lcnr Jan 24, 2021
d00c850
BTreeMap: correct tests for alternative choices of B
ssomers Jan 20, 2021
8db2782
refactor: moved new out of ZipImpl
DeveloperC286 Dec 16, 2020
bfb0e4a
refactor: moved next_back out of ZipImpl
DeveloperC286 Dec 16, 2020
0597339
refactor: removed ZipImpl
DeveloperC286 Dec 16, 2020
f2bb202
refactor: updated zip nth() to iterator nth()
DeveloperC286 Dec 16, 2020
328abfb
Slight simplification of chars().count()
gilescope Jan 26, 2021
425a70a
Removing if so it's more like the previous implementation.
gilescope Jan 26, 2021
c07e558
Let's try the most idiomatic way.
gilescope Jan 26, 2021
a623ea5
Same instructions, but simpler.
gilescope Jan 26, 2021
063b427
Bump rustfmt version
Mark-Simulacrum Jan 9, 2021
ad14924
path trimming: ignore type aliases
da-x Jan 28, 2021
9dc0d1d
path trimming: disable on src/test/run-make-fulldeps/coverage-spanview
da-x Jan 28, 2021
152f500
refactor: removing redundant variables
DeveloperC286 Jan 28, 2021
5e983d7
Add a test for syntax like: ..t.s
null-sleep Jan 29, 2021
24d2e9a
Rollup merge of #78052 - da-x:path-trimming-type-aliases, r=davidtwco
henryboisdequin Jan 29, 2021
98d7686
Rollup merge of #79173 - DeveloperC286:zip_nth_cleanup, r=kennytm
henryboisdequin Jan 29, 2021
881fb27
Rollup merge of #80843 - Mark-Simulacrum:fmt-bump, r=petrochenkov
henryboisdequin Jan 29, 2021
be12f96
Rollup merge of #81210 - ssomers:btree_fix_node_size_test, r=Mark-Sim…
henryboisdequin Jan 29, 2021
352fd3c
Rollup merge of #81255 - sunfishcode:wasi-no-export-dynamic, r=alexcr…
henryboisdequin Jan 29, 2021
1256217
Rollup merge of #81291 - sexxi-goose:fix-struct-update-functional-rec…
henryboisdequin Jan 29, 2021
69dd59f
Rollup merge of #81351 - lcnr:big-money-big-prices, r=oli-obk
henryboisdequin Jan 29, 2021
8d41097
Rollup merge of #81409 - gilescope:chars_count, r=joshtriplett
henryboisdequin Jan 29, 2021
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
4 changes: 3 additions & 1 deletion compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
let count = generics
.params
.iter()
.filter(|param| matches!(param.kind, ast::GenericParamKind::Lifetime { .. }))
.filter(|param| {
matches!(param.kind, ast::GenericParamKind::Lifetime { .. })
})
.count();
self.lctx.type_def_lifetime_params.insert(def_id.to_def_id(), count);
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ impl<'a> TraitDef<'a> {

let mut ty_params = params
.iter()
.filter(|param| matches!(param.kind, ast::GenericParamKind::Type{..}))
.filter(|param| matches!(param.kind, ast::GenericParamKind::Type { .. }))
.peekable();

if ty_params.peek().is_some() {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_errors/src/diagnostic_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ macro_rules! forward_inner_docs {
($e:expr => $i:item) => {
#[doc = $e]
$i
}
};
}

/// In general, the `DiagnosticBuilder` uses deref to allow access to
Expand Down
15 changes: 10 additions & 5 deletions compiler/rustc_errors/src/snippet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,13 @@ impl Annotation {
}

pub fn is_multiline(&self) -> bool {
matches!(self.annotation_type,
matches!(
self.annotation_type,
AnnotationType::Multiline(_)
| AnnotationType::MultilineStart(_)
| AnnotationType::MultilineLine(_)
| AnnotationType::MultilineEnd(_))
| AnnotationType::MultilineStart(_)
| AnnotationType::MultilineLine(_)
| AnnotationType::MultilineEnd(_)
)
}

pub fn len(&self) -> usize {
Expand Down Expand Up @@ -158,7 +160,10 @@ impl Annotation {

pub fn takes_space(&self) -> bool {
// Multiline annotations always have to keep vertical space.
matches!(self.annotation_type, AnnotationType::MultilineStart(_) | AnnotationType::MultilineEnd(_))
matches!(
self.annotation_type,
AnnotationType::MultilineStart(_) | AnnotationType::MultilineEnd(_)
)
}
}

Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1543,10 +1543,10 @@ pub fn is_range_literal(expr: &Expr<'_>) -> bool {
**qpath,
QPath::LangItem(
LangItem::Range
| LangItem::RangeTo
| LangItem::RangeFrom
| LangItem::RangeFull
| LangItem::RangeToInclusive,
| LangItem::RangeTo
| LangItem::RangeFrom
| LangItem::RangeFull
| LangItem::RangeToInclusive,
_,
)
),
Expand Down
28 changes: 20 additions & 8 deletions compiler/rustc_infer/src/infer/combine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,10 +542,6 @@ impl TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
true
}

fn visit_ct_substs(&self) -> bool {
true
}

fn binders<T>(
&mut self,
a: ty::Binder<T>,
Expand Down Expand Up @@ -736,6 +732,16 @@ impl TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
}
}
}
ty::ConstKind::Unevaluated(def, substs, promoted)
if self.tcx().lazy_normalization() =>
{
assert_eq!(promoted, None);
let substs = self.relate_with_variance(ty::Variance::Invariant, substs, substs)?;
Ok(self.tcx().mk_const(ty::Const {
ty: c.ty,
val: ty::ConstKind::Unevaluated(def, substs, promoted),
}))
}
_ => relate::super_relate_consts(self, c, c),
}
}
Expand Down Expand Up @@ -821,10 +827,6 @@ impl TypeRelation<'tcx> for ConstInferUnifier<'_, 'tcx> {
true
}

fn visit_ct_substs(&self) -> bool {
true
}

fn relate_with_variance<T: Relate<'tcx>>(
&mut self,
_variance: ty::Variance,
Expand Down Expand Up @@ -958,6 +960,16 @@ impl TypeRelation<'tcx> for ConstInferUnifier<'_, 'tcx> {
}
}
}
ty::ConstKind::Unevaluated(def, substs, promoted)
if self.tcx().lazy_normalization() =>
{
assert_eq!(promoted, None);
let substs = self.relate_with_variance(ty::Variance::Invariant, substs, substs)?;
Ok(self.tcx().mk_const(ty::Const {
ty: c.ty,
val: ty::ConstKind::Unevaluated(def, substs, promoted),
}))
}
_ => relate::super_relate_consts(self, c, c),
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,12 @@ impl Visitor<'tcx> for TypeParamSpanVisitor<'tcx> {
[segment]
if segment
.res
.map(|res| matches!(res, Res::SelfTy(_, _) | Res::Def(hir::def::DefKind::TyParam, _)))
.map(|res| {
matches!(
res,
Res::SelfTy(_, _) | Res::Def(hir::def::DefKind::TyParam, _)
)
})
.unwrap_or(false) =>
{
self.types.push(path.span);
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_middle/src/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,9 +559,9 @@ impl<'hir> Map<'hir> {
self.find(self.get_parent_node(id)),
Some(
Node::Item(_)
| Node::TraitItem(_)
| Node::ImplItem(_)
| Node::Expr(Expr { kind: ExprKind::Closure(..), .. }),
| Node::TraitItem(_)
| Node::ImplItem(_)
| Node::Expr(Expr { kind: ExprKind::Closure(..), .. }),
)
)
}
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_middle/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -962,8 +962,7 @@ impl<'tcx> LocalDecl<'tcx> {
opt_ty_info: _,
opt_match_place: _,
pat_span: _,
})
| BindingForm::ImplicitSelf(ImplicitSelfKind::Imm),
}) | BindingForm::ImplicitSelf(ImplicitSelfKind::Imm),
)))
)
}
Expand All @@ -980,8 +979,7 @@ impl<'tcx> LocalDecl<'tcx> {
opt_ty_info: _,
opt_match_place: _,
pat_span: _,
})
| BindingForm::ImplicitSelf(_),
}) | BindingForm::ImplicitSelf(_),
)))
)
}
Expand Down
18 changes: 11 additions & 7 deletions compiler/rustc_middle/src/ty/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ impl<'tcx> TyS<'tcx> {
pub fn is_primitive_ty(&self) -> bool {
matches!(
self.kind(),
Bool | Char | Str | Int(_) | Uint(_) | Float(_)
| Infer(
InferTy::IntVar(_)
| InferTy::FloatVar(_)
| InferTy::FreshIntTy(_)
| InferTy::FreshFloatTy(_)
)
Bool | Char
| Str
| Int(_)
| Uint(_)
| Float(_)
| Infer(
InferTy::IntVar(_)
| InferTy::FloatVar(_)
| InferTy::FreshIntTy(_)
| InferTy::FreshFloatTy(_)
)
)
}

Expand Down
11 changes: 7 additions & 4 deletions compiler/rustc_middle/src/ty/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -646,11 +646,14 @@ impl<T> Trait<T> for X {
let current_method_ident = body_owner.and_then(|n| n.ident()).map(|i| i.name);

// We don't want to suggest calling an assoc fn in a scope where that isn't feasible.
let callable_scope = matches!(body_owner, Some(
let callable_scope = matches!(
body_owner,
Some(
hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn(..), .. })
| hir::Node::TraitItem(hir::TraitItem { kind: hir::TraitItemKind::Fn(..), .. })
| hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Fn(..), .. }),
));
| hir::Node::TraitItem(hir::TraitItem { kind: hir::TraitItemKind::Fn(..), .. })
| hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Fn(..), .. }),
)
);
let impl_comparison = matches!(
cause_code,
ObligationCauseCode::CompareImplMethodObligation { .. }
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_middle/src/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2143,6 +2143,7 @@ fn for_each_def(tcx: TyCtxt<'_>, mut collect_fn: impl for<'b> FnMut(&'b Ident, N

match child.res {
def::Res::Def(DefKind::AssocTy, _) => {}
def::Res::Def(DefKind::TyAlias, _) => {}
def::Res::Def(defkind, def_id) => {
if let Some(ns) = defkind.ns() {
collect_fn(&child.ident, ns, def_id);
Expand Down
11 changes: 1 addition & 10 deletions compiler/rustc_middle/src/ty/relate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,6 @@ pub trait TypeRelation<'tcx>: Sized {
/// relation. Just affects error messages.
fn a_is_expected(&self) -> bool;

/// Whether we should look into the substs of unevaluated constants
/// even if `feature(const_evaluatable_checked)` is active.
///
/// This is needed in `combine` to prevent accidentially creating
/// infinite types as we abuse `TypeRelation` to walk a type there.
fn visit_ct_substs(&self) -> bool {
false
}

fn with_cause<F, R>(&mut self, _cause: Cause, f: F) -> R
where
F: FnOnce(&mut Self) -> R,
Expand Down Expand Up @@ -588,7 +579,7 @@ pub fn super_relate_consts<R: TypeRelation<'tcx>>(
(
ty::ConstKind::Unevaluated(a_def, a_substs, None),
ty::ConstKind::Unevaluated(b_def, b_substs, None),
) if tcx.features().const_evaluatable_checked && !relation.visit_ct_substs() => {
) if tcx.features().const_evaluatable_checked => {
if tcx.try_unify_abstract_consts(((a_def, a_substs), (b_def, b_substs))) {
Ok(a.val)
} else {
Expand Down
10 changes: 8 additions & 2 deletions compiler/rustc_middle/src/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1871,8 +1871,14 @@ impl<'tcx> TyS<'tcx> {
pub fn is_scalar(&self) -> bool {
matches!(
self.kind(),
Bool | Char | Int(_) | Float(_) | Uint(_) | FnDef(..) | FnPtr(_) | RawPtr(_)
| Infer(IntVar(_) | FloatVar(_))
Bool | Char
| Int(_)
| Float(_)
| Uint(_)
| FnDef(..)
| FnPtr(_)
| RawPtr(_)
| Infer(IntVar(_) | FloatVar(_))
)
}

Expand Down
Loading