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

Update rust version to 1.80 #1805

Merged
merged 9 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .ado/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ schedules:

variables:
CARGO_TERM_COLOR: always
RUST_TOOLCHAIN_VERSION: "1.78"
RUST_TOOLCHAIN_VERSION: "1.80"

resources:
repositories:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/bench-reports.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ env:
CARGO_TERM_COLOR: always
NODE_VERSION: "18.17.1"
PYTHON_VERSION: "3.11"
RUST_TOOLCHAIN_VERSION: "1.78"
RUST_TOOLCHAIN_VERSION: "1.80"
RUST_TOOLCHAIN_COMPONENTS: rustfmt clippy

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ env:
CARGO_TERM_COLOR: always
NODE_VERSION: "18.17.1"
PYTHON_VERSION: "3.11"
RUST_TOOLCHAIN_VERSION: "1.78"
RUST_TOOLCHAIN_VERSION: "1.80"
RUST_TOOLCHAIN_COMPONENTS: rustfmt clippy

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-playground.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:

env:
CARGO_TERM_COLOR: always
RUST_TOOLCHAIN_VERSION: "1.78"
RUST_TOOLCHAIN_VERSION: "1.80"
RUST_TOOLCHAIN_COMPONENTS: rustfmt clippy

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ tokio = { version = "1.35", features = ["macros", "rt"] }

[workspace.lints.clippy]
mod_module_files = "warn"
pedantic = "warn"
pedantic = { level = "warn", priority = -1 }
unwrap_used = "warn"
missing_errors_doc = "allow"
missing_panics_doc = "allow"
Expand Down
14 changes: 7 additions & 7 deletions compiler/qsc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ impl Display for TyDefKind {
} else {
write!(indent, "Tuple:")?;
indent = set_indentation(indent, 1);
for t in ts.iter() {
for t in &**ts {
write!(indent, "\n{t}")?;
}
}
Expand Down Expand Up @@ -531,7 +531,7 @@ impl Display for CallableBody {
let mut indent = set_indentation(indented(f), 0);
write!(indent, "Specializations:")?;
indent = set_indentation(indent, 1);
for spec in specs.iter() {
for spec in &**specs {
write!(indent, "\n{spec}")?;
}
}
Expand Down Expand Up @@ -697,7 +697,7 @@ impl Display for TyKind {
indent = indent.with_format(Format::Uniform {
indentation: " ",
});
for t in ts.iter() {
for t in &**ts {
write!(indent, "\n{t}")?;
}
}
Expand Down Expand Up @@ -1309,7 +1309,7 @@ impl Display for PatKind {
} else {
write!(indent, "Tuple:")?;
indent = set_indentation(indent, 1);
for p in ps.iter() {
for p in &**ps {
write!(indent, "\n{p}")?;
}
}
Expand Down Expand Up @@ -1380,7 +1380,7 @@ impl Display for QubitInitKind {
} else {
write!(indent, "Tuple:")?;
indent = set_indentation(indent, 1);
for qi in qis.iter() {
for qi in &**qis {
write!(indent, "\n{qi}")?;
}
}
Expand Down Expand Up @@ -1512,7 +1512,7 @@ impl Display for Idents {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
let mut buf = Vec::with_capacity(self.0.len());

for ident in self.0.iter() {
for ident in &*self.0 {
buf.push(format!("{ident}"));
}
if buf.len() > 1 {
Expand Down Expand Up @@ -1595,7 +1595,7 @@ impl Idents {
return self.0[0].name.clone();
}
let mut buf = String::new();
for ident in self.0.iter() {
for ident in &*self.0 {
if !buf.is_empty() {
buf.push('.');
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/qsc_ast/src/mut_visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ pub fn walk_item(vis: &mut impl MutVisitor, item: &mut Item) {
ItemKind::Struct(decl) => vis.visit_struct_decl(decl),
ItemKind::ImportOrExport(export) => {
vis.visit_span(&mut export.span);
for item in export.items.iter_mut() {
for item in &mut *export.items {
vis.visit_path(&mut item.path);
if let Some(ref mut alias) = item.alias {
vis.visit_ident(alias);
Expand Down Expand Up @@ -389,7 +389,7 @@ pub fn walk_ident(vis: &mut impl MutVisitor, ident: &mut Ident) {
}

pub fn walk_idents(vis: &mut impl MutVisitor, ident: &mut crate::ast::Idents) {
for ref mut ident in ident.0.iter_mut() {
for ref mut ident in &mut *ident.0 {
vis.visit_ident(ident);
}
}
2 changes: 1 addition & 1 deletion compiler/qsc_ast/src/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub fn walk_item<'a>(vis: &mut impl Visitor<'a>, item: &'a Item) {
}
ItemKind::Struct(decl) => vis.visit_struct_decl(decl),
ItemKind::ImportOrExport(decl) => {
for item in decl.items.iter() {
for item in &*decl.items {
vis.visit_path(&item.path);
if let Some(ref alias) = item.alias {
vis.visit_ident(alias);
Expand Down
10 changes: 5 additions & 5 deletions compiler/qsc_codegen/src/qsharp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl<W: Write> Visitor<'_> for QSharpGen<W> {
fn visit_ty_def(&mut self, def: &'_ TyDef) {
match &*def.kind {
TyDefKind::Field(name, ty) => {
for n in name {
if let Some(n) = name {
self.visit_ident(n);
self.write(": ");
}
Expand Down Expand Up @@ -479,7 +479,7 @@ impl<W: Write> Visitor<'_> for QSharpGen<W> {
self.visit_expr(cond);
self.write(" ");
self.visit_block(body);
for expr in otherwise {
if let Some(expr) = otherwise {
if matches!(*expr.kind, ExprKind::If(..)) {
// visiting expr as if writes 'if' to make 'elif'
self.write(" el");
Expand Down Expand Up @@ -610,7 +610,7 @@ impl<W: Write> Visitor<'_> for QSharpGen<W> {
self.visit_block(body);
self.write("until ");
self.visit_expr(until);
for fixup in fixup {
if let Some(fixup) = fixup {
self.write(" fixup ");
self.visit_block(fixup);
}
Expand Down Expand Up @@ -709,14 +709,14 @@ impl<W: Write> Visitor<'_> for QSharpGen<W> {
PatKind::Bind(name, ty) => {
self.visit_ident(name);

for t in ty {
if let Some(t) = ty {
self.write(": ");
self.visit_ty(t);
}
}
PatKind::Discard(ty) => {
self.write("_");
for t in ty {
if let Some(t) = ty {
self.write(": ");
self.visit_ty(t);
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/qsc_doc_gen/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ fn ast_callable_functors(callable: &ast::CallableDecl) -> ty::FunctorSetValue {
});

if let ast::CallableBody::Specs(specs) = callable.body.as_ref() {
for spec in specs.iter() {
for spec in &**specs {
let spec_functors = match spec.spec {
ast::Spec::Body => ty::FunctorSetValue::Empty,
ast::Spec::Adj => ty::FunctorSetValue::Adj,
Expand Down Expand Up @@ -678,7 +678,7 @@ fn as_struct(ty_def: &ast::TyDef) -> Option<Vec<ast::FieldDef>> {
ast::TyDefKind::Paren(inner) => as_struct(inner),
ast::TyDefKind::Tuple(fields) => {
let mut converted_fields = Vec::new();
for field in fields.iter() {
for field in &**fields {
let field = remove_parens(field);
match field.kind.as_ref() {
ast::TyDefKind::Field(Some(name), field_ty) => {
Expand Down
2 changes: 1 addition & 1 deletion compiler/qsc_frontend/src/incremental.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ impl Compiler {
let offset = sources.push(source_name.into(), source_contents.into());

let mut offsetter = Offsetter(offset);
for node in package.nodes.iter_mut() {
for node in &mut *package.nodes {
match node {
ast::TopLevelNode::Namespace(ns) => offsetter.visit_namespace(ns),
ast::TopLevelNode::Stmt(stmt) => offsetter.visit_stmt(stmt),
Expand Down
2 changes: 1 addition & 1 deletion compiler/qsc_frontend/src/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ impl With<'_> {
if item.is_import() {
return None;
}
for item in item.items.iter() {
for item in &*item.items {
let Some((id, alias)) = resolve_id(item.name().id) else {
continue;
};
Expand Down
8 changes: 5 additions & 3 deletions compiler/qsc_frontend/src/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1674,7 +1674,7 @@ fn bind_global_item(
if decl.is_import() {
Ok(())
} else {
for decl_item in decl.items.iter() {
for decl_item in &*decl.items {
// if the item is a namespace, bind it here as an item
let Some(ns) = scope
.namespaces
Expand Down Expand Up @@ -1832,6 +1832,7 @@ fn decl_is_intrinsic(decl: &CallableDecl) -> bool {
/// - Next, we check open statements for a non-prelude open.
/// - Then, we check the prelude.
/// - Lastly, we check the global namespace.
///
/// In the example `Foo.Bar.Baz()` -- the `provided_namespace_name` would be
///`Foo.Bar` and the `provided_symbol_name` would be `Baz`.
///
Expand Down Expand Up @@ -1960,6 +1961,7 @@ fn check_all_scopes<'a>(
/// 1. if any locally declared symbols match `provided_symbol_name`
/// 2. if any aliases in this scope match the provided namespace, and if they contain `provided_symbol_name`
/// 3. if any opens in this scope contain the `provided_symbol_name`
///
/// It follows the Q# shadowing rules:
/// - Local variables shadow everything. They are the first priority.
/// - Next, we check open statements for an explicit open.
Expand Down Expand Up @@ -2046,8 +2048,8 @@ fn check_scoped_resolutions(
/// * `globals` - The global scope to resolve the name against.
/// * `provided_symbol_name` - The symbol name that is ambiguous.
/// * `candidates` - A map of possible resolutions for the symbol, each associated with the `Open`
/// statement that brought it into scope. Note that only the first two opens in
/// the candidates are actually used in the error message.
/// statement that brought it into scope. Note that only the first two opens in
/// the candidates are actually used in the error message.
fn ambiguous_symbol_error(
globals: &GlobalScope,
provided_symbol_name: &Ident,
Expand Down
2 changes: 1 addition & 1 deletion compiler/qsc_frontend/src/typeck/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl Checker {
},
),
ast::CallableBody::Specs(specs) => {
for spec in specs.iter() {
for spec in &**specs {
if let ast::SpecBody::Impl(input, block) = &spec.body {
self.check_spec(
names,
Expand Down
8 changes: 4 additions & 4 deletions compiler/qsc_frontend/src/typeck/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub(crate) fn ty_from_ast(names: &Names, ty: &ast::Ty) -> (Ty, Vec<MissingTyErro
TyKind::Tuple(items) => {
let mut tys = Vec::new();
let mut errors = Vec::new();
for item in items.iter() {
for item in &**items {
let (item_ty, item_errors) = ty_from_ast(names, item);
tys.push(item_ty);
errors.extend(item_errors);
Expand Down Expand Up @@ -132,7 +132,7 @@ fn ast_ty_def_base(names: &Names, def: &TyDef) -> (Ty, Vec<MissingTyError>) {
TyDefKind::Tuple(items) => {
let mut tys = Vec::new();
let mut errors = Vec::new();
for item in items.iter() {
for item in &**items {
let (item_ty, item_errors) = ast_ty_def_base(names, item);
tys.push(item_ty);
errors.extend(item_errors);
Expand Down Expand Up @@ -285,7 +285,7 @@ pub(crate) fn ast_pat_ty(names: &Names, pat: &Pat) -> (Ty, Vec<MissingTyError>)
PatKind::Tuple(items) => {
let mut tys = Vec::new();
let mut errors = Vec::new();
for item in items.iter() {
for item in &**items {
let (item_ty, item_errors) = ast_pat_ty(names, item);
tys.push(item_ty);
errors.extend(item_errors);
Expand All @@ -303,7 +303,7 @@ pub(crate) fn ast_callable_functors(callable: &CallableDecl) -> FunctorSetValue
.map_or(FunctorSetValue::Empty, |f| eval_functor_expr(f.as_ref()));

if let CallableBody::Specs(specs) = callable.body.as_ref() {
for spec in specs.iter() {
for spec in &**specs {
let spec_functors = match spec.spec {
Spec::Body => FunctorSetValue::Empty,
Spec::Adj => FunctorSetValue::Adj,
Expand Down
10 changes: 5 additions & 5 deletions compiler/qsc_frontend/src/typeck/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ impl<'a> Context<'a> {
}
ExprKind::Interpolate(components) => {
let mut diverges = false;
for component in components.iter() {
for component in &**components {
match component {
StringComponent::Expr(expr) => {
let span = expr.span;
Expand Down Expand Up @@ -465,7 +465,7 @@ impl<'a> Context<'a> {
self.inferrer.eq(copy.span, container.clone(), copy_ty.ty);
}

for field in fields.iter() {
for field in &**fields {
self.infer_field_assign(
field.span,
container.clone(),
Expand Down Expand Up @@ -499,7 +499,7 @@ impl<'a> Context<'a> {
ExprKind::Tuple(items) => {
let mut tys = Vec::new();
let mut diverges = false;
for item in items.iter() {
for item in &**items {
let item = self.infer_expr(item);
diverges = diverges || item.diverges;
tys.push(item.ty);
Expand Down Expand Up @@ -626,7 +626,7 @@ impl<'a> Context<'a> {
ExprKind::Tuple(items) => {
let mut tys = Vec::new();
let mut diverges = false;
for item in items.iter() {
for item in &**items {
let item = self.infer_hole_tuple(hole, given, tuple, to_ty, item);
diverges = diverges || item.diverges;
tys.push(item.ty);
Expand Down Expand Up @@ -847,7 +847,7 @@ impl<'a> Context<'a> {
QubitInitKind::Tuple(items) => {
let mut diverges = false;
let mut tys = Vec::new();
for item in items.iter() {
for item in &**items {
let item = self.infer_qubit_init(item);
diverges = diverges || item.diverges;
tys.push(item.ty);
Expand Down
4 changes: 2 additions & 2 deletions compiler/qsc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,7 @@ impl Display for Idents {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
let mut buf = Vec::with_capacity(self.0.len());

for ident in self.0.iter() {
for ident in &*self.0 {
buf.push(format!("{ident}"));
}
if buf.len() > 1 {
Expand Down Expand Up @@ -1313,7 +1313,7 @@ impl Idents {
return self.0[0].name.clone();
}
let mut buf = String::new();
for ident in self.0.iter() {
for ident in &*self.0 {
if !buf.is_empty() {
buf.push('.');
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/qsc_hir/src/mut_visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ pub fn walk_ident(vis: &mut impl MutVisitor, ident: &mut Ident) {
}

pub fn walk_idents(vis: &mut impl MutVisitor, ident: &mut crate::hir::Idents) {
for ref mut ident in ident.0.iter_mut() {
for ref mut ident in &mut *ident.0 {
vis.visit_ident(ident);
}
}
2 changes: 1 addition & 1 deletion compiler/qsc_linter/src/linter/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub fn run_ast_lints(package: &qsc_ast::ast::Package, config: Option<&[LintConfi

let mut lints = CombinedAstLints::from_config(config);

for node in package.nodes.iter() {
for node in &*package.nodes {
match node {
TopLevelNode::Namespace(namespace) => lints.visit_namespace(namespace),
TopLevelNode::Stmt(stmt) => lints.visit_stmt(stmt),
Expand Down
2 changes: 1 addition & 1 deletion compiler/qsc_linter/src/lints/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl AstLintPass for RedundantSemicolons {
// Some(_): one or more redundant semicolons
let mut seq: Option<Span> = None;

for stmt in block.stmts.iter() {
for stmt in &*block.stmts {
match (&*stmt.kind, &mut seq) {
(StmtKind::Empty, None) => seq = Some(stmt.span),
(StmtKind::Empty, Some(span)) => span.hi = stmt.span.hi,
Expand Down
2 changes: 1 addition & 1 deletion compiler/qsc_parse/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ fn try_tydef_as_ty(tydef: &TyDef) -> Option<Ty> {
TyDefKind::Paren(tydef) => try_tydef_as_ty(tydef.as_ref()),
TyDefKind::Tuple(tup) => {
let mut ty_tup = Vec::new();
for tydef in tup.iter() {
for tydef in &**tup {
ty_tup.push(try_tydef_as_ty(tydef)?);
}
Some(Ty {
Expand Down
Loading
Loading