Skip to content
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 src/libcore/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ macro_rules! assert {
#[stable(feature = "rust1", since = "1.0.0")]
macro_rules! assert_eq {
($left:expr , $right:expr) => ({
match (&($left), &($right)) {
match (&$left, &$right) {
(left_val, right_val) => {
if !(*left_val == *right_val) {
panic!("assertion failed: `(left == right)` \
Expand Down
6 changes: 5 additions & 1 deletion src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1260,8 +1260,12 @@ impl<'a> LoweringContext<'a> {
maybe_expr.as_ref().map(|x| self.lower_expr(x)))
}
ExprKind::Paren(ref ex) => {
// merge attributes into the inner expression.
return self.lower_expr(ex).map(|mut ex| {
// include parens in span, but only if it is a super-span.
if e.span.contains(ex.span) {
ex.span = e.span;
}
// merge attributes into the inner expression.
ex.attrs.update(|attrs| {
attrs.prepend(e.attrs.clone())
});
Expand Down
6 changes: 3 additions & 3 deletions src/test/compile-fail/issue-2392.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ impl FuncContainerOuter {
fn run(&self) {
unsafe {
(*self.container).f1(1); //~ ERROR no method named `f1` found
//~^ NOTE use `(*self.container.f1)(...)`
//~^ NOTE use `((*self.container).f1)(...)`
(*self.container).f2(1); //~ ERROR no method named `f2` found
//~^ NOTE use `(*self.container.f2)(...)`
//~^ NOTE use `((*self.container).f2)(...)`
(*self.container).f3(1); //~ ERROR no method named `f3` found
//~^ NOTE use `(*self.container.f3)(...)`
//~^ NOTE use `((*self.container).f3)(...)`
}
}
}
31 changes: 31 additions & 0 deletions src/test/compile-fail/paren-span.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// Be smart about span of parenthesized expression in macro.

macro_rules! paren {
($e:expr) => (($e))
// ^^^^ do not highlight here
}

mod m {
pub struct S {
x: i32
}
pub fn make() -> S {
S { x: 0 }
}
}

fn main() {
let s = m::make();
paren!(s.x); //~ ERROR field `x` of struct `m::S` is private
// ^^^ highlight here
}