Skip to content

Commit

Permalink
rebase gone wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomocavalieri committed Dec 16, 2024
1 parent 882af24 commit 3ecd9c9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 29 deletions.
30 changes: 2 additions & 28 deletions compiler-core/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![allow(clippy::unwrap_used, clippy::expect_used)]
use crate::build::{Outcome, Runtime, Target};
use crate::diagnostic::{Diagnostic, ExtraLabel, Label, Location};
use crate::type_::collapse_links;
use crate::type_::error::{
MissingAnnotation, ModuleValueUsageContext, Named, UnknownField, UnknownTypeHint,
UnsafeRecordUpdateReason,
Expand All @@ -22,6 +23,7 @@ use std::env;
use std::fmt::{Debug, Display};
use std::io::Write;
use std::path::PathBuf;
use std::sync::Arc;
use termcolor::Buffer;
use thiserror::Error;
use vec1::Vec1;
Expand Down Expand Up @@ -1880,10 +1882,6 @@ But function expects:
text.push_str("\n\nFound type:\n\n ");
text.push_str(&printer.print_type(given));

if hint.is_some() {
text.push('\n');
}

let (main_message_location, main_message_text, extra_labels) = match situation {
// When the mismatch error comes from a case clause we want to highlight the
// entire branch (pattern included) when reporting the error; in addition,
Expand Down Expand Up @@ -3913,30 +3911,6 @@ fn hint_wrap_value_into_result(expected: &Arc<Type>, given: &Arc<Type>) -> Optio
}
}

fn hint_unwrap_result(
expected: &Arc<Type>,
given: &Arc<Type>,
printer: &mut Printer<'_>,
) -> Option<String> {
// If the got type is `Result(a, _)` and the expected one is
// `a` then we can display the hint.
let wrapped_type = given.result_ok_type()?;
if !wrapped_type.same_as(expected) {
None
} else {
Some(wrap_format!(
"If you want to get a `{}` out of a `{}` you can pattern match on it:
case result {{
Ok(value) -> todo
Error(error) -> todo
}}",
printer.print_type(expected),
printer.print_type(given),
))
}
}

fn hint_numeric_message(alt: &str, type_: &str) -> String {
format!("the {alt} operator can be used with {type_}s\n")
}
Expand Down
15 changes: 14 additions & 1 deletion compiler-core/src/type_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,20 @@ impl Type {
(one @ Type::Named { .. }, Type::Var { type_ }) => {
type_.as_ref().borrow().same_as_other_type(one)
}
(Type::Named { .. }, Type::Named { .. }) => self == other,
(
Type::Named {
package,
module,
name,
..
},
Type::Named {
package: other_package,
module: other_module,
name: other_name,
..
},
) => package == other_package && module == other_module && name == other_name,

(Type::Fn { .. }, Type::Named { .. } | Type::Tuple { .. }) => false,
(one @ Type::Fn { .. }, Type::Var { type_ }) => {
Expand Down

0 comments on commit 3ecd9c9

Please sign in to comment.