Friendly Ferris

Developing kind compiler errors

 

 

 

 

 

 


							error[E0631]: type mismatch in closure arguments
							  --> $DIR/expect-fn-supply-fn.rs:46:5
							   |
							LL |     foo(
							   |     ^^^ expected signature of `fn(for<'r> fn(&'r u32), &i32) -> _`
							LL |         |x: Foo<'_>, y| {
							   |         --------------- found signature of `for<'r> fn(fn(&'r u32), _) -> _`
							   |
							note: required by `foo`
							  --> $DIR/expect-fn-supply-fn.rs:6:1
							   |
							LL | / fn foo(_: F)
							LL | |     where F: FnOnce(fn(&u32), &i32)
							LL | | {
							LL | | }
							   | |_^
								

							error[E0631]: type mismatch in closure arguments
							  --> $DIR/expect-fn-supply-fn.rs:46:5
							   |
							LL |     foo(
							   |     ^^^ expected signature of `fn(for<'r> fn(&'r u32), &i32) -> _`
							LL |         |x: Foo<'_>, y| {
							   |         --------------- found signature of `for<'r> fn(fn(&'r u32), _) -> _`
							   |
							note: required by `foo`
							  --> $DIR/expect-fn-supply-fn.rs:6:1
							   |
							LL | / fn foo(_: F)
							LL | |     where F: FnOnce(fn(&u32), &i32)
							LL | | {
							LL | | }
							   | |_^
											

							error[E0631]: type mismatch in closure arguments
							  --> $DIR/expect-fn-supply-fn.rs:46:5
							   |
							LL |     foo(
							   |     ^^^ expected signature of `fn(for<'r> fn(&'r u32), &i32) -> _`
							LL |         |x: Foo<'_>, y| {
							   |         --------------- found signature of `for<'r> fn(fn(&'r u32), _) -> _`
							   |
							note: required by `foo`
							  --> $DIR/expect-fn-supply-fn.rs:6:1
							   |
							LL | / fn foo(_: F)
							LL | |     where F: FnOnce(fn(&u32), &i32)
							LL | | {
							LL | | }
							   | |_^
											

							error[E0631]: type mismatch in closure arguments
							  --> $DIR/expect-fn-supply-fn.rs:46:5
							   |
							LL |     foo(
							   |     ^^^ expected signature of `fn(for<'r> fn(&'r u32), &i32) -> _`
							LL |         |x: Foo<'_>, y| {
							   |         --------------- found signature of `for<'r> fn(fn(&'r u32), _) -> _`
							   |
							note: required by `foo`
							  --> $DIR/expect-fn-supply-fn.rs:6:1
							   |
							LL | / fn foo(_: F)
							LL | |     where F: FnOnce(fn(&u32), &i32)
							LL | | {
							LL | | }
							   | |_^
											

							error[E0631]: type mismatch in closure arguments
							  --> $DIR/expect-fn-supply-fn.rs:46:5
							
| LL | foo( | ^^^ expected signature of `fn(for<'r> fn(&'r u32), &i32) -> _` LL | |x: Foo<'_>, y| { | --------------- found signature of `for<'r> fn(fn(&'r u32), _) -> _` |
note: required by `foo` --> $DIR/expect-fn-supply-fn.rs:6:1 | LL | / fn foo(_: F) LL | | where F: FnOnce(fn(&u32), &i32) LL | | { LL | | } | |_^

							error[E0631]: type mismatch in closure arguments
							  --> $DIR/expect-fn-supply-fn.rs:46:5
							   |
							LL |     foo(
							   |     ^^^ expected signature of `fn(for<'r> fn(&'r u32), &i32) -> _`
							LL |         |x: Foo<'_>, y| {
							   |         --------------- found signature of `for<'r> fn(fn(&'r u32), _) -> _`
							   |
							note: required by `foo`
							  --> $DIR/expect-fn-supply-fn.rs:6:1
							   |
							LL | / fn foo(_: F)
							LL | |     where F: FnOnce(fn(&u32), &i32)
							LL | | {
							LL | | }
							   | |_^
											

							error[E0631]: type mismatch in closure arguments
							  --> $DIR/expect-fn-supply-fn.rs:46:5
							   |
							LL |     foo(
							   |     ^^^ expected signature of `fn(for<'r> fn(&'r u32), &i32) -> _`
							LL |         |x: Foo<'_>, y| {
							   |         --------------- found signature of `for<'r> fn(fn(&'r u32), _) -> _`
							   |
							note: required by `foo`
							  --> $DIR/expect-fn-supply-fn.rs:6:1
							   |
							LL | / fn foo(_: F)
							LL | |     where F: FnOnce(fn(&u32), &i32)
							LL | | {
							LL | | }
							   | |_^
											

							error[E0631]: type mismatch in closure arguments
							  --> $DIR/expect-fn-supply-fn.rs:46:5
							   |
							LL |     foo(
							   |     ^^^ expected signature of `fn(for<'r> fn(&'r u32), &i32) -> _`
							LL |         |x: Foo<'_>, y| {
							   |         --------------- found signature of `for<'r> fn(fn(&'r u32), _) -> _`
							   |
							
note: required by `foo` --> $DIR/expect-fn-supply-fn.rs:6:1 | LL | / fn foo(_: F) LL | | where F: FnOnce(fn(&u32), &i32) LL | | { LL | | } | |_^

 


						fn main() {
						    let x = 3;
						    foo(x);
						}
					

Lexer


						fn main() {
						    let x = 3;
						    foo(x);
						}
					

Lexer


						fn main() {
						    let x = 3;
						    foo(x);
						}
					

Lexer


						fn main() {
						    let x = 3;
						    foo(x);
						}
					

Lexer


						fn main() {
						    let x = 3;
						    foo(x);
						}
					

Lexer


						fn main() {
						    let x = 3;
						    foo(x);
						}
					

Lexer


						fn main() {
						    let x = 3;
						    foo(x);
						}
					

Lexer


						fn main() {
						    let x = 3;
						    foo(x);
						}
					

Lexer


						fn main() {
						    let x = 3;
						    foo(x);
						}
					

Lexer


						fn main() {
						    let x = 3;
						    foo(x);
						}
					

Lexer


						fn main() {
						    let x = 3;
						    foo(x);
						}
					

Lexer


						fn main() {
						    let x = 3;
						    foo(x);
						}
					

Lexer


						fn main() {
						    let x = 3;
						    foo(x);
						}
					

Lexer


						fn main() {
						    let x = 3;
						    foo(x);
						}
					

Lexer


						fn main() {
						    let x = 3;
						    foo(x);
						}
					

Lexer


						fn main() {
						    let x = 3;
						    foo(x);
						}
					

Lexer


						fn main() {
						    let x = 3;
						    foo(x);
						}
					

Lexer


						fn main() {
						    let x = 3;
						    foo(x);
						}
					

						fn main() {
						    let x = 3;
						    foo(x);
						}
					

						token_tree_stream = Base(
							Keyword(fn),
							Ident(main),
							Delimited(Paren, []),
							Delimited(Brace, [
								Keyword(let),
								Ident(x),
								Token(=),
								Lit(3),
								Token(;),
								Ident(foo),
								Delimited(Paren, [Ident(x)]),
								Token(;),
							]);
					

Parser


						fn main() {
						    let x = 3;
						    foo(x);
						}
					

					/// An expression
					#[derive(Clone, RustcEncodable, RustcDecodable)]
					pub struct Expr {
						pub id: NodeId,
						pub node: ExprKind,
						pub span: Span,
						pub attrs: ThinVec,
					}
					
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum ExprKind {
    Box(P<Expr>),
    Array(Vec<P<Expr>>),
    Call(P<Expr>, Vec<P<Expr>>),
    MethodCall(PathSegment, Vec<P<Expr>>),
    Tup(Vec<P<Expr>>),
    Binary(BinOp, P<Expr>, P<Expr>),
    Unary(UnOp, P<Expr>),
    Lit(Lit),
    Cast(P<Expr>, P<Ty>),
    Type(P<Expr>, P<Ty>),
    If(P<Expr>, P<Block>, Option<P<Expr>>),
    IfLet(Vec<P<Pat>>, P<Expr>, P<Block>, Option<P<Expr>>),
    While(P<Expr>, P<Block>, Option<Label>),
    WhileLet(Vec<P<Pat>>, P<Expr>, P<Block>, Option<Label>),
    ForLoop(P<Pat>, P<Expr>, P<Block>, Option<Label>),
    Loop(P<Block>, Option<Label>),
    Match(P<Expr>, Vec<Arm>),
    Closure(CaptureBy, IsAsync, Movability, P<FnDecl>, P<Expr>, Span),
    Block(P<Block>, Option<Label>),
    Async(CaptureBy, NodeId, P<Block>),
    TryBlock(P<Block>),
    Assign(P<Expr>, P<Expr>),
    AssignOp(BinOp, P<Expr>, P<Expr>),
    Field(P<Expr>, Ident),
    Index(P<Expr>, P<Expr>),
    Range(Option<P<Expr>>, Option<P<Expr>>, RangeLimits),
    Path(Option<QSelf>, Path),
    AddrOf(Mutability, P<Expr>),
    Break(Option<Label>, Option<P<Expr>>),
    Continue(Option<Label>),
    Ret(Option<P<Expr>>),
    InlineAsm(P<InlineAsm>),
    Mac(Mac),
    Struct(Path, Vec<Field>, Option<P<Expr>>),
    Repeat(P<Expr>, AnonConst),
    Paren(P<Expr>),
    Try(P<Expr>),
    Yield(Option<P<Expr>>),
    /* ... */
}
				

Parser


						fn main() {
						    let x = 3; // Lit
						    foo(x);    // Call(Path(None, Path), Path(None, Path))
						}
					

Parser: statement


						fn main() {
						    let x = 3;
						    foo(x);
						}
					

Parser is confused: expression, not a statement


						fn foo() {
						    let x = 3  // <-- !`;`
						}
					

							error: expected one of `.`, `;`, `?`, or an operator, found `}`
							 --> $DIR/file.rs:3:1
							  |
							3 |     let x = 3
							  |              - expected one of `.`, `;`, `?`, or an operator here
							4 | }
							  | ^ unexpected token
						

Parser

Name resolution, macro expansion


						error[E0425]: cannot find function `foo` in this scope
						 --> $DIR/file.rs:4:5
						  |
						4 |     foo(x);
						  |     ^^^ not found in this scope
						

Lowering to HIR


						if let Some(x) = foo {
						    println!("x: {}", x);
						} else {
						    println!("Nada");
						}
					

						match foo {
						    Some(x) => {
						        println!("x: {}", x);
						    }
						    _ => {
						        println!("Nada", x);
						    }
						}
					

Lowering to HIR

rustc file.rs -Z unpretty=hir,identified


						fn main() {
						    let x = 3;
						    foo(x);
						}
					

fn main() ({
   let x /*
           pat hir_id: HirId { owner: DefIndex(0:3), local_id: 2 } hir local_id: 2
           */ =
       (3 /*
           expr hir_id: HirId { owner: DefIndex(0:3), local_id: 3 } hir local_id: 3
           */);
   ((foo /*
        expr hir_id: HirId { owner: DefIndex(0:3), local_id: 7 } hir local_id: 7
        */)((x /*
                expr hir_id: HirId { owner: DefIndex(0:3), local_id: 9 } hir local_id: 9
                */)) /*
       expr hir_id: HirId { owner: DefIndex(0:3), local_id: 10 } hir local_id: 10
       */);
} /*
   block hir_id: HirId { owner: DefIndex(0:3), local_id: 11 } hir local_id: 11
   */ /*
   expr hir_id: HirId { owner: DefIndex(0:3), local_id: 12 } hir local_id: 12
   */) /*
hir_id: HirId { owner: DefIndex(0:3), local_id: 0 } hir local_id: 0 */
					

Type Checking


						error[E0308]: mismatched types
						 --> $DIR/file.rs:4:9
						  |
						4 |     foo(x);
						  |         ^ expected &str, found integer
						  = note: expected type `&str`
						             found type `{integer}`
						

Privacy Checking


						error[E0603]: function `foo` is private
						 --> $DIR/file.rs:4:9
						  |
						4 |     bar::foo(x);
						  |          ^^^
						

Lifetime Analysis


						error[E0597]: `x` does not live long enough
						 --> $DIR/file.rs:4:6
						  |
						4 |     &x
						  |      ^ borrowed value does not live long enough
						5 | }
						  | - borrowed value only lives until here
						note: borrowed value must be valid for the lifetime 'a as defined on the function body at 1:8...
						 --> $DIR/file.rs:1:8
						  |
						1 | fn bar<'a>() -> &'a usize {
						  |        ^^
						

LLVM IL Code generation

LLVM Optimizations

 

 

 

 

 

 

 

Linking


						error: linking with `cc` failed: signal: 4
						
  • Lexer
  • Parser
  • Macro Expansion
  • Name Resolution
  • HIR Lowering
  • Type Checking
  • Privacy Checking
  • Lifetime Analysis
  • LLVM IL Code Generation
  • LLVM Optimizations
  • Linking

                          rustc_driver
                        /      |       \
                      /        |         \
                    /          |           \
                  /            v             \
        rustc_codegen  rustc_borrowck   ...  rustc_metadata
                  \            |            /
                    \          |          /
                      \        |        /
                        \      v      /
                            rustc
                               |
                               v
                            syntax
                            /    \
                          /       \
                   syntax_pos  syntax_ext

Guiding principles

Clear generic errors

Clear generic errors


error[E0308]: mismatched types
 --> file.rs:3:9
  |
3 |     foo(&x);
  |         ^^ expected usize, found u32
  |
  = note: expected type `&usize`
             found type `&u32`

error: aborting due to previous error

Targeted errors for common problems


file.rs:1:1: 3:2 error: not all control paths return a value [E0308]
file.rs:1 pub fn foo() -> usize {
file.rs:2     3;
file.rs:3 }
					

						error[E0308]: mismatched types
						 --> file.rs:1:17
						  |
						1 | pub fn foo() -> usize {
						  |        ---      ^^^^^ expected usize, found ()
						  |        |
						  |        this function's body doesn't return
						2 |     3;
						  |      - help: consider removing this semicolon
						  = note: expected type `usize`
						             found type `()`
					

trait T {
    fn foo<'a, 'b>(&self, a: &'a usize, b: &'b usize) -> &'a usize;
}

struct S;

impl T for S {
    fn foo<'a, 'b>(&self, a: &'a usize, b: &'b usize) -> &'a usize {
        if true {
            a
        } else {
            b
        }
    }
}
					

error[E0312]: lifetime of reference outlives lifetime of borrowed content...
  --> file.rs:12:13
   |
12 |             b
   |             ^
   |
note: ...the reference is valid for the lifetime 'a as defined on the body at 8:67...
  --> file.rs:8:68
   |
8  |       fn foo<'a, 'b>(&self, a: &'a usize, b: &'b usize) -> &'a usize {
   |  ____________________________________________________________________^ starting here...
9  | |         if true {
10 | |             a
11 | |         } else {
12 | |             b
13 | |         }
14 | |     }
   | |_____^ ...ending here
note: ...but the borrowed content is only valid for the lifetime 'b as defined on the body at 8:67
  --> file.rs:8:68
   |
8  |       fn foo<'a, 'b>(&self, a: &'a usize, b: &'b usize) -> &'a usize {
   |  ____________________________________________________________________^ starting here...
9  | |         if true {
10 | |             a
11 | |         } else {
12 | |             b
13 | |         }
14 | |     }
   | |_____^ ...ending here
					

error[E0623]: lifetime mismatch
  --> file.rs:12:13
   |
8  |     fn foo<'a, 'b>(&self, a: &'a usize, b: &'b usize) -> &'a usize {
   |                                            ---------     ---------
   |                                            |
   |                                            this parameter and the return type are declared with different lifetimes...
...
12 |             b
   |             ^ ...but data from `b` is returned here
					

trait T {
    fn foo<'a, 'b>(&self, a: &'a usize, b: &'b usize) -> &'a usize;
}

struct S;

impl T for S {
    fn foo<'a>(&self, a: &'a usize, b: &'a usize) -> &'a usize {
        if true {
            a
        } else {
            b
        }
    }
}
					

error[E0495]: cannot infer an appropriate lifetime for lifetime parameter 'a in generic type due to conflicting requirements
  --> file.rs:8:5
   |
8  |       fn foo<'a, 'b>(&self, a: &'a usize, b: &'b usize) -> &'a usize {
   |  _____^ starting here...
9  | |         if true {
10 | |             a
11 | |         } else {
12 | |             b
13 | |         }
14 | |     }
   | |_____^ ...ending here
note: first, the lifetime cannot outlive the lifetime 'b as defined on the body at 8:63...
  --> file.rs:8:68
   |
8  |       fn foo<'a, 'b>(&self, a: &'a usize, b: &'b usize) -> &'a usize {
   |  ____________________________________________________________________^ starting here...
9  | |         if true {
10 | |             a
11 | |         } else {
12 | |             b
13 | |         }
14 | |     }
   | |_____^ ...ending here
note: ...so that method type is compatible with trait (expected fn(&S, &'a usize, &'b usize) -> &'a usize, found fn(&S, &usize, &usize) -> &usize)
  --> file.rs:8:5
   |
8  |       fn foo<'a, 'b>(&self, a: &'a usize, b: &'b usize) -> &'a usize {
   |  _____^ starting here...
9  | |         if true {
10 | |             a
11 | |         } else {
12 | |             b
13 | |         }
14 | |     }
   | |_____^ ...ending here
note: but, the lifetime must be valid for the lifetime 'a as defined on the body at 8:63...
  --> file.rs:8:68
   |
8  |       fn foo<'a, 'b>(&self, a: &'a usize, b: &'b usize) -> &'a usize {
   |  ____________________________________________________________________^ starting here...
9  | |         if true {
10 | |             a
11 | |         } else {
12 | |             b
13 | |         }
14 | |     }
   | |_____^ ...ending here
note: ...so that method type is compatible with trait (expected fn(&S, &'a usize, &'b usize) -> &'a usize, found fn(&S, &usize, &usize) -> &usize)
  --> file.rs:8:5
   |
8  |       fn foo<'a, 'b>(&self, a: &'a usize, b: &'b usize) -> &'a usize {
   |  _____^ starting here...
9  | |         if true {
10 | |             a
11 | |         } else {
12 | |             b
13 | |         }
14 | |     }
   | |_____^ ...ending here
					

error[E0495]: cannot infer an appropriate lifetime for lifetime parameter 'a in generic type due to conflicting requirements
 --> file.rs:8:5
  |
8 |     fn foo<'a>(&self, a: &'a usize, b: &'a usize) -> &'a usize {
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
note: first, the lifetime cannot outlive the lifetime 'b as defined on the method body at 8:5...
 --> file.rs:8:5
  |
8 |     fn foo<'a>(&self, a: &'a usize, b: &'a usize) -> &'a usize {
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...but the lifetime must also be valid for the lifetime 'a as defined on the method body at 8:12...
 --> file.rs:8:12
  |
8 |     fn foo<'a>(&self, a: &'a usize, b: &'a usize) -> &'a usize {
  |            ^^
  = note: ...so that the method type is compatible with trait:
          expected fn(&S, &'a usize, &'b usize) -> &'a usize
             found fn(&S, &usize, &usize) -> &usize
					

Recovery from error states

Recovery from error states

  • Lexer
  • Parser
  • Macro Expansion
  • Name Resolution
  • HIR Lowering
  • Type Checking
  • Privacy Checking
  • Lifetime Analysis
  • LLVM IL Code Generation
  • LLVM Optimizations
  • Linking
extern "C" fn foo(x: u8, ...) -> u8 { x }
extern "C" fn foo(x: u8, ...) -> u8 { x }

error: only foreign functions are allowed to be variadic
  --> $DIR/invalid-variadic-function.rs:11:26
   |
11 | extern "C" fn foo(x: u8, ...) -> u8 { x }
   |                          ^^^
					

Hiding errors caused by earlier problems

Hiding errors caused by earlier problems

Hiding errors caused by earlier problems

let (a, b, c) = (A::new(), A::new());

Hiding errors caused by earlier problems

let (a, b, c) = (A::new(), A::new());

						error[E0308]: mismatched types
						  --> file.rs:12:9
						   |
						12 | let (a, b, c) = (A::new(), A::new());
						   |     ^^^^^^^^^ expected a tuple with 2 elements, found one with 3 elements
						   = note: expected type `(A, A)`
						              found type `(_, _, _)`

						error[E0277]: the trait bound `T: std::marker::Sized` is not satisfied
						  --> file.rs:12:10
						   |
						12 | let (a, b, c) = (A::new(), A::new());
						   |      ^ the trait `std::marker::Sized` is not implemented for `T`
						   = note: `T` does not have a constant size known at compile-time
						   = note: all local variables must have a statically known size

						error[E0277]: the trait bound `T: std::marker::Sized` is not satisfied
						  --> file.rs:12:13
						   |
						12 | let (a, b, c) = (A::new(), A::new());
						   |         ^ the trait `std::marker::Sized` is not implemented for `T`
						   = note: `T` does not have a constant size known at compile-time
						   = note: all local variables must have a statically known size

						error[E0277]: the trait bound `T: std::marker::Sized` is not satisfied
						  --> file.rs:12:16
						   |
						12 | let (a, b, c) = (A::new(), A::new());
						   |            ^ the trait `std::marker::Sized` is not implemented for `T`
						   = note: `T` does not have a constant size known at compile-time
						   = note: all local variables must have a statically known size

Hiding errors caused by earlier problems

let (a, b, c) = (A::new(), A::new());

						error[E0308]: mismatched types
						  --> file.rs:12:9
						   |
						12 | let (a, b, c) = (A::new(), A::new());
						   |     ^^^^^^^^^ expected a tuple with 2 elements, found one with 3 elements
						   = note: expected type `(A, A)`
						              found type `(_, _, _)`
					
  • Clear generic errors
  • Targetted errors for common problems
  • Recovery from error states
  • Hiding errors caused by earlier problems

The compiler as teacher


						error: crate name using dashes are not valid in `extern crate` statements
						  --> $DIR/bad-crate-name.rs:11:14
						   |
						11 | extern crate krate-name-here;
						   |              ^^^^^^^^^^^^^^^ dash-separated idents are not valid
						help: if the original crate name uses dashes you need to use underscores in the code
						   |
						11 | extern crate krate_name_here;
						   |                   ^    ^
					
Evolution of diagnostics over time

						pub fn main() {
						    let x: u32 = 42;
						    foo(&x);
						}
						
						fn foo<'a>(x: &'a usize) -> &'a usize {
						    println!("{}", x);
						    x
						}
					

file.rs:3:9: 3:11 error: mismatched types:
 expected `&usize`,
    found `&u32`
(expected usize,
    found u32) [E0308]
file.rs:3     foo(&x);
                  ^~
error: aborting due to previous error

file.rs:3:9: 3:11 error: mismatched types:
 expected `&usize`
    found `&u32` [E0308]
file.rs:3     foo(&x);
                  ^~
file.rs:3:9: 3:11 help: run `rustc --explain E0308` to see a detailed explanation
error: aborting due to previous error

file.rs:3:9: 3:11 error: mismatched types [E0308]
file.rs:3 foo(&x);
              ^~
file.rs:3:9: 3:11 help: run `rustc --explain E0308` to see a detailed explanation
file.rs:3:9: 3:11 note: expected type `&usize`
file.rs:3:9: 3:11 note: found type `&u32`

error: aborting due to previous error

error[E0308]: mismatched types
 --> file.rs:3:9
  |
3 |     foo(&x);
  |         ^^ expected usize, found u32

error: aborting due to previous error

error[E0308]: mismatched types
 --> file.rs:3:9
  |
3 |     foo(&x);
  |         ^^ expected usize, found u32
  |
  = note: expected type `&usize`
  = note: found type `&u32`

error: aborting due to previous error

error[E0308]: mismatched types
 --> file.rs:3:9
  |
3 |     foo(&x);
  |         ^^ expected usize, found u32
  |
  = note: expected type `&usize`
  = note:    found type `&u32`

error: aborting due to previous error

error[E0308]: mismatched types
 --> file.rs:3:9
  |
3 |     foo(&x);
  |         ^^ expected usize, found u32
  |
  = note: expected type `&usize`
             found type `&u32`

error: aborting due to previous error

error[E0308]: mismatched types
 --> file.rs:3:9
  |
3 |     foo(&x);
  |         ^^ expected usize, found u32
  |
  = note: expected type `&usize`
             found type `&u32`

error: aborting due to previous error

error[E0308]: mismatched types
 --> file.rs:3:9
  |
3 |     foo(&x);
  |         ^^ expected usize, found u32
  |
  = note: expected type `&usize`
             found type `&u32`

error: aborting due to previous error

github.com/rust-lang/rust

forge.rust-lang.org

github.com/rust-lang/rfcs

internals.rust-lang.org

Mozilla IRC #rust

rust-lang.zulipchat.com

discord.gg/rust-lang

¡Gracias!

@ekuber

@estebank

estebank.github.io/rust