-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Modify compile-fail/E0389 error message WIP #48914
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
Changes from 21 commits
7d590b5
308e30e
f60788b
3f0ce08
bfc9b76
7a266a6
0c7fc04
fdb2f7f
55bd914
50299c6
7745b52
311a8be
6c649fb
1b06fe1
c119206
12d1415
1fb25fb
e6938ee
6686d10
e18a83b
e5a96a4
cbde62c
2ad20e8
c792d1e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment! | |
#![cfg_attr(stage0, feature(underscore_lifetimes))] | ||
#![cfg_attr(stage0, feature(never_type))] | ||
#![feature(inclusive_range_fields)] | ||
#![feature(crate_visibility_modifier)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was this needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, due to the usage here |
||
|
||
extern crate arena; | ||
#[macro_use] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright 2018 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. | ||
|
||
use rustc::mir::{Local, Location}; | ||
use rustc::mir::Mir; | ||
use rustc::mir::visit::PlaceContext; | ||
use rustc::mir::visit::Visitor; | ||
|
||
crate trait FindAssignments { | ||
// Finds all statements that assign directly to local (i.e., X = ...) | ||
// and returns their locations. | ||
fn find_assignments(&self, local: Local) -> Vec<Location>; | ||
} | ||
|
||
impl<'tcx> FindAssignments for Mir<'tcx>{ | ||
fn find_assignments(&self, local: Local) -> Vec<Location>{ | ||
let mut visitor = FindLocalAssignmentVisitor{ needle: local, locations: vec![]}; | ||
visitor.visit_mir(self); | ||
visitor.locations | ||
} | ||
} | ||
|
||
// The Visitor walks the MIR to return the assignment statements corresponding | ||
// to a Local. | ||
struct FindLocalAssignmentVisitor { | ||
needle: Local, | ||
locations: Vec<Location>, | ||
} | ||
|
||
impl<'tcx> Visitor<'tcx> for FindLocalAssignmentVisitor { | ||
fn visit_local(&mut self, | ||
local: &Local, | ||
place_context: PlaceContext<'tcx>, | ||
location: Location) { | ||
if self.needle != *local { | ||
return; | ||
} | ||
|
||
match place_context { | ||
PlaceContext::Store | PlaceContext::Call => { | ||
self.locations.push(location); | ||
} | ||
PlaceContext::AsmOutput | | ||
PlaceContext::Drop | | ||
PlaceContext::Inspect | | ||
PlaceContext::Borrow { .. } | | ||
PlaceContext::Projection(..) | | ||
PlaceContext::Copy | | ||
PlaceContext::Move | | ||
PlaceContext::StorageLive | | ||
PlaceContext::StorageDead | | ||
PlaceContext::Validate => { | ||
// TO-DO | ||
// self.super_local(local) | ||
} | ||
} | ||
} | ||
// TO-DO | ||
// fn super_local() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright 2018 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. | ||
#![feature(nll)] | ||
struct FancyNum { | ||
num: u8, | ||
} | ||
|
||
fn main() { | ||
let mut fancy = FancyNum{ num: 5 }; | ||
let fancy_ref = &(&mut fancy); | ||
fancy_ref.num = 6; //~ ERROR E0594 | ||
println!("{}", fancy_ref.num); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
error[E0594]: cannot assign to data in a `&` reference | ||
--> $DIR/issue-47388.rs:18:5 | ||
| | ||
LL | let fancy_ref = &(&mut fancy); | ||
| ------------- help: consider changing this to be a mutable reference: `&mut` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe either the span or the suggestion text might be incorrect. It should either suggest There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Filed #49859 |
||
LL | fancy_ref.num = 6; //~ ERROR E0594 | ||
| ^^^^^^^^^^^^^^^^^ `fancy_ref` is a `&` reference, so the data it refers to cannot be written | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0594`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A line consisting of only spaces is also considered "trailing whitespaces".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @kennytm :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kennytm can you help out with the fixes for the tidy errors? I've tried certain things but they don't seem to work. One of the errors is also in the previously written code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gaurikholkar The line numbers seems wrong. You could run
tidy
locally byThe lines with trailing whitespaces are:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks you @kennytm . Yeah the line nos were wrong. My local tidy script panics -> logs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gaurikholkar you should just remove the entire
binaryen
folder, it is no longer used.