8000 Rollup of 7 pull requests by Centril · Pull Request #65587 · rust-lang/rust · GitHub
[go: up one dir, main page]

Skip to content

Rollup of 7 pull requests #65587

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

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
23d3ff1
Fix zero-size uninitialized boxes
SimonSapin Oct 6, 2019
90d0baf
Upgrade GCC to 8.3.0, glibc to 1.17.0 and crosstool-ng to 1.24.0 for …
msizanoen1 Oct 11, 2019
4f97e5d
Remove reference to Ubuntu 15.10 ARM toolchain
msizanoen1 Oct 11, 2019
e2ce082
Revert "Remove reference to Ubuntu 15.10 ARM toolchain"
msizanoen1 Oct 11, 2019
88ea4ff
Add crosstool-ng 1.24.0 unzip dependency
msizanoen1 Oct 12, 2019
e58ad8d
Fix path to crosstool-ng.sh
msizanoen1 Oct 13, 2019
9d5208a
Remove sanitizer runtime crates
tmiasko Oct 6, 2019
c1b5249
Remove sanitizer_runtime attribute
tmiasko Oct 7, 2019
87c3eed
Link sanitizer runtimes instead of injecting crate dependencies
tmiasko Oct 6, 2019
ac3cf6b
Compile main executable with rustc in staticlib test
tmiasko Oct 7, 2019
7864cb4
Enable sanitizer-leak test case
tmiasko Oct 8, 2019
01008e4
Update libc to 0.2.64
mati865 Oct 16, 2019
870ea52
Mirror crosstool-ng on rust-lang-ci-mirrors
msizanoen1 Oct 16, 2019
c2c290e
Document sanitizers in unstable-book
tmiasko Oct 16, 2019
ca1cfda
Uninitialized boxes: check for zero-size allocation based on Layout::…
SimonSapin Oct 16, 2019
dd4d6a9
Verify that sanitizer runtime is not part of staticlib
tmiasko Oct 17, 2019
75f4dac
Add regression test for #65394
ecstatic-morse Oct 17, 2019
22a0856
Enable `drain_filter`
ecstatic-morse Oct 17, 2019
af691de
Suppress validation mismatch ICE in the presence of mut borrows
ecstatic-morse Oct 17, 2019
6de4924
Update emscripten functions declarations
mati865 Oct 17, 2019
1101101
Refer to "associated functions" instead of "static methods"
estebank Oct 18, 2019
d8fca9e
Use `with` in `Symbol` trait methods.
nnethercote Oct 17, 2019
3532863
Change how `Symbol::Debug` works.
nnethercote Oct 17, 2019
f65a492
Point at enclosing function without `self` receiver
estebank Oct 18, 2019
0879f63
Remove `Copy` and `Clone` impls for `LocalInternedString`.
nnethercote Oct 18, 2019
d343ee8
Remove `Hash` impls for `DefPath`, `DisambiguatedDefPathData`, and `D…
nnethercote Oct 18, 2019
865c4bc
review comments: help wording
estebank Oct 18, 2019
bd813bf
review comment: span bug label
estebank Oct 18, 2019
2b76c8b
review comments
estebank Oct 18, 2019
227db40
Uninitialized boxes: add test for zero-size allocations
SimonSapin Oct 16, 2019
fbd078a
Rollup merge of #65174 - SimonSapin:zero-box, r=alexcrichton
Centril Oct 19, 2019
d5a5c32
Rollup merge of #65241 - tmiasko:no-std-san, r=nikomatsakis
Centril Oct 19, 2019
6ebf23e
Rollup merge of #65302 - msizanoen1:fix-armv7-segfault, r=alexcrichton
Centril Oct 19, 2019
0ace8e0
Rollup merge of #65469 - mati865:libc, r=alexcrichton
Centril Oct 19, 2019
6d6681a
Rollup merge of #65485 - ecstatic-morse:const-validation-mismatch-ugl…
Centril Oct 19, 2019
45a5dab
Rollup merge of #65542 - estebank:kill-static-methods, r=Centril
Centril Oct 19, 2019
c21c919
Rollup merge of #65545 - nnethercote:more-symbol-cleanups, r=petroche…
Centril Oct 19, 2019
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
25 changes: 17 additions & 8 deletions src/librustc_resolve/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1013,33 +1013,42 @@ fn h1() -> i32 {
"##,

E0424: r##"
The `self` keyword was used in a static method.
The `self` keyword was used inside of an associated function without a "`self`
receiver" parameter.

Erroneous code example:

```compile_fail,E0424
struct Foo;

impl Foo {
fn bar(self) {}
// `bar` is a method, because it has a receiver parameter.
fn bar(&self) {}

// `foo` is not a method, because it has no receiver parameter.
fn foo() {
self.bar(); // error: `self` is not available in a static method.
self.bar(); // error: `self` value is a keyword only available in
// methods with a `self` parameter
}
}
```

Please check if the method's argument list should have contained `self`,
`&self`, or `&mut self` (in case you didn't want to create a static
method), and add it if so. Example:
The `self` keyword can only be used inside methods, which are associated
functions (functions defined inside of a `trait` or `impl` block) that have a
`self` receiver as its first parameter, like `self`, `&self`, `&mut self` or
`self: &mut Pin<Self>` (this last one is an example of an ["abitrary `self`
type"](https://github.com/rust-lang/rust/issues/44874)).

Check if the associated function's parameter list should have contained a `self`
receiver for it to be a method, and add it if so. Example:

```
struct Foo;

impl Foo {
fn bar(self) {}
fn bar(&self) {}

fn foo(self) {
fn foo(self) { // `foo` is now a method.
self.bar(); // ok!
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/librustc_resolve/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,9 @@ struct LateResolutionVisitor<'a, 'b> {
/// The current self item if inside an ADT (used for better errors).
current_self_item: Option<NodeId>,

/// The current enclosing funciton (used for better errors).
current_function: Option<Span>,

/// A list of labels as of yet unused. Labels will be removed from this map when
/// they are used (in a `break` or `continue` statement)
unused_labels: FxHashMap<NodeId, Span>,
Expand Down Expand Up @@ -415,7 +418,8 @@ impl<'a, 'tcx> Visitor<'tcx> for LateResolutionVisitor<'a, '_> {
}
}
}
fn visit_fn(&mut self, fn_kind: FnKind<'tcx>, declaration: &'tcx FnDecl, _: Span, _: NodeId) {
fn visit_fn(&mut self, fn_kind: FnKind<'tcx>, declaration: &'tcx FnDecl, sp: Span, _: NodeId) {
let previous_value = replace(&mut self.current_function, Some(sp));
debug!("(resolving function) entering function");
let rib_kind = match fn_kind {
FnKind::ItemFn(..) => FnItemRibKind,
Expand All @@ -441,6 +445,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LateResolutionVisitor<'a, '_> {
debug!("(resolving function) leaving function");
})
});
self.current_function = previous_value;
}

fn visit_generics(&mut self, generics: &'tcx Generics) {
Expand Down Expand Up @@ -546,6 +551,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
current_trait_assoc_types: Vec::new(),
current_self_type: None,
current_self_item: None,
current_function: None,
unused_labels: Default::default(),
current_type_ascription: Vec::new(),
}
Expand Down
25 changes: 13 additions & 12 deletions src/librustc_resolve/late/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,10 @@ impl<'a> LateResolutionVisitor<'a, '_> {
if is_self_type(path, ns) {
syntax::diagnostic_used!(E0411);
err.code(DiagnosticId::Error("E0411".into()));
err.span_label(span, format!("`Self` is only available in impls, traits, \
and type definitions"));
err.span_label(
span,
format!("`Self` is only available in impls, traits, and type definitions"),
);
return (err, Vec::new());
}
if is_self_value(path, ns) {
Expand All @@ -125,17 +127,16 @@ impl<'a> LateResolutionVisitor<'a, '_> {
syntax::diagnostic_used!(E0424);
err.code(DiagnosticId::Error("E0424".into()));
err.span_label(span, match source {
PathSource::Pat => {
format!("`self` value is a keyword \
and may not be bound to \
variables or shadowed")
}
_ => {
format!("`self` value is a keyword \
only available in methods \
with `self` parameter")
}
PathSource::Pat => format!(
"`self` value is a keyword and may not be bound to variables or shadowed",
),
_ => format!(
"`self` value is a keyword only available in methods with a `self` parameter",
),
});
if let Some(span) = &self.current_function {
err.span_label(*span, "this function doesn't have a `self` parameter");
}
return (err, Vec::new());
}

Expand Down
22 changes: 9 additions & 13 deletions src/libsyntax_ext/deriving/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,12 @@ fn cs_clone(name: &str,
all_fields = af;
vdata = &variant.data;
}
EnumNonMatchingCollapsed(..) => {
cx.span_bug(trait_span,
&format!("non-matching enum variants in \
`derive({})`",
name))
}
EnumNonMatchingCollapsed(..) => cx.span_bug(trait_span, &format!(
"non-matching enum variants in `derive({})`",
name,
)),
StaticEnum(..) | StaticStruct(..) => {
cx.span_bug(trait_span, &format!("static method in `derive({})`", name))
cx.span_bug(trait_span, &format!("associated function in `derive({})`", name))
}
}

Expand All @@ -191,12 +189,10 @@ fn cs_clone(name: &str,
.map(|field| {
let ident = match field.name {
Some(i) => i,
None => {
cx.span_bug(trait_span,
&format!("unnamed field in normal struct in \
`derive({})`",
name))
}
None => cx.span_bug(trait_span, &format!(
"unnamed field in normal struct in `derive({})`",
name,
)),
};
let call = subcall(cx, field);
cx.field_imm(field.span, ident, call)
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax_ext/deriving/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ fn default_substructure(cx: &mut ExtCtxt<'_>,
// let compilation continue
DummyResult::raw_expr(trait_span, true)
}
_ => cx.span_bug(trait_span, "Non-static method in `derive(Default)`"),
_ => cx.span_bug(trait_span, "method in `derive(Default)`"),
};
}
4 changes: 1 addition & 3 deletions src/libsyntax_ext/deriving/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1055,9 +1055,7 @@ impl<'a> MethodDef<'a> {
})
.collect()
} else {
cx.span_bug(trait_.span,
"no self arguments to non-static method in generic \
`derive`")
cx.span_bug(trait_.span, "no `self` parameter for method in generic `derive`")
};

// body of the inner most destructuring match
Expand Down
14 changes: 10 additions & 4 deletions src/test/ui/error-codes/E0424.stderr
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
error[E0424]: expected value, found module `self`
--> $DIR/E0424.rs:7:9
|
LL | self.bar();
| ^^^^ `self` value is a keyword only available in methods with `self` parameter
LL | / fn foo() {
LL | | self.bar();
| | ^^^^ `self` value is a keyword only available in methods with a `self` parameter
LL | | }
| |_____- this function doesn't have a `self` parameter

error[E0424]: expected unit struct/variant or constant, found module `self`
--> $DIR/E0424.rs:12:9
|
LL | let self = "self";
| ^^^^ `self` value is a keyword and may not be bound to variables or shadowed
LL | / fn main () {
LL | | let self = "self";
| | ^^^^ `self` value is a keyword and may not be bound to variables or shadowed
LL | | }
| |_- this function doesn't have a `self` parameter

error: aborting due to 2 previous errors

Expand Down
18 changes: 14 additions & 4 deletions src/test/ui/resolve/issue-2356.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,14 @@ LL | purr();
error[E0424]: expected value, found module `self`
--> $DIR/issue-2356.rs:65:8
|
LL | if self.whiskers > 3 {
| ^^^^ `self` value is a keyword only available in methods with `self` parameter
LL | / fn meow() {
LL | | if self.whiskers > 3 {
| | ^^^^ `self` value is a keyword only available in methods with a `self` parameter
LL | |
LL | | println!("MEOW");
LL | | }
LL | | }
| |___- this function doesn't have a `self` parameter

error[E0425]: cannot find function `grow_older` in this scope
--> $DIR/issue-2356.rs:72:5
Expand Down Expand Up @@ -97,8 +103,12 @@ LL | purr_louder();
error[E0424]: expected value, found module `self`
--> $DIR/issue-2356.rs:92:5
|
LL | self += 1;
| ^^^^ `self` value is a keyword only available in methods with `self` parameter
LL | / fn main() {
LL | | self += 1;
| | ^^^^ `self` value is a keyword only available in methods with a `self` parameter
LL | |
LL | | }
| |_- this function doesn't have a `self` parameter

error: aborting due to 17 previous errors

Expand Down
0