Skip to content

Compatibility to rustc (1.50.0+dfsg1+llvm-0ubuntu5) shipped with Ubuntu 21.04 (hirsute) #9629

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

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
15fb83a
Removed usage of "modern" resolver.
KOLANICH Jul 19, 2021
5898639
Added missing .iter() and a borrow in `has_ref` introduced in 9a3eae8…
KOLANICH Jul 19, 2021
3cd4a2a
Replaced std::array::IntoIter with ArrayIterator::new
KOLANICH Jul 19, 2021
d41edc9
Replaced std::array::IntoIter introduced in 9f9cc72ee5dbb0991951ec1a3…
KOLANICH Jul 19, 2021
a81b594
Replaced or-patterns in the code introduced in 9abd28ac372f8b883ab3fe…
KOLANICH Jul 19, 2021
e19a215
Removed or-patterns introduced in 0729913525a55cad3ffe9876c1eb05f7b88…
KOLANICH Jul 19, 2021
9623277
Replaced or-patterns introduced in 4450365ec8743fa583758dfa74e3f276b1…
KOLANICH Jul 19, 2021
3461ca3
Replaced or-expr introduced in da00208ab94f1109c630f28adef033c83558a8…
KOLANICH Jul 19, 2021
e7c1152
Replaced split_inclusive with split
KOLANICH Jul 19, 2021
2a336ee
Replaced split_once. May be incorrect.
KOLANICH Jul 19, 2021
d70b592
Reverted 6a16ec52aa0d91945577c99cdf421b303b59301e
KOLANICH Jul 19, 2021
e7349e3
Reverted 36c20dc23d20d1ad277aa197013b837fb83b6501 which depends on ls…
KOLANICH Jul 19, 2021
201b887
Reverted 9787bddac577a6aa24388fb91286474a7a8cf0bc, upgrading arrayvec…
KOLANICH Jul 19, 2021
e02f485
Reverted repr patterns
KOLANICH Jul 19, 2021
c989497
Got rid of split_inclusive and split_once in fixture.rs
KOLANICH Jul 19, 2021
bb87ba7
Reverted introducing of new or-patterns in 95c8c65139c10e4de44367fead…
KOLANICH Jul 19, 2021
1bbd85d
Reverted f1f3d5cb844b01b4025a1be94c6f9bde4929f797, which seems to be …
KOLANICH Jul 19, 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
17 changes: 11 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
resolver = "2"
#resolver = "2"
members = ["xtask/", "lib/*", "crates/*"]
exclude = ["crates/proc_macro_test/imp"]

Expand Down
2 changes: 1 addition & 1 deletion crates/hir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ doctest = false
log = "0.4.8"
rustc-hash = "1.1.0"
either = "1.5.3"
arrayvec = "0.7"
arrayvec = "0.5.1"
itertools = "0.10.0"
smallvec = "1.4.0"
once_cell = "1"
Expand Down
2 changes: 1 addition & 1 deletion crates/hir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2669,7 +2669,7 @@ pub enum ScopeDef {
}

impl ScopeDef {
pub fn all_items(def: PerNs) -> ArrayVec<Self, 3> {
pub fn all_items(def: PerNs) -> ArrayVec<[Self; 3]> {
let mut items = ArrayVec::new();

match (def.take_types(), def.take_values()) {
Expand Down
17 changes: 8 additions & 9 deletions crates/hir/src/semantics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,12 @@ impl PathResolution {
PathResolution::Def(ModuleDef::BuiltinType(builtin)) => {
Some(TypeNs::BuiltinType((*builtin).into()))
}
PathResolution::Def(
ModuleDef::Const(_)
| ModuleDef::Variant(_)
| ModuleDef::Function(_)
| ModuleDef::Module(_)
| ModuleDef::Static(_)
| ModuleDef::Trait(_),
) => None,
PathResolution::Def(ModuleDef::Const(_))
| PathResolution::Def(ModuleDef::Variant(_))
| PathResolution::Def(ModuleDef::Function(_))
| PathResolution::Def(ModuleDef::Module(_))
| PathResolution::Def(ModuleDef::Static(_))
| PathResolution::Def(ModuleDef::Trait(_)) => None,
PathResolution::Def(ModuleDef::TypeAlias(alias)) => {
Some(TypeNs::TypeAliasId((*alias).into()))
}
Expand All @@ -67,7 +65,8 @@ impl PathResolution {
}
PathResolution::TypeParam(param) => Some(TypeNs::GenericParam((*param).into())),
PathResolution::SelfType(impl_def) => Some(TypeNs::SelfType((*impl_def).into())),
PathResolution::AssocItem(AssocItem::Const(_) | AssocItem::Function(_)) => None,
PathResolution::AssocItem(AssocItem::Const(_))
| PathResolution::AssocItem(AssocItem::Function(_)) => None,
PathResolution::AssocItem(AssocItem::TypeAlias(alias)) => {
Some(TypeNs::TypeAliasId((*alias).into()))
}
Expand Down
18 changes: 10 additions & 8 deletions crates/hir_def/src/item_tree/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl<'a> Printer<'a> {
fn blank(&mut self) {
let mut iter = self.buf.chars().rev().fuse();
match (iter.next(), iter.next()) {
(Some('\n'), Some('\n') | None) | (None, None) => {}
(Some('\n'), Some('\n')) | (Some('\n'), None) | (None, None) => {}
(Some('\n'), Some(_)) => {
self.buf.push('\n');
}
Expand All @@ -79,7 +79,7 @@ impl<'a> Printer<'a> {

fn whitespace(&mut self) {
match self.buf.chars().next_back() {
None | Some('\n' | ' ') => {}
None | Some('\n') | Some(' ') => {}
_ => self.buf.push(' '),
}
}
Expand Down Expand Up @@ -721,18 +721,20 @@ impl<'a> Printer<'a> {

impl<'a> Write for Printer<'a> {
fn write_str(&mut self, s: &str) -> fmt::Result {
for line in s.split_inclusive('\n') {
match self.buf.chars().last() {
Some('\n') | None => {}
_ => self.buf.push('\n'),
}

for line in s.split('\n') {
if self.needs_indent {
match self.buf.chars().last() {
Some('\n') | None => {}
_ => self.buf.push('\n'),
}
self.buf.push('\n');
self.buf.push_str(&" ".repeat(self.indent_level));
self.needs_indent = false;
}

self.buf.push_str(line);
self.needs_indent = line.ends_with('\n');
self.needs_indent = true;
}

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion crates/hir_def/src/nameres/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,7 @@ impl DefCollector<'_> {
for directive in &self.unresolved_imports {
if let ImportSource::Import { id: import, use_tree } = &directive.import.source {
match (directive.import.path.segments().first(), &directive.import.path.kind) {
(Some(krate), PathKind::Plain | PathKind::Abs) => {
(Some(krate), PathKind::Plain) | (Some(krate), PathKind::Abs) => {
if diagnosed_extern_crates.contains(krate) {
continue;
}
Expand Down
3 changes: 2 additions & 1 deletion crates/hir_def/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,8 @@ fn to_value_ns(per_ns: PerNs) -> Option<ValueNs> {
ModuleDefId::ConstId(it) => ValueNs::ConstId(it),
ModuleDefId::StaticId(it) => ValueNs::StaticId(it),

ModuleDefId::AdtId(AdtId::EnumId(_) | AdtId::UnionId(_))
ModuleDefId::AdtId(AdtId::EnumId(_))
| ModuleDefId::AdtId(AdtId::UnionId(_))
| ModuleDefId::TraitId(_)
| ModuleDefId::TypeAliasId(_)
| ModuleDefId::BuiltinType(_)
Expand Down
5 changes: 3 additions & 2 deletions crates/hir_def/src/visibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,9 @@ impl Visibility {
/// visible in unrelated modules).
pub(crate) fn max(self, other: Visibility, def_map: &DefMap) -> Option<Visibility> {
match (self, other) {
(Visibility::Module(_) | Visibility::Public, Visibility::Public)
| (Visibility::Public, Visibility::Module(_)) => Some(Visibility::Public),
(Visibility::Module(_), Visibility::Public)
| (Visibility::Public, Visibility::Module(_))
| (Visibility::Public, Visibility::Public) => Some(Visibility::Public),
(Visibility::Module(mod_a), Visibility::Module(mod_b)) => {
if mod_a.krate != mod_b.krate {
return None;
Expand Down
9 changes: 4 additions & 5 deletions crates/hir_expand/src/hygiene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,10 @@ impl HygieneInfo {
(&self.macro_arg.1, InFile::new(loc.kind.file_id(), arg_start))
}
mbe::Origin::Def => match (&*self.macro_def, self.def_start) {
(
TokenExpander::MacroDef { def_site_token_map, .. }
| TokenExpander::MacroRules { def_site_token_map, .. },
Some(tt),
) => (def_site_token_map, tt),
(TokenExpander::MacroDef { def_site_token_map, .. }, Some(tt))
| (TokenExpander::MacroRules { def_site_token_map, .. }, Some(tt)) => {
(def_site_token_map, tt)
}
_ => panic!("`Origin::Def` used with non-`macro_rules!` macro"),
},
};
Expand Down
9 changes: 4 additions & 5 deletions crates/hir_expand/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,11 +368,10 @@ impl ExpansionInfo {
let (token_map, tt) = match origin {
mbe::Origin::Call => (&self.macro_arg.1, self.arg.clone()),
mbe::Origin::Def => match (&*self.macro_def, self.def.as_ref()) {
(
db::TokenExpander::MacroRules { def_site_token_map, .. }
| db::TokenExpander::MacroDef { def_site_token_map, .. },
Some(tt),
) => (def_site_token_map, tt.as_ref().map(|tt| tt.syntax().clone())),
(db::TokenExpander::MacroRules { def_site_token_map, .. }, Some(tt))
| (db::TokenExpander::MacroDef { def_site_token_map, .. }, Some(tt)) => {
(def_site_token_map, tt.as_ref().map(|tt| tt.syntax().clone()))
}
_ => panic!("`Origin::Def` used with non-`macro_rules!` macro"),
},
};
Expand Down
2 changes: 1 addition & 1 deletion crates/hir_ty/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ doctest = false
[dependencies]
cov-mark = "2.0.0-pre.1"
itertools = "0.10.0"
arrayvec = "0.7"
arrayvec = "0.5.1"
smallvec = "1.2.0"
ena = "0.14.0"
log = "0.4.8"
Expand Down
3 changes: 2 additions & 1 deletion crates/hir_ty/src/consteval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ impl ConstExt for Const {
// FIXME: support more than just evaluating literals
pub fn eval_usize(expr: &Expr) -> Option<u64> {
match expr {
Expr::Literal(Literal::Uint(v, None | Some(BuiltinUint::Usize))) => (*v).try_into().ok(),
Expr::Literal(Literal::Uint(v, None))
| Expr::Literal(Literal::Uint(v, Some(BuiltinUint::Usize))) => (*v).try_into().ok(),
_ => None,
}
}
Expand Down
9 changes: 6 additions & 3 deletions crates/hir_ty/src/diagnostics/match_check/deconstruct_pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ impl IntRange {
#[inline]
fn is_integral(ty: &Ty) -> bool {
match ty.kind(&Interner) {
TyKind::Scalar(Scalar::Char | Scalar::Int(_) | Scalar::Uint(_) | Scalar::Bool) => true,
TyKind::Scalar(Scalar::Char)
| TyKind::Scalar(Scalar::Int(_))
| TyKind::Scalar(Scalar::Uint(_))
| TyKind::Scalar(Scalar::Bool) => true,
_ => false,
}
}
Expand Down Expand Up @@ -378,7 +381,7 @@ impl Constructor {
// Wildcards cover anything
(_, Wildcard) => true,
// The missing ctors are not covered by anything in the matrix except wildcards.
(Missing | Wildcard, _) => false,
(Missing, _) | (Wildcard, _) => false,

(Single, Single) => true,
(Variant(self_id), Variant(other_id)) => self_id == other_id,
Expand Down Expand Up @@ -520,7 +523,7 @@ impl SplitWildcard {
}
}
TyKind::Scalar(Scalar::Char) => unhandled(),
TyKind::Scalar(Scalar::Int(..) | Scalar::Uint(..)) => unhandled(),
TyKind::Scalar(Scalar::Int(..)) | TyKind::Scalar(Scalar::Uint(..)) => unhandled(),
TyKind::Never if !cx.feature_exhaustive_patterns() && !pcx.is_top_level => {
smallvec![NonExhaustive]
}
Expand Down
9 changes: 7 additions & 2 deletions crates/hir_ty/src/infer/coerce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ impl CoerceMany {
// pointers to have a chance at getting a match. See
// https://github.com/rust-lang/rust/blob/7b805396bf46dce972692a6846ce2ad8481c5f85/src/librustc_typeck/check/coercion.rs#L877-L916
let sig = match (self.expected_ty.kind(&Interner), expr_ty.kind(&Interner)) {
(TyKind::FnDef(..) | TyKind::Closure(..), TyKind::FnDef(..) | TyKind::Closure(..)) => {
(TyKind::FnDef(..), TyKind::FnDef(..)) |
(TyKind::FnDef(..), TyKind::Closure(..)) |
(TyKind::Closure(..), TyKind::FnDef(..)) |
(TyKind::Closure(..), TyKind::Closure(..))
=> {
// FIXME: we're ignoring safety here. To be more correct, if we have one FnDef and one Closure,
// we should be coercing the closure to a fn pointer of the safety of the FnDef
cov_mark::hit!(coerce_fn_reification);
Expand Down Expand Up @@ -611,7 +615,8 @@ fn safe_to_unsafe_fn_ty(fn_ty: FnPointer) -> FnPointer {

fn coerce_mutabilities(from: Mutability, to: Mutability) -> Result<(), TypeError> {
match (from, to) {
(Mutability::Mut, Mutability::Mut | Mutability::Not)
(Mutability::Mut, Mutability::Mut)
| (Mutability::Mut, Mutability::Not)
| (Mutability::Not, Mutability::Not) => Ok(()),
(Mutability::Not, Mutability::Mut) => Err(TypeError),
}
Expand Down
16 changes: 9 additions & 7 deletions crates/hir_ty/src/infer/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -623,11 +623,11 @@ impl<'a> InferenceContext<'a> {
UnaryOp::Neg => {
match inner_ty.kind(&Interner) {
// Fast path for builtins
TyKind::Scalar(Scalar::Int(_) | Scalar::Uint(_) | Scalar::Float(_))
| TyKind::InferenceVar(
_,
TyVariableKind::Integer | TyVariableKind::Float,
) => inner_ty,
TyKind::Scalar(Scalar::Int(_))
| TyKind::Scalar(Scalar::Uint(_))
| TyKind::Scalar(Scalar::Float(_))
| TyKind::InferenceVar(_, TyVariableKind::Integer)
| TyKind::InferenceVar(_, TyVariableKind::Float) => inner_ty,
// Otherwise we resolve via the std::ops::Neg trait
_ => self
.resolve_associated_type(inner_ty, self.resolve_ops_neg_output()),
Expand All @@ -636,7 +636,9 @@ impl<'a> InferenceContext<'a> {
UnaryOp::Not => {
match inner_ty.kind(&Interner) {
// Fast path for builtins
TyKind::Scalar(Scalar::Bool | Scalar::Int(_) | Scalar::Uint(_))
TyKind::Scalar(Scalar::Bool)
| TyKind::Scalar(Scalar::Int(_))
| TyKind::Scalar(Scalar::Uint(_))
| TyKind::InferenceVar(_, TyVariableKind::Integer) => inner_ty,
// Otherwise we resolve via the std::ops::Not trait
_ => self
Expand Down Expand Up @@ -763,7 +765,7 @@ impl<'a> InferenceContext<'a> {
Expr::Array(array) => {
let elem_ty =
match expected.to_option(&mut self.table).as_ref().map(|t| t.kind(&Interner)) {
Some(TyKind::Array(st, _) | TyKind::Slice(st)) => st.clone(),
Some(TyKind::Array(st, _)) | Some(TyKind::Slice(st)) => st.clone(),
_ => self.table.new_type_var(),
};
let mut coerce = CoerceMany::new(elem_ty.clone());
Expand Down
9 changes: 4 additions & 5 deletions crates/hir_ty/src/infer/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,10 @@ fn is_non_ref_pat(body: &hir_def::body::Body, pat: PatId) -> bool {
Expr::Literal(Literal::String(..)) => false,
_ => true,
},
Pat::Bind {
mode: BindingAnnotation::Mutable | BindingAnnotation::Unannotated,
subpat: Some(subpat),
..
} => is_non_ref_pat(body, *subpat),
Pat::Bind { mode: BindingAnnotation::Mutable, subpat: Some(subpat), .. }
| Pat::Bind { mode: BindingAnnotation::Unannotated, subpat: Some(subpat), .. } => {
is_non_ref_pat(body, *subpat)
}
Pat::Wild | Pat::Bind { .. } | Pat::Ref { .. } | Pat::Box { .. } | Pat::Missing => false,
}
}
4 changes: 2 additions & 2 deletions crates/hir_ty/src/method_resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,12 +309,12 @@ pub fn def_crates(
db: &dyn HirDatabase,
ty: &Ty,
cur_crate: CrateId,
) -> Option<ArrayVec<CrateId, 2>> {
) -> Option<ArrayVec<[CrateId; 2]>> {
// Types like slice can have inherent impls in several crates, (core and alloc).
// The corresponding impls are marked with lang items, so we can use them to find the required crates.
macro_rules! lang_item_crate {
($($name:expr),+ $(,)?) => {{
let mut v = ArrayVec::<LangItemTarget, 2>::new();
let mut v = ArrayVec::<[LangItemTarget; 2]>::new();
$(
v.extend(db.lang_item(cur_crate, $name.into()));
)+
Expand Down
Loading