You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/items/use-declarations.md
+4-52Lines changed: 4 additions & 52 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -116,6 +116,7 @@ They may create bindings for:
116
116
*[Built-in types]
117
117
*[Attributes]
118
118
*[Derive macros]
119
+
*[Macros by example]
119
120
120
121
r[items.use.path.disallowed]
121
122
They cannot import [associated items], [generic parameters], [local variables], paths with [`Self`], or [tool attributes]. More restrictions are described below.
Some situations are an error when there is an ambiguity as to which name a `use` declaration refers. This happens when there are two name candidates that do not resolve to the same entity.
400
-
401
-
r[items.use.ambiguities.glob]
402
-
Glob imports are allowed to import conflicting names in the same namespace as long as the name is not used.
403
-
For example:
404
-
405
-
```rust
406
-
modfoo {
407
-
pubstructQux;
408
-
}
409
-
410
-
modbar {
411
-
pubstructQux;
412
-
}
413
-
414
-
usefoo::*;
415
-
usebar::*; //~ OK, no name conflict.
416
-
417
-
fnmain() {
418
-
// This would be an error, due to the ambiguity.
419
-
//let x = Qux;
420
-
}
421
-
```
422
-
423
-
Multiple glob imports are allowed to import the same name, and that name is allowed to be used, if the imports are of the same item (following re-exports). The visibility of the name is the maximum visibility of the imports. For example:
424
-
425
-
```rust
426
-
modfoo {
427
-
pubstructQux;
428
-
}
429
-
430
-
modbar {
431
-
pubusesuper::foo::Qux;
432
-
}
433
-
434
-
// These both import the same `Qux`. The visibility of `Qux`
435
-
// is `pub` because that is the maximum visibility between
436
-
// these two `use` declarations.
437
-
pubusebar::*;
438
-
usefoo::*;
439
-
440
-
fnmain() {
441
-
let_:Qux=Qux;
442
-
}
443
-
```
393
+
TODO mention ambiguities and link to name-res. Moved to name-res because
394
+
ambiguities are fundamentally a product of the place of use, not the use
0 commit comments